@tresjs/core 5.1.1 → 5.2.1
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.
package/dist/tres.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v5.
|
|
3
|
+
* version: v5.2.1
|
|
4
4
|
* (c) 2025
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
@@ -72,8 +72,9 @@ interface RafLoopContext {
|
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/composables/useSizes/index.d.ts
|
|
74
74
|
interface SizesType {
|
|
75
|
-
height: Readonly<Ref<number>>;
|
|
76
75
|
width: Readonly<Ref<number>>;
|
|
76
|
+
height: Readonly<Ref<number>>;
|
|
77
|
+
pixelRatio: Readonly<Ref<number>>;
|
|
77
78
|
aspectRatio: ComputedRef<number>;
|
|
78
79
|
}
|
|
79
80
|
//#endregion
|
|
@@ -329,7 +330,7 @@ declare function useEventManager({
|
|
|
329
330
|
canvas: MaybeRef<HTMLCanvasElement>;
|
|
330
331
|
contextParts: Pick<TresContext, 'scene' | 'camera' | 'renderer'>;
|
|
331
332
|
}): {
|
|
332
|
-
onPointerMissed: _vueuse_core0.EventHookOn<
|
|
333
|
+
onPointerMissed: _vueuse_core0.EventHookOn<TresPointerEvent & Event<"click", Object3D<Object3DEventMap & PointerEventsMap>>>;
|
|
333
334
|
};
|
|
334
335
|
//#endregion
|
|
335
336
|
//#region src/composables/useTresContextProvider/index.d.ts
|
|
@@ -353,6 +354,7 @@ declare const useTresContext: () => TresContext;
|
|
|
353
354
|
//#region src/utils/pointerEvents.d.ts
|
|
354
355
|
declare const supportedPointerEvents: readonly ["onClick", "onContextmenu", "onPointermove", "onPointerenter", "onPointerleave", "onPointerover", "onPointerout", "onDblclick", "onPointerdown", "onPointerup", "onPointercancel", "onLostpointercapture", "onWheel"];
|
|
355
356
|
type SupportedVuePointerEvent = typeof supportedPointerEvents[number];
|
|
357
|
+
type TresPointerEventName = 'click' | 'contextmenu' | 'pointermove' | 'pointerenter' | 'pointerleave' | 'pointerover' | 'pointerout' | 'dblclick' | 'pointerdown' | 'pointerup' | 'pointercancel' | 'lostpointercapture' | 'wheel';
|
|
356
358
|
type TresPointerEvent = PointerEvent<MouseEvent>;
|
|
357
359
|
type PointerEventHandlers = { [key in SupportedVuePointerEvent]: (event: TresPointerEvent) => void };
|
|
358
360
|
//#endregion
|
|
@@ -361,10 +363,10 @@ type AttachFnType = (parent: any, self: TresInstance) => () => void;
|
|
|
361
363
|
type AttachType = string | AttachFnType;
|
|
362
364
|
type DisposeType = ((self: TresInstance) => void) | boolean | 'default';
|
|
363
365
|
type ConstructorRepresentation = new (...args: any[]) => any;
|
|
364
|
-
type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends ((...args: any[]) => any) ? never : K }[keyof P];
|
|
365
|
-
type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
|
|
366
|
+
type NonFunctionKeys<P$1> = { [K in keyof P$1]-?: P$1[K] extends ((...args: any[]) => any) ? never : K }[keyof P$1];
|
|
367
|
+
type Overwrite<P$1, O> = Omit<P$1, NonFunctionKeys<O>> & O;
|
|
366
368
|
type Properties<T> = Pick<T, NonFunctionKeys<T>>;
|
|
367
|
-
type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> };
|
|
369
|
+
type Mutable<P$1> = { [K in keyof P$1]: P$1[K] | Readonly<P$1[K]> };
|
|
368
370
|
type Args<T> = T extends ConstructorRepresentation ? ConstructorParameters<T> : any[];
|
|
369
371
|
interface TresCatalogue {
|
|
370
372
|
[name: string]: ConstructorRepresentation;
|
|
@@ -376,8 +378,8 @@ type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
|
376
378
|
* @template T - The type of the object.
|
|
377
379
|
* @template P - The type of the arguments.
|
|
378
380
|
*/
|
|
379
|
-
interface InstanceProps<T = any, P = any> {
|
|
380
|
-
args?: Args<P>;
|
|
381
|
+
interface InstanceProps<T = any, P$1 = any> {
|
|
382
|
+
args?: Args<P$1>;
|
|
381
383
|
object?: T;
|
|
382
384
|
visible?: boolean;
|
|
383
385
|
dispose?: null;
|
|
@@ -454,17 +456,17 @@ type TresContextWithClock = TresContext & {
|
|
|
454
456
|
delta: number;
|
|
455
457
|
elapsed: number;
|
|
456
458
|
};
|
|
457
|
-
type WithMathProps<P> = { [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K] };
|
|
459
|
+
type WithMathProps<P$1> = { [K in keyof P$1]: P$1[K] extends MathRepresentation | THREE.Euler ? MathType<P$1[K]> : P$1[K] };
|
|
458
460
|
interface RaycastableRepresentation {
|
|
459
461
|
raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
460
462
|
}
|
|
461
|
-
type EventProps<P> = P extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
|
|
463
|
+
type EventProps<P$1> = P$1 extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
|
|
462
464
|
interface VueProps {
|
|
463
465
|
children?: VNode[];
|
|
464
466
|
ref?: VNodeRef;
|
|
465
467
|
key?: string | number | symbol;
|
|
466
468
|
}
|
|
467
|
-
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>>;
|
|
469
|
+
type ElementProps<T extends ConstructorRepresentation, P$1 = InstanceType<T>> = Partial<Overwrite<P$1, WithMathProps<P$1> & VueProps & EventProps<P$1>>>;
|
|
468
470
|
type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
|
|
469
471
|
type ThreeExports = typeof THREE;
|
|
470
472
|
type ThreeInstancesImpl = { [K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never };
|
|
@@ -496,7 +498,7 @@ interface TresObjectMap {
|
|
|
496
498
|
declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
|
|
497
499
|
//#endregion
|
|
498
500
|
//#region src/composables/useLoader/component.vue.d.ts
|
|
499
|
-
declare const __VLS_export$1: <T extends TresObjectMap>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>,
|
|
501
|
+
declare const __VLS_export$1: <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<{
|
|
500
502
|
props: __VLS_PrettifyLocal<{
|
|
501
503
|
/**
|
|
502
504
|
* The THREE.js loader to use
|
|
@@ -513,7 +515,9 @@ declare const __VLS_export$1: <T extends TresObjectMap>(__VLS_props: NonNullable
|
|
|
513
515
|
} & {
|
|
514
516
|
onLoaded?: ((result: T) => any) | undefined;
|
|
515
517
|
onError?: ((error: unknown) => any) | undefined;
|
|
516
|
-
}> & vue0.PublicProps
|
|
518
|
+
}> & vue0.PublicProps & (typeof globalThis extends {
|
|
519
|
+
__VLS_PROPS_FALLBACK: infer P;
|
|
520
|
+
} ? P : {});
|
|
517
521
|
expose: (exposed: {}) => void;
|
|
518
522
|
attrs: any;
|
|
519
523
|
slots: {
|
|
@@ -528,7 +532,7 @@ declare const __VLS_export$1: <T extends TresObjectMap>(__VLS_props: NonNullable
|
|
|
528
532
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
529
533
|
};
|
|
530
534
|
declare const _default$1: typeof __VLS_export$1;
|
|
531
|
-
type __VLS_PrettifyLocal<T> = { [K in keyof T as K]: T[K] } & {};
|
|
535
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
532
536
|
//#endregion
|
|
533
537
|
//#region src/composables/useGraph/index.d.ts
|
|
534
538
|
declare const useGraph: (object: MaybeRef$1<TresObject | undefined>) => vue0.ComputedRef<TresObjectMap | undefined>;
|
|
@@ -660,44 +664,55 @@ interface TresCanvasProps extends RendererOptions {
|
|
|
660
664
|
*/
|
|
661
665
|
enableProvideBridge?: boolean;
|
|
662
666
|
}
|
|
663
|
-
|
|
664
|
-
context:
|
|
667
|
+
type TresCanvasEmits = {
|
|
668
|
+
ready: [context: TresContext];
|
|
669
|
+
pointermissed: [event: TresPointerEvent];
|
|
670
|
+
render: [context: TresContext];
|
|
671
|
+
beforeLoop: [context: TresContextWithClock];
|
|
672
|
+
loop: [context: TresContextWithClock];
|
|
673
|
+
} & { [key in TresPointerEventName]: [event: TresPointerEvent] };
|
|
674
|
+
interface TresCanvasInstance {
|
|
675
|
+
get context(): TresContext | undefined;
|
|
665
676
|
dispose: () => void;
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
677
|
+
}
|
|
678
|
+
type __VLS_Slots = {
|
|
679
|
+
default: () => any;
|
|
680
|
+
};
|
|
681
|
+
declare const __VLS_base: vue0.DefineComponent<TresCanvasProps, TresCanvasInstance, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {
|
|
682
|
+
click: (event: TresPointerEvent) => any;
|
|
683
|
+
contextmenu: (event: TresPointerEvent) => any;
|
|
684
|
+
pointermove: (event: TresPointerEvent) => any;
|
|
685
|
+
pointerenter: (event: TresPointerEvent) => any;
|
|
686
|
+
pointerleave: (event: TresPointerEvent) => any;
|
|
687
|
+
pointerover: (event: TresPointerEvent) => any;
|
|
688
|
+
pointerout: (event: TresPointerEvent) => any;
|
|
689
|
+
dblclick: (event: TresPointerEvent) => any;
|
|
690
|
+
pointerdown: (event: TresPointerEvent) => any;
|
|
691
|
+
pointerup: (event: TresPointerEvent) => any;
|
|
692
|
+
pointercancel: (event: TresPointerEvent) => any;
|
|
693
|
+
lostpointercapture: (event: TresPointerEvent) => any;
|
|
694
|
+
wheel: (event: TresPointerEvent) => any;
|
|
680
695
|
ready: (context: TresContext) => any;
|
|
681
|
-
pointermissed: (event:
|
|
696
|
+
pointermissed: (event: TresPointerEvent) => any;
|
|
682
697
|
render: (context: TresContext) => any;
|
|
683
698
|
beforeLoop: (context: TresContextWithClock) => any;
|
|
684
699
|
loop: (context: TresContextWithClock) => any;
|
|
685
700
|
}, string, vue0.PublicProps, Readonly<TresCanvasProps> & Readonly<{
|
|
686
|
-
onClick?: ((event:
|
|
687
|
-
onContextmenu?: ((event:
|
|
688
|
-
onPointermove?: ((event:
|
|
689
|
-
onPointerenter?: ((event:
|
|
690
|
-
onPointerleave?: ((event:
|
|
691
|
-
onPointerover?: ((event:
|
|
692
|
-
onPointerout?: ((event:
|
|
693
|
-
onDblclick?: ((event:
|
|
694
|
-
onPointerdown?: ((event:
|
|
695
|
-
onPointerup?: ((event:
|
|
696
|
-
onPointercancel?: ((event:
|
|
697
|
-
onLostpointercapture?: ((event:
|
|
698
|
-
onWheel?: ((event:
|
|
701
|
+
onClick?: ((event: TresPointerEvent) => any) | undefined;
|
|
702
|
+
onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
|
|
703
|
+
onPointermove?: ((event: TresPointerEvent) => any) | undefined;
|
|
704
|
+
onPointerenter?: ((event: TresPointerEvent) => any) | undefined;
|
|
705
|
+
onPointerleave?: ((event: TresPointerEvent) => any) | undefined;
|
|
706
|
+
onPointerover?: ((event: TresPointerEvent) => any) | undefined;
|
|
707
|
+
onPointerout?: ((event: TresPointerEvent) => any) | undefined;
|
|
708
|
+
onDblclick?: ((event: TresPointerEvent) => any) | undefined;
|
|
709
|
+
onPointerdown?: ((event: TresPointerEvent) => any) | undefined;
|
|
710
|
+
onPointerup?: ((event: TresPointerEvent) => any) | undefined;
|
|
711
|
+
onPointercancel?: ((event: TresPointerEvent) => any) | undefined;
|
|
712
|
+
onLostpointercapture?: ((event: TresPointerEvent) => any) | undefined;
|
|
713
|
+
onWheel?: ((event: TresPointerEvent) => any) | undefined;
|
|
699
714
|
onReady?: ((context: TresContext) => any) | undefined;
|
|
700
|
-
onPointermissed?: ((event:
|
|
715
|
+
onPointermissed?: ((event: TresPointerEvent) => any) | undefined;
|
|
701
716
|
onRender?: ((context: TresContext) => any) | undefined;
|
|
702
717
|
onBeforeLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
703
718
|
onLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
@@ -718,9 +733,8 @@ declare const __VLS_export: __VLS_WithSlots<vue0.DefineComponent<TresCanvasProps
|
|
|
718
733
|
useLegacyLights: boolean;
|
|
719
734
|
renderMode: "always" | "on-demand" | "manual";
|
|
720
735
|
enableProvideBridge: boolean;
|
|
721
|
-
}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any
|
|
722
|
-
|
|
723
|
-
}>;
|
|
736
|
+
}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
|
|
737
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
724
738
|
declare const _default: typeof __VLS_export;
|
|
725
739
|
type __VLS_WithSlots<T, S> = T & {
|
|
726
740
|
new (): {
|
|
@@ -1053,4 +1067,4 @@ interface TresPlugin {
|
|
|
1053
1067
|
}
|
|
1054
1068
|
declare const plugin: TresPlugin;
|
|
1055
1069
|
//#endregion
|
|
1056
|
-
export { Args, AssetLoadData, AttachFnType, AttachType, ConstructorRepresentation, DevtoolsMessage, DevtoolsMessageType, DevtoolsMessenger, DevtoolsSubscriber, DisposeType, ElementProps, InstanceProps, LoaderMethods, LoaderProto, LocalState, LoopContext, MathType, Mutable, NonFunctionKeys, Overwrite, Properties, RenderFunction, RenderMode, RendererOptions, ThreeElement, ThreeInstances, TresCamera, _default as TresCanvas, TresCatalogue, TresColor, TresColorArray, type TresContext, TresContextWithClock, TresControl, TresEuler, TresInstance, TresLayers, TresLoader, TresLoaderOptions, TresMaterial, TresObject, TresObject3D, TresObjectMap, TresOptions, TresPartialContext, TresPlugin, type TresPointerEvent, TresPrimitive, TresQuaternion, TresRenderer, TresRendererSetupContext, TresScene, TresVector2, TresVector3, TresVector4, UseCameraReturn, _default$1 as UseLoader, UseLoaderReturn, UseRendererManagerReturn, UseRendererOptions, VectorCoordinates, type VectorFlexibleParams, VueProps, WithMathProps, buildGraph, catalogue, plugin as default, disposeObject3D as dispose, extend, isBufferGeometry, isCamera, isClassInstance, isColor, isColorRepresentation, isCopyable, isFog, isGroup, isLayers, isLight, isMaterial, isMesh, isObject3D, isOrthographicCamera, isPerspectiveCamera, isProd, isScene, isTresCamera, isTresInstance, isTresObject, isTresPrimitive, isVectorLike, logError, logMessage, logWarning, normalizeColor, normalizeVectorFlexibleParam, registerTresDevtools, templateCompilerOptions, useCameraManager, useGraph, useLoader, useLoop, useRendererManager, useTres, useTresContext, useTresContextProvider, vDistanceTo, vLightHelper, vLog };
|
|
1070
|
+
export { Args, AssetLoadData, AttachFnType, AttachType, ConstructorRepresentation, DevtoolsMessage, DevtoolsMessageType, DevtoolsMessenger, DevtoolsSubscriber, DisposeType, ElementProps, InstanceProps, LoaderMethods, LoaderProto, LocalState, LoopContext, MathType, Mutable, NonFunctionKeys, Overwrite, Properties, RenderFunction, RenderMode, RendererOptions, ThreeElement, ThreeInstances, TresCamera, _default as TresCanvas, type TresCanvasEmits, type TresCanvasInstance, type TresCanvasProps, TresCatalogue, TresColor, TresColorArray, type TresContext, TresContextWithClock, TresControl, TresEuler, TresInstance, TresLayers, TresLoader, TresLoaderOptions, TresMaterial, TresObject, TresObject3D, TresObjectMap, TresOptions, TresPartialContext, TresPlugin, type TresPointerEvent, TresPrimitive, TresQuaternion, TresRenderer, TresRendererSetupContext, TresScene, TresVector2, TresVector3, TresVector4, UseCameraReturn, _default$1 as UseLoader, UseLoaderReturn, UseRendererManagerReturn, UseRendererOptions, VectorCoordinates, type VectorFlexibleParams, VueProps, WithMathProps, buildGraph, catalogue, plugin as default, disposeObject3D as dispose, extend, isBufferGeometry, isCamera, isClassInstance, isColor, isColorRepresentation, isCopyable, isFog, isGroup, isLayers, isLight, isMaterial, isMesh, isObject3D, isOrthographicCamera, isPerspectiveCamera, isProd, isScene, isTresCamera, isTresInstance, isTresObject, isTresPrimitive, isVectorLike, logError, logMessage, logWarning, normalizeColor, normalizeVectorFlexibleParam, registerTresDevtools, templateCompilerOptions, useCameraManager, useGraph, useLoader, useLoop, useRendererManager, useTres, useTresContext, useTresContextProvider, vDistanceTo, vLightHelper, vLog };
|
package/dist/tres.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v5.
|
|
3
|
+
* version: v5.2.1
|
|
4
4
|
* (c) 2025
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
import { Fragment, computed, createElementBlock, createRenderer, defineComponent, getCurrentInstance, h, isRef, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, provide, reactive, readonly, ref, renderSlot, shallowRef, toValue, unref, useSlots, watch, watchEffect } from "vue";
|
|
8
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createRenderer, defineComponent, getCurrentInstance, h, isRef, mergeProps, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, provide, reactive, readonly, ref, renderSlot, shallowRef, toValue, unref, useSlots, watch, watchEffect, withCtx } from "vue";
|
|
9
9
|
import * as THREE from "three";
|
|
10
10
|
import { ACESFilmicToneMapping, ArrowHelper, BackSide, BufferAttribute, BufferGeometry, Clock, Color, DirectionalLightHelper, DoubleSide, Float32BufferAttribute, HemisphereLightHelper, Layers, Line, LineBasicMaterial, Material, MathUtils, Mesh, MeshBasicMaterial, Object3D, PCFSoftShadowMap, PerspectiveCamera, PointLightHelper, Scene, SpotLightHelper, Vector3, WebGLRenderer } from "three";
|
|
11
11
|
import { createEventHook, createInjectionState, promiseTimeout, refDebounced, tryOnScopeDispose, unrefElement, useAsyncState, useDevicePixelRatio, useElementSize, useFps, useMemory, useRafFn, useTimeout, useWindowSize, whenever } from "@vueuse/core";
|
|
@@ -14,88 +14,7 @@ import { forwardHtmlEvents, getVoidObject } from "@pmndrs/pointer-events";
|
|
|
14
14
|
import { setupDevtoolsPlugin } from "@vue/devtools-api";
|
|
15
15
|
|
|
16
16
|
//#region package.json
|
|
17
|
-
var
|
|
18
|
-
name: "@tresjs/core",
|
|
19
|
-
type: "module",
|
|
20
|
-
version: "5.1.1",
|
|
21
|
-
description: "Declarative ThreeJS using Vue Components",
|
|
22
|
-
author: "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
23
|
-
license: "MIT",
|
|
24
|
-
repository: {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "git+https://github.com/Tresjs/tres.git",
|
|
27
|
-
"directory": "packages/core"
|
|
28
|
-
},
|
|
29
|
-
keywords: [
|
|
30
|
-
"vue",
|
|
31
|
-
"3d",
|
|
32
|
-
"threejs",
|
|
33
|
-
"three",
|
|
34
|
-
"threejs-vue"
|
|
35
|
-
],
|
|
36
|
-
sideEffects: false,
|
|
37
|
-
exports: {
|
|
38
|
-
".": "./dist/tres.js",
|
|
39
|
-
"./template-compiler-options": "./dist/template-compiler-options.mjs",
|
|
40
|
-
"./package.json": "./package.json"
|
|
41
|
-
},
|
|
42
|
-
main: "./dist/tres.js",
|
|
43
|
-
module: "./dist/tres.js",
|
|
44
|
-
types: "./dist/tres.d.ts",
|
|
45
|
-
typesVersions: { "*": { "template-compiler-options": ["dist/template-compiler-options.d.mts"] } },
|
|
46
|
-
files: ["*.d.ts", "dist"],
|
|
47
|
-
publishConfig: { "access": "public" },
|
|
48
|
-
scripts: {
|
|
49
|
-
"build": "tsdown",
|
|
50
|
-
"test": "vitest",
|
|
51
|
-
"test:ci": "vitest run",
|
|
52
|
-
"test:ui": "vitest --ui --coverage.enabled=true",
|
|
53
|
-
"coverage": "vitest run --coverage",
|
|
54
|
-
"lint": "eslint .",
|
|
55
|
-
"lint:fix": "eslint . --fix",
|
|
56
|
-
"typecheck": "vue-tsc --noEmit"
|
|
57
|
-
},
|
|
58
|
-
peerDependencies: {
|
|
59
|
-
"three": ">=0.133",
|
|
60
|
-
"vue": ">=3.4"
|
|
61
|
-
},
|
|
62
|
-
dependencies: {
|
|
63
|
-
"@pmndrs/pointer-events": "^6.6.17",
|
|
64
|
-
"@vue/devtools-api": "^7.7.2",
|
|
65
|
-
"@vueuse/core": "catalog:utils",
|
|
66
|
-
"radashi": "^12.6.2",
|
|
67
|
-
"typescript": "catalog:typescript"
|
|
68
|
-
},
|
|
69
|
-
devDependencies: {
|
|
70
|
-
"@tresjs/eslint-config": "workspace:*",
|
|
71
|
-
"@types/three": "catalog:three",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "catalog:eslint",
|
|
73
|
-
"@typescript-eslint/parser": "catalog:eslint",
|
|
74
|
-
"@vitejs/plugin-vue": "catalog:vite",
|
|
75
|
-
"@vitest/coverage-v8": "3.2.4",
|
|
76
|
-
"@vitest/ui": "catalog:testing",
|
|
77
|
-
"@vue/test-utils": "catalog:testing",
|
|
78
|
-
"eslint": "catalog:eslint",
|
|
79
|
-
"eslint-plugin-vue": "catalog:eslint",
|
|
80
|
-
"jsdom": "catalog:testing",
|
|
81
|
-
"kolorist": "catalog:utils",
|
|
82
|
-
"pathe": "catalog:utils",
|
|
83
|
-
"rollup-plugin-analyzer": "catalog:build",
|
|
84
|
-
"rollup-plugin-copy": "^3.5.0",
|
|
85
|
-
"rollup-plugin-visualizer": "catalog:build",
|
|
86
|
-
"three": "catalog:three",
|
|
87
|
-
"tsdown": "catalog:build",
|
|
88
|
-
"vite": "catalog:vite",
|
|
89
|
-
"vite-plugin-banner": "catalog:vite",
|
|
90
|
-
"vite-plugin-dts": "catalog:vite",
|
|
91
|
-
"vite-plugin-inspect": "^11.3.3",
|
|
92
|
-
"vitest": "catalog:testing",
|
|
93
|
-
"vue": "catalog:vue",
|
|
94
|
-
"vue-demi": "^0.14.10",
|
|
95
|
-
"vue-tsc": "catalog:typescript"
|
|
96
|
-
},
|
|
97
|
-
nx: { "implicitDependencies": ["!@tresjs/core-*"] }
|
|
98
|
-
};
|
|
17
|
+
var version = "5.2.1";
|
|
99
18
|
|
|
100
19
|
//#endregion
|
|
101
20
|
//#region src/utils/makeMap.ts
|
|
@@ -401,8 +320,8 @@ function logWarning(...args) {
|
|
|
401
320
|
* @param name - Name of the message
|
|
402
321
|
* @param value - Value to log
|
|
403
322
|
*/
|
|
404
|
-
function logMessage(name
|
|
405
|
-
if (!isProd) console.log(`${logPrefix} - ${name
|
|
323
|
+
function logMessage(name, value) {
|
|
324
|
+
if (!isProd) console.log(`${logPrefix} - ${name}:`, value);
|
|
406
325
|
}
|
|
407
326
|
|
|
408
327
|
//#endregion
|
|
@@ -446,11 +365,11 @@ function resolve(obj, key) {
|
|
|
446
365
|
function joinAsCamelCase(...strings) {
|
|
447
366
|
return strings.map((s, i) => i === 0 ? s : s.charAt(0).toUpperCase() + s.slice(1)).join("");
|
|
448
367
|
}
|
|
449
|
-
function attach(parent, child, type
|
|
368
|
+
function attach(parent, child, type) {
|
|
450
369
|
const INDEX_REGEX = /-\d+$/;
|
|
451
|
-
if (isString(type
|
|
452
|
-
if (INDEX_REGEX.test(type
|
|
453
|
-
const { target: target$1, key: key$1 } = resolve(parent, type
|
|
370
|
+
if (isString(type)) {
|
|
371
|
+
if (INDEX_REGEX.test(type)) {
|
|
372
|
+
const { target: target$1, key: key$1 } = resolve(parent, type.replace(INDEX_REGEX, ""));
|
|
454
373
|
if (!Array.isArray(target$1[key$1])) {
|
|
455
374
|
const previousAttach = target$1[key$1];
|
|
456
375
|
const augmentedArray = [];
|
|
@@ -460,14 +379,14 @@ function attach(parent, child, type$1) {
|
|
|
460
379
|
target$1[key$1] = augmentedArray;
|
|
461
380
|
}
|
|
462
381
|
}
|
|
463
|
-
const { target, key } = resolve(parent, type
|
|
382
|
+
const { target, key } = resolve(parent, type);
|
|
464
383
|
child.__tres.previousAttach = target[key];
|
|
465
384
|
target[key] = unboxTresPrimitive(child);
|
|
466
|
-
} else child.__tres.previousAttach = type
|
|
385
|
+
} else child.__tres.previousAttach = type(parent, child);
|
|
467
386
|
}
|
|
468
|
-
function detach(parent, child, type
|
|
469
|
-
if (isString(type
|
|
470
|
-
const { target, key } = resolve(parent, type
|
|
387
|
+
function detach(parent, child, type) {
|
|
388
|
+
if (isString(type)) {
|
|
389
|
+
const { target, key } = resolve(parent, type);
|
|
471
390
|
const previous = child.__tres.previousAttach;
|
|
472
391
|
if (previous === void 0) delete target[key];
|
|
473
392
|
else target[key] = previous;
|
|
@@ -907,9 +826,8 @@ function useRendererManager({ scene, canvas, options, contextParts: { sizes, cam
|
|
|
907
826
|
}
|
|
908
827
|
invalidateOnDemand();
|
|
909
828
|
}, { immediate: true });
|
|
910
|
-
const { pixelRatio } = useDevicePixelRatio();
|
|
911
829
|
watchEffect(() => {
|
|
912
|
-
setPixelRatio(renderer, pixelRatio.value, toValue(options.dpr));
|
|
830
|
+
setPixelRatio(renderer, sizes.pixelRatio.value, toValue(options.dpr));
|
|
913
831
|
});
|
|
914
832
|
if (toValue(options.renderMode) === "on-demand") invalidate();
|
|
915
833
|
if (toValue(options.renderMode) === "manual") useTimeout(100, { callback: advance });
|
|
@@ -976,12 +894,14 @@ function useRendererManager({ scene, canvas, options, contextParts: { sizes, cam
|
|
|
976
894
|
//#endregion
|
|
977
895
|
//#region src/composables/useSizes/index.ts
|
|
978
896
|
function useSizes(windowSize, canvas, debounceMs = 10) {
|
|
897
|
+
const { pixelRatio } = useDevicePixelRatio();
|
|
979
898
|
const reactiveSize = toValue(windowSize) ? useWindowSize() : useElementSize(computed(() => toValue(canvas).parentElement));
|
|
980
899
|
const debouncedReactiveWidth = readonly(refDebounced(reactiveSize.width, debounceMs));
|
|
981
900
|
const debouncedReactiveHeight = readonly(refDebounced(reactiveSize.height, debounceMs));
|
|
982
901
|
return {
|
|
983
|
-
height: debouncedReactiveHeight,
|
|
984
902
|
width: debouncedReactiveWidth,
|
|
903
|
+
height: debouncedReactiveHeight,
|
|
904
|
+
pixelRatio,
|
|
985
905
|
aspectRatio: computed(() => debouncedReactiveWidth.value / debouncedReactiveHeight.value)
|
|
986
906
|
};
|
|
987
907
|
}
|
|
@@ -1159,11 +1079,11 @@ const nodeOps = (context) => {
|
|
|
1159
1079
|
if (!props.args) props.args = [];
|
|
1160
1080
|
if (isHTMLTag(tag)) return null;
|
|
1161
1081
|
if (tag.includes("-")) tag = tag.replace(/-([a-z])/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
|
|
1162
|
-
let name
|
|
1082
|
+
let name = tag.replace("Tres", "");
|
|
1163
1083
|
let obj;
|
|
1164
1084
|
if (tag === "primitive") {
|
|
1165
1085
|
if (!isObject(props.object) || isRef(props.object)) logError("Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>");
|
|
1166
|
-
name
|
|
1086
|
+
name = props.object.type;
|
|
1167
1087
|
const __tres = {};
|
|
1168
1088
|
obj = createRetargetingProxy(props.object, {
|
|
1169
1089
|
object: (t) => t,
|
|
@@ -1182,8 +1102,8 @@ const nodeOps = (context) => {
|
|
|
1182
1102
|
}
|
|
1183
1103
|
});
|
|
1184
1104
|
} else {
|
|
1185
|
-
const target = catalogue.value[name
|
|
1186
|
-
if (!target) logError(`${name
|
|
1105
|
+
const target = catalogue.value[name];
|
|
1106
|
+
if (!target) logError(`${name} is not defined on the THREE namespace. Use extend to add it to the catalog.`);
|
|
1187
1107
|
obj = new target(...props.args);
|
|
1188
1108
|
}
|
|
1189
1109
|
if (!obj) return null;
|
|
@@ -1193,7 +1113,7 @@ const nodeOps = (context) => {
|
|
|
1193
1113
|
}
|
|
1194
1114
|
obj = prepareTresInstance(obj, {
|
|
1195
1115
|
...isTresInstance(obj) ? obj.__tres : {},
|
|
1196
|
-
type: name
|
|
1116
|
+
type: name,
|
|
1197
1117
|
memoizedProps: props,
|
|
1198
1118
|
primitive: tag === "primitive",
|
|
1199
1119
|
attach: props.attach
|
|
@@ -1375,14 +1295,14 @@ var DevtoolsMessenger = class {
|
|
|
1375
1295
|
* Send a message to devtools subscribers
|
|
1376
1296
|
* If no subscribers are available, only queueable message types are queued
|
|
1377
1297
|
*/
|
|
1378
|
-
send(type
|
|
1298
|
+
send(type, data) {
|
|
1379
1299
|
const message = {
|
|
1380
|
-
type
|
|
1300
|
+
type,
|
|
1381
1301
|
data,
|
|
1382
1302
|
timestamp: Date.now()
|
|
1383
1303
|
};
|
|
1384
1304
|
if (this.subscribers.size > 0) this.subscribers.forEach((subscriber) => subscriber(message));
|
|
1385
|
-
else if (QUEUEABLE_MESSAGE_TYPES.includes(type
|
|
1305
|
+
else if (QUEUEABLE_MESSAGE_TYPES.includes(type)) this.queueMessage(message);
|
|
1386
1306
|
}
|
|
1387
1307
|
/**
|
|
1388
1308
|
* Queue a message for later delivery
|
|
@@ -1440,15 +1360,15 @@ var DevtoolsMessenger = class {
|
|
|
1440
1360
|
* @param message - message to log
|
|
1441
1361
|
* @param type - different color of the tooltip
|
|
1442
1362
|
*/
|
|
1443
|
-
function toastMessage(message, type
|
|
1363
|
+
function toastMessage(message, type) {
|
|
1444
1364
|
const tresMessage = `▲ ■ ●${message}`;
|
|
1445
|
-
if (typeof __VUE_DEVTOOLS_TOAST__ === "function") __VUE_DEVTOOLS_TOAST__(tresMessage, type
|
|
1446
|
-
else if (type
|
|
1447
|
-
else if (type
|
|
1365
|
+
if (typeof __VUE_DEVTOOLS_TOAST__ === "function") __VUE_DEVTOOLS_TOAST__(tresMessage, type);
|
|
1366
|
+
else if (type === "error") console.error(tresMessage);
|
|
1367
|
+
else if (type === "warn") console.warn(tresMessage);
|
|
1448
1368
|
else console.log(tresMessage);
|
|
1449
1369
|
}
|
|
1450
|
-
function __VUE_DEVTOOLS_TOAST__(tresMessage, type
|
|
1451
|
-
throw new Error(tresMessage + type
|
|
1370
|
+
function __VUE_DEVTOOLS_TOAST__(tresMessage, type) {
|
|
1371
|
+
throw new Error(tresMessage + type);
|
|
1452
1372
|
}
|
|
1453
1373
|
|
|
1454
1374
|
//#endregion
|
|
@@ -1889,10 +1809,9 @@ function registerTresDevtools(app, tres) {
|
|
|
1889
1809
|
}
|
|
1890
1810
|
|
|
1891
1811
|
//#endregion
|
|
1892
|
-
//#region src/components/
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
__name: "TresCanvas",
|
|
1812
|
+
//#region src/components/Context.vue?vue&type=script&setup=true&lang.ts
|
|
1813
|
+
var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
1814
|
+
__name: "Context",
|
|
1896
1815
|
props: {
|
|
1897
1816
|
camera: {
|
|
1898
1817
|
type: null,
|
|
@@ -1900,28 +1819,23 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1900
1819
|
},
|
|
1901
1820
|
windowSize: {
|
|
1902
1821
|
type: Boolean,
|
|
1903
|
-
required: false
|
|
1904
|
-
default: void 0
|
|
1822
|
+
required: false
|
|
1905
1823
|
},
|
|
1906
1824
|
enableProvideBridge: {
|
|
1907
1825
|
type: Boolean,
|
|
1908
|
-
required: false
|
|
1909
|
-
default: true
|
|
1826
|
+
required: false
|
|
1910
1827
|
},
|
|
1911
1828
|
antialias: {
|
|
1912
1829
|
type: Boolean,
|
|
1913
|
-
required: false
|
|
1914
|
-
default: true
|
|
1830
|
+
required: false
|
|
1915
1831
|
},
|
|
1916
1832
|
stencil: {
|
|
1917
1833
|
type: Boolean,
|
|
1918
|
-
required: false
|
|
1919
|
-
default: void 0
|
|
1834
|
+
required: false
|
|
1920
1835
|
},
|
|
1921
1836
|
depth: {
|
|
1922
1837
|
type: Boolean,
|
|
1923
|
-
required: false
|
|
1924
|
-
default: void 0
|
|
1838
|
+
required: false
|
|
1925
1839
|
},
|
|
1926
1840
|
precision: {
|
|
1927
1841
|
type: String,
|
|
@@ -1929,13 +1843,11 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1929
1843
|
},
|
|
1930
1844
|
logarithmicDepthBuffer: {
|
|
1931
1845
|
type: Boolean,
|
|
1932
|
-
required: false
|
|
1933
|
-
default: void 0
|
|
1846
|
+
required: false
|
|
1934
1847
|
},
|
|
1935
1848
|
preserveDrawingBuffer: {
|
|
1936
1849
|
type: Boolean,
|
|
1937
|
-
required: false
|
|
1938
|
-
default: void 0
|
|
1850
|
+
required: false
|
|
1939
1851
|
},
|
|
1940
1852
|
powerPreference: {
|
|
1941
1853
|
type: null,
|
|
@@ -1943,8 +1855,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1943
1855
|
},
|
|
1944
1856
|
alpha: {
|
|
1945
1857
|
type: Boolean,
|
|
1946
|
-
required: false
|
|
1947
|
-
default: void 0
|
|
1858
|
+
required: false
|
|
1948
1859
|
},
|
|
1949
1860
|
premultipliedAlpha: {
|
|
1950
1861
|
type: Boolean,
|
|
@@ -1952,8 +1863,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1952
1863
|
},
|
|
1953
1864
|
failIfMajorPerformanceCaveat: {
|
|
1954
1865
|
type: Boolean,
|
|
1955
|
-
required: false
|
|
1956
|
-
default: void 0
|
|
1866
|
+
required: false
|
|
1957
1867
|
},
|
|
1958
1868
|
clearColor: {
|
|
1959
1869
|
type: [
|
|
@@ -1961,33 +1871,27 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1961
1871
|
String,
|
|
1962
1872
|
Number
|
|
1963
1873
|
],
|
|
1964
|
-
required: false
|
|
1965
|
-
default: "#000000"
|
|
1874
|
+
required: false
|
|
1966
1875
|
},
|
|
1967
1876
|
clearAlpha: {
|
|
1968
1877
|
type: Number,
|
|
1969
|
-
required: false
|
|
1970
|
-
default: 1
|
|
1878
|
+
required: false
|
|
1971
1879
|
},
|
|
1972
1880
|
shadows: {
|
|
1973
1881
|
type: Boolean,
|
|
1974
|
-
required: false
|
|
1975
|
-
default: void 0
|
|
1882
|
+
required: false
|
|
1976
1883
|
},
|
|
1977
1884
|
toneMapping: {
|
|
1978
1885
|
type: null,
|
|
1979
|
-
required: false
|
|
1980
|
-
default: ACESFilmicToneMapping
|
|
1886
|
+
required: false
|
|
1981
1887
|
},
|
|
1982
1888
|
shadowMapType: {
|
|
1983
1889
|
type: null,
|
|
1984
|
-
required: false
|
|
1985
|
-
default: PCFSoftShadowMap
|
|
1890
|
+
required: false
|
|
1986
1891
|
},
|
|
1987
1892
|
useLegacyLights: {
|
|
1988
1893
|
type: Boolean,
|
|
1989
|
-
required: false
|
|
1990
|
-
default: void 0
|
|
1894
|
+
required: false
|
|
1991
1895
|
},
|
|
1992
1896
|
outputColorSpace: {
|
|
1993
1897
|
type: null,
|
|
@@ -1999,8 +1903,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1999
1903
|
},
|
|
2000
1904
|
renderMode: {
|
|
2001
1905
|
type: String,
|
|
2002
|
-
required: false
|
|
2003
|
-
default: "always"
|
|
1906
|
+
required: false
|
|
2004
1907
|
},
|
|
2005
1908
|
dpr: {
|
|
2006
1909
|
type: [Number, Array],
|
|
@@ -2009,6 +1912,10 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2009
1912
|
renderer: {
|
|
2010
1913
|
type: Function,
|
|
2011
1914
|
required: false
|
|
1915
|
+
},
|
|
1916
|
+
canvas: {
|
|
1917
|
+
type: null,
|
|
1918
|
+
required: true
|
|
2012
1919
|
}
|
|
2013
1920
|
},
|
|
2014
1921
|
emits: [
|
|
@@ -2035,7 +1942,6 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2035
1942
|
const props = __props;
|
|
2036
1943
|
const emit = __emit;
|
|
2037
1944
|
const slots = useSlots();
|
|
2038
|
-
const canvasRef = ref();
|
|
2039
1945
|
const scene = shallowRef(new Scene());
|
|
2040
1946
|
const instance = getCurrentInstance();
|
|
2041
1947
|
extend(THREE);
|
|
@@ -2075,7 +1981,12 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2075
1981
|
}
|
|
2076
1982
|
scene.value.__tres = { root: context$1 };
|
|
2077
1983
|
};
|
|
2078
|
-
const context = shallowRef(
|
|
1984
|
+
const context = shallowRef(useTresContextProvider({
|
|
1985
|
+
scene: scene.value,
|
|
1986
|
+
canvas: props.canvas,
|
|
1987
|
+
windowSize: props.windowSize ?? false,
|
|
1988
|
+
rendererOptions: props
|
|
1989
|
+
}));
|
|
2079
1990
|
__expose({
|
|
2080
1991
|
context,
|
|
2081
1992
|
dispose: () => dispose(context.value, true)
|
|
@@ -2088,73 +1999,226 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2088
1999
|
dispose(context.value);
|
|
2089
2000
|
mountCustomRenderer(context.value, true);
|
|
2090
2001
|
};
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
camera$1.position.set(3, 3, 3);
|
|
2105
|
-
camera$1.lookAt(0, 0, 0);
|
|
2106
|
-
registerCamera(camera$1);
|
|
2107
|
-
const unwatch = watchEffect(() => {
|
|
2108
|
-
if (cameras.value.length >= 2) {
|
|
2109
|
-
camera$1.removeFromParent();
|
|
2110
|
-
deregisterCamera(camera$1);
|
|
2111
|
-
unwatch?.();
|
|
2112
|
-
}
|
|
2113
|
-
});
|
|
2114
|
-
};
|
|
2115
|
-
context.value.events.onPointerMissed((event) => {
|
|
2116
|
-
emit("pointermissed", event);
|
|
2117
|
-
});
|
|
2118
|
-
watch(() => props.camera, (newCamera, oldCamera) => {
|
|
2119
|
-
if (newCamera) registerCamera(toValue(newCamera), true);
|
|
2120
|
-
if (oldCamera) {
|
|
2121
|
-
toValue(oldCamera).removeFromParent();
|
|
2122
|
-
deregisterCamera(toValue(oldCamera));
|
|
2002
|
+
const { camera, renderer } = context.value;
|
|
2003
|
+
const { registerCamera, cameras, activeCamera, deregisterCamera } = camera;
|
|
2004
|
+
mountCustomRenderer(context.value);
|
|
2005
|
+
const addDefaultCamera = () => {
|
|
2006
|
+
const camera$1 = new PerspectiveCamera(45, window.innerWidth / window.innerHeight, .1, 1e3);
|
|
2007
|
+
camera$1.position.set(3, 3, 3);
|
|
2008
|
+
camera$1.lookAt(0, 0, 0);
|
|
2009
|
+
registerCamera(camera$1);
|
|
2010
|
+
const unwatch = watchEffect(() => {
|
|
2011
|
+
if (cameras.value.length >= 2) {
|
|
2012
|
+
camera$1.removeFromParent();
|
|
2013
|
+
deregisterCamera(camera$1);
|
|
2014
|
+
unwatch?.();
|
|
2123
2015
|
}
|
|
2124
|
-
}, { immediate: true });
|
|
2125
|
-
if (!activeCamera.value) addDefaultCamera();
|
|
2126
|
-
renderer.onRender(() => {
|
|
2127
|
-
if (context.value) emit("render", context.value);
|
|
2128
|
-
});
|
|
2129
|
-
renderer.loop.onLoop((loopContext) => {
|
|
2130
|
-
if (context.value) emit("loop", {
|
|
2131
|
-
...context.value,
|
|
2132
|
-
...loopContext
|
|
2133
|
-
});
|
|
2134
2016
|
});
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2017
|
+
};
|
|
2018
|
+
context.value.events.onPointerMissed((event) => {
|
|
2019
|
+
emit("pointermissed", event);
|
|
2020
|
+
});
|
|
2021
|
+
watch(() => props.camera, (newCamera, oldCamera) => {
|
|
2022
|
+
if (newCamera) registerCamera(toValue(newCamera), true);
|
|
2023
|
+
if (oldCamera) {
|
|
2024
|
+
toValue(oldCamera).removeFromParent();
|
|
2025
|
+
deregisterCamera(toValue(oldCamera));
|
|
2026
|
+
}
|
|
2027
|
+
}, { immediate: true });
|
|
2028
|
+
if (!activeCamera.value) addDefaultCamera();
|
|
2029
|
+
renderer.onRender(() => {
|
|
2030
|
+
if (context.value) emit("render", context.value);
|
|
2031
|
+
});
|
|
2032
|
+
renderer.loop.onLoop((loopContext) => {
|
|
2033
|
+
if (context.value) emit("loop", {
|
|
2034
|
+
...context.value,
|
|
2035
|
+
...loopContext
|
|
2140
2036
|
});
|
|
2141
|
-
|
|
2142
|
-
|
|
2037
|
+
});
|
|
2038
|
+
renderer.loop.onBeforeLoop((loopContext) => {
|
|
2039
|
+
if (context.value) emit("beforeLoop", {
|
|
2040
|
+
...context.value,
|
|
2041
|
+
...loopContext
|
|
2143
2042
|
});
|
|
2144
|
-
if (import.meta.hot && context.value) import.meta.hot.on("vite:afterUpdate", () => handleHMR(context.value));
|
|
2145
2043
|
});
|
|
2044
|
+
renderer.onReady(() => {
|
|
2045
|
+
emit("ready", context.value);
|
|
2046
|
+
});
|
|
2047
|
+
if (import.meta.hot) import.meta.hot.on("vite:afterUpdate", () => handleHMR(context.value));
|
|
2146
2048
|
onMounted(async () => {
|
|
2147
2049
|
await promiseTimeout(3e3);
|
|
2148
|
-
if (
|
|
2050
|
+
if (!context.value.sizes.width || !context.value.sizes.height.value) console.warn(`TresCanvas: The canvas has no area, so nothing can be rendered. Set it manually on the parent element or use the prop windowSize.`);
|
|
2149
2051
|
});
|
|
2150
2052
|
onUnmounted(unmountCanvas);
|
|
2053
|
+
return () => {};
|
|
2054
|
+
}
|
|
2055
|
+
});
|
|
2056
|
+
|
|
2057
|
+
//#endregion
|
|
2058
|
+
//#region src/components/Context.vue
|
|
2059
|
+
var Context_default = Context_vue_vue_type_script_setup_true_lang_default;
|
|
2060
|
+
|
|
2061
|
+
//#endregion
|
|
2062
|
+
//#region src/components/TresCanvas.vue?vue&type=script&setup=true&lang.ts
|
|
2063
|
+
const _hoisted_1 = ["data-scene", "data-tres"];
|
|
2064
|
+
var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
2065
|
+
__name: "TresCanvas",
|
|
2066
|
+
props: {
|
|
2067
|
+
camera: {
|
|
2068
|
+
type: null,
|
|
2069
|
+
required: false
|
|
2070
|
+
},
|
|
2071
|
+
windowSize: {
|
|
2072
|
+
type: Boolean,
|
|
2073
|
+
required: false,
|
|
2074
|
+
default: void 0
|
|
2075
|
+
},
|
|
2076
|
+
enableProvideBridge: {
|
|
2077
|
+
type: Boolean,
|
|
2078
|
+
required: false,
|
|
2079
|
+
default: true
|
|
2080
|
+
},
|
|
2081
|
+
antialias: {
|
|
2082
|
+
type: Boolean,
|
|
2083
|
+
required: false,
|
|
2084
|
+
default: true
|
|
2085
|
+
},
|
|
2086
|
+
stencil: {
|
|
2087
|
+
type: Boolean,
|
|
2088
|
+
required: false,
|
|
2089
|
+
default: void 0
|
|
2090
|
+
},
|
|
2091
|
+
depth: {
|
|
2092
|
+
type: Boolean,
|
|
2093
|
+
required: false,
|
|
2094
|
+
default: void 0
|
|
2095
|
+
},
|
|
2096
|
+
precision: {
|
|
2097
|
+
type: String,
|
|
2098
|
+
required: false
|
|
2099
|
+
},
|
|
2100
|
+
logarithmicDepthBuffer: {
|
|
2101
|
+
type: Boolean,
|
|
2102
|
+
required: false,
|
|
2103
|
+
default: void 0
|
|
2104
|
+
},
|
|
2105
|
+
preserveDrawingBuffer: {
|
|
2106
|
+
type: Boolean,
|
|
2107
|
+
required: false,
|
|
2108
|
+
default: void 0
|
|
2109
|
+
},
|
|
2110
|
+
powerPreference: {
|
|
2111
|
+
type: null,
|
|
2112
|
+
required: false
|
|
2113
|
+
},
|
|
2114
|
+
alpha: {
|
|
2115
|
+
type: Boolean,
|
|
2116
|
+
required: false,
|
|
2117
|
+
default: void 0
|
|
2118
|
+
},
|
|
2119
|
+
premultipliedAlpha: {
|
|
2120
|
+
type: Boolean,
|
|
2121
|
+
required: false
|
|
2122
|
+
},
|
|
2123
|
+
failIfMajorPerformanceCaveat: {
|
|
2124
|
+
type: Boolean,
|
|
2125
|
+
required: false,
|
|
2126
|
+
default: void 0
|
|
2127
|
+
},
|
|
2128
|
+
clearColor: {
|
|
2129
|
+
type: [
|
|
2130
|
+
Object,
|
|
2131
|
+
String,
|
|
2132
|
+
Number
|
|
2133
|
+
],
|
|
2134
|
+
required: false,
|
|
2135
|
+
default: "#000000"
|
|
2136
|
+
},
|
|
2137
|
+
clearAlpha: {
|
|
2138
|
+
type: Number,
|
|
2139
|
+
required: false,
|
|
2140
|
+
default: 1
|
|
2141
|
+
},
|
|
2142
|
+
shadows: {
|
|
2143
|
+
type: Boolean,
|
|
2144
|
+
required: false,
|
|
2145
|
+
default: void 0
|
|
2146
|
+
},
|
|
2147
|
+
toneMapping: {
|
|
2148
|
+
type: null,
|
|
2149
|
+
required: false,
|
|
2150
|
+
default: ACESFilmicToneMapping
|
|
2151
|
+
},
|
|
2152
|
+
shadowMapType: {
|
|
2153
|
+
type: null,
|
|
2154
|
+
required: false,
|
|
2155
|
+
default: PCFSoftShadowMap
|
|
2156
|
+
},
|
|
2157
|
+
useLegacyLights: {
|
|
2158
|
+
type: Boolean,
|
|
2159
|
+
required: false,
|
|
2160
|
+
default: void 0
|
|
2161
|
+
},
|
|
2162
|
+
outputColorSpace: {
|
|
2163
|
+
type: null,
|
|
2164
|
+
required: false
|
|
2165
|
+
},
|
|
2166
|
+
toneMappingExposure: {
|
|
2167
|
+
type: Number,
|
|
2168
|
+
required: false
|
|
2169
|
+
},
|
|
2170
|
+
renderMode: {
|
|
2171
|
+
type: String,
|
|
2172
|
+
required: false,
|
|
2173
|
+
default: "always"
|
|
2174
|
+
},
|
|
2175
|
+
dpr: {
|
|
2176
|
+
type: [Number, Array],
|
|
2177
|
+
required: false
|
|
2178
|
+
},
|
|
2179
|
+
renderer: {
|
|
2180
|
+
type: Function,
|
|
2181
|
+
required: false
|
|
2182
|
+
}
|
|
2183
|
+
},
|
|
2184
|
+
emits: [
|
|
2185
|
+
"ready",
|
|
2186
|
+
"pointermissed",
|
|
2187
|
+
"render",
|
|
2188
|
+
"beforeLoop",
|
|
2189
|
+
"loop",
|
|
2190
|
+
"click",
|
|
2191
|
+
"contextmenu",
|
|
2192
|
+
"pointermove",
|
|
2193
|
+
"pointerenter",
|
|
2194
|
+
"pointerleave",
|
|
2195
|
+
"pointerover",
|
|
2196
|
+
"pointerout",
|
|
2197
|
+
"dblclick",
|
|
2198
|
+
"pointerdown",
|
|
2199
|
+
"pointerup",
|
|
2200
|
+
"pointercancel",
|
|
2201
|
+
"lostpointercapture",
|
|
2202
|
+
"wheel"
|
|
2203
|
+
],
|
|
2204
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2205
|
+
const props = __props;
|
|
2206
|
+
const emit = __emit;
|
|
2207
|
+
const canvasRef = ref();
|
|
2208
|
+
const contextRef = shallowRef();
|
|
2209
|
+
__expose({
|
|
2210
|
+
get context() {
|
|
2211
|
+
return contextRef.value?.context;
|
|
2212
|
+
},
|
|
2213
|
+
dispose: () => contextRef.value?.dispose()
|
|
2214
|
+
});
|
|
2151
2215
|
return (_ctx, _cache) => {
|
|
2152
2216
|
return openBlock(), createElementBlock("canvas", {
|
|
2153
2217
|
ref_key: "canvasRef",
|
|
2154
2218
|
ref: canvasRef,
|
|
2155
|
-
"data-scene": scene.value.uuid,
|
|
2219
|
+
"data-scene": contextRef.value?.context?.scene.value.uuid,
|
|
2156
2220
|
class: normalizeClass(_ctx.$attrs.class),
|
|
2157
|
-
"data-tres": `tresjs ${unref(
|
|
2221
|
+
"data-tres": `tresjs ${unref(version)}`,
|
|
2158
2222
|
style: normalizeStyle({
|
|
2159
2223
|
display: "block",
|
|
2160
2224
|
width: "100%",
|
|
@@ -2166,7 +2230,34 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2166
2230
|
touchAction: "none",
|
|
2167
2231
|
..._ctx.$attrs.style
|
|
2168
2232
|
})
|
|
2169
|
-
},
|
|
2233
|
+
}, [canvasRef.value ? (openBlock(), createBlock(Context_default, mergeProps({
|
|
2234
|
+
key: 0,
|
|
2235
|
+
ref_key: "contextRef",
|
|
2236
|
+
ref: contextRef,
|
|
2237
|
+
canvas: canvasRef.value
|
|
2238
|
+
}, props, {
|
|
2239
|
+
onReady: _cache[0] || (_cache[0] = ($event) => emit("ready", $event)),
|
|
2240
|
+
onPointermissed: _cache[1] || (_cache[1] = ($event) => emit("pointermissed", $event)),
|
|
2241
|
+
onRender: _cache[2] || (_cache[2] = ($event) => emit("render", $event)),
|
|
2242
|
+
onBeforeLoop: _cache[3] || (_cache[3] = ($event) => emit("beforeLoop", $event)),
|
|
2243
|
+
onLoop: _cache[4] || (_cache[4] = ($event) => emit("loop", $event)),
|
|
2244
|
+
onClick: _cache[5] || (_cache[5] = ($event) => emit("click", $event)),
|
|
2245
|
+
onContextmenu: _cache[6] || (_cache[6] = ($event) => emit("contextmenu", $event)),
|
|
2246
|
+
onPointermove: _cache[7] || (_cache[7] = ($event) => emit("pointermove", $event)),
|
|
2247
|
+
onPointerenter: _cache[8] || (_cache[8] = ($event) => emit("pointerenter", $event)),
|
|
2248
|
+
onPointerleave: _cache[9] || (_cache[9] = ($event) => emit("pointerleave", $event)),
|
|
2249
|
+
onPointerover: _cache[10] || (_cache[10] = ($event) => emit("pointerover", $event)),
|
|
2250
|
+
onPointerout: _cache[11] || (_cache[11] = ($event) => emit("pointerout", $event)),
|
|
2251
|
+
onDblclick: _cache[12] || (_cache[12] = ($event) => emit("dblclick", $event)),
|
|
2252
|
+
onPointerdown: _cache[13] || (_cache[13] = ($event) => emit("pointerdown", $event)),
|
|
2253
|
+
onPointerup: _cache[14] || (_cache[14] = ($event) => emit("pointerup", $event)),
|
|
2254
|
+
onPointercancel: _cache[15] || (_cache[15] = ($event) => emit("pointercancel", $event)),
|
|
2255
|
+
onLostpointercapture: _cache[16] || (_cache[16] = ($event) => emit("lostpointercapture", $event)),
|
|
2256
|
+
onWheel: _cache[17] || (_cache[17] = ($event) => emit("wheel", $event))
|
|
2257
|
+
}), {
|
|
2258
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
2259
|
+
_: 3
|
|
2260
|
+
}, 16, ["canvas"])) : createCommentVNode("v-if", true)], 14, _hoisted_1);
|
|
2170
2261
|
};
|
|
2171
2262
|
}
|
|
2172
2263
|
});
|
|
@@ -2243,7 +2334,7 @@ const vDistanceTo = {
|
|
|
2243
2334
|
};
|
|
2244
2335
|
|
|
2245
2336
|
//#endregion
|
|
2246
|
-
//#region ../../node_modules/.pnpm/three-stdlib@2.36.
|
|
2337
|
+
//#region ../../node_modules/.pnpm/three-stdlib@2.36.1_three@0.180.0/node_modules/three-stdlib/helpers/RectAreaLightHelper.js
|
|
2247
2338
|
var RectAreaLightHelper = class extends Line {
|
|
2248
2339
|
constructor(light, color) {
|
|
2249
2340
|
const positions = [
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.2.1",
|
|
5
5
|
"description": "Declarative ThreeJS using Vue Components",
|
|
6
6
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -48,8 +48,7 @@
|
|
|
48
48
|
"@pmndrs/pointer-events": "^6.6.17",
|
|
49
49
|
"@vue/devtools-api": "^7.7.2",
|
|
50
50
|
"@vueuse/core": "^13.9.0",
|
|
51
|
-
"radashi": "^12.6.2"
|
|
52
|
-
"typescript": "^5.8.3"
|
|
51
|
+
"radashi": "^12.6.2"
|
|
53
52
|
},
|
|
54
53
|
"devDependencies": {
|
|
55
54
|
"@types/three": "^0.180.0",
|
|
@@ -69,6 +68,7 @@
|
|
|
69
68
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
70
69
|
"three": "^0.180.0",
|
|
71
70
|
"tsdown": "0.16.1",
|
|
71
|
+
"typescript": "^5.8.3",
|
|
72
72
|
"vite": "^7.1.9",
|
|
73
73
|
"vite-plugin-banner": "^0.8.1",
|
|
74
74
|
"vite-plugin-dts": "4.5.4",
|