matrix - Scaling of mesh world-relative -
matrix - Scaling of mesh world-relative -
in object3d contains mesh object3d has arbitrary scaling mesh has arbitrary rotation. mesh scaled relative world coordinates.
but when detach mesh in scene (for example, aid of three.sceneutils.detach (mesh, obj3d, scene) wrong result, mesh scaled locally.
i tried alter geometry of mesh, still wrong result:
http://jsfiddle.net/ni55an/vswb9/3426/
var euler = new three.euler(-mesh.rotation.x,-mesh.rotation.y,-mesh.rotation.z); mesh.geometry.applymatrix(new three.matrix4().makerotationfromeuler(mesh.rotation)); mesh.geometry.applymatrix(new three.matrix4().makescale( obj.scale.x, obj.scale.y, obj.scale.z )); mesh.geometry.applymatrix(new three.matrix4().makerotationfromeuler(euler)); mesh.geometry.verticesneedupdate=true;
i realized mistake. necessary apply getinverse of first matrix instead .makerotationfromeuler negative values
var firstmatrix=new three.matrix4().makerotationfromeuler(mesh.rotation); var inversematrix=new three.matrix4().getinverse(firstmatrix); mesh.geometry.applymatrix(firstmatrix); mesh.geometry.applymatrix(new three.matrix4().makescale( obj.scale.x, obj.scale.y, obj.scale.z )); mesh.geometry.applymatrix(inversematrix); mesh.geometry.verticesneedupdate=true;
matrix three.js
Comments
Post a Comment