Edgeshelper 不更新网格的位置 [英] Edgeshelper not updating position of mesh

查看:35
本文介绍了Edgeshelper 不更新网格的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画一个有颜色的盒子,包括边缘(不同的颜色)这是我用来创建框和边缘的代码.我已将它们都添加到 object3D 中,因为我将在场景中拥有许多不同的对象并希望强制执行封装.

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);

仅移动边缘.为什么?

将 .updateMatrix() 添加到容器、网格或边对象似乎不会产生不同的结果.

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?

推荐答案

需要直接将helper添加为场景的子级.

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

three.js r.70

这篇关于Edgeshelper 不更新网格的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆