소스 검색

Merge pull request #9529 from bghgary/sandbox-camera-fix

Fix camera panning when setting position via url
David Catuhe 4 년 전
부모
커밋
216e9c9d1e
1개의 변경된 파일19개의 추가작업 그리고 19개의 파일을 삭제
  1. 19 19
      sandbox/src/components/renderingZone.tsx

+ 19 - 19
sandbox/src/components/renderingZone.tsx

@@ -149,29 +149,29 @@ export class RenderingZone extends React.Component<IRenderingZoneProps> {
 
             camera = this._scene.activeCamera! as ArcRotateCamera;
 
-            if (this.props.cameraPosition) {
-                camera.setPosition(this.props.cameraPosition);
-            } else {
-                if (this._currentPluginName === "gltf") {
-                    // glTF assets use a +Z forward convention while the default camera faces +Z. Rotate the camera to look at the front of the asset.
-                    camera.alpha += Math.PI;
-                }
+            if (this._currentPluginName === "gltf") {
+                // glTF assets use a +Z forward convention while the default camera faces +Z. Rotate the camera to look at the front of the asset.
+                camera.alpha += Math.PI;
+            }
 
-                // Enable camera's behaviors
-                camera.useFramingBehavior = true;
+            // Enable camera's behaviors
+            camera.useFramingBehavior = true;
 
-                var framingBehavior = camera.getBehaviorByName("Framing") as FramingBehavior;
-                framingBehavior.framingTime = 0;
-                framingBehavior.elevationReturnTime = -1;
+            var framingBehavior = camera.getBehaviorByName("Framing") as FramingBehavior;
+            framingBehavior.framingTime = 0;
+            framingBehavior.elevationReturnTime = -1;
 
-                if (this._scene.meshes.length) {
-                    camera.lowerRadiusLimit = null;
+            if (this._scene.meshes.length) {
+                camera.lowerRadiusLimit = null;
 
-                    var worldExtends = this._scene.getWorldExtends(function (mesh) {
-                        return mesh.isVisible && mesh.isEnabled();
-                    });
-                    framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);
-                }
+                var worldExtends = this._scene.getWorldExtends(function (mesh) {
+                    return mesh.isVisible && mesh.isEnabled();
+                });
+                framingBehavior.zoomOnBoundingInfo(worldExtends.min, worldExtends.max);
+            }
+
+            if (this.props.cameraPosition) {
+                camera.setPosition(this.props.cameraPosition);
             }
 
             camera.pinchPrecision = 200 / camera.radius;