Skip to content

Instantly share code, notes, and snippets.

@ayamflow
Created April 5, 2018 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayamflow/0c857da45e276311be222aeb76cacf31 to your computer and use it in GitHub Desktop.
Save ayamflow/0c857da45e276311be222aeb76cacf31 to your computer and use it in GitHub Desktop.
Threejs Object3D position/rotation/scale getters/setters for tweens & convenience
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