我随机选择了"在我的场景中走来走去"(某种3D蛇),接下来要做的就是在它的头部设置一个盒子.该行bufferGeometry
由设置
var positions1 = new Float32Array( MAX_POINTS * 3 ); // 3 vertices per point
var positions2 = new Float32Array( MAX_POINTS * 3 ); // 3 vertices per point
buffGeometry1.addAttribute( 'position', new THREE.BufferAttribute( positions1, 3 ) );
buffGeometry2.addAttribute( 'position', new THREE.BufferAttribute( positions2, 3 ) );
Run Code Online (Sandbox Code Playgroud)
我选择boxGeometry
在它周围设置一个立方体(对象),并使用以下代码行来尝试实现:
var positioning = buffGeometry1.getAttribute('position');
cube.position.x = positioning[0];//(line1.geometry.attributes.position.array[drawCount]);
cube.position.y = positioning[1];//(line1.geometry.attributes.position.array[drawCount + 1]);
cube.position.z = positioning[2];
Run Code Online (Sandbox Code Playgroud)
在调试时,我看到我的positioning
数组未定义.所以我觉得出了问题.
谢谢.