three.js - 如何链接矩阵变换操作?
问题描述
为什么对象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))
解决方案
Matrix4.makeTranslation()创建一个纯平移矩阵。所有现有的矩阵元素都被覆盖。因此,该方法不打算将转换应用于现有的变换矩阵。
Object3D.applyMatrix()的工作方式不同,因为它将给定矩阵与对象的局部变换矩阵相乘。这导致了给定和现有转换的组合。
three.js R104
推荐阅读
- laravel - laravel 5:“未按要求设置会话存储。” 在 api.php
- javascript - 使用 react 和 componentDidMount 获取数据
- django - 在 nginx Docker 容器中重写 URL 错误地使用了内部端口
- linux - 如何使用期望运行 SSH 脚本?
- arrays - 在 Julia 中查找特定类型的数组中的元素
- php - 处理数组并更改日期格式
- javascript - 使用带有 jquery 变量的 sql 查询
- c# - 使用 Linq 查找具有特定日期的列表中的所有项目
- reactjs - 语义 UI 样式的问题
- javascript - 如何连接到友好的 URL 套接字?