瀏覽代碼

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

Mr.doob 13 年之前
父節點
當前提交
5e2df8e0f1
共有 1 個文件被更改,包括 14 次插入0 次删除
  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 );
+
 	}
 
 };