Skip to content

Commit

Permalink
fix: correct type exporting issues (#625)
Browse files Browse the repository at this point in the history
* fix: correct type exporting issues

* chore: fix lint
  • Loading branch information
alvarosabu authored Apr 8, 2024
1 parent 1650b34 commit 8e52cf1
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 31 deletions.
2 changes: 1 addition & 1 deletion components.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/components/index.js'
export * from './dist/src/components/index.js'
2 changes: 1 addition & 1 deletion composables.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/composables/index.js'
export * from './dist/src/composables/index.js'
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"import": "./dist/tres.js"
},
"./components": {
"types": "./dist/components/index.d.ts"
"types": "./dist/src/components/index.d.ts"
},
"./composables": {
"types": "./dist/composables/index.d.ts"
"types": "./dist/src/composables/index.d.ts"
},
"./types": {
"types": "./dist/types/index.d.ts"
"types": "./dist/src/types/index.d.ts"
},
"./utils": {
"types": "./dist/utils/index.d.ts"
"types": "./dist/src/utils/index.d.ts"
},
"./*": "./*"
},
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useLoader/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isArray } from '@alvarosabu/utils'
import type { Object3D } from 'three'
import type { Loader, Object3D } from 'three'
import { useLogger } from '../useLogger'

export interface TresLoader<T> extends THREE.Loader {
export interface TresLoader<T> extends Loader {
load(
url: string,
onLoad?: (result: T) => void,
Expand Down
6 changes: 3 additions & 3 deletions src/composables/useRaycaster/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Vector2 } from 'three'
import type { Object3D, type Intersection } from 'three'
import type { Object3D, Intersection, Object3DEventMap } from 'three'
import type { Ref } from 'vue'
import { computed, onUnmounted } from 'vue'
import type { EventHook } from '@vueuse/core'
import { createEventHook, useElementBounding, usePointer } from '@vueuse/core'

import { type TresContext } from '../useTresContextProvider'

export type Intersects = Intersection<THREE.Object3D<THREE.Event>>[]
export type Intersects = Intersection<Object3D<Object3DEventMap>>[]
interface PointerMoveEventPayload {
intersects?: Intersects
event: PointerEvent
Expand All @@ -19,7 +19,7 @@ interface PointerClickEventPayload {
}

export const useRaycaster = (
objects: Ref<THREE.Object3D[]>,
objects: Ref<Object3D[]>,
{ renderer, camera, raycaster }: Pick<TresContext, 'renderer' | 'camera' | 'raycaster'>,
) => {
// having a separate computed makes useElementBounding work
Expand Down
37 changes: 19 additions & 18 deletions src/composables/useSeek/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Scene, Object3D } from 'three'
import { useLogger } from '../useLogger'

/**
Expand All @@ -7,10 +8,10 @@ import { useLogger } from '../useLogger'
* @interface UseSeekReturn
*/
export interface UseSeekReturn {
seek: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D | null
seekByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D | null
seekAll: (parent: THREE.Scene | THREE.Object3D, property: string, value: string) => THREE.Object3D[]
seekAllByName: (parent: THREE.Scene | THREE.Object3D, value: string) => THREE.Object3D[]
seek: (parent: Scene | Object3D, property: string, value: string) => Object3D | null
seekByName: (parent: Scene | Object3D, value: string) => Object3D | null
seekAll: (parent: Scene | Object3D, property: string, value: string) => Object3D[]
seekAllByName: (parent: Scene | Object3D, value: string) => Object3D[]
}

/**
Expand All @@ -25,13 +26,13 @@ export function useSeek(): UseSeekReturn {
/**
* Returns a child object of the parent given a property
*
* @param {(THREE.Scene | THREE.Object3D)} parent
* @param {(Scene | Object3D)} parent
* @param {string} property
* @param {string} value
* @return {*} {(THREE.Object3D | null)}
* @return {*} {(Object3D | null)}
*/
function seek(parent: THREE.Scene | THREE.Object3D, property: string, value: string): THREE.Object3D | null {
let foundChild: THREE.Object3D | null = null
function seek(parent: Scene | Object3D, property: string, value: string): Object3D | null {
let foundChild: Object3D | null = null

parent.traverse((child) => {
if ((child as any)[property] === value) {
Expand All @@ -49,13 +50,13 @@ export function useSeek(): UseSeekReturn {
/**
* Returns an array of child objects of the parent given a property
*
* @param {(THREE.Scene | THREE.Object3D)} parent
* @param {(Scene | Object3D)} parent
* @param {string} property
* @param {string} value
* @return {*} {(THREE.Object3D[])}
* @return {*} {(Object3D[])}
*/
function seekAll(parent: THREE.Scene | THREE.Object3D, property: string, value: string): THREE.Object3D[] {
const foundChildren: THREE.Object3D[] = []
function seekAll(parent: Scene | Object3D, property: string, value: string): Object3D[] {
const foundChildren: Object3D[] = []

parent.traverse((child) => {
if ((child as any)[property].includes(value)) {
Expand All @@ -73,22 +74,22 @@ export function useSeek(): UseSeekReturn {
/**
* Returns a child object of the parent given a child.name
*
* @param {(THREE.Scene | THREE.Object3D)} parent
* @param {(Scene | Object3D)} parent
* @param {string} value
* @return {*} {(THREE.Object3D | null)}
* @return {*} {(Object3D | null)}
*/
function seekByName(parent: THREE.Scene | THREE.Object3D, value: string): THREE.Object3D | null {
function seekByName(parent: Scene | Object3D, value: string): Object3D | null {
return seek(parent, 'name', value)
}

/**
* Returns an array of child objects of the parent given a child.name
*
* @param {(THREE.Scene | THREE.Object3D)} parent
* @param {(Scene | Object3D)} parent
* @param {string} value
* @return {*} {(THREE.Object3D[])}
* @return {*} {(Object3D[])}
*/
function seekAllByName(parent: THREE.Scene | THREE.Object3D, value: string): THREE.Object3D[] {
function seekAllByName(parent: Scene | Object3D, value: string): Object3D[] {
return seekAll(parent, 'name', value)
}

Expand Down
2 changes: 1 addition & 1 deletion types.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/types/index.js'
export * from './dist/src/types/index.js'
2 changes: 1 addition & 1 deletion utils.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/utils/index.js'
export * from './dist/src/utils/index.js'

0 comments on commit 8e52cf1

Please sign in to comment.