1
0
Эх сурвалжийг харах

fix: temporaly cast the `disableRender` prop (#322)

* fix: temporaly cast the `disableRender` prop

* chore: add comment for refactor
Alvaro Saburido 1 жил өмнө
parent
commit
9cc63d2af5

+ 5 - 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 { ColorSpace, ShadowMapType, ToneMapping } from 'three'
 import { createTres } from '../core/renderer'
@@ -64,6 +64,9 @@ export const TresScene = defineComponent<TresSceneProps>({
       logWarning('physicallyCorrectLights is deprecated, useLegacyLights is now false by default')
     }
 
+    // TODO: refactor this when this component is refactored to SFC (single file component)
+    const isRenderDisabled = computed(() => props.disableRender !== false && props.disableRender !== undefined)
+
     const container = ref<HTMLElement>()
     const canvas = ref<HTMLElement>()
 
@@ -115,7 +118,7 @@ export const TresScene = defineComponent<TresSceneProps>({
       }
 
       onLoop(() => {
-        if (activeCamera.value && props.disableRender !== true) renderer.value?.render(scene, activeCamera.value)
+        if (activeCamera.value && !isRenderDisabled.value) renderer.value?.render(scene, activeCamera.value)
       })
     }