首页 > 解决方案 > 如何链接矩阵变换操作?

问题描述

为什么对象makeTranslation上的链接方法matrix不起作用?

      boxMesh.matrixAutoUpdate = false
      boxMesh.matrix.makeTranslation(30, 0, 0)
      boxMesh.matrix.makeTranslation(30, 0, 0)

网格在x轴上仅移动 30 个单位,而不是 60

但是当我使用applyMatrix方法时,一切都按预期工作:

      boxMesh.applyMatrix(new THREE.Matrix4().makeTranslation(30, 0, 0))
      boxMesh.applyMatrix(new THREE.Matrix4().makeTranslation(30, 0, 0))

标签: three.js

解决方案


Matrix4.makeTranslation()创建一个纯平移矩阵。所有现有的矩阵元素都被覆盖。因此,该方法不打算将转换应用于现有的变换矩阵。

Object3D.applyMatrix()的工作方式不同,因为它将给定矩阵与对象的局部变换矩阵相乘。这导致了给定和现有转换的组合。

three.js R104


推荐阅读