Procházet zdrojové kódy

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

alvarosabu před 2 roky
rodič
revize
17a8368e67

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

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