浏览代码

fix(core): added check for fog

Alvaro 2 年之前
父节点
当前提交
0a0f7d39ac
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      packages/tres/src/core/useInstanceCreator/index.ts

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

@@ -1,6 +1,6 @@
 /* eslint-disable new-cap */
 /* eslint-disable new-cap */
 /* eslint-disable @typescript-eslint/no-empty-function */
 /* eslint-disable @typescript-eslint/no-empty-function */
-import { OrthographicCamera, PerspectiveCamera, Scene } from 'three'
+import { FogBase, OrthographicCamera, PerspectiveCamera, Scene } from 'three'
 import { defineComponent, inject, Ref } from 'vue'
 import { defineComponent, inject, Ref } from 'vue'
 import { isArray, isDefined, isFunction } from '@alvarosabu/utils'
 import { isArray, isDefined, isFunction } from '@alvarosabu/utils'
 import { normalizeVectorFlexibleParam } from '/@/utils/normalize'
 import { normalizeVectorFlexibleParam } from '/@/utils/normalize'
@@ -45,7 +45,7 @@ export function useInstanceCreator(prefix: string) {
 
 
           // Check if the property is a function
           // Check if the property is a function
           if (isFunction(instance[camelKey])) {
           if (isFunction(instance[camelKey])) {
-            if(key === 'center' && !value) return
+            if (key === 'center' && !value) return
             // Call the function with the value, spread if it's an array
             // Call the function with the value, spread if it's an array
             instance[camelKey](...(isArray(value) ? value : [value]))
             instance[camelKey](...(isArray(value) ? value : [value]))
             return
             return
@@ -144,6 +144,10 @@ export function useInstanceCreator(prefix: string) {
               scene?.value.add(instance)
               scene?.value.add(instance)
             }
             }
 
 
+            if (scene?.value && instance.isFog) {
+              scene.value.fog = instance as unknown as FogBase
+            }
+
             if (import.meta.hot) {
             if (import.meta.hot) {
               import.meta.hot.on('vite:beforeUpdate', () => {
               import.meta.hot.on('vite:beforeUpdate', () => {
                 scene.value.remove(instance)
                 scene.value.remove(instance)