Created
April 5, 2018 17:05
-
-
Save ayamflow/0c857da45e276311be222aeb76cacf31 to your computer and use it in GitHub Desktop.
Threejs Object3D position/rotation/scale getters/setters for tweens & convenience
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperties(THREE.Object3D.prototype, { | |
x: { | |
get: function() { | |
return this.position.x | |
}, | |
set: function(value) { | |
this.position.x = value | |
} | |
}, | |
y: { | |
get: function() { | |
return this.position.y | |
}, | |
set: function(value) { | |
this.position.y = value | |
} | |
}, | |
z: { | |
get: function() { | |
return this.position.z | |
}, | |
set: function(value) { | |
this.position.z = value | |
} | |
}, | |
scaleX: { | |
get: function() { | |
return this.scale.x | |
}, | |
set: function(value) { | |
this.scale.x = value | |
} | |
}, | |
scaleY: { | |
get: function() { | |
return this.scale.y | |
}, | |
set: function(value) { | |
this.scale.y = value | |
} | |
}, | |
scaleZ: { | |
get: function() { | |
return this.scale.z | |
}, | |
set: function(value) { | |
this.scale.z = value | |
} | |
}, | |
rotationX: { | |
get: function() { | |
return this.rotation.x | |
}, | |
set: function(value) { | |
this.rotation.x = value | |
} | |
}, | |
rotationY: { | |
get: function() { | |
return this.rotation.y | |
}, | |
set: function(value) { | |
this.rotation.y = value | |
} | |
}, | |
rotationZ: { | |
get: function() { | |
return this.rotation.z | |
}, | |
set: function(value) { | |
this.rotation.z = value | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment