Skip to content

Commit

Permalink
fix: akwardly added fog and fixed also typing
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed May 8, 2023
1 parent e744672 commit e256768
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions playground/src/components/TheExperience.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ watchEffect(() => {
<TresCanvas v-bind="gl" ref="context">
<TresPerspectiveCamera :position="[7, 7, 7]" :look-at="[0, 4, 0]" />
<OrbitControls />
<TresFog :color="gl.clearColor" :near="5" :far="15" />
<TresMesh :position="[-2, 6, 0]" :rotation="[0, Math.PI, 0]" cast-shadow>
<TresConeGeometry :args="[1, 1.5, 3]" />
<TresMeshToonMaterial color="#82DBC5" />
Expand Down
6 changes: 4 additions & 2 deletions plugins/vite-tres-types-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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<Partial<Omit<${key}, OverwrittenProps > & TresModifiedObject>>`)
.join('\n')}
Expand Down
2 changes: 2 additions & 0 deletions src/core/nodeOps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export const nodeOps: RendererOptions<TresObject, TresObject> = {
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) {
Expand Down
2 changes: 2 additions & 0 deletions src/types/tres-components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ DodecahedronGeometry,
EdgesGeometry,
ExtrudeBufferGeometry,
ExtrudeGeometry,
Fog,
GridHelper,
HemisphereLight,
HemisphereLightHelper,
Expand Down Expand Up @@ -206,6 +207,7 @@ TresDodecahedronGeometry: DefineComponent<Partial<Omit<DodecahedronGeometry, Ove
TresEdgesGeometry: DefineComponent<Partial<Omit<EdgesGeometry, OverwrittenProps > & TresModifiedObject>>
TresExtrudeBufferGeometry: DefineComponent<Partial<Omit<ExtrudeBufferGeometry, OverwrittenProps > & TresModifiedObject>>
TresExtrudeGeometry: DefineComponent<Partial<Omit<ExtrudeGeometry, OverwrittenProps > & TresModifiedObject>>
TresFog: DefineComponent<Partial<Omit<Fog, OverwrittenProps > & TresModifiedObject>>
TresGridHelper: DefineComponent<Partial<Omit<GridHelper, OverwrittenProps > & TresModifiedObject>>
TresHemisphereLight: DefineComponent<Partial<Omit<HemisphereLight, OverwrittenProps > & TresModifiedObject>>
TresHemisphereLightHelper: DefineComponent<Partial<Omit<HemisphereLightHelper, OverwrittenProps > & TresModifiedObject>>
Expand Down

0 comments on commit e256768

Please sign in to comment.