简体   繁体   中英

How to apply a matrix transformation and set the result as default state in ThreeJS?

I have a group of THREE.Mesh objects. My goal is to use something like group.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2) ); . Then, I would like to make the result as the group default matrix, so that I can use matrixUpdate() in my animation.

In ThreeJS docs, we can find: "Calling updateMatrix will clobber the manual changes made to the matrix, recalculating the matrix from position, scale, and so on."

Is there a way to make the manual changes I want and then set the result as if it was the default state of group?

Based on @WestLangley related answer , here is the solution for my problem! After executing all the matrix transformations I want, I just needed to do:

group.children.forEach( function(mesh) {
    mesh.geometry.applyMatrix( group.matrix );
});
group.updateMatrix();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM