Răsfoiți Sursa

fix: temporaly cast the `disableRender` prop

alvarosabu 1 an în urmă
părinte
comite
16e215dd64
1 a modificat fișierele cu 4 adăugiri și 2 ștergeri
  1. 4 2
      src/components/TresScene.ts

+ 4 - 2
src/components/TresScene.ts

@@ -1,4 +1,4 @@
-import { App, defineComponent, h, onMounted, onUnmounted, ref, watch } from 'vue'
+import { App, computed, defineComponent, h, onMounted, onUnmounted, ref, watch, watchEffect } from 'vue'
 import * as THREE from 'three'
 import * as THREE from 'three'
 import { ColorSpace, ShadowMapType, ToneMapping } from 'three'
 import { ColorSpace, ShadowMapType, ToneMapping } from 'three'
 import { createTres } from '../core/renderer'
 import { createTres } from '../core/renderer'
@@ -64,6 +64,8 @@ export const TresScene = defineComponent<TresSceneProps>({
       logWarning('physicallyCorrectLights is deprecated, useLegacyLights is now false by default')
       logWarning('physicallyCorrectLights is deprecated, useLegacyLights is now false by default')
     }
     }
 
 
+    const isRenderDisabled = computed(() => props.disableRender !== false && props.disableRender !== undefined)
+
     const container = ref<HTMLElement>()
     const container = ref<HTMLElement>()
     const canvas = ref<HTMLElement>()
     const canvas = ref<HTMLElement>()
 
 
@@ -115,7 +117,7 @@ export const TresScene = defineComponent<TresSceneProps>({
       }
       }
 
 
       onLoop(() => {
       onLoop(() => {
-        if (activeCamera.value && props.disableRender !== true) renderer.value?.render(scene, activeCamera.value)
+        if (activeCamera.value && !isRenderDisabled.value) renderer.value?.render(scene, activeCamera.value)
       })
       })
     }
     }