简体   繁体   English

如何在ThreeJS中应用矩阵变换并将结果设置为默认状态?

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

I have a group of THREE.Mesh objects. 我有一组THREE.Mesh对象。 My goal is to use something like group.applyMatrix( new THREE.Matrix4().makeRotationX( Math.PI / 2) ); 我的目标是使用诸如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. 然后,我想将结果作为组默认矩阵,以便可以在动画中使用matrixUpdate()。

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." 在ThreeJS文档中,我们可以找到:“调用updateMatrix将破坏对矩阵的手动更改,从位置,比例等重新计算矩阵。”

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! 基于@WestLangley相关答案 ,这是我的问题的解决方案! 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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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