三.js.应用EdgesHelper后更改网格位置 [英] THREE.js. Change mesh position after applying EdgesHelper

查看:151
本文介绍了三.js.应用EdgesHelper后更改网格位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用EdgesHelper之后,我尝试旋转或更改网格的位置,但是它不起作用-网格保持在同一位置. (没有EdgesHelper,它可以正常工作).我在做什么错了?

I tried to rotate or change position of a mesh after applying EdgesHelper, but it doesn't work — mesh stays on the same position. (Without EdgesHelper it works fine). What am I doing wrong?

var mesh = new THREE.Mesh( geometry, material );
var edges = new THREE.EdgesHelper( mesh, 0xcf0000 );

edges.position.z = 100;
edges.position.x = 100;

scene.add( edges );            

推荐答案

我有同样的问题,如我建议的那样:

I had the same problem, as suggested I added:

        egh.matrixAutoUpdate = true;

边缘和立方体遵循我使用的坐标:

That the edge and the cube followed my coordinates I used:

        var cube = new THREE.Mesh( new THREE.CubeGeometry(width,height,depth), 
                        new THREE.MeshBasicMaterial( {color: 0x00AA00, side:THREE.DoubleSide, opacity: 0.5, transparent: true } ) );
        scene.add(cube);

        var egh = new THREE.EdgesHelper(cube, 0x777777);
        egh.material.linewidth = 1;
        egh.position.x = cube.position.x;
        egh.position.y = cube.position.y;
        egh.position.z = cube.position.z;
        egh.matrixAutoUpdate = true; // this helped
        scene.add(egh);

这篇关于三.js.应用EdgesHelper后更改网格位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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