Three.js: Rotate at center of an object -
i've modified single spinning cube contain 3 cubes in object3d
http://jsfiddle.net/vswb9/1243/
in above example uses first cube. need rotate on single axis @ exact center of object.
the object3d code
geometry = new three.cubegeometry(50, 50, 50); material = new three.meshnormalmaterial(); mesh = new three.object3d(); mesh1 = new three.mesh(geometry, material); mesh1.position.x = 50; mesh2 = new three.mesh(geometry, material); mesh2.position.x = 100; mesh3 = new three.mesh(geometry, material); mesh.add(mesh1); mesh.add(mesh2); mesh.add(mesh3); scene.add(mesh); here rotation
mesh.rotation.x += 0.01; mesh.rotation.y += 0.02; edit: example demonstrate problem, actual code object contains many different sized shapes.
you may define coordinates of center.
mesh.position.set( center.x, center.y, center.z ); mesh.geometry.applymatrix(new three.matrix4().maketranslation( -center.x, -center.y, -center.z ) );
Comments
Post a Comment