Three.js Quaternion cannot assign to read only property

I’m trying to create a class (with three.js) that uses an array with vector names compare to an array with a set of vectors 3 and generates the mesh of the flat face, but I’m getting an error.

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

Answer

The class Tponto is derived from THREE.Object3D. The resulting quaternion property is read-only. Meaning the following assignment in your criaFace() method is invalid.

this.quaternion = new THREE.Quaternion().setFromUnitVectors(this.normal, this.baseNormal);

It should be:

this.quaternion.setFromUnitVectors(this.normal, this.baseNormal);