use*_*777 1 javascript three.js buffer-geometry
我试图制作一个显示许多球形对象的三个 js 文档,最快的方法是使用缓冲区几何。从这里的这篇文章中,我了解到我可以使用以下方法将普通几何体转换为缓冲几何体:
var sphere = new THREE.SphereGeometry( 4, 0.05, 0.025 );
var geometry = THREE.BufferGeometryUtils.fromGeometry( sphere );
Run Code Online (Sandbox Code Playgroud)
但这对我来说似乎不起作用,创建对象的其余代码如下:
var positions = new Float32Array( x_GAMA.length * 3 );
for ( var i = 0; i < x_GAMA.length; i += 1 ) {
// positions
positions[ 3*i ] = x_GAMA[i]*10000;
positions[ 3*i + 1 ] = y_GAMA[i]*10000;
positions[ 3*i + 2 ] = z_GAMA[i]*10000;
}
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
var material = new THREE.PointCloudMaterial( {size:1,color:0x999999} );
geometry.computeBoundingSphere();
particleSystem = new THREE.PointCloud( geometry, material );
scene.add( particleSystem );
Run Code Online (Sandbox Code Playgroud)
如果我使用它可以正常工作,var geometry = new THREE.BufferGeometry();
但这会创建我不想要的方块。任何人都知道为什么这似乎不起作用?提前致谢。
在Three.js r71 中,您可以像这样创建球体缓冲区几何:
var sphereGeometry = new THREE.SphereGeometry( 4, 3, 2 );
var bufferSphereGeometry = new THREE.BufferGeometry().fromGeometry( sphereGeometry );
Run Code Online (Sandbox Code Playgroud)
在r72 dev 中,你可以像这样简单地做:
// constructor: radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength
var sphereGeo = new THREE.SphereBufferGeometry( 4, 3, 2 ); //r72
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3765 次 |
最近记录: |