简体   繁体   中英

Edgeshelper not updating position of mesh

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:

IMG

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM