瀏覽代碼

make camera optional

Gregg Tavares 7 年之前
父節點
當前提交
fbf6a820de
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      threejs/lessons/resources/threejs-lesson-utils.js

+ 5 - 1
threejs/lessons/resources/threejs-lesson-utils.js

@@ -82,7 +82,7 @@ window.threejsLessonUtils = {
     const aspect = 1;
     const zNear = 0.1;
     const zFar = 50;
-    const camera = new THREE.PerspectiveCamera(targetFOVDeg, aspect, zNear, zFar);
+    let camera = new THREE.PerspectiveCamera(targetFOVDeg, aspect, zNear, zFar);
     camera.position.z = 15;
     scene.add(camera);
 
@@ -129,6 +129,10 @@ window.threejsLessonUtils = {
       if (info.resize) {
         resizeFunctions.push(info.resize);
       }
+      if (info.camera) {
+        camera = info.camera;
+        renderInfo.camera = camera;
+      }
 
       Object.assign(settings, info);
       targetFOVDeg = camera.fov;