浏览代码

Fix MeshBuilder.CreatePlane using source plane

See http://www.html5gamedevs.com/topic/41064-meshbuilder-createplane-from-sourceplane/
thscott 6 年之前
父节点
当前提交
da571c9dbb
共有 1 个文件被更改,包括 4 次插入7 次删除
  1. 4 7
      src/Mesh/babylon.meshBuilder.ts

+ 4 - 7
src/Mesh/babylon.meshBuilder.ts

@@ -694,14 +694,11 @@ module BABYLON {
             vertexData.applyToMesh(plane, options.updatable);
 
             if (options.sourcePlane) {
-                plane.translate(options.sourcePlane.normal, options.sourcePlane.d);
+                plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
 
-                var product = Math.acos(Vector3.Dot(options.sourcePlane.normal, Axis.Z));
-                var vectorProduct = Vector3.Cross(Axis.Z, options.sourcePlane.normal);
-
-                if (vectorProduct.lengthSquared() > Epsilon) {
-                    plane.rotate(vectorProduct, product);
-                }
+                const dot = BABYLON.Vector3.Dot(plane.position, options.sourcePlane.normal);
+                const flip = dot >= 0;
+                plane.lookAt(BABYLON.Vector3.Zero(), 0, flip ? Math.PI : 0, 0);
             }
 
             return plane;