Parcourir la source

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

Mr.doob il y a 13 ans
Parent
commit
5e2df8e0f1
1 fichiers modifiés avec 14 ajouts et 0 suppressions
  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 );
+
 	}
 
 };