为什么three中position,scale,rotation, quaternion, modelViewMatrix ,normalMatrix 等属性 直接修改属性值失败
在以前做项目的时候,我想改一个Mesh的顶点值为鼠标点击的坐标,直接设置设置失败,原因是这样的,以下是源码:
Object3D 对象中:
Object.defineProperties( this, { position: { enumerable: true, value: position }, rotation: { enumerable: true, value: rotation }, quaternion: { enumerable: true, value: quaternion }, scale: { enumerable: true, value: scale }, modelViewMatrix: { value: new Matrix4() }, normalMatrix: { value: new Matrix3() } } );Object.definedPropertices 方法,自定义的属性,属性的描述对象:
属性对象可参考:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties
自定义 object3d 对象的属性,通过defineProperties 定义的属性,其属性对象的 enumerable(是否可以通过for...in..循环得到)默认为false,configurable
(是否可以删除对象属性) 默认为false,wirtable(是否可以修改),默认为false。所以此处的属性不可以修改哦!!例:你修改position的值,只能这样修改 position.x = 7,不能 position = new Vector3(7,8,9);