提交 5549e242 编写于 作者: M Mr.doob

Object3D: Using Object.defineProperties to avoid object.rotation = new...

Object3D: Using Object.defineProperties to avoid object.rotation = new THREE.Euler() pattern. See fffeeb63.
上级 eabdc896
......@@ -7,8 +7,6 @@
THREE.Object3D = function () {
var scope = this;
this.id = THREE.Object3DIdCount ++;
this.uuid = THREE.Math.generateUUID();
......@@ -19,11 +17,30 @@ THREE.Object3D = function () {
this.up = new THREE.Vector3( 0, 1, 0 );
this.position = new THREE.Vector3();
this.rotation = new THREE.Euler().onChange( function () { scope.quaternion.setFromEuler( scope.rotation, false ); } );
this.quaternion = new THREE.Quaternion().onChange( function () { scope.rotation.setFromQuaternion( scope.quaternion, undefined, false );
} );
this.scale = new THREE.Vector3( 1, 1, 1 );
var scope = this;
Object.defineProperties( this, {
position: {
enumerable: true,
value: new THREE.Vector3()
},
rotation: {
enumerable: true,
value: new THREE.Euler().onChange( function () {
scope.quaternion.setFromEuler( scope.rotation, false );
} )
},
quaternion: {
enumerable: true,
value: new THREE.Quaternion().onChange( function () {
scope.rotation.setFromQuaternion( scope.quaternion, undefined, false );
} )
},
scale: {
enumerable: true,
value: new THREE.Vector3( 1, 1, 1 )
}
} );
this.renderDepth = null;
......
......@@ -41,7 +41,6 @@ THREE.Vector2.prototype = {
},
setComponent: function ( index, value ) {
switch ( index ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册