javascript - Three.js 四元数不能分配给只读属性
问题描述
我正在尝试创建一个类(使用three.js),该类使用具有向量名称的数组与具有一组向量3 的数组进行比较,并生成平面的网格,但出现错误。
Uncaught TypeError: Cannot assign to read only property 'quaternion' of object '# <Tface>'
at Tface.criaFace (Tface.js: 58)
at eval (index.js: 54)
at Module ../ src / index.js (bundle.js: 651)
at __webpack_require__ (bundle.js: 674)
at bundle.js: 738
at bundle.js: 741
https://github.com/gisselecardozo/teste-classes/blob/master/src/classes/Tface.js
解决方案
该类Tponto
派生自THREE.Object3D
. 结果quaternion
属性是只读的。criaFace()
这意味着您的方法中的以下分配无效。
this.quaternion = new THREE.Quaternion().setFromUnitVectors(this.normal, this.baseNormal);
它应该是:
this.quaternion.setFromUnitVectors(this.normal, this.baseNormal);
推荐阅读
- android - Android Kotlin 问题解析器 Gson 与 Retrofit2 预期 BEGIN_OBJECT 但在第 1 行第 2 列路径 $ BEGIN_ARRAY
- python - Seaborn Matplotlib:在情节之外获取自定义图例
- javascript - 为什么这个函数在调用它时记录未定义?
- entity-framework - 具有指定外键列名的 TPT
- sql - JPA/Hibernate 重叠 PK 和 FK 列
- python - 用于生成 SVG 线框球体的 Python 脚本
- javascript - 将所有对象对放入一个数组(Javascript)
- tkinter - 如何在 Tkinter 中并排放置窗口和顶层?
- python - 动态张量的堆栈
- python - 循环 HTML 以解析字典,但返回重复值