瀏覽代碼

Rotate the camera in sandbox when using glTF

Gary Hsu 7 年之前
父節點
當前提交
7e86fcb44d
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      sandbox/index.js

+ 3 - 0
sandbox/index.js

@@ -105,6 +105,9 @@ if (BABYLON.Engine.isSupported()) {
         if (currentPluginName === "gltf") {
             var hdrTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("Assets/environment.dds", currentScene);
             currentSkybox = currentScene.createDefaultSkybox(hdrTexture, true, (currentScene.activeCamera.maxZ - currentScene.activeCamera.minZ) / 2, 0.3);
+
+            // glTF assets use a +Z forward convention while the default camera faces +Z. Rotate the camera to look at the front of the asset.
+            currentScene.activeCamera.alpha += Math.PI;
         }
 
         // In case of error during loading, meshes will be empty and clearColor is set to red