Преглед изворни кода

World extents only for visible and enabled meshes

Gary Hsu пре 5 година
родитељ
комит
97e6d1a6ae
2 измењених фајлова са 5 додато и 2 уклоњено
  1. 4 1
      sandbox/index.js
  2. 1 1
      src/Helpers/sceneHelpers.ts

+ 4 - 1
sandbox/index.js

@@ -165,8 +165,11 @@ if (BABYLON.Engine.isSupported()) {
                 framingBehavior.elevationReturnTime = -1;
                 framingBehavior.elevationReturnTime = -1;
 
 
                 if (currentScene.meshes.length) {
                 if (currentScene.meshes.length) {
-                    var worldExtends = currentScene.getWorldExtends();
                     currentScene.activeCamera.lowerRadiusLimit = null;
                     currentScene.activeCamera.lowerRadiusLimit = null;
+
+                    var worldExtends = currentScene.getWorldExtends(function (mesh) {
+                        return mesh.isVisible && mesh.isEnabled();
+                    });
                     framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);
                     framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);
                 }
                 }
             }
             }

+ 1 - 1
src/Helpers/sceneHelpers.ts

@@ -115,7 +115,7 @@ Scene.prototype.createDefaultCamera = function(createArcRotateCamera = false, re
 
 
     // Camera
     // Camera
     if (!this.activeCamera) {
     if (!this.activeCamera) {
-        var worldExtends = this.getWorldExtends();
+        var worldExtends = this.getWorldExtends((mesh) => mesh.isVisible && mesh.isEnabled());
         var worldSize = worldExtends.max.subtract(worldExtends.min);
         var worldSize = worldExtends.max.subtract(worldExtends.min);
         var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
         var worldCenter = worldExtends.min.add(worldSize.scale(0.5));