Edgeshelper not updating position of mesh

天大地大妈咪最大 提交于 2019-12-24 11:40:26

问题


I would like to draw a coloured box, including the edges (in a different colour) This is the code I am using to create the box and edges. I have added them both to a object3D since I will have a number of differnt objects in the scene and would like to enforce encapsulation.

var mesh = new THREE.Mesh( geo, material );   
var edge = new THREE.EdgesHelper( mesh, 0xffffff );

var container = new THREE.Object3D();
container.add(mesh);
container.add(edge);

scene.add(container);

The above posted code works and produces this:

But when I change the position of the parent object like so:

container.position.set(0,30,0);

Only the edges are moved. Why?

Adding .updateMatrix() to the container, mesh, or edges objects doesnt seem to produce different results.

How can the parent object be moved, included all of its children?


回答1:


You need to add the helpers as children of the scene directly.

This is due to the following lines that appear in many of the helpers:

this.matrix = object.matrixWorld;
this.matrixAutoUpdate = false;

three.js r.70



来源:https://stackoverflow.com/questions/28321947/edgeshelper-not-updating-position-of-mesh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!