David Catuhe 6 лет назад
Родитель
Сommit
3daab33014

+ 1 - 1
inspector/src/components/actionTabs/tabs/toolsTabComponent.tsx

@@ -47,7 +47,7 @@ export class ToolsTabComponent extends PaneComponent {
     captureScreenshot() {
         const scene = this.props.scene;
         if (scene.activeCamera) {
-            Tools.CreateScreenshotUsingRenderTarget(scene.getEngine(), scene.activeCamera, { precision: 1.0 }, undefined, undefined, 4, true);
+            Tools.CreateScreenshot(scene.getEngine(), scene.activeCamera, { precision: 1.0 });
         }
     }
 

+ 24 - 2
src/Meshes/abstractMesh.ts

@@ -944,10 +944,24 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
 
     /**
      * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
-     * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
+     * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
+     * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
      * @returns the current mesh
      */
-    public normalizeToUnitCube(includeDescendants = true): AbstractMesh {
+    public normalizeToUnitCube(includeDescendants = true, ignoreRotation = false): AbstractMesh {
+        let storedRotation: Nullable<Vector3> = null;
+        let storedRotationQuaternion: Nullable<Quaternion> = null;
+
+        if (ignoreRotation) {
+            if (this.rotationQuaternion) {
+                storedRotationQuaternion = this.rotationQuaternion.clone();
+                this.rotationQuaternion.copyFromFloats(0, 0, 0, 1);
+            } else if (this.rotation) {
+                storedRotation = this.rotation.clone();
+                this.rotation.copyFromFloats(0, 0, 0);
+            }
+        }
+
         let boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
         let sizeVec = boundingVectors.max.subtract(boundingVectors.min);
         let maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
@@ -960,6 +974,14 @@ export class AbstractMesh extends TransformNode implements IDisposable, ICullabl
 
         this.scaling.scaleInPlace(scale);
 
+        if (ignoreRotation) {
+            if (this.rotationQuaternion && storedRotationQuaternion) {
+                this.rotationQuaternion.copyFrom(storedRotationQuaternion);
+            } else if (this.rotation && storedRotation) {
+                this.rotation.copyFrom(storedRotation);
+            }
+        }
+
         return this;
     }