Skip to content Skip to sidebar Skip to footer

Three.js. Change Mesh Position After Applying 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 d

Solution 1:

Looking into the source of THREE.EdgesHelper it seems that the matrixAutoUpdate is set to false. This prevents the computation of the position and rotation on every update.

https://github.com/mrdoob/three.js/blob/master/src/extras/helpers/EdgesHelper.js

Setting the matrixAutoUpdate of the EdgesHelper to true should do the trick, but calling the .updateMatrix() function after setting the new position or rotation seems cleaner.

Solution 2:

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

Post a Comment for "Three.js. Change Mesh Position After Applying Edgeshelper"