未验证 提交 4f7b2437 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #18296 from Mugen87/dev29

Docs: Use BufferGeometry in PointsMaterial code example.
......@@ -32,25 +32,26 @@
</p>
<code>
//This will add a starfield to the background of a scene
var starsGeometry = new THREE.Geometry();
var vertices = [];
for ( var i = 0; i < 10000; i ++ ) {
var star = new THREE.Vector3();
star.x = THREE.MathUtils.randFloatSpread( 2000 );
star.y = THREE.MathUtils.randFloatSpread( 2000 );
star.z = THREE.MathUtils.randFloatSpread( 2000 );
var x = THREE.MathUtils.randFloatSpread( 2000 );
var y = THREE.MathUtils.randFloatSpread( 2000 );
var z = THREE.MathUtils.randFloatSpread( 2000 );
starsGeometry.vertices.push( star );
vertices.push( x, y, z );
}
var starsMaterial = new THREE.PointsMaterial( { color: 0x888888 } );
var geometry = new THREE.BufferGeometry();
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
var starField = new THREE.Points( starsGeometry, starsMaterial );
var material = new THREE.PointsMaterial( { color: 0x888888 } );
scene.add( starField );
var points = new THREE.Points( geometry, material );
scene.add( points );
</code>
<h3>[name]( [param:Object parameters] )</h3>
......
......@@ -34,25 +34,26 @@
</p>
<code>
//This will add a starfield to the background of a scene
var starsGeometry = new THREE.Geometry();
var vertices = [];
for ( var i = 0; i < 10000; i ++ ) {
var star = new THREE.Vector3();
star.x = THREE.MathUtils.randFloatSpread( 2000 );
star.y = THREE.MathUtils.randFloatSpread( 2000 );
star.z = THREE.MathUtils.randFloatSpread( 2000 );
var x = THREE.MathUtils.randFloatSpread( 2000 );
var y = THREE.MathUtils.randFloatSpread( 2000 );
var z = THREE.MathUtils.randFloatSpread( 2000 );
starsGeometry.vertices.push( star );
vertices.push( x, y, z );
}
var starsMaterial = new THREE.PointsMaterial( { color: 0x888888 } );
var geometry = new THREE.BufferGeometry();
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
var starField = new THREE.Points( starsGeometry, starsMaterial );
var material = new THREE.PointsMaterial( { color: 0x888888 } );
scene.add( starField );
var points = new THREE.Points( geometry, material );
scene.add( points );
</code>
<h3>[name]( [param:Object parameters] )</h3>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册