소스 검색

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

alvarosabu 2 년 전
부모
커밋
17a8368e67
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  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)
               }