Skip to content
This repository was archived by the owner on Feb 1, 2026. It is now read-only.

Commit 1d8dbb8

Browse files
committed
refactor: update type references to TresObject for improved type safety
- Changed the type of `dummy` in `TransformPayload` to `TresObject` for better alignment with TresJS framework. - Updated `objRef` and `parentRef` in `Helper/component.vue` to use `TresObject`, enhancing type accuracy. - Modified the `useHelper` function to accept `MaybeRefOrGetter<TresObject>` instead of `Object3D`, ensuring consistency across helper functionalities. - These changes improve type safety and maintainability in the codebase.
1 parent eb337d4 commit 1d8dbb8

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/core/abstractions/useSurfaceSampler/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { MeshSurfaceSampler } from 'three-stdlib'
88
import { ref } from 'vue'
99
import type { InstancedMesh, Mesh, Object3DEventMap } from 'three'
10+
import type { TresObject } from '@tresjs/core'
1011

1112
export interface useSurfaceSamplerProps {
1213
/*
@@ -67,7 +68,7 @@ type TransformPayload = SamplePayload & {
6768
* This object's matrix will be updated after transforming & it will be used
6869
* to set the instance's matrix.
6970
*/
70-
dummy: Object3D<Object3DEventMap>
71+
dummy: TresObject
7172
/**
7273
* The mesh that's initially passed to the sampler.
7374
* Use this if you need to apply transforms from your mesh to your instances
@@ -101,7 +102,7 @@ export const useSurfaceSampler = (
101102
const position = new Vector3()
102103
const normal = new Vector3()
103104
const color = new Color()
104-
const dummy = new Object3D<Object3DEventMap>()
105+
const dummy = new Object3D<Object3DEventMap>() as TresObject
105106

106107
mesh.updateMatrixWorld(true)
107108

src/core/controls/Helper/component.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import type { Object3D } from 'three'
33
import { shallowRef, watchEffect } from 'vue'
44
import { useHelper } from './useHelper'
5+
import type { TresObject } from '@tresjs/core'
56
67
type HelperConstructor = new (...args: any[]) => any
78
@@ -12,8 +13,8 @@ export interface HelperProps {
1213
1314
const props = defineProps<HelperProps>()
1415
15-
const objRef = shallowRef<Object3D>()
16-
const parentRef = shallowRef<Object3D>()
16+
const objRef = shallowRef<TresObject>()
17+
const parentRef = shallowRef<TresObject>()
1718
1819
watchEffect(() => {
1920
if (objRef.value && objRef.value.parent) {

src/core/controls/Helper/useHelper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Object3D } from 'three'
22
import type { MaybeRefOrGetter } from 'vue'
33
import { onBeforeUnmount, shallowRef, toValue, watchEffect } from 'vue'
4+
import type { TresObject } from '@tresjs/core'
45
import { useLoop, useTres } from '@tresjs/core'
56

67
// NOTE: Source
@@ -10,7 +11,7 @@ type HelperType = Object3D & { update: () => void, dispose: () => void }
1011
type HelperConstructor = new (...args: any[]) => any
1112

1213
export function useHelper<T extends HelperConstructor>(
13-
object3D: MaybeRefOrGetter<Object3D | null | undefined | false>,
14+
object3D: MaybeRefOrGetter<TresObject | null | undefined | false>,
1415
helperConstructor: T,
1516
...args: any[]
1617
) {

0 commit comments

Comments
 (0)