【发布时间】:2016-07-31 07:08:51
【问题描述】:
我在已添加到场景中的 Mesh 中有一个合并的几何体。我更新网格中的合并几何并将其添加到场景中。这是一个区间。
scene.remove(that.graph[i]);
that.graph[i].geometry.dispose();
var planeMaterial = new THREE.MeshLambertMaterial({
color: 0xffffff,
vertexColors: THREE.VertexColors
});
var boxGeometry = new THREE.BoxGeometry(50, 50, Math.random() * 10000, 1, 1);
var cube = new THREE.Mesh(boxGeometry, planeMaterial);
cube.material.color = new THREE.Color(1,0,0);
cube.updateMatrix();
that.graph[i].geometry.dynamic = true;
that.graph[i].geometry.merge(cube.geometry, cube.matrix);
that.graph[i].geometry.mergeVertices();
that.graph[i].geometry.verticesNeedUpdate = true;
that.graph[i].geometry.elementsNeedUpdate = true;
that.graph[i].geometry.morphTargetsNeedUpdate = true;
that.graph[i].geometry.uvsNeedUpdate = true;
that.graph[i].geometry.normalsNeedUpdate = true;
that.graph[i].geometry.colorsNeedUpdate = true;
that.graph[i].geometry.tangentsNeedUpdate = true;
that.graph[i].geometry.groupsNeedUpdate = true;
scene.add(that.graph[i]);
我知道大多数更新标志都不需要,但我想表明我添加了所有内容。
我确定几何图形已更新,但它只是在初始渲染后未渲染。
到目前为止,我可以让它渲染的唯一方法是在将网格添加到场景之前添加以下内容。
that.graph[i].geometry = that.graph[i].geometry.clone();
但这会导致标签在大约 5 次迭代后崩溃。
为什么我的网格没有使用新几何体更新?
【问题讨论】:
标签: javascript three.js