-
-
Notifications
You must be signed in to change notification settings - Fork 36k
Docs: Improve BufferGeometry
page.
#25824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
84debcc
docs(bufferGeometry): adding indexed version code example
abernier 06d62ef
updating doc + adding 2 live examples
abernier bb9e8fd
Update BufferGeometry.html
abernier 8a763e2
removing browser examples
abernier f98de46
fixing sentences
abernier ddc4c5c
Update BufferGeometry.html
Mugen87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Three.js CCDIKSolver Browser</title> | ||
<link rel="shortcut icon" href="../../files/favicon.ico" /> | ||
<link rel="stylesheet" type="text/css" href="../../files/main.css"> | ||
<style> | ||
canvas { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#newWindow { | ||
display: block; | ||
position: absolute; | ||
bottom: 0.3em; | ||
left: 0.5em; | ||
color: #fff; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<!-- Import maps polyfill --> | ||
<!-- Remove this when import maps will be widely supported --> | ||
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script> | ||
|
||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"three": "../../build/three.module.js", | ||
"three/addons/": "../../examples/jsm/" | ||
} | ||
} | ||
</script> | ||
|
||
<a id='newWindow' href='./buffergeometry-browser.html' target='_blank'>Open in New Window</a> | ||
|
||
<script type="module"> | ||
abernier marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { | ||
Color, | ||
ColorManagement, | ||
PerspectiveCamera, | ||
Scene, | ||
WebGLRenderer, | ||
BufferGeometry, | ||
BufferAttribute, | ||
MeshBasicMaterial, | ||
Mesh | ||
} from 'three'; | ||
|
||
import { GUI } from 'three/addons/libs/lil-gui.module.min.js'; | ||
|
||
ColorManagement.enabled = true; | ||
|
||
let gui, scene, camera, renderer, material; | ||
|
||
function initScene() { | ||
|
||
gui = new GUI(); | ||
|
||
scene = new Scene(); | ||
scene.background = new Color( 0x444444 ); | ||
|
||
camera = new PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 200 ); | ||
camera.position.z = 5; | ||
|
||
renderer = new WebGLRenderer( { antialias: true } ); | ||
renderer.setPixelRatio( window.devicePixelRatio ); | ||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
document.body.appendChild( renderer.domElement ); | ||
|
||
window.addEventListener( 'resize', function () { | ||
|
||
camera.aspect = window.innerWidth / window.innerHeight; | ||
camera.updateProjectionMatrix(); | ||
|
||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
|
||
}, false ); | ||
|
||
initBufferGeometry(); | ||
setupDatGui(); | ||
|
||
} | ||
|
||
function setupDatGui() { | ||
|
||
gui.add( material, 'wireframe' ); | ||
|
||
} | ||
|
||
function initBufferGeometry() { | ||
|
||
const geometry = new BufferGeometry(); | ||
// create a simple square shape. We duplicate the top left and bottom right | ||
// vertices because each vertex needs to appear once per triangle. | ||
const vertices = new Float32Array( [ | ||
- 1.0, - 1.0, 1.0, | ||
1.0, - 1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
|
||
1.0, 1.0, 1.0, | ||
- 1.0, 1.0, 1.0, | ||
- 1.0, - 1.0, 1.0 | ||
] ); | ||
|
||
// itemSize = 3 because there are 3 values (components) per vertex | ||
geometry.setAttribute( 'position', new BufferAttribute( vertices, 3 ) ); | ||
material = new MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); | ||
const mesh = new Mesh( geometry, material ); | ||
|
||
scene.add( mesh ); | ||
|
||
} | ||
|
||
function render() { | ||
|
||
requestAnimationFrame( render ); | ||
|
||
renderer.render( scene, camera ); | ||
|
||
} | ||
|
||
initScene(); | ||
render(); | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title> .js CCDIKSolver Browser</title> | ||
<link rel="shortcut icon" href="../../files/favicon.ico" /> | ||
<link rel="stylesheet" type="text/css" href="../../files/main.css"> | ||
<style> | ||
canvas { | ||
display: block; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
#newWindow { | ||
display: block; | ||
position: absolute; | ||
bottom: 0.3em; | ||
left: 0.5em; | ||
color: #fff; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<!-- Import maps polyfill --> | ||
<!-- Remove this when import maps will be widely supported --> | ||
<script async src="https://unpkg.com/[email protected]/dist/es-module-shims.js"></script> | ||
|
||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"three": "../../build/three.module.js", | ||
"three/addons/": "../../examples/jsm/" | ||
} | ||
} | ||
</script> | ||
|
||
<a id='newWindow' href='./buffergeometry-browser.html' target='_blank'>Open in New Window</a> | ||
|
||
<script type="module"> | ||
import { | ||
Color, | ||
ColorManagement, | ||
PerspectiveCamera, | ||
Scene, | ||
WebGLRenderer, | ||
BufferGeometry, | ||
BufferAttribute, | ||
MeshBasicMaterial, | ||
Mesh | ||
} from 'three'; | ||
|
||
import { GUI } from 'three/addons/libs/lil-gui.module.min.js'; | ||
|
||
ColorManagement.enabled = true; | ||
|
||
let gui, scene, camera, renderer, material; | ||
|
||
function initScene() { | ||
|
||
gui = new GUI(); | ||
|
||
scene = new Scene(); | ||
scene.background = new Color( 0x444444 ); | ||
|
||
camera = new PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 200 ); | ||
camera.position.z = 5; | ||
|
||
renderer = new WebGLRenderer( { antialias: true } ); | ||
renderer.setPixelRatio( window.devicePixelRatio ); | ||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
document.body.appendChild( renderer.domElement ); | ||
|
||
window.addEventListener( 'resize', function () { | ||
|
||
camera.aspect = window.innerWidth / window.innerHeight; | ||
camera.updateProjectionMatrix(); | ||
|
||
renderer.setSize( window.innerWidth, window.innerHeight ); | ||
|
||
}, false ); | ||
|
||
initBufferGeometry(); | ||
setupDatGui(); | ||
|
||
} | ||
|
||
function setupDatGui() { | ||
|
||
gui.add( material, 'wireframe' ); | ||
|
||
} | ||
|
||
function initBufferGeometry() { | ||
|
||
const geometry = new BufferGeometry(); | ||
// create a simple square shape. We duplicate the top left and bottom right | ||
// vertices because each vertex needs to appear once per triangle. | ||
const vertices = new Float32Array( [ | ||
- 1.0, - 1.0, 1.0, | ||
1.0, - 1.0, 1.0, | ||
1.0, 1.0, 1.0, | ||
- 1.0, 1.0, 1.0, | ||
] ); | ||
geometry.setAttribute( 'position', new BufferAttribute( vertices, 3 ) ); | ||
|
||
const indices = [ | ||
0, 1, 2, // triangle 1: "0, 1, 2" | ||
2, 3, 0, // triangle 2: "2, 3, 0" | ||
]; | ||
geometry.setIndex( indices ); | ||
|
||
material = new MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ); | ||
const mesh = new Mesh( geometry, material ); | ||
|
||
scene.add( mesh ); | ||
|
||
} | ||
|
||
function render() { | ||
|
||
requestAnimationFrame( render ); | ||
|
||
renderer.render( scene, camera ); | ||
|
||
} | ||
|
||
initScene(); | ||
render(); | ||
|
||
</script> | ||
</body> | ||
</html> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.