嘿我在我的场景中创建了一个类型的山峰,并希望让它的顶部摆动到特定的值。现在我试图访问我之前设置的顶点,并通过更新功能随时间再次指定它们。我如何访问它们并重新计算面孔?
geom1.vertices = [
new THREE.Vector3( -1000, -300, 0 ),
new THREE.Vector3( -1000, 0, 0 ),
new THREE.Vector3( -20, 120, 0 ),
new THREE.Vector3( 60, 85, 0 ),
new THREE.Vector3( 140, 100, 0 ),
new THREE.Vector3( 1000, 0, 0 ),
new THREE.Vector3( 1000, -300, 0 ),
new THREE.Vector3( 0, -300 , 0 ),
];
geom1.faces = [
new THREE.Face3( 7, 0, 1 ),
new THREE.Face3( 7, 1, 2 ),
new THREE.Face3( 7, 2, 3 ),
new THREE.Face3( 7, 3, 4 ),
new THREE.Face3( 7, 4, 5 ),
new THREE.Face3( 7, 5, 6 ),
];
geom1.computeFaceNormals();
geom1.dynamic = true;
var material1 = new THREE.MeshBasicMaterial( {
color: 0x7dae81,
side: THREE.DoubleSide,
} );
hill1 = new THREE.Mesh( geom1, material1);
在更新功能中我这样做
geom1.vertices[2].y += 0.1;
geom1.verticesNeedUpdate;
答案 0 :(得分:3)
您需要设置
geometry.verticesNeedUpdate = true;
有关详细信息,请参阅verticesNeedUpdate in Three.js。
此外,Geometry
没有dynamic
属性。
three.js r.85