@tresjs/core 5.9.2 → 5.10.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.
@@ -0,0 +1,1270 @@
1
+ /**
2
+ * name: @tresjs/core
3
+ * version: v5.10.0
4
+ * (c) 2026
5
+ * description: Declarative ThreeJS using Vue Components
6
+ * author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
7
+ */
8
+ import { App, ComputedRef, DefineComponent, MaybeRef, MaybeRefOrGetter, Reactive, Ref, ShallowRef, VNode, VNodeRef } from "vue";
9
+ import { EventHookOff, UseAsyncStateOptions, UseAsyncStateReturn } from "@vueuse/core";
10
+ import * as THREE from "three";
11
+ import { BufferGeometry, Camera, Color, ColorRepresentation, ColorSpace, Event, Fog, Group, Layers, Light, Loader, LoadingManager, Material, Mesh, Object3D, Object3DEventMap, OrthographicCamera, PerspectiveCamera, Scene, ShadowMapType, ToneMapping, Vector3, WebGLRenderer } from "three";
12
+ import { PointerEvent, PointerEventsMap } from "@pmndrs/pointer-events";
13
+ import { Node, NodeMaterial, Renderer } from "three/webgpu";
14
+ //#region src/composables/useLoader/index.d.ts
15
+ interface LoaderMethods {
16
+ setDRACOLoader: (dracoLoader: any) => void;
17
+ setMeshoptDecoder: (meshoptDecoder: any) => void;
18
+ setKTX2Loader: (ktx2Loader: any) => void;
19
+ }
20
+ type TresLoader<T> = Loader & Partial<LoaderMethods> & {
21
+ load: (url: string, onLoad: (result: T) => void, onProgress?: (event: ProgressEvent<EventTarget>) => void, onError?: (err: unknown) => void) => void;
22
+ loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<T>;
23
+ };
24
+ type LoaderProto<T> = new (manager?: LoadingManager) => TresLoader<T>;
25
+ interface TresLoaderOptions<T, Shallow extends boolean> {
26
+ manager?: LoadingManager;
27
+ extensions?: (loader: TresLoader<T>) => void;
28
+ initialValue?: T;
29
+ asyncOptions?: UseAsyncStateOptions<Shallow, any | null>;
30
+ }
31
+ /**
32
+ * Return type for the useLoader composable
33
+ * @template T - The type of the loaded asset (e.g., GLTF, Texture, etc.)
34
+ * @template Shallow - Whether to use shallow reactivity for better performance
35
+ * @extends {UseAsyncStateReturn<T, [string], Shallow>} - Extends VueUse's useAsyncState return type
36
+ */
37
+ type UseLoaderReturn<T, Shallow extends boolean> = UseAsyncStateReturn<T, [string], Shallow> & {
38
+ /**
39
+ * Loads a new asset from the given path
40
+ * @param path - The URL or path to the asset to load
41
+ */
42
+ load: (path: string) => void;
43
+ /**
44
+ * Progress of the loading process
45
+ * @property loaded - The number of bytes loaded
46
+ * @property total - The total number of bytes to load
47
+ * @property percentage - The percentage of the loading process
48
+ */
49
+ progress: {
50
+ loaded: number;
51
+ total: number;
52
+ percentage: number;
53
+ };
54
+ };
55
+ /**
56
+ * Vue composable for loading 3D models using Three.js loaders
57
+ * @param Loader - The Three.js loader constructor
58
+ * @param path - The path to the model file
59
+ * @param options - Optional configuration for the loader
60
+ * @returns UseAsyncState composable with the loaded model
61
+ */
62
+ declare function useLoader<T, Shallow extends boolean = true>(Loader: LoaderProto<T>, path: MaybeRef<string>, options?: TresLoaderOptions<T, Shallow>): UseLoaderReturn<T, Shallow>;
63
+ //#endregion
64
+ //#region src/composables/useCreateRafLoop/index.d.ts
65
+ interface RafLoopContext {
66
+ delta: number;
67
+ elapsed: number;
68
+ }
69
+ //#endregion
70
+ //#region src/composables/useSizes/index.d.ts
71
+ interface SizesType {
72
+ width: Readonly<Ref<number>>;
73
+ height: Readonly<Ref<number>>;
74
+ pixelRatio: Readonly<Ref<number>>;
75
+ aspectRatio: ComputedRef<number>;
76
+ }
77
+ //#endregion
78
+ //#region src/composables/useCamera/index.d.ts
79
+ /**
80
+ * Interface for the return value of the useCamera composable
81
+ */
82
+ interface UseCameraReturn {
83
+ activeCamera: ComputedRef<TresCamera>;
84
+ /**
85
+ * The list of cameras
86
+ */
87
+ cameras: ShallowRef<TresCamera[]>;
88
+ /**
89
+ * Register a camera
90
+ * @param camera - The camera to register
91
+ * @param active - Whether to set the camera as active
92
+ */
93
+ registerCamera: (camera: TresCamera, active?: boolean) => void;
94
+ /**
95
+ * Deregister a camera
96
+ * @param camera - The camera to deregister
97
+ */
98
+ deregisterCamera: (camera: TresCamera) => void;
99
+ /**
100
+ * Set the active camera
101
+ * @param cameraOrUuid - The camera or its UUID to set as active
102
+ */
103
+ setActiveCamera: (cameraOrUuid: string | TresCamera) => void;
104
+ }
105
+ /**
106
+ * Interface for the parameters of the useCamera composable
107
+ */
108
+ interface UseCameraParams {
109
+ sizes: TresContext['sizes'];
110
+ }
111
+ /**
112
+ * Composable for managing cameras in a Three.js scene
113
+ * @param params - The parameters for the composable
114
+ * @param params.sizes - The sizes object containing window dimensions
115
+ * @returns The camera management functions and state
116
+ */
117
+ declare const useCameraManager: ({ sizes }: UseCameraParams) => UseCameraReturn;
118
+ //#endregion
119
+ //#region src/utils/error.d.ts
120
+ type TresRendererErrorCode = 'INITIALIZATION_FAILED';
121
+ declare class TresRendererError extends Error {
122
+ readonly code: TresRendererErrorCode;
123
+ readonly name = "TresRendererError";
124
+ constructor(message: string, code: TresRendererErrorCode, options?: ErrorOptions);
125
+ }
126
+ //#endregion
127
+ //#region src/composables/useRenderer/useRendererManager.d.ts
128
+ /**
129
+ * If set to 'on-demand', the scene will only be rendered when the current frame is invalidated
130
+ * If set to 'manual', the scene will only be rendered when advance() is called
131
+ * If set to 'always', the scene will be rendered every frame
132
+ */
133
+ type RenderMode = 'always' | 'on-demand' | 'manual';
134
+ type RenderFunction = (notifySuccess: () => void) => void;
135
+ type TresRenderer = WebGLRenderer | Renderer;
136
+ interface RendererOptions {
137
+ /**
138
+ * WebGL Context options (Readonly because they are passed to the renderer constructor)
139
+ * They can't be changed after the renderer is created because they are passed to the canvas context
140
+ */
141
+ antialias?: boolean;
142
+ /**
143
+ * Enables stencil buffer with 8 bits.
144
+ * Required for stencil-based operations like shadow volumes or post-processing effects.
145
+ * @readonly
146
+ * @default true
147
+ */
148
+ stencil?: boolean;
149
+ /**
150
+ * Enables depth buffer with at least 16 bits.
151
+ * Required for proper 3D rendering and depth testing.
152
+ * @readonly
153
+ * @default true
154
+ */
155
+ depth?: boolean;
156
+ /**
157
+ * Sets the shader precision of the renderer.
158
+ * @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
159
+ * @default 'highp'
160
+ */
161
+ precision?: 'highp' | 'mediump' | 'lowp';
162
+ /**
163
+ * Enables logarithmic depth buffer. Useful for scenes with large differences in scale.
164
+ * Helps prevent z-fighting in scenes with objects very close and very far from the camera.
165
+ * @readonly
166
+ * @default false
167
+ */
168
+ logarithmicDepthBuffer?: boolean;
169
+ /**
170
+ * Preserves the buffers until manually cleared or overwritten.
171
+ * Needed for screenshots or when reading pixels from the canvas.
172
+ * Warning: This may impact performance.
173
+ * @readonly
174
+ * @default false
175
+ */
176
+ preserveDrawingBuffer?: boolean;
177
+ /**
178
+ * Power preference for the renderer.
179
+ * Power preference for the renderer.
180
+ * - `default`: Automatically chooses the most suitable power setting.
181
+ * - `high-performance`: Prioritizes rendering performance.
182
+ * - `low-power`: Tries to reduce power usage.
183
+ * @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
184
+ * @default 'default'
185
+ * @readonly
186
+ */
187
+ powerPreference?: WebGLPowerPreference;
188
+ /**
189
+ * Whether to create the WebGL context with an alpha buffer.
190
+ * This is a WebGL context option that must be set during context creation and cannot be changed later.
191
+ * When true, the canvas can be transparent, showing content behind it.
192
+ * @readonly
193
+ * @default false
194
+ */
195
+ alpha?: boolean;
196
+ /**
197
+ * Whether to premultiply the alpha of the canvas.
198
+ * @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
199
+ * @default true
200
+ */
201
+ premultipliedAlpha?: boolean;
202
+ /**
203
+ * Whether to fail if the major performance caveat is detected.
204
+ * @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
205
+ * @default false
206
+ */
207
+ failIfMajorPerformanceCaveat?: boolean;
208
+ /**
209
+ * WebGL options with set methods
210
+ * @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
211
+ */
212
+ /**
213
+ * Clear color for the canvas
214
+ * Can include alpha value (e.g. '#00808000' for fully transparent teal)
215
+ */
216
+ clearColor?: ColorRepresentation;
217
+ /**
218
+ * The opacity of the clear color (0-1)
219
+ * Controls the transparency of the clear color
220
+ * @default 1
221
+ */
222
+ clearAlpha?: number;
223
+ /**
224
+ * Enable shadow rendering in the scene
225
+ * @default false
226
+ */
227
+ shadows?: boolean;
228
+ /**
229
+ * Tone mapping technique to use for the scene
230
+ * - `NoToneMapping`: No tone mapping is applied.
231
+ * - `LinearToneMapping`: Linear tone mapping.
232
+ * - `ReinhardToneMapping`: Reinhard tone mapping.
233
+ * - `CineonToneMapping`: Cineon tone mapping.
234
+ * - `ACESFilmicToneMapping`: ACES Filmic tone mapping.
235
+ * - `AgXToneMapping`: AgX tone mapping.
236
+ * - `NeutralToneMapping`: Neutral tone mapping.
237
+ * @see {@link https://threejs.org/docs/#api/en/constants/Renderer}
238
+ * @default ACESFilmicToneMapping (Opinionated default by TresJS)
239
+ */
240
+ toneMapping?: ToneMapping;
241
+ /**
242
+ * Type of shadow map to use for shadow calculations
243
+ * - `BasicShadowMap`: Basic shadow map.
244
+ * - `PCFShadowMap`: Percentage-Closer Filtering shadow map.
245
+ * - `PCFSoftShadowMap`: Deprecated. three falls back to `PCFShadowMap` on WebGL, and on WebGPU since r186.
246
+ * - `VSMShadowMap`: Variance shadow map.
247
+ * @see {@link https://threejs.org/docs/#api/en/constants/Renderer}
248
+ * @default PCFShadowMap. On WebGPU before r186, PCFSoftShadowMap (Opinionated default by TresJS)
249
+ */
250
+ shadowMapType?: ShadowMapType;
251
+ /**
252
+ * Whether to use legacy lights system instead of the new one
253
+ * @deprecated Use `useLegacyLights: false` for the new lighting system
254
+ */
255
+ useLegacyLights?: boolean;
256
+ /**
257
+ * Color space for the output render
258
+ * @see {@link https://threejs.org/docs/#api/en/constants/Renderer}
259
+ */
260
+ outputColorSpace?: ColorSpace;
261
+ /**
262
+ * Exposure level of tone mapping
263
+ * @default 1
264
+ */
265
+ toneMappingExposure?: number;
266
+ /**
267
+ * Rendering mode for the canvas
268
+ * - 'always': Renders every frame
269
+ * - 'on-demand': Renders only when changes are detected
270
+ * - 'manual': Renders only when explicitly called
271
+ * @default 'always'
272
+ */
273
+ renderMode?: 'always' | 'on-demand' | 'manual';
274
+ /**
275
+ * Device Pixel Ratio for the renderer
276
+ * Can be a single number or a tuple defining a range [min, max]
277
+ */
278
+ dpr?: number | [number, number];
279
+ /**
280
+ * Custom WebGL renderer instance
281
+ * Allows using a pre-configured renderer instead of creating a new one
282
+ */
283
+ renderer?: (ctx: TresRendererSetupContext) => TresRenderer;
284
+ }
285
+ interface TresRendererSetupContext {
286
+ sizes: SizesType;
287
+ scene: ShallowRef<TresScene>;
288
+ camera: UseCameraReturn;
289
+ canvas: MaybeRef<HTMLCanvasElement>;
290
+ }
291
+ /**
292
+ * Builds the renderer when the `renderer` option is not set. Each entry has its own.
293
+ */
294
+ type DefaultRendererFactory = (ctx: TresRendererSetupContext, options: RendererOptions) => TresRenderer;
295
+ interface UseRendererOptions {
296
+ scene: ShallowRef<TresScene>;
297
+ canvas: MaybeRef<HTMLCanvasElement>;
298
+ options: Reactive<RendererOptions>;
299
+ fpsLimit?: MaybeRefOrGetter<number>;
300
+ contextParts: Pick<TresContext, 'sizes' | 'camera'>;
301
+ }
302
+ declare function useBaseRendererManager({ scene, canvas, options, fpsLimit, contextParts: { sizes, camera } }: UseRendererOptions, createDefaultRenderer?: DefaultRendererFactory): {
303
+ loop: {
304
+ start: () => void;
305
+ stop: () => void;
306
+ isActive: Readonly<ShallowRef<boolean>>;
307
+ onBeforeLoop: import("@vueuse/core").EventHookOn<RafLoopContext>;
308
+ onLoop: import("@vueuse/core").EventHookOn<RafLoopContext>;
309
+ };
310
+ instance: TresRenderer;
311
+ advance: () => void;
312
+ onReady: import("@vueuse/core").EventHookOn<TresRenderer>;
313
+ onRender: import("@vueuse/core").EventHookOn<TresRenderer>;
314
+ onError: import("@vueuse/core").EventHookOn<TresRendererError>;
315
+ invalidate: (amountOfFramesToInvalidate?: number) => void;
316
+ canBeInvalidated: import("vue").ComputedRef<boolean>;
317
+ mode: "always" | "on-demand" | "manual" | undefined;
318
+ replaceRenderFunction: (fn: RenderFunction) => void;
319
+ isInitialized: import("vue").Ref<boolean, boolean>;
320
+ error: import("vue").Ref<TresRendererError | null, TresRendererError | null>;
321
+ };
322
+ type UseRendererManagerReturn = ReturnType<typeof useBaseRendererManager>;
323
+ //#endregion
324
+ //#region src/composables/useEventManager/index.d.ts
325
+ declare function useEventManager({ canvas, contextParts: { scene, camera, renderer } }: {
326
+ canvas: MaybeRef<HTMLCanvasElement>;
327
+ contextParts: Pick<TresContext, 'scene' | 'camera' | 'renderer'>;
328
+ }): {
329
+ onPointerMissed: import("@vueuse/core").EventHookOn<TresPointerEvent & Event<"click", Object3D<Object3DEventMap & PointerEventsMap>>>;
330
+ };
331
+ //#endregion
332
+ //#region src/composables/useTresContextProvider/index.d.ts
333
+ interface TresContext {
334
+ scene: ShallowRef<TresScene>;
335
+ sizes: SizesType;
336
+ extend: (objects: any) => void;
337
+ camera: UseCameraReturn;
338
+ controls: Ref<TresControl | null>;
339
+ renderer: UseRendererManagerReturn;
340
+ /**
341
+ * Whether the active renderer is a Three.js WebGPU `Renderer` (as opposed to a
342
+ * `WebGLRenderer`). Reactive so downstream components can branch on it without
343
+ * re-deriving it from `renderer.instance`.
344
+ *
345
+ * Note: this reflects the renderer instance, not the active backend — a
346
+ * `WebGPURenderer` running on its WebGL2 fallback still reports `true`.
347
+ */
348
+ isWebGPU: ComputedRef<boolean>;
349
+ events: ReturnType<typeof useEventManager>;
350
+ }
351
+ declare const INJECTION_KEY = "useTres";
352
+ interface TresContextProviderOptions {
353
+ scene: TresScene;
354
+ canvas: MaybeRef<HTMLCanvasElement>;
355
+ fpsLimit?: MaybeRefOrGetter<number>;
356
+ windowSize: MaybeRefOrGetter<boolean>;
357
+ rendererOptions: RendererOptions;
358
+ }
359
+ declare const useTresContext: () => TresContext;
360
+ //#endregion
361
+ //#region src/utils/pointerEvents.d.ts
362
+ declare const supportedPointerEvents: readonly ["onClick", "onContextmenu", "onPointermove", "onPointerenter", "onPointerleave", "onPointerover", "onPointerout", "onDblclick", "onPointerdown", "onPointerup", "onPointercancel", "onLostpointercapture", "onWheel"];
363
+ type SupportedVuePointerEvent = typeof supportedPointerEvents[number];
364
+ type TresPointerEventName = 'click' | 'contextmenu' | 'pointermove' | 'pointerenter' | 'pointerleave' | 'pointerover' | 'pointerout' | 'dblclick' | 'pointerdown' | 'pointerup' | 'pointercancel' | 'lostpointercapture' | 'wheel';
365
+ type TresPointerEvent = PointerEvent<MouseEvent>;
366
+ type PointerEventHandlers = { [key in SupportedVuePointerEvent]: (event: TresPointerEvent) => void; };
367
+ //#endregion
368
+ //#region src/types/index.d.ts
369
+ type AttachFnType = (parent: any, self: TresInstance) => () => void;
370
+ type AttachType = string | AttachFnType;
371
+ type DisposeType = ((self: TresInstance) => void) | boolean | 'default' | null;
372
+ type ConstructorRepresentation = new (...args: any[]) => any;
373
+ type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends ((...args: any[]) => any) ? never : K; }[keyof P];
374
+ type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
375
+ type Properties<T> = Pick<T, NonFunctionKeys<T>>;
376
+ type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]>; };
377
+ type Args<T> = T extends ConstructorRepresentation ? ConstructorParameters<T> : any[];
378
+ interface TresCatalogue {
379
+ [name: string]: ConstructorRepresentation;
380
+ }
381
+ type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
382
+ /**
383
+ * Represents the properties of an instance.
384
+ *
385
+ * @template T - The type of the object.
386
+ * @template P - The type of the arguments.
387
+ */
388
+ interface InstanceProps<T = any, P = any> {
389
+ args?: Args<P>;
390
+ object?: T;
391
+ visible?: boolean;
392
+ dispose?: null;
393
+ attach?: AttachType;
394
+ }
395
+ interface TresBaseObject {
396
+ removeFromParent?: () => void;
397
+ dispose?: () => void;
398
+ [prop: string]: any;
399
+ }
400
+ interface LocalState {
401
+ type: string;
402
+ root: TresContext;
403
+ memoizedProps: {
404
+ [key: string]: any;
405
+ };
406
+ objects: TresObject[];
407
+ parent: TresObject | null;
408
+ primitive?: boolean;
409
+ dispose?: DisposeType;
410
+ attach?: AttachType;
411
+ previousAttach: any;
412
+ }
413
+ interface TresObject3D extends THREE.Object3D<THREE.Object3DEventMap> {
414
+ geometry?: THREE.BufferGeometry & TresBaseObject;
415
+ material?: THREE.Material & TresBaseObject;
416
+ }
417
+ type TresObject = TresBaseObject & (TresObject3D | THREE.BufferGeometry | THREE.Material | THREE.Fog) & {
418
+ __tres?: LocalState;
419
+ };
420
+ /**
421
+ * Union type covering all common Three.js material types
422
+ * This provides better TypeScript intellisense and type checking
423
+ * when accessing specific material properties
424
+ */
425
+ type TresMaterial = THREE.MeshBasicMaterial | THREE.MeshStandardMaterial | THREE.MeshPhysicalMaterial | THREE.MeshLambertMaterial | THREE.MeshPhongMaterial | THREE.MeshToonMaterial | THREE.MeshNormalMaterial | THREE.MeshMatcapMaterial | THREE.MeshDepthMaterial | THREE.MeshDistanceMaterial | THREE.LineBasicMaterial | THREE.LineDashedMaterial | THREE.PointsMaterial | THREE.SpriteMaterial | THREE.ShaderMaterial | THREE.RawShaderMaterial | THREE.ShadowMaterial | THREE.Material;
426
+ type TresInstance = TresObject & {
427
+ __tres: LocalState;
428
+ };
429
+ type TresPrimitive = TresInstance & {
430
+ object: TresInstance;
431
+ isPrimitive: true;
432
+ };
433
+ interface TresScene extends THREE.Scene {
434
+ __tres: {
435
+ root: TresContext;
436
+ objects: TresObject[];
437
+ isUnmounting: boolean;
438
+ };
439
+ }
440
+ interface MathRepresentation {
441
+ set(...args: number[]): any;
442
+ }
443
+ interface VectorRepresentation extends MathRepresentation {
444
+ setScalar(s: number): any;
445
+ }
446
+ type MathTypes = MathRepresentation | THREE.Euler | THREE.Color;
447
+ interface VectorCoordinates {
448
+ x: number;
449
+ y: number;
450
+ z: number;
451
+ }
452
+ type MathType<T extends MathTypes> = T extends THREE.Color ? ConstructorParameters<typeof THREE.Color> | THREE.ColorRepresentation : T extends VectorRepresentation | THREE.Layers | THREE.Euler ? T | Parameters<T['set']> | number | VectorCoordinates : T | Parameters<T['set']>;
453
+ type VectorLike$1<VectorClass extends THREE.Vector2 | THREE.Vector3 | THREE.Vector4> = VectorClass | Parameters<VectorClass['set']> | Readonly<Parameters<VectorClass['set']>> | Parameters<VectorClass['setScalar']>[0];
454
+ type TresVector2 = VectorLike$1<THREE.Vector2>;
455
+ type TresVector3 = VectorLike$1<THREE.Vector3>;
456
+ type TresVector4 = VectorLike$1<THREE.Vector4>;
457
+ type TresColor = ConstructorParameters<typeof THREE.Color> | THREE.Color | number | string;
458
+ type TresColorArray = typeof THREE.Color | [color: THREE.ColorRepresentation];
459
+ type TresLayers = THREE.Layers | Parameters<THREE.Layers['set']>[0];
460
+ type TresQuaternion = THREE.Quaternion | Parameters<THREE.Quaternion['set']>;
461
+ type TresEuler = THREE.Euler;
462
+ type TresControl = THREE.EventDispatcher & {
463
+ enabled: boolean;
464
+ };
465
+ type TresContextWithClock = TresContext & {
466
+ delta: number;
467
+ elapsed: number;
468
+ };
469
+ type WithMathProps<P> = { [K in keyof P]: P[K] extends MathTypes ? MathType<P[K]> : P[K]; };
470
+ interface RaycastableRepresentation {
471
+ raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
472
+ }
473
+ type EventProps<P> = P extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
474
+ interface VueProps {
475
+ children?: VNode[];
476
+ ref?: VNodeRef;
477
+ key?: string | number | symbol;
478
+ }
479
+ type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>>;
480
+ type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
481
+ /**
482
+ * Element types for every export of a Three.js namespace (`three`, `three/webgpu`, ...).
483
+ */
484
+ type ThreeInstancesOf<Exports> = { [K in keyof Exports as Uncapitalize<string & K>]: Exports[K] extends ConstructorRepresentation ? ThreeElement<Exports[K]> : never; };
485
+ /**
486
+ * Tres component types for every export of a Three.js namespace.
487
+ */
488
+ type TresComponentsOf<Instances> = { [K in keyof Instances as `Tres${Capitalize<string & K>}`]: DefineComponent<Instances[K]>; };
489
+ type ThreeInstancesImpl = ThreeInstancesOf<typeof THREE>;
490
+ interface ThreeInstances extends ThreeInstancesImpl {
491
+ primitive: Omit<ThreeElement<any>, 'args'> & {
492
+ object: object;
493
+ };
494
+ }
495
+ type TresComponents = TresComponentsOf<ThreeInstances>;
496
+ declare module 'vue' {
497
+ interface GlobalComponents extends TresComponents {
498
+ primitive: DefineComponent<TresPrimitive>;
499
+ }
500
+ }
501
+ //#endregion
502
+ //#region src/utils/graph.d.ts
503
+ interface TresObjectMap {
504
+ nodes: {
505
+ [name: string]: TresObject;
506
+ };
507
+ materials: {
508
+ [name: string]: TresMaterial;
509
+ };
510
+ meshes: {
511
+ [name: string]: Mesh;
512
+ };
513
+ scene?: Scene;
514
+ }
515
+ declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
516
+ //#endregion
517
+ //#region src/composables/useLoader/component.vue.d.ts
518
+ declare const __VLS_export$3: <T extends TresObjectMap>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
519
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<{
520
+ /**
521
+ * The THREE.js loader to use
522
+ */
523
+ loader: LoaderProto<T>;
524
+ /**
525
+ * Path to resource
526
+ */
527
+ path: string;
528
+ /**
529
+ * Optional THREE.js LoadingManager
530
+ */
531
+ manager?: LoadingManager;
532
+ extensions?: (res: T) => void;
533
+ } & {
534
+ onError?: ((error: unknown) => any) | undefined;
535
+ onLoaded?: ((result: T) => any) | undefined;
536
+ }> & (typeof globalThis extends {
537
+ __VLS_PROPS_FALLBACK: infer P;
538
+ } ? P : {});
539
+ expose: (exposed: {}) => void;
540
+ attrs: any;
541
+ slots: {
542
+ default?: (props: {
543
+ state: T;
544
+ isLoading: boolean;
545
+ error: unknown;
546
+ }) => any;
547
+ };
548
+ emit: ((evt: "error", error: unknown) => void) & ((evt: "loaded", result: T) => void);
549
+ }>) => import("vue").VNode & {
550
+ __ctx?: NonNullable<Awaited<typeof __VLS_setup>>;
551
+ };
552
+ declare const _default$3: typeof __VLS_export$3;
553
+ type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {};
554
+ //#endregion
555
+ //#region src/webgl/renderer.d.ts
556
+ declare const useRendererManager: (options: UseRendererOptions) => {
557
+ loop: {
558
+ start: () => void;
559
+ stop: () => void;
560
+ isActive: Readonly<import("vue").ShallowRef<boolean>>;
561
+ onBeforeLoop: import("@vueuse/core").EventHookOn<RafLoopContext>;
562
+ onLoop: import("@vueuse/core").EventHookOn<RafLoopContext>;
563
+ };
564
+ instance: TresRenderer;
565
+ advance: () => void;
566
+ onReady: import("@vueuse/core").EventHookOn<TresRenderer>;
567
+ onRender: import("@vueuse/core").EventHookOn<TresRenderer>;
568
+ onError: import("@vueuse/core").EventHookOn<TresRendererError>;
569
+ invalidate: (amountOfFramesToInvalidate?: number) => void;
570
+ canBeInvalidated: import("vue").ComputedRef<boolean>;
571
+ mode: "always" | "on-demand" | "manual" | undefined;
572
+ replaceRenderFunction: (fn: RenderFunction) => void;
573
+ isInitialized: import("vue").Ref<boolean, boolean>;
574
+ error: import("vue").Ref<TresRendererError | null, TresRendererError | null>;
575
+ };
576
+ declare const useTresContextProvider: (options: TresContextProviderOptions) => TresContext;
577
+ //#endregion
578
+ //#region src/composables/useGraph/index.d.ts
579
+ declare const useGraph: (object: MaybeRef<TresObject | undefined>) => import("vue").ComputedRef<TresObjectMap | undefined>;
580
+ //#endregion
581
+ //#region src/utils/createPriorityEventHook.d.ts
582
+ type Callback<T> = Parameters<EventHookOff<T>>[0];
583
+ type PriorityEventHookOn<T> = (fn: Callback<T>, priority?: number) => {
584
+ off: () => void;
585
+ };
586
+ //#endregion
587
+ //#region src/composables/useTres/index.d.ts
588
+ interface TresPartialContext extends Omit<TresContext, 'renderer' | 'camera'> {
589
+ /**
590
+ * The renderer instance
591
+ *
592
+ * @type {TresRenderer}
593
+ * @memberof TresPartialContext
594
+ */
595
+ renderer: TresRenderer;
596
+ /**
597
+ * The current active camera
598
+ *
599
+ * @type {ComputedRef<Camera | undefined>}
600
+ * @memberof TresPartialContext
601
+ */
602
+ camera: ComputedRef<Camera | undefined>;
603
+ /**
604
+ * Marks the scene as needing an update in the next frame.
605
+ * This is used in on-demand rendering mode to schedule a render.
606
+ *
607
+ * @type {() => void}
608
+ * @memberof TresPartialContext
609
+ */
610
+ invalidate: () => void;
611
+ /**
612
+ * Manually advances the render loop by one frame.
613
+ * This is particularly useful in manual rendering mode where you want explicit control over when frames are rendered.
614
+ *
615
+ * @type {() => void}
616
+ * @memberof TresPartialContext
617
+ */
618
+ advance: () => void;
619
+ }
620
+ declare function useTres(): TresPartialContext;
621
+ //#endregion
622
+ //#region src/composables/useLoop/index.d.ts
623
+ type LoopContext = RafLoopContext & TresPartialContext;
624
+ /**
625
+ * Composable that provides control over the render loop and animation lifecycle.
626
+ */
627
+ declare const useLoop: () => {
628
+ stop: () => void;
629
+ start: () => void;
630
+ isActive: Readonly<import("vue").ShallowRef<boolean>>;
631
+ onBeforeRender: PriorityEventHookOn<LoopContext>;
632
+ onRender: PriorityEventHookOn<LoopContext>;
633
+ render: (fn: RenderFunction) => void;
634
+ };
635
+ //#endregion
636
+ //#region src/core/nodeOps.d.ts
637
+ interface TresCustomRendererOptions {
638
+ primitivePrefix?: string;
639
+ }
640
+ //#endregion
641
+ //#region src/utils/logger.d.ts
642
+ /**
643
+ * Logger utility for TresJS
644
+ * @module logger
645
+ */
646
+ declare const isProd: boolean;
647
+ type OneOrMore<T> = {
648
+ 0: T;
649
+ } & Array<T>;
650
+ /**
651
+ * Logs an error message with the TresJS prefix
652
+ * @param args - Arguments to log
653
+ */
654
+ declare function logError(...args: OneOrMore<any>): void;
655
+ /**
656
+ * Logs a warning message with the TresJS prefix
657
+ * @param args - Arguments to log
658
+ */
659
+ declare function logWarning(...args: OneOrMore<any>): void;
660
+ /**
661
+ * Logs a message with the TresJS prefix (only in development mode)
662
+ * @param name - Name of the message
663
+ * @param value - Value to log
664
+ */
665
+ declare function logMessage(name: string, value: any): void;
666
+ //#endregion
667
+ //#region src/utils/index.d.ts
668
+ declare function disposeObject3D(object: TresObject): void;
669
+ //#endregion
670
+ //#region src/utils/normalize.d.ts
671
+ interface Vector2PropInterface {
672
+ x?: number;
673
+ y?: number;
674
+ width?: number;
675
+ height?: number;
676
+ }
677
+ interface Vector3PropInterface extends Vector2PropInterface {
678
+ z?: number;
679
+ }
680
+ type VectorFlexibleParams = Vector3 | number[] | Vector3PropInterface | number;
681
+ declare function normalizeVectorFlexibleParam(value: VectorFlexibleParams): Array<number>;
682
+ declare function normalizeColor(value: Color | Array<number> | string | number | ColorRepresentation): Color;
683
+ //#endregion
684
+ //#region src/utils/template-compiler-options.d.ts
685
+ declare const templateCompilerOptions: {
686
+ template: {
687
+ compilerOptions: {
688
+ isCustomElement: (tag: string) => boolean;
689
+ };
690
+ };
691
+ };
692
+ //#endregion
693
+ //#region src/components/Context.vue.d.ts
694
+ interface ContextProps extends RendererOptions {
695
+ /**
696
+ * Custom camera instance to use as main camera
697
+ * If not provided, a default PerspectiveCamera will be created
698
+ */
699
+ camera?: TresCamera;
700
+ /**
701
+ * Whether the canvas should be sized to the window
702
+ * When true, canvas will be fixed positioned and full viewport size
703
+ * @default false
704
+ */
705
+ windowSize?: boolean;
706
+ /**
707
+ * The maximum number of frames per second to render
708
+ * @default undefined
709
+ */
710
+ fpsLimit?: number;
711
+ /**
712
+ * Whether to enable the provide/inject bridge between Vue and TresJS
713
+ * When true, Vue's provide/inject will work across the TresJS boundary
714
+ * @default true
715
+ */
716
+ enableProvideBridge?: boolean;
717
+ /**
718
+ * Options for the TresJS custom renderer
719
+ *
720
+ */
721
+ customRendererOptions?: TresCustomRendererOptions;
722
+ }
723
+ type ContextEmits = {
724
+ ready: [context: TresContext];
725
+ error: [error: Error];
726
+ pointermissed: [event: TresPointerEvent];
727
+ render: [context: TresContext];
728
+ beforeLoop: [context: TresContextWithClock];
729
+ loop: [context: TresContextWithClock];
730
+ } & { [key in TresPointerEventName]: [event: TresPointerEvent]; };
731
+ //#endregion
732
+ //#region src/components/BaseCanvas.vue.d.ts
733
+ type TresCanvasEmits = ContextEmits;
734
+ type TresCanvasProps = ContextProps;
735
+ interface TresCanvasInstance {
736
+ get context(): TresContext | undefined;
737
+ dispose: () => void;
738
+ }
739
+ //#endregion
740
+ //#region src/components/TresCanvas.vue.d.ts
741
+ type __VLS_Slots$2 = {
742
+ default: () => any;
743
+ };
744
+ declare const __VLS_base$2: import("vue").DefineComponent<ContextProps, TresCanvasInstance, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
745
+ click: (event: TresPointerEvent) => any;
746
+ contextmenu: (event: TresPointerEvent) => any;
747
+ pointermove: (event: TresPointerEvent) => any;
748
+ pointerenter: (event: TresPointerEvent) => any;
749
+ pointerleave: (event: TresPointerEvent) => any;
750
+ pointerover: (event: TresPointerEvent) => any;
751
+ pointerout: (event: TresPointerEvent) => any;
752
+ dblclick: (event: TresPointerEvent) => any;
753
+ pointerdown: (event: TresPointerEvent) => any;
754
+ pointerup: (event: TresPointerEvent) => any;
755
+ pointercancel: (event: TresPointerEvent) => any;
756
+ lostpointercapture: (event: TresPointerEvent) => any;
757
+ wheel: (event: TresPointerEvent) => any;
758
+ ready: (context: TresContext) => any;
759
+ error: (error: Error) => any;
760
+ pointermissed: (event: TresPointerEvent) => any;
761
+ render: (context: TresContext) => any;
762
+ beforeLoop: (context: TresContextWithClock) => any;
763
+ loop: (context: TresContextWithClock) => any;
764
+ }, string, import("vue").PublicProps, Readonly<ContextProps> & Readonly<{
765
+ onClick?: ((event: TresPointerEvent) => any) | undefined;
766
+ onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
767
+ onPointermove?: ((event: TresPointerEvent) => any) | undefined;
768
+ onPointerenter?: ((event: TresPointerEvent) => any) | undefined;
769
+ onPointerleave?: ((event: TresPointerEvent) => any) | undefined;
770
+ onPointerover?: ((event: TresPointerEvent) => any) | undefined;
771
+ onPointerout?: ((event: TresPointerEvent) => any) | undefined;
772
+ onDblclick?: ((event: TresPointerEvent) => any) | undefined;
773
+ onPointerdown?: ((event: TresPointerEvent) => any) | undefined;
774
+ onPointerup?: ((event: TresPointerEvent) => any) | undefined;
775
+ onPointercancel?: ((event: TresPointerEvent) => any) | undefined;
776
+ onLostpointercapture?: ((event: TresPointerEvent) => any) | undefined;
777
+ onWheel?: ((event: TresPointerEvent) => any) | undefined;
778
+ onReady?: ((context: TresContext) => any) | undefined;
779
+ onError?: ((error: Error) => any) | undefined;
780
+ onPointermissed?: ((event: TresPointerEvent) => any) | undefined;
781
+ onRender?: ((context: TresContext) => any) | undefined;
782
+ onBeforeLoop?: ((context: TresContextWithClock) => any) | undefined;
783
+ onLoop?: ((context: TresContextWithClock) => any) | undefined;
784
+ }>, {
785
+ windowSize: boolean;
786
+ enableProvideBridge: boolean;
787
+ customRendererOptions: TresCustomRendererOptions;
788
+ antialias: boolean;
789
+ stencil: boolean;
790
+ depth: boolean;
791
+ logarithmicDepthBuffer: boolean;
792
+ preserveDrawingBuffer: boolean;
793
+ alpha: boolean;
794
+ failIfMajorPerformanceCaveat: boolean;
795
+ clearColor: import("three").ColorRepresentation;
796
+ clearAlpha: number;
797
+ shadows: boolean;
798
+ toneMapping: import("three").ToneMapping;
799
+ shadowMapType: import("three").ShadowMapType;
800
+ useLegacyLights: boolean;
801
+ renderMode: "always" | "on-demand" | "manual";
802
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
803
+ declare const __VLS_export$2: __VLS_WithSlots$2<typeof __VLS_base$2, __VLS_Slots$2>;
804
+ declare const _default$2: typeof __VLS_export$2;
805
+ type __VLS_WithSlots$2<T, S> = T & {
806
+ new (): {
807
+ $slots: S;
808
+ };
809
+ };
810
+ //#endregion
811
+ //#region src/components/WebGLContext.vue.d.ts
812
+ type __VLS_Props$1 = ContextProps & {
813
+ canvas: HTMLCanvasElement;
814
+ };
815
+ type __VLS_Slots$1 = {
816
+ default: () => any;
817
+ };
818
+ declare const __VLS_base$1: import("vue").DefineComponent<__VLS_Props$1, TresCanvasInstance, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
819
+ click: (event: TresPointerEvent) => any;
820
+ contextmenu: (event: TresPointerEvent) => any;
821
+ pointermove: (event: TresPointerEvent) => any;
822
+ pointerenter: (event: TresPointerEvent) => any;
823
+ pointerleave: (event: TresPointerEvent) => any;
824
+ pointerover: (event: TresPointerEvent) => any;
825
+ pointerout: (event: TresPointerEvent) => any;
826
+ dblclick: (event: TresPointerEvent) => any;
827
+ pointerdown: (event: TresPointerEvent) => any;
828
+ pointerup: (event: TresPointerEvent) => any;
829
+ pointercancel: (event: TresPointerEvent) => any;
830
+ lostpointercapture: (event: TresPointerEvent) => any;
831
+ wheel: (event: TresPointerEvent) => any;
832
+ ready: (context: TresContext) => any;
833
+ error: (error: Error) => any;
834
+ pointermissed: (event: TresPointerEvent) => any;
835
+ render: (context: TresContext) => any;
836
+ beforeLoop: (context: TresContextWithClock) => any;
837
+ loop: (context: TresContextWithClock) => any;
838
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props$1> & Readonly<{
839
+ onClick?: ((event: TresPointerEvent) => any) | undefined;
840
+ onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
841
+ onPointermove?: ((event: TresPointerEvent) => any) | undefined;
842
+ onPointerenter?: ((event: TresPointerEvent) => any) | undefined;
843
+ onPointerleave?: ((event: TresPointerEvent) => any) | undefined;
844
+ onPointerover?: ((event: TresPointerEvent) => any) | undefined;
845
+ onPointerout?: ((event: TresPointerEvent) => any) | undefined;
846
+ onDblclick?: ((event: TresPointerEvent) => any) | undefined;
847
+ onPointerdown?: ((event: TresPointerEvent) => any) | undefined;
848
+ onPointerup?: ((event: TresPointerEvent) => any) | undefined;
849
+ onPointercancel?: ((event: TresPointerEvent) => any) | undefined;
850
+ onLostpointercapture?: ((event: TresPointerEvent) => any) | undefined;
851
+ onWheel?: ((event: TresPointerEvent) => any) | undefined;
852
+ onReady?: ((context: TresContext) => any) | undefined;
853
+ onError?: ((error: Error) => any) | undefined;
854
+ onPointermissed?: ((event: TresPointerEvent) => any) | undefined;
855
+ onRender?: ((context: TresContext) => any) | undefined;
856
+ onBeforeLoop?: ((context: TresContextWithClock) => any) | undefined;
857
+ onLoop?: ((context: TresContextWithClock) => any) | undefined;
858
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
859
+ declare const __VLS_export$1: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
860
+ declare const _default$1: typeof __VLS_export$1;
861
+ type __VLS_WithSlots$1<T, S> = T & {
862
+ new (): {
863
+ $slots: S;
864
+ };
865
+ };
866
+ //#endregion
867
+ //#region src/components/TresPortal.vue.d.ts
868
+ type __VLS_Props = {
869
+ /** Target Object3D/Scene to reparent children into. */
870
+ to: Object3D;
871
+ /** When true, children render in place (main scene) instead of the target. */
872
+ disabled?: boolean;
873
+ };
874
+ declare var __VLS_7: {};
875
+ type __VLS_Slots = {} & {
876
+ default?: (props: typeof __VLS_7) => any;
877
+ };
878
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
879
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
880
+ declare const _default: typeof __VLS_export;
881
+ type __VLS_WithSlots<T, S> = T & {
882
+ new (): {
883
+ $slots: S;
884
+ };
885
+ };
886
+ //#endregion
887
+ //#region src/core/catalogue.d.ts
888
+ declare const catalogue: Ref<TresCatalogue>;
889
+ declare const extend: (objects: any) => any;
890
+ //#endregion
891
+ //#region src/devtools/DevtoolsMessenger.d.ts
892
+ type DevtoolsMessageType = 'performance' | 'context' | 'asset-load';
893
+ interface AssetLoadData {
894
+ url: string;
895
+ type: string;
896
+ loaded: boolean;
897
+ size: number;
898
+ asset: HTMLImageElement | HTMLScriptElement | HTMLLinkElement | Blob | ArrayBuffer | null;
899
+ }
900
+ interface DevtoolsMessage<T = any> {
901
+ type: DevtoolsMessageType;
902
+ data: T;
903
+ timestamp?: number;
904
+ }
905
+ type DevtoolsSubscriber = (message: DevtoolsMessage) => void;
906
+ /**
907
+ * Messenger class for communicating with Tres DevTools
908
+ * This class will be attached to window.__TRES__DEVTOOLS__
909
+ */
910
+ declare class DevtoolsMessenger {
911
+ private subscribers;
912
+ private messageQueue;
913
+ private maxQueueSize;
914
+ /**
915
+ * Send a message to devtools subscribers
916
+ * If no subscribers are available, only queueable message types are queued
917
+ */
918
+ send<T>(type: DevtoolsMessageType, data: T): void;
919
+ /**
920
+ * Queue a message for later delivery
921
+ */
922
+ private queueMessage;
923
+ /**
924
+ * Flush all queued messages to current subscribers
925
+ */
926
+ private flushQueue;
927
+ /**
928
+ * Subscribe to devtools messages
929
+ * When a new subscriber is added, all queued messages (asset-load events) are immediately delivered
930
+ */
931
+ subscribe(subscriber: DevtoolsSubscriber): () => void;
932
+ /**
933
+ * Check if there are any subscribers
934
+ */
935
+ get hasSubscribers(): boolean;
936
+ /**
937
+ * Get the current queue size
938
+ */
939
+ get queueSize(): number;
940
+ /**
941
+ * Clear all queued messages
942
+ */
943
+ clearQueue(): void;
944
+ }
945
+ //#endregion
946
+ //#region src/devtools/plugin.d.ts
947
+ declare function registerTresDevtools(app: App, tres: TresContext): void;
948
+ //#endregion
949
+ //#region src/directives/vDistanceTo.d.ts
950
+ declare const vDistanceTo: {
951
+ updated: (el: TresObject, binding: Ref<TresObject>) => void;
952
+ unmounted: (el: TresObject) => void;
953
+ };
954
+ //#endregion
955
+ //#region src/directives/vLightHelper.d.ts
956
+ declare const vLightHelper: {
957
+ mounted: (el: TresObject) => void;
958
+ updated: (el: TresObject) => void;
959
+ unmounted: (el: TresObject) => void;
960
+ };
961
+ //#endregion
962
+ //#region src/directives/vLog.d.ts
963
+ declare const vLog: {
964
+ mounted: (el: TresObject, binding: {
965
+ arg: string;
966
+ }) => void;
967
+ };
968
+ //#endregion
969
+ //#region src/utils/createTimer.d.ts
970
+ interface TresTimer {
971
+ getDelta: () => number;
972
+ getElapsed: () => number;
973
+ update: () => void;
974
+ start: () => void;
975
+ stop: () => void;
976
+ }
977
+ /**
978
+ * Creates a unified timer abstraction that uses `Timer` on Three.js r179+
979
+ * and falls back to `Clock` on older versions.
980
+ *
981
+ * - On r179+: uses `Timer` with its Page Visibility API support (`connect`/`disconnect`).
982
+ * - On older versions: uses `Clock` with `start`/`stop`.
983
+ *
984
+ */
985
+ declare function createTimer(): TresTimer;
986
+ //#endregion
987
+ //#region src/utils/is/three.d.ts
988
+ /**
989
+ * Type guard to check if a value is a Three.js Object3D
990
+ * @param value - The value to check
991
+ * @returns True if the value is a Three.js Object3D instance, false otherwise
992
+ * @example
993
+ * ```ts
994
+ * const value = new THREE.Object3D()
995
+ * if (isObject3D(value)) {
996
+ * // TypeScript knows value is Object3D here
997
+ * value.position // OK
998
+ * value.rotation // OK
999
+ * value.scale // OK
1000
+ * }
1001
+ * ```
1002
+ */
1003
+ declare const isObject3D: (value: unknown) => value is Object3D<import("three").Object3DEventMap>;
1004
+ /**
1005
+ * Type guard to check if a value is a Three.js Mesh
1006
+ * @param value - The value to check
1007
+ * @returns True if the value is a Three.js Mesh instance, false otherwise
1008
+ * @example
1009
+ * ```ts
1010
+ * const value = new THREE.Mesh()
1011
+ * if (isMesh(value)) {
1012
+ * // TypeScript knows value is Mesh here
1013
+ * value.geometry // OK
1014
+ */
1015
+ declare const isMesh: (value: unknown) => value is Mesh<BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>, Material<import("three").MaterialEventMap> | Material<import("three").MaterialEventMap>[], import("three").Object3DEventMap>;
1016
+ /**
1017
+ * Type guard to check if a value is a Three.js Camera
1018
+ * @param value - The value to check
1019
+ * @returns True if the value is a Three.js Camera instance, false otherwise
1020
+ * @example
1021
+ * ```ts
1022
+ * const value = new THREE.PerspectiveCamera()
1023
+ * if (isCamera(value)) {
1024
+ * // TypeScript knows value is Camera here
1025
+ * value.fov // OK
1026
+ * value.near // OK
1027
+ * value.far // OK
1028
+ * }
1029
+ * ```
1030
+ */
1031
+ declare const isCamera: (value: unknown) => value is Camera;
1032
+ /**
1033
+ * Type guard to check if a value is a Three.js OrthographicCamera
1034
+ * @param value - The value to check
1035
+ * @returns True if the value is a Three.js OrthographicCamera instance, false otherwise
1036
+ */
1037
+ declare const isOrthographicCamera: (value: unknown) => value is OrthographicCamera;
1038
+ /**
1039
+ * Type guard to check if a value is a Three.js PerspectiveCamera
1040
+ * @param value - The value to check
1041
+ * @returns True if the value is a Three.js PerspectiveCamera instance, false otherwise
1042
+ */
1043
+ declare const isPerspectiveCamera: (value: unknown) => value is PerspectiveCamera;
1044
+ /**
1045
+ * Type guard to check if a value is a Three.js Color
1046
+ * @param value - The value to check
1047
+ * @returns True if the value is a Three.js Color instance, false otherwise
1048
+ */
1049
+ declare const isColor: (value: unknown) => value is Color;
1050
+ /**
1051
+ * Type guard to check if a value is a Three.js ColorRepresentation
1052
+ * @param value - The value to check
1053
+ * @returns True if the value is a Three.js ColorRepresentation instance, false otherwise
1054
+ */
1055
+ declare const isColorRepresentation: (value: unknown) => value is ColorRepresentation;
1056
+ /**
1057
+ * Type guard to check if a value is a Three.js Layers
1058
+ * @param value - The value to check
1059
+ * @returns True if the value is a Three.js Layers instance, false otherwise
1060
+ */
1061
+ declare const isLayers: (value: unknown) => value is Layers;
1062
+ /**
1063
+ * Type guard to check if a value is a Three.js BufferGeometry
1064
+ * @param value - The value to check
1065
+ * @returns True if the value is a Three.js BufferGeometry instance, false otherwise
1066
+ * @example
1067
+ * ```ts
1068
+ * const value = new THREE.BufferGeometry()
1069
+ * if (isBufferGeometry(value)) {
1070
+ * // TypeScript knows value is BufferGeometry here
1071
+ * value.attributes // OK
1072
+ * value.index // OK
1073
+ * value.computeVertexNormals() // OK
1074
+ * }
1075
+ * ```
1076
+ */
1077
+ declare const isBufferGeometry: (value: unknown) => value is BufferGeometry<import("three").NormalBufferAttributes, import("three").BufferGeometryEventMap>;
1078
+ /**
1079
+ * Type guard to check if a value is a Three.js Material
1080
+ * @param value - The value to check
1081
+ * @returns True if the value is a Three.js Material instance, false otherwise
1082
+ * @example
1083
+ * ```ts
1084
+ * const value = new THREE.MeshStandardMaterial()
1085
+ * if (isMaterial(value)) {
1086
+ * // TypeScript knows value is Material here
1087
+ * value.color // OK
1088
+ * value.metalness // OK
1089
+ * value.roughness // OK
1090
+ * }
1091
+ * ```
1092
+ */
1093
+ declare const isMaterial: (value: unknown) => value is Material<import("three").MaterialEventMap>;
1094
+ /**
1095
+ * Type guard to check if a value is a Three.js NodeMaterial
1096
+ * @param value - The value to check
1097
+ * @returns True if the value is a Three.js NodeMaterial instance, false otherwise
1098
+ */
1099
+ declare const isNodeMaterial: (value: unknown) => value is NodeMaterial;
1100
+ /**
1101
+ * Type guard to check if a value is a Three.js TSL Node
1102
+ * @param value - The value to check
1103
+ * @returns True if the value is a Three.js Node instance, false otherwise
1104
+ */
1105
+ declare const isNode: (value: unknown) => value is Node;
1106
+ /**
1107
+ * Type guard to check if a value is a Three.js Light
1108
+ * @param value - The value to check
1109
+ * @returns True if the value is a Three.js Light instance, false otherwise
1110
+ * @example
1111
+ * ```ts
1112
+ * const value = new THREE.DirectionalLight()
1113
+ * if (isLight(value)) {
1114
+ * // TypeScript knows value is Light here
1115
+ * value.intensity // OK
1116
+ * value.color // OK
1117
+ * value.position // OK
1118
+ * }
1119
+ * ```
1120
+ */
1121
+ declare const isLight: (value: unknown) => value is Light;
1122
+ /**
1123
+ * Type guard to check if a value is a Three.js Fog
1124
+ * @param value - The value to check
1125
+ * @returns True if the value is a Three.js Fog instance, false otherwise
1126
+ * @example
1127
+ * ```ts
1128
+ * const value = new THREE.Fog(0x000000, 1, 1000)
1129
+ * if (isFog(value)) {
1130
+ * // TypeScript knows value is Fog here
1131
+ * value.color // OK
1132
+ * value.near // OK
1133
+ * value.far // OK
1134
+ * }
1135
+ * ```
1136
+ */
1137
+ declare const isFog: (value: unknown) => value is Fog;
1138
+ /**
1139
+ * Type guard to check if a value is a Three.js Scene
1140
+ * @param value - The value to check
1141
+ * @returns True if the value is a Three.js Scene instance, false otherwise
1142
+ * @example
1143
+ * ```ts
1144
+ * const value = new THREE.Scene()
1145
+ * if (isScene(value)) {
1146
+ * // TypeScript knows value is Scene here
1147
+ * value.children // OK
1148
+ * value.add(new THREE.Object3D()) // OK
1149
+ * value.remove(new THREE.Object3D()) // OK
1150
+ * }
1151
+ * ```
1152
+ */
1153
+ declare const isScene: (value: unknown) => value is Scene<import("three").Object3DEventMap>;
1154
+ /**
1155
+ * Type guard to check if a value is a Three.js Group
1156
+ * @param value - The value to check
1157
+ * @returns True if the value is a Three.js Group instance, false otherwise
1158
+ * ```
1159
+ */
1160
+ declare const isGroup: (value: unknown) => value is Group<import("three").Object3DEventMap>;
1161
+ //#endregion
1162
+ //#region src/utils/is/tres.d.ts
1163
+ interface VectorLike {
1164
+ set: (...args: any[]) => void;
1165
+ constructor?: (...args: any[]) => any;
1166
+ }
1167
+ declare const isVectorLike: (value: unknown) => value is VectorLike;
1168
+ interface Copyable {
1169
+ copy: (...args: any[]) => void;
1170
+ constructor?: (...args: any[]) => any;
1171
+ }
1172
+ declare const isCopyable: (value: unknown) => value is Copyable;
1173
+ interface ClassInstance {
1174
+ constructor?: (...args: any[]) => any;
1175
+ }
1176
+ declare const isClassInstance: (object: unknown) => object is ClassInstance;
1177
+ /**
1178
+ * Type guard to check if a value is a TresCamera
1179
+ * @param value - The value to check
1180
+ * @returns True if the value is a TresCamera instance, false otherwise
1181
+ */
1182
+ declare const isTresCamera: (value: unknown) => value is TresCamera;
1183
+ /**
1184
+ * Type guard to check if a value is a TresObject
1185
+ * @param value - The value to check
1186
+ * @returns True if the value is a TresObject (Object3D | BufferGeometry | Material | Fog), false otherwise
1187
+ * @example
1188
+ * ```ts
1189
+ * const value = new THREE.Mesh()
1190
+ * if (isTresObject(value)) {
1191
+ * // TypeScript knows value is TresObject here
1192
+ * // You can use common properties and methods shared by all TresObjects
1193
+ * }
1194
+ * ```
1195
+ * @remarks
1196
+ * TresObject is a union type that represents the core Three.js objects that can be used in TresJS.
1197
+ * This includes Object3D, BufferGeometry, Material, and Fog instances.
1198
+ */
1199
+ declare const isTresObject: (value: unknown) => value is TresObject;
1200
+ /**
1201
+ * Type guard to check if a value is a TresPrimitive
1202
+ * @param value - The value to check
1203
+ * @returns True if the value is a TresPrimitive instance, false otherwise
1204
+ * @example
1205
+ * ```ts
1206
+ * const value = { isPrimitive: true }
1207
+ * if (isTresPrimitive(value)) {
1208
+ * // TypeScript knows value is TresPrimitive here
1209
+ * // You can use properties and methods specific to TresPrimitives
1210
+ * }
1211
+ * ```
1212
+ * @remarks
1213
+ * TresPrimitive is a special type in TresJS that represents primitive objects
1214
+ * that can be used directly in the scene without needing to be wrapped in a Three.js object.
1215
+ */
1216
+ declare const isTresPrimitive: (value: unknown) => value is TresPrimitive;
1217
+ /**
1218
+ * Type guard to check if a value is a TresInstance (has __tres property)
1219
+ * @param value - The value to check
1220
+ * @returns True if the value is a TresInstance (has __tres property), false otherwise
1221
+ * @example
1222
+ * ```ts
1223
+ * const value = new THREE.Mesh()
1224
+ * if (isTresInstance(value)) {
1225
+ * // TypeScript knows value is TresInstance here
1226
+ * // You can safely access value.__tres
1227
+ * }
1228
+ * ```
1229
+ */
1230
+ declare const isTresInstance: (value: unknown) => value is TresInstance;
1231
+ /**
1232
+ * Type guard to check if a value is a Three.js WebGPU `Renderer`.
1233
+ *
1234
+ * Identifies the renderer *instance*, not the active backend: a `WebGPURenderer`
1235
+ * can run on a WebGPU **or** a WebGL2 fallback backend, and this returns `true`
1236
+ * for both. That is the right granularity for branching on capabilities —
1237
+ * `NodeMaterial` works on either backend, while a GLSL `ShaderMaterial` works on
1238
+ * neither under the WebGPU renderer.
1239
+ * @param value - The value to check
1240
+ * @returns True if the value is a WebGPU `Renderer` instance, false otherwise
1241
+ * @example
1242
+ * ```ts
1243
+ * const { renderer } = useTresContext()
1244
+ * if (isWebGPURenderer(renderer.instance)) {
1245
+ * // TypeScript knows renderer.instance is a WebGPU Renderer here
1246
+ * }
1247
+ * ```
1248
+ */
1249
+ declare const isWebGPURenderer: (value: unknown) => value is Renderer;
1250
+ /**
1251
+ * Type guard to check if a value is a Three.js `WebGLRenderer`.
1252
+ * @param value - The value to check
1253
+ * @returns True if the value is a `WebGLRenderer` instance, false otherwise
1254
+ * @see {@link isWebGPURenderer}
1255
+ */
1256
+ declare const isWebGLRenderer: (value: unknown) => value is WebGLRenderer & {
1257
+ isWebGLRenderer: true;
1258
+ };
1259
+ //#endregion
1260
+ //#region src/index.d.ts
1261
+ interface TresOptions {
1262
+ extends?: Record<string, unknown>;
1263
+ }
1264
+ interface TresPlugin {
1265
+ [key: string]: any;
1266
+ install: (app: App, options?: TresOptions) => void;
1267
+ }
1268
+ declare const plugin: TresPlugin;
1269
+ //#endregion
1270
+ export { isProd as $, TresPointerEvent as $t, createTimer as A, TresCamera as At, catalogue as B, TresLayers as Bt, isNode as C, Mutable as Ct, isPerspectiveCamera as D, ThreeElement as Dt, isOrthographicCamera as E, Properties as Et, AssetLoadData as F, TresComponentsOf as Ft, TresCanvasEmits as G, TresQuaternion as Gt, _default as H, TresObject as Ht, DevtoolsMessage as I, TresContextWithClock as It, templateCompilerOptions as J, TresVector3 as Jt, TresCanvasInstance as K, TresScene as Kt, DevtoolsMessageType as L, TresControl as Lt, vLightHelper as M, TresColor as Mt, vDistanceTo as N, TresColorArray as Nt, isScene as O, ThreeInstances as Ot, registerTresDevtools as P, TresComponents as Pt, disposeObject3D as Q, WithMathProps as Qt, DevtoolsMessenger as R, TresEuler as Rt, isMesh as S, MathType as St, isObject3D as T, Overwrite as Tt, _default$1 as U, TresObject3D as Ut, extend as V, TresMaterial as Vt, _default$2 as W, TresPrimitive as Wt, normalizeColor as X, VectorCoordinates as Xt, VectorFlexibleParams as Y, TresVector4 as Yt, normalizeVectorFlexibleParam as Z, VueProps as Zt, isFog as _, LoaderProto as _n, ConstructorRepresentation as _t, isCopyable as a, RenderMode as an, useLoop as at, isLight as b, UseLoaderReturn as bn, InstanceProps as bt, isTresObject as c, TresRendererSetupContext as cn, useGraph as ct, isWebGLRenderer as d, TresRendererError as dn, _default$3 as dt, INJECTION_KEY as en, logError as et, isWebGPURenderer as f, TresRendererErrorCode as fn, TresObjectMap as ft, isColorRepresentation as g, LoaderMethods as gn, AttachType as gt, isColor as h, RafLoopContext as hn, AttachFnType as ht, isClassInstance as i, RenderFunction as in, LoopContext as it, vLog as j, TresCatalogue as jt, TresTimer as k, ThreeInstancesOf as kt, isTresPrimitive as l, UseRendererManagerReturn as ln, useRendererManager as lt, isCamera as m, useCameraManager as mn, Args as mt, TresPlugin as n, TresContextProviderOptions as nn, logWarning as nt, isTresCamera as o, RendererOptions as on, TresPartialContext as ot, isBufferGeometry as p, UseCameraReturn as pn, buildGraph as pt, TresCanvasProps as q, TresVector2 as qt, plugin as r, useTresContext as rn, TresCustomRendererOptions as rt, isTresInstance as s, TresRenderer as sn, useTres as st, TresOptions as t, TresContext as tn, logMessage as tt, isVectorLike as u, UseRendererOptions as un, useTresContextProvider as ut, isGroup as v, TresLoader as vn, DisposeType as vt, isNodeMaterial as w, NonFunctionKeys as wt, isMaterial as x, useLoader as xn, LocalState as xt, isLayers as y, TresLoaderOptions as yn, ElementProps as yt, DevtoolsSubscriber as z, TresInstance as zt };