javascript - ThreeJS Voxel not fixed to grid -
i using voxel painter example threejs git repo.
i have changed voxels bigger example. instead of taking 1 grid space on x coordinate, take 2.
however doing means roll on mesh isn't fixed grid , instead goes on half of 1 on 1 side, , half of 1 on other side.
here code:
// in example geometry set (50, 50, 50) self.rollovergeo = new three.cubegeometry(100, 50, 50); self.rollovermaterial = new three.meshbasicmaterial({ color: 0xff0000, opacity: 0.5, transparent: true }); self.rollovermesh = new three.mesh(self.rollovergeo, self.rollovermaterial); self.rollovermesh.position = new three.vector3(0, 25, 0);
does know why is?
the geometry centered @ origin in local coordinate system. need translate geometry so:
rollovergeo = new three.cubegeometry( 100, 50, 50 ); rollovergeo.applymatrix( new three.matrix4().maketranslation( 25, 0, 0 ) ); cubegeo = new three.cubegeometry( 100, 50, 50 ); cubegeo.applymatrix( new three.matrix4().maketranslation( 25, 0, 0 ) );
three.js r.61
Comments
Post a Comment