Browse Source

fix: only set default camera settings to first camera

alvarosabu 2 years ago
parent
commit
7f1e7cdf46
1 changed files with 4 additions and 6 deletions
  1. 4 6
      src/core/nodeOps.ts

+ 4 - 6
src/core/nodeOps.ts

@@ -48,18 +48,16 @@ export const nodeOps: RendererOptions<TresObject, TresObject> = {
       instance = new target(...props.args)
     }
 
-    if (instance.isCamera) {
+    if (instance.isCamera && firstCamera) {
       if (!props?.position) {
         instance.position.set(3, 3, 3)
       }
       if (!props?.lookAt) {
         instance.lookAt(0, 0, 0)
       }
-      if (firstCamera) {
-        const { setFirstCamera } = useCamera()
-        setFirstCamera(instance)
-        firstCamera = false
-      }
+      const { setFirstCamera } = useCamera()
+      setFirstCamera(instance)
+      firstCamera = false
     }
 
     if (props?.attach === undefined) {