From e2567681c678089463437723d6a505ac630f2849 Mon Sep 17 00:00:00 2001 From: alvarosabu Date: Mon, 8 May 2023 15:10:25 +0200 Subject: [PATCH] fix: akwardly added fog and fixed also typing --- playground/src/components/TheExperience.vue | 1 + plugins/vite-tres-types-plugin.ts | 6 ++++-- src/core/nodeOps.ts | 2 ++ src/types/tres-components.d.ts | 2 ++ 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/playground/src/components/TheExperience.vue b/playground/src/components/TheExperience.vue index bfe582379..1e00f9a12 100644 --- a/playground/src/components/TheExperience.vue +++ b/playground/src/components/TheExperience.vue @@ -31,6 +31,7 @@ watchEffect(() => { + diff --git a/plugins/vite-tres-types-plugin.ts b/plugins/vite-tres-types-plugin.ts index fe0aae63e..8d1562b5d 100644 --- a/plugins/vite-tres-types-plugin.ts +++ b/plugins/vite-tres-types-plugin.ts @@ -29,7 +29,8 @@ export const unplugin = createUnplugin(() => { key.endsWith('Material') || key.endsWith('Helper') || key.endsWith('Light') || - key.endsWith('Camera'), + key.endsWith('Camera') || + key.endsWith('Fog'), ) .join(',\n')} } from 'three'; @@ -92,7 +93,8 @@ export const unplugin = createUnplugin(() => { key.endsWith('Material') || key.endsWith('Helper') || key.endsWith('Light') || - key.endsWith('Camera'), + key.endsWith('Camera') || + key.endsWith('Fog'), ) .map(key => `Tres${key}: DefineComponent & TresModifiedObject>>`) .join('\n')} diff --git a/src/core/nodeOps.ts b/src/core/nodeOps.ts index d80585e03..fce3dc2c3 100644 --- a/src/core/nodeOps.ts +++ b/src/core/nodeOps.ts @@ -93,6 +93,8 @@ export const nodeOps: RendererOptions = { if (child?.isObject3D && parent?.isObject3D) { parent.add(child) child.dispatchEvent({ type: 'added' }) + } else if (child?.isFog) { + parent.fog = child } else if (typeof child?.attach === 'string') { child.__previousAttach = child[parent?.attach] if (parent) { diff --git a/src/types/tres-components.d.ts b/src/types/tres-components.d.ts index 6dbab621f..30de587b3 100644 --- a/src/types/tres-components.d.ts +++ b/src/types/tres-components.d.ts @@ -32,6 +32,7 @@ DodecahedronGeometry, EdgesGeometry, ExtrudeBufferGeometry, ExtrudeGeometry, +Fog, GridHelper, HemisphereLight, HemisphereLightHelper, @@ -206,6 +207,7 @@ TresDodecahedronGeometry: DefineComponent & TresModifiedObject>> TresExtrudeBufferGeometry: DefineComponent & TresModifiedObject>> TresExtrudeGeometry: DefineComponent & TresModifiedObject>> +TresFog: DefineComponent & TresModifiedObject>> TresGridHelper: DefineComponent & TresModifiedObject>> TresHemisphereLight: DefineComponent & TresModifiedObject>> TresHemisphereLightHelper: DefineComponent & TresModifiedObject>>