@tresjs/core 5.0.0-next.5 → 5.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,39 +25,39 @@ declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<Tr
25
25
  context: import('vue').ShallowRef<TresContext | null, TresContext | null>;
26
26
  dispose: () => void;
27
27
  }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
28
- click: (event: PointerEvent<MouseEvent>) => any;
29
- contextmenu: (event: PointerEvent<MouseEvent>) => any;
28
+ render: (context: TresContext) => any;
30
29
  pointermove: (event: PointerEvent<MouseEvent>) => any;
30
+ pointercancel: (event: PointerEvent<MouseEvent>) => any;
31
+ pointerdown: (event: PointerEvent<MouseEvent>) => any;
32
+ pointerup: (event: PointerEvent<MouseEvent>) => any;
31
33
  pointerenter: (event: PointerEvent<MouseEvent>) => any;
32
34
  pointerleave: (event: PointerEvent<MouseEvent>) => any;
33
35
  pointerover: (event: PointerEvent<MouseEvent>) => any;
34
36
  pointerout: (event: PointerEvent<MouseEvent>) => any;
37
+ click: (event: PointerEvent<MouseEvent>) => any;
35
38
  dblclick: (event: PointerEvent<MouseEvent>) => any;
36
- pointerdown: (event: PointerEvent<MouseEvent>) => any;
37
- pointerup: (event: PointerEvent<MouseEvent>) => any;
38
- pointercancel: (event: PointerEvent<MouseEvent>) => any;
39
- lostpointercapture: (event: PointerEvent<MouseEvent>) => any;
39
+ contextmenu: (event: PointerEvent<MouseEvent>) => any;
40
40
  wheel: (event: PointerEvent<MouseEvent>) => any;
41
- render: (context: TresContext) => any;
41
+ lostpointercapture: (event: PointerEvent<MouseEvent>) => any;
42
42
  loop: (context: TresContextWithClock) => any;
43
43
  ready: (context: TresContext) => any;
44
44
  pointermissed: (event: PointerEvent<MouseEvent>) => any;
45
45
  beforeLoop: (context: TresContextWithClock) => any;
46
46
  }, string, import('vue').PublicProps, Readonly<TresCanvasProps> & Readonly<{
47
- onClick?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
48
- onContextmenu?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
47
+ onRender?: ((context: TresContext) => any) | undefined;
49
48
  onPointermove?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
49
+ onPointercancel?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
50
+ onPointerdown?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
51
+ onPointerup?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
50
52
  onPointerenter?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
51
53
  onPointerleave?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
52
54
  onPointerover?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
53
55
  onPointerout?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
56
+ onClick?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
54
57
  onDblclick?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
55
- onPointerdown?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
56
- onPointerup?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
57
- onPointercancel?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
58
- onLostpointercapture?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
58
+ onContextmenu?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
59
59
  onWheel?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
60
- onRender?: ((context: TresContext) => any) | undefined;
60
+ onLostpointercapture?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
61
61
  onLoop?: ((context: TresContextWithClock) => any) | undefined;
62
62
  onReady?: ((context: TresContext) => any) | undefined;
63
63
  onPointermissed?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
@@ -5,5 +5,5 @@ export * from './useLoader';
5
5
  export * from './useLoop';
6
6
  export * from './useRenderer/useRendererManager';
7
7
  export * from './useTres';
8
- export * from './useTresContextProvider';
8
+ export { type TresContext, useTresContext, useTresContextProvider } from './useTresContextProvider';
9
9
  export { UseLoader };
@@ -2,17 +2,13 @@ export interface RafLoopContext {
2
2
  delta: number;
3
3
  elapsed: number;
4
4
  }
5
- type LoopFunction = (notifySuccess: () => void) => void;
6
5
  /**
7
- * @param defaultFunction the default function that is called before after the after event hook is triggered and after the before is triggered.
8
- * @param notifySuccess a callback that should be called to indicate a successfull cycle.
6
+ * @param cycleFn the function that is called before the after event hook is triggered and after the before event hook is triggered.
9
7
  */
10
- export declare const useCreateRafLoop: (defaultFunction: LoopFunction, notifySuccess: () => void) => {
8
+ export declare const useCreateRafLoop: (cycleFn: () => void) => {
11
9
  start: () => void;
12
10
  stop: () => void;
13
11
  isActive: Readonly<import('vue').ShallowRef<boolean>>;
14
12
  onBeforeLoop: import('@vueuse/core').EventHookOn<RafLoopContext>;
15
13
  onLoop: import('@vueuse/core').EventHookOn<RafLoopContext>;
16
- replaceLoopFunction: (fn: LoopFunction) => void;
17
14
  };
18
- export {};
@@ -1,3 +1,3 @@
1
1
  import { MaybeRef } from '@vueuse/core';
2
2
  import { TresObject } from '../../types';
3
- export declare function useGraph(object: MaybeRef<TresObject>): import('vue').ComputedRef<import('../..').TresObjectMap>;
3
+ export declare const useGraph: (object: MaybeRef<TresObject | undefined>) => import('vue').ComputedRef<import('../..').TresObjectMap | undefined>;
@@ -5,7 +5,7 @@ declare const _default: <T extends TresObjectMap>(__VLS_props: NonNullable<Await
5
5
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
6
6
  readonly onLoaded?: ((result: T) => any) | undefined;
7
7
  readonly onError?: ((error: unknown) => any) | undefined;
8
- } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onLoaded" | "onError"> & {
8
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onError" | "onLoaded"> & {
9
9
  /**
10
10
  * The THREE.js loader to use
11
11
  */
@@ -10,5 +10,5 @@ export declare const useLoop: () => {
10
10
  isActive: Readonly<import('vue').ShallowRef<boolean>>;
11
11
  onBeforeRender: import('../../utils/createPriorityEventHook').PriorityEventHookOn<LoopContext>;
12
12
  onRender: import('../../utils/createPriorityEventHook').PriorityEventHookOn<LoopContext>;
13
- render: (fn: (notifySuccess: () => void) => void) => void;
13
+ render: (fn: import('..').RenderFunction) => void;
14
14
  };
@@ -0,0 +1,4 @@
1
+ export declare const setPixelRatio: (renderer: {
2
+ setPixelRatio?: (dpr: number) => void;
3
+ getPixelRatio?: () => number;
4
+ }, systemDpr: number, userDpr?: number | [number, number]) => void;
@@ -11,6 +11,7 @@ import { TresScene } from '../../types';
11
11
  * If set to 'always', the scene will be rendered every frame
12
12
  */
13
13
  export type RenderMode = 'always' | 'on-demand' | 'manual';
14
+ export type RenderFunction = (notifySuccess: () => void) => void;
14
15
  export type TresRenderer = WebGLRenderer | Renderer;
15
16
  export interface RendererOptions {
16
17
  /**
@@ -180,7 +181,6 @@ export declare function useRendererManager({ scene, canvas, options, contextPart
180
181
  isActive: Readonly<ShallowRef<boolean>>;
181
182
  onBeforeLoop: import('@vueuse/core').EventHookOn<import('../useCreateRafLoop').RafLoopContext>;
182
183
  onLoop: import('@vueuse/core').EventHookOn<import('../useCreateRafLoop').RafLoopContext>;
183
- replaceLoopFunction: (fn: (notifySuccess: () => void) => void) => void;
184
184
  };
185
185
  instance: TresRenderer;
186
186
  advance: () => void;
@@ -189,5 +189,6 @@ export declare function useRendererManager({ scene, canvas, options, contextPart
189
189
  invalidate: (amountOfFramesToInvalidate?: number) => void;
190
190
  canBeInvalidated: import('vue').ComputedRef<boolean>;
191
191
  mode: "always" | "on-demand" | "manual" | undefined;
192
+ replaceRenderFunction: (fn: RenderFunction) => void;
192
193
  };
193
194
  export type UseRendererManagerReturn = ReturnType<typeof useRendererManager>;
@@ -13,10 +13,12 @@ export interface TresContext {
13
13
  renderer: UseRendererManagerReturn;
14
14
  events: ReturnType<typeof useEventManager>;
15
15
  }
16
- export declare function useTresContextProvider({ scene, canvas, windowSize, rendererOptions, }: {
16
+ export declare const INJECTION_KEY = "useTres";
17
+ declare const useTresContextProvider: (args_0: {
17
18
  scene: TresScene;
18
19
  canvas: MaybeRef<HTMLCanvasElement>;
19
20
  windowSize: MaybeRefOrGetter<boolean>;
20
21
  rendererOptions: RendererOptions;
21
- }): TresContext;
22
- export declare function useTresContext(): TresContext;
22
+ }) => TresContext;
23
+ declare const useTresContext: () => TresContext;
24
+ export { useTresContext, useTresContextProvider };
@@ -0,0 +1,53 @@
1
+ export type DevtoolsMessageType = 'performance' | 'context' | 'asset-load';
2
+ export interface AssetLoadData {
3
+ url: string;
4
+ type: string;
5
+ loaded: boolean;
6
+ size: number;
7
+ asset: HTMLImageElement | HTMLScriptElement | HTMLLinkElement | Blob | ArrayBuffer | null;
8
+ }
9
+ export interface DevtoolsMessage<T = any> {
10
+ type: DevtoolsMessageType;
11
+ data: T;
12
+ timestamp?: number;
13
+ }
14
+ export type DevtoolsSubscriber = (message: DevtoolsMessage) => void;
15
+ /**
16
+ * Messenger class for communicating with Tres DevTools
17
+ * This class will be attached to window.__TRES__DEVTOOLS__
18
+ */
19
+ export declare class DevtoolsMessenger {
20
+ private subscribers;
21
+ private messageQueue;
22
+ private maxQueueSize;
23
+ /**
24
+ * Send a message to devtools subscribers
25
+ * If no subscribers are available, only queueable message types are queued
26
+ */
27
+ send<T>(type: DevtoolsMessageType, data: T): void;
28
+ /**
29
+ * Queue a message for later delivery
30
+ */
31
+ private queueMessage;
32
+ /**
33
+ * Flush all queued messages to current subscribers
34
+ */
35
+ private flushQueue;
36
+ /**
37
+ * Subscribe to devtools messages
38
+ * When a new subscriber is added, all queued messages (asset-load events) are immediately delivered
39
+ */
40
+ subscribe(subscriber: DevtoolsSubscriber): () => void;
41
+ /**
42
+ * Check if there are any subscribers
43
+ */
44
+ get hasSubscribers(): boolean;
45
+ /**
46
+ * Get the current queue size
47
+ */
48
+ get queueSize(): number;
49
+ /**
50
+ * Clear all queued messages
51
+ */
52
+ clearQueue(): void;
53
+ }
@@ -1 +1,2 @@
1
+ export * from './DevtoolsMessenger';
1
2
  export { registerTresDevtools } from './plugin';
@@ -5,9 +5,12 @@ import { default as templateCompilerOptions } from './utils/template-compiler-op
5
5
  export * from './components';
6
6
  export * from './composables';
7
7
  export * from './core/catalogue';
8
+ export * from './devtools';
8
9
  export * from './directives';
9
10
  export * from './types';
10
11
  export * from './utils/graph';
12
+ export * from './utils/is/three';
13
+ export * from './utils/is/tres';
11
14
  export * from './utils/logger';
12
15
  export interface TresOptions {
13
16
  extends?: Record<string, unknown>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Like Array.filter, but modifies the array in place.
3
+ * @param array - Array to modify
4
+ * @param callbackFn - A function called for each element of the array. It should return a truthy value to keep the element in the array.
5
+ */
6
+ export declare const filterInPlace: <T>(array: T[], callbackFn: (element: T, index: number) => unknown) => T[];
@@ -1,4 +1,4 @@
1
- import { Mesh, Scene } from 'three';
1
+ import { Mesh, Object3D, Scene } from 'three';
2
2
  import { TresMaterial, TresObject } from '../types';
3
3
  export interface TresObjectMap {
4
4
  nodes: {
@@ -12,4 +12,4 @@ export interface TresObjectMap {
12
12
  };
13
13
  scene?: Scene;
14
14
  }
15
- export declare function buildGraph(object: TresObject): TresObjectMap;
15
+ export declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
@@ -1,34 +1,10 @@
1
1
  import { nodeOps } from 'src/core/nodeOps';
2
2
  import { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types';
3
- import { Material, Mesh, MeshBasicMaterial, Scene, Vector3 } from 'three';
3
+ import { Material } from 'three';
4
4
  import { TresContext } from '../composables/useTresContextProvider';
5
5
  export * from './logger';
6
- export declare function toSetMethodName(key: string): string;
7
- export declare const merge: (target: any, source: any) => any;
8
- export declare const isHTMLTag: (key: string) => boolean;
9
- export declare function isDOMElement(obj: any): obj is HTMLElement;
10
- export declare function kebabToCamel(str: string): string;
11
- export declare function hyphenate(str: string): string;
12
- export declare function makeMap(str: string, expectsLowerCase?: boolean): (key: string) => boolean;
13
- export declare const uniqueBy: <T, K>(array: T[], iteratee: (value: T) => K) => T[];
14
- export declare const get: <T>(obj: any, path: string | string[]) => T | undefined;
15
- export declare const set: (obj: any, path: string | string[], value: any) => void;
16
- export declare function deepEqual(a: any, b: any): boolean;
17
- export declare function deepArrayEqual(arr1: any[], arr2: any[]): boolean;
18
- export declare function editSceneObject(scene: Scene, objectUuid: string, propertyPath: string[], value: any): void;
19
- export declare function createHighlightMaterial(): MeshBasicMaterial;
20
- export declare function animateHighlight(highlightMesh: Mesh, startTime: number): void;
21
- export declare function stopHighlightAnimation(): void;
22
- export declare function createHighlightMesh(object: TresObject): Mesh;
23
- export declare function extractBindingPosition(binding: any): Vector3;
24
6
  export declare function disposeMaterial(material: Material): void;
25
7
  export declare function disposeObject3D(object: TresObject): void;
26
- /**
27
- * Like Array.filter, but modifies the array in place.
28
- * @param array - Array to modify
29
- * @param callbackFn - A function called for each element of the array. It should return a truthy value to keep the element in the array.
30
- */
31
- export declare function filterInPlace<T>(array: T[], callbackFn: (element: T, index: number) => unknown): T[];
32
8
  export declare function resolve(obj: Record<string, any>, key: string): {
33
9
  target: Record<string, any>;
34
10
  key: string;
@@ -37,11 +13,6 @@ export declare function attach(parent: TresInstance, child: TresInstance, type:
37
13
  export declare function detach(parent: any, child: TresInstance, type: AttachType): void;
38
14
  export declare function prepareTresInstance<T extends TresObject>(obj: T, state: Partial<LocalState>, context: TresContext): TresInstance;
39
15
  export declare function invalidateInstance(instance: TresObject): void;
40
- export declare function noop(fn: string): any;
41
- export declare function setPixelRatio(renderer: {
42
- setPixelRatio?: (dpr: number) => void;
43
- getPixelRatio?: () => number;
44
- }, systemDpr: number, userDpr?: number | [number, number]): void;
45
16
  export declare function setPrimitiveObject(newObject: TresObject, primitive: TresPrimitive, setTarget: (object: TresObject) => void, nodeOpsFns: Pick<ReturnType<typeof nodeOps>, 'patchProp' | 'insert' | 'remove'>, context: TresContext): boolean;
46
17
  export declare function unboxTresPrimitive<T>(maybePrimitive: T): T | TresInstance;
47
18
  export declare function doRemoveDetach(node: TresObject, context: TresContext): void;
@@ -0,0 +1 @@
1
+ export declare const isHTMLTag: (key: string) => boolean;
@@ -0,0 +1,4 @@
1
+ export * from './dom';
2
+ export * from './three';
3
+ export * from './tres';
4
+ export * from './typed';
@@ -0,0 +1,162 @@
1
+ import { BufferGeometry, Camera, Color, ColorRepresentation, Fog, Group, Light, Material, Mesh, Object3D, OrthographicCamera, PerspectiveCamera, Scene, Layers } from 'three';
2
+ /**
3
+ * Type guard to check if a value is a Three.js Object3D
4
+ * @param value - The value to check
5
+ * @returns True if the value is a Three.js Object3D instance, false otherwise
6
+ * @example
7
+ * ```ts
8
+ * const value = new THREE.Object3D()
9
+ * if (isObject3D(value)) {
10
+ * // TypeScript knows value is Object3D here
11
+ * value.position // OK
12
+ * value.rotation // OK
13
+ * value.scale // OK
14
+ * }
15
+ * ```
16
+ */
17
+ export declare const isObject3D: (value: unknown) => value is Object3D<import('three').Object3DEventMap>;
18
+ /**
19
+ * Type guard to check if a value is a Three.js Mesh
20
+ * @param value - The value to check
21
+ * @returns True if the value is a Three.js Mesh instance, false otherwise
22
+ * @example
23
+ * ```ts
24
+ * const value = new THREE.Mesh()
25
+ * if (isMesh(value)) {
26
+ * // TypeScript knows value is Mesh here
27
+ * value.geometry // OK
28
+ */
29
+ export declare const isMesh: (value: unknown) => value is Mesh<BufferGeometry<import('three').NormalBufferAttributes, import('three').BufferGeometryEventMap>, Material | Material[], import('three').Object3DEventMap>;
30
+ /**
31
+ * Type guard to check if a value is a Three.js Camera
32
+ * @param value - The value to check
33
+ * @returns True if the value is a Three.js Camera instance, false otherwise
34
+ * @example
35
+ * ```ts
36
+ * const value = new THREE.PerspectiveCamera()
37
+ * if (isCamera(value)) {
38
+ * // TypeScript knows value is Camera here
39
+ * value.fov // OK
40
+ * value.near // OK
41
+ * value.far // OK
42
+ * }
43
+ * ```
44
+ */
45
+ export declare const isCamera: (value: unknown) => value is Camera;
46
+ /**
47
+ * Type guard to check if a value is a Three.js OrthographicCamera
48
+ * @param value - The value to check
49
+ * @returns True if the value is a Three.js OrthographicCamera instance, false otherwise
50
+ */
51
+ export declare const isOrthographicCamera: (value: unknown) => value is OrthographicCamera;
52
+ /**
53
+ * Type guard to check if a value is a Three.js PerspectiveCamera
54
+ * @param value - The value to check
55
+ * @returns True if the value is a Three.js PerspectiveCamera instance, false otherwise
56
+ */
57
+ export declare const isPerspectiveCamera: (value: unknown) => value is PerspectiveCamera;
58
+ /**
59
+ * Type guard to check if a value is a Three.js Color
60
+ * @param value - The value to check
61
+ * @returns True if the value is a Three.js Color instance, false otherwise
62
+ */
63
+ export declare const isColor: (value: unknown) => value is Color;
64
+ /**
65
+ * Type guard to check if a value is a Three.js ColorRepresentation
66
+ * @param value - The value to check
67
+ * @returns True if the value is a Three.js ColorRepresentation instance, false otherwise
68
+ */
69
+ export declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation;
70
+ /**
71
+ * Type guard to check if a value is a Three.js Layers
72
+ * @param value - The value to check
73
+ * @returns True if the value is a Three.js Layers instance, false otherwise
74
+ */
75
+ export declare const isLayers: (value: unknown) => value is Layers;
76
+ /**
77
+ * Type guard to check if a value is a Three.js BufferGeometry
78
+ * @param value - The value to check
79
+ * @returns True if the value is a Three.js BufferGeometry instance, false otherwise
80
+ * @example
81
+ * ```ts
82
+ * const value = new THREE.BufferGeometry()
83
+ * if (isBufferGeometry(value)) {
84
+ * // TypeScript knows value is BufferGeometry here
85
+ * value.attributes // OK
86
+ * value.index // OK
87
+ * value.computeVertexNormals() // OK
88
+ * }
89
+ * ```
90
+ */
91
+ export declare const isBufferGeometry: (value: unknown) => value is BufferGeometry<import('three').NormalBufferAttributes, import('three').BufferGeometryEventMap>;
92
+ /**
93
+ * Type guard to check if a value is a Three.js Material
94
+ * @param value - The value to check
95
+ * @returns True if the value is a Three.js Material instance, false otherwise
96
+ * @example
97
+ * ```ts
98
+ * const value = new THREE.MeshStandardMaterial()
99
+ * if (isMaterial(value)) {
100
+ * // TypeScript knows value is Material here
101
+ * value.color // OK
102
+ * value.metalness // OK
103
+ * value.roughness // OK
104
+ * }
105
+ * ```
106
+ */
107
+ export declare const isMaterial: (value: unknown) => value is Material;
108
+ /**
109
+ * Type guard to check if a value is a Three.js Light
110
+ * @param value - The value to check
111
+ * @returns True if the value is a Three.js Light instance, false otherwise
112
+ * @example
113
+ * ```ts
114
+ * const value = new THREE.DirectionalLight()
115
+ * if (isLight(value)) {
116
+ * // TypeScript knows value is Light here
117
+ * value.intensity // OK
118
+ * value.color // OK
119
+ * value.position // OK
120
+ * }
121
+ * ```
122
+ */
123
+ export declare const isLight: (value: unknown) => value is Light<import('three').LightShadow<Camera> | undefined>;
124
+ /**
125
+ * Type guard to check if a value is a Three.js Fog
126
+ * @param value - The value to check
127
+ * @returns True if the value is a Three.js Fog instance, false otherwise
128
+ * @example
129
+ * ```ts
130
+ * const value = new THREE.Fog(0x000000, 1, 1000)
131
+ * if (isFog(value)) {
132
+ * // TypeScript knows value is Fog here
133
+ * value.color // OK
134
+ * value.near // OK
135
+ * value.far // OK
136
+ * }
137
+ * ```
138
+ */
139
+ export declare const isFog: (value: unknown) => value is Fog;
140
+ /**
141
+ * Type guard to check if a value is a Three.js Scene
142
+ * @param value - The value to check
143
+ * @returns True if the value is a Three.js Scene instance, false otherwise
144
+ * @example
145
+ * ```ts
146
+ * const value = new THREE.Scene()
147
+ * if (isScene(value)) {
148
+ * // TypeScript knows value is Scene here
149
+ * value.children // OK
150
+ * value.add(new THREE.Object3D()) // OK
151
+ * value.remove(new THREE.Object3D()) // OK
152
+ * }
153
+ * ```
154
+ */
155
+ export declare const isScene: (value: unknown) => value is Scene;
156
+ /**
157
+ * Type guard to check if a value is a Three.js Group
158
+ * @param value - The value to check
159
+ * @returns True if the value is a Three.js Group instance, false otherwise
160
+ * ```
161
+ */
162
+ export declare const isGroup: (value: unknown) => value is Group<import('three').Object3DEventMap>;
@@ -0,0 +1,70 @@
1
+ import { TresCamera, TresInstance, TresObject, TresPrimitive } from 'src/types';
2
+ interface VectorLike {
3
+ set: (...args: any[]) => void;
4
+ constructor?: (...args: any[]) => any;
5
+ }
6
+ export declare const isVectorLike: (value: unknown) => value is VectorLike;
7
+ interface Copyable {
8
+ copy: (...args: any[]) => void;
9
+ constructor?: (...args: any[]) => any;
10
+ }
11
+ export declare const isCopyable: (value: unknown) => value is Copyable;
12
+ interface ClassInstance {
13
+ constructor?: (...args: any[]) => any;
14
+ }
15
+ export declare const isClassInstance: (object: unknown) => object is ClassInstance;
16
+ /**
17
+ * Type guard to check if a value is a TresCamera
18
+ * @param value - The value to check
19
+ * @returns True if the value is a TresCamera instance, false otherwise
20
+ */
21
+ export declare const isTresCamera: (value: unknown) => value is TresCamera;
22
+ /**
23
+ * Type guard to check if a value is a TresObject
24
+ * @param value - The value to check
25
+ * @returns True if the value is a TresObject (Object3D | BufferGeometry | Material | Fog), false otherwise
26
+ * @example
27
+ * ```ts
28
+ * const value = new THREE.Mesh()
29
+ * if (isTresObject(value)) {
30
+ * // TypeScript knows value is TresObject here
31
+ * // You can use common properties and methods shared by all TresObjects
32
+ * }
33
+ * ```
34
+ * @remarks
35
+ * TresObject is a union type that represents the core Three.js objects that can be used in TresJS.
36
+ * This includes Object3D, BufferGeometry, Material, and Fog instances.
37
+ */
38
+ export declare const isTresObject: (value: unknown) => value is TresObject;
39
+ /**
40
+ * Type guard to check if a value is a TresPrimitive
41
+ * @param value - The value to check
42
+ * @returns True if the value is a TresPrimitive instance, false otherwise
43
+ * @example
44
+ * ```ts
45
+ * const value = { isPrimitive: true }
46
+ * if (isTresPrimitive(value)) {
47
+ * // TypeScript knows value is TresPrimitive here
48
+ * // You can use properties and methods specific to TresPrimitives
49
+ * }
50
+ * ```
51
+ * @remarks
52
+ * TresPrimitive is a special type in TresJS that represents primitive objects
53
+ * that can be used directly in the scene without needing to be wrapped in a Three.js object.
54
+ */
55
+ export declare const isTresPrimitive: (value: unknown) => value is TresPrimitive;
56
+ /**
57
+ * Type guard to check if a value is a TresInstance (has __tres property)
58
+ * @param value - The value to check
59
+ * @returns True if the value is a TresInstance (has __tres property), false otherwise
60
+ * @example
61
+ * ```ts
62
+ * const value = new THREE.Mesh()
63
+ * if (isTresInstance(value)) {
64
+ * // TypeScript knows value is TresInstance here
65
+ * // You can safely access value.__tres
66
+ * }
67
+ * ```
68
+ */
69
+ export declare const isTresInstance: (value: unknown) => value is TresInstance;
70
+ export {};
@@ -0,0 +1 @@
1
+ export { isBoolean, isEqual, isFunction, isNumber, isObject, isString, isUndefined } from 'radashi';
@@ -0,0 +1 @@
1
+ export declare const createTypeGuard: <T>(property: keyof T) => (value: unknown) => value is T;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Make a map and return a function for checking if a key
3
+ * is in that map.
4
+ * IMPORTANT: all calls of this function must be prefixed with
5
+ * \/\*#\_\_PURE\_\_\*\/
6
+ * So that rollup can tree-shake them if necessary.
7
+ */
8
+ /*! #__NO_SIDE_EFFECTS__ */
9
+ export declare function makeMap(str: string): (key: string) => boolean;
@@ -0,0 +1 @@
1
+ export { camel } from 'radashi';
@@ -0,0 +1,9 @@
1
+ import { Object3D } from 'three';
2
+ /**
3
+ * Recursively searches for an Object3D with the specified UUID within a Three.js scene graph.
4
+ *
5
+ * @param node - The root Object3D to start searching from
6
+ * @param uuid - The unique identifier of the object to find
7
+ * @returns The Object3D with the matching UUID, or undefined if not found
8
+ */
9
+ export declare const getObjectByUuid: (node: Object3D, uuid: string) => Object3D | undefined;