Three.js clone matrix Matrix4 of other models

Three.js four-dimensional matrix Matrix4

Documentation that people love to hate! !
The two methods compose and decompose are used to process the matrix of the model, which almost drove me crazy all afternoon. The
following two methods are explained in detail, so that newcomers like me will no longer lie in the Three.js pit.
insert image description here
This method is passed in The three-piece generator matrix for the model
is used as follows:

let matrixData = new Matrix4.compose(object3d.position, object3d.quaternion, object3d.scale)

insert image description here
Just saw this method, did you think that the 3 parameters passed are the values ​​you want to modify?
If you answered yes! ! Congratulations, you have also been led into the ditch! ! !

The correct usage is:

设:
target = 被复制矩阵的模型
newObj = 被更新矩阵的模型

解:
target.matrixWorld.decompose(newObj.position,newObj.quaternion,newObj.scale)

How, the parameters in the brackets turned out to be the data to be updated ! ! I was shocked! ! !

Guess you like

Origin blog.csdn.net/weixin_39423672/article/details/117319268