Browse Source

fix(core): only call the useCamera if the instance is camera

alvarosabu 2 years ago
parent
commit
17a8368e67
1 changed files with 2 additions and 1 deletions
  1. 2 1
      packages/tres/src/core/useInstanceCreator/index.ts

+ 2 - 1
packages/tres/src/core/useInstanceCreator/index.ts

@@ -24,7 +24,7 @@ const COLOR_KEYS = ['r', 'g', 'b']
  */
 export function useInstanceCreator(prefix: string) {
   const { /* logMessage, */ logError } = useLogger()
-  const { pushCamera } = useCamera()
+
   /**
    * Process props to `.setAttribute` on instance.
    *
@@ -270,6 +270,7 @@ export function useInstanceCreator(prefix: string) {
               processProps(attrs, instance)
               // If the instance is a camera, push it to the camera stack
               if (instance instanceof PerspectiveCamera || instance instanceof OrthographicCamera) {
+                const { pushCamera } = useCamera()
                 pushCamera(instance)
               }