Browse Source

Merge remote-tracking branch 'zz85/worldToLocal' into dev

Mr.doob 13 years ago
parent
commit
5e2df8e0f1
1 changed files with 14 additions and 0 deletions
  1. 14 0
      src/core/Object3D.js

+ 14 - 0
src/core/Object3D.js

@@ -263,6 +263,20 @@ THREE.Object3D.prototype = {
 
 		}
 
+	},
+
+	worldToLocal: function ( vector ) {
+
+		if ( !this.__inverseMatrixWorld ) this.__inverseMatrixWorld = new THREE.Matrix4();
+
+		return this.__inverseMatrixWorld.getInverse( this.matrixWorld ).multiplyVector3( vector );
+
+	},
+
+	localToWorld: function ( vector ) {
+
+		return this.matrixWorld.multiplyVector3( vector );
+
 	}
 
 };