@tresjs/core 5.2.0 → 5.3.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.
- package/dist/template-compiler-options.d.mts +2 -2
- package/dist/template-compiler-options.mjs +2 -2
- package/dist/tres.d.ts +49 -31
- package/dist/tres.js +338 -101
- package/package.json +3 -3
- package/dist/chunk-DADVwcMf.js +0 -30
package/dist/tres.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v5.
|
|
4
|
-
* (c)
|
|
3
|
+
* version: v5.3.0
|
|
4
|
+
* (c) 2026
|
|
5
5
|
* description: Declarative ThreeJS using Vue Components
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
8
|
+
import * as vue8 from "vue";
|
|
9
9
|
import { App, ComputedRef, DefineComponent, MaybeRef, MaybeRefOrGetter, Reactive, Ref, ShallowRef, VNode, VNodeRef } from "vue";
|
|
10
10
|
import * as THREE from "three";
|
|
11
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";
|
|
@@ -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
|
|
@@ -311,7 +312,7 @@ declare function useRendererManager({
|
|
|
311
312
|
onReady: _vueuse_core0.EventHookOn<TresRenderer>;
|
|
312
313
|
onRender: _vueuse_core0.EventHookOn<TresRenderer>;
|
|
313
314
|
invalidate: (amountOfFramesToInvalidate?: number) => void;
|
|
314
|
-
canBeInvalidated:
|
|
315
|
+
canBeInvalidated: vue8.ComputedRef<boolean>;
|
|
315
316
|
mode: "always" | "on-demand" | "manual" | undefined;
|
|
316
317
|
replaceRenderFunction: (fn: RenderFunction) => void;
|
|
317
318
|
};
|
|
@@ -362,10 +363,10 @@ type AttachFnType = (parent: any, self: TresInstance) => () => void;
|
|
|
362
363
|
type AttachType = string | AttachFnType;
|
|
363
364
|
type DisposeType = ((self: TresInstance) => void) | boolean | 'default';
|
|
364
365
|
type ConstructorRepresentation = new (...args: any[]) => any;
|
|
365
|
-
type NonFunctionKeys<P
|
|
366
|
-
type Overwrite<P
|
|
366
|
+
type NonFunctionKeys<P> = { [K in keyof P]-?: P[K] extends ((...args: any[]) => any) ? never : K }[keyof P];
|
|
367
|
+
type Overwrite<P, O> = Omit<P, NonFunctionKeys<O>> & O;
|
|
367
368
|
type Properties<T> = Pick<T, NonFunctionKeys<T>>;
|
|
368
|
-
type Mutable<P
|
|
369
|
+
type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> };
|
|
369
370
|
type Args<T> = T extends ConstructorRepresentation ? ConstructorParameters<T> : any[];
|
|
370
371
|
interface TresCatalogue {
|
|
371
372
|
[name: string]: ConstructorRepresentation;
|
|
@@ -377,8 +378,8 @@ type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
|
377
378
|
* @template T - The type of the object.
|
|
378
379
|
* @template P - The type of the arguments.
|
|
379
380
|
*/
|
|
380
|
-
interface InstanceProps<T = any, P
|
|
381
|
-
args?: Args<P
|
|
381
|
+
interface InstanceProps<T = any, P = any> {
|
|
382
|
+
args?: Args<P>;
|
|
382
383
|
object?: T;
|
|
383
384
|
visible?: boolean;
|
|
384
385
|
dispose?: null;
|
|
@@ -455,17 +456,17 @@ type TresContextWithClock = TresContext & {
|
|
|
455
456
|
delta: number;
|
|
456
457
|
elapsed: number;
|
|
457
458
|
};
|
|
458
|
-
type WithMathProps<P
|
|
459
|
+
type WithMathProps<P> = { [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K] };
|
|
459
460
|
interface RaycastableRepresentation {
|
|
460
461
|
raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
461
462
|
}
|
|
462
|
-
type EventProps<P
|
|
463
|
+
type EventProps<P> = P extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
|
|
463
464
|
interface VueProps {
|
|
464
465
|
children?: VNode[];
|
|
465
466
|
ref?: VNodeRef;
|
|
466
467
|
key?: string | number | symbol;
|
|
467
468
|
}
|
|
468
|
-
type ElementProps<T extends ConstructorRepresentation, P
|
|
469
|
+
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>>;
|
|
469
470
|
type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
|
|
470
471
|
type ThreeExports = typeof THREE;
|
|
471
472
|
type ThreeInstancesImpl = { [K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never };
|
|
@@ -498,7 +499,7 @@ declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
|
|
|
498
499
|
//#endregion
|
|
499
500
|
//#region src/composables/useLoader/component.vue.d.ts
|
|
500
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<{
|
|
501
|
-
props: __VLS_PrettifyLocal<{
|
|
502
|
+
props: vue8.PublicProps & __VLS_PrettifyLocal<{
|
|
502
503
|
/**
|
|
503
504
|
* The THREE.js loader to use
|
|
504
505
|
*/
|
|
@@ -514,27 +515,27 @@ declare const __VLS_export$1: <T extends TresObjectMap>(__VLS_props: NonNullable
|
|
|
514
515
|
} & {
|
|
515
516
|
onLoaded?: ((result: T) => any) | undefined;
|
|
516
517
|
onError?: ((error: unknown) => any) | undefined;
|
|
517
|
-
}> &
|
|
518
|
+
}> & (typeof globalThis extends {
|
|
518
519
|
__VLS_PROPS_FALLBACK: infer P;
|
|
519
520
|
} ? P : {});
|
|
520
521
|
expose: (exposed: {}) => void;
|
|
521
522
|
attrs: any;
|
|
522
523
|
slots: {
|
|
523
524
|
default?: (props: {
|
|
524
|
-
state:
|
|
525
|
+
state: vue8.UnwrapRef<T>;
|
|
525
526
|
isLoading: boolean;
|
|
526
527
|
error: unknown;
|
|
527
528
|
}) => any;
|
|
528
529
|
};
|
|
529
530
|
emit: ((evt: "loaded", result: T) => void) & ((evt: "error", error: unknown) => void);
|
|
530
|
-
}>) =>
|
|
531
|
+
}>) => vue8.VNode & {
|
|
531
532
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
532
533
|
};
|
|
533
534
|
declare const _default$1: typeof __VLS_export$1;
|
|
534
535
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
535
536
|
//#endregion
|
|
536
537
|
//#region src/composables/useGraph/index.d.ts
|
|
537
|
-
declare const useGraph: (object: MaybeRef$1<TresObject | undefined>) =>
|
|
538
|
+
declare const useGraph: (object: MaybeRef$1<TresObject | undefined>) => vue8.ComputedRef<TresObjectMap | undefined>;
|
|
538
539
|
//#endregion
|
|
539
540
|
//#region src/utils/createPriorityEventHook.d.ts
|
|
540
541
|
type Callback<T> = Parameters<EventHookOff<T>>[0];
|
|
@@ -585,12 +586,17 @@ type LoopContext = RafLoopContext & TresPartialContext;
|
|
|
585
586
|
declare const useLoop: () => {
|
|
586
587
|
stop: () => void;
|
|
587
588
|
start: () => void;
|
|
588
|
-
isActive: Readonly<
|
|
589
|
+
isActive: Readonly<vue8.ShallowRef<boolean>>;
|
|
589
590
|
onBeforeRender: PriorityEventHookOn<LoopContext>;
|
|
590
591
|
onRender: PriorityEventHookOn<LoopContext>;
|
|
591
592
|
render: (fn: RenderFunction) => void;
|
|
592
593
|
};
|
|
593
594
|
//#endregion
|
|
595
|
+
//#region src/core/nodeOps.d.ts
|
|
596
|
+
interface TresCustomRendererOptions {
|
|
597
|
+
primitivePrefix?: string;
|
|
598
|
+
}
|
|
599
|
+
//#endregion
|
|
594
600
|
//#region src/utils/logger.d.ts
|
|
595
601
|
/**
|
|
596
602
|
* Logger utility for TresJS
|
|
@@ -643,8 +649,8 @@ declare const templateCompilerOptions: {
|
|
|
643
649
|
};
|
|
644
650
|
};
|
|
645
651
|
//#endregion
|
|
646
|
-
//#region src/components/
|
|
647
|
-
interface
|
|
652
|
+
//#region src/components/Context.vue.d.ts
|
|
653
|
+
interface ContextProps extends RendererOptions {
|
|
648
654
|
/**
|
|
649
655
|
* Custom camera instance to use as main camera
|
|
650
656
|
* If not provided, a default PerspectiveCamera will be created
|
|
@@ -662,19 +668,31 @@ interface TresCanvasProps extends RendererOptions {
|
|
|
662
668
|
* @default true
|
|
663
669
|
*/
|
|
664
670
|
enableProvideBridge?: boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Options for the TresJS custom renderer
|
|
673
|
+
*
|
|
674
|
+
*/
|
|
675
|
+
customRendererOptions?: TresCustomRendererOptions;
|
|
665
676
|
}
|
|
666
|
-
type
|
|
677
|
+
type ContextEmits = {
|
|
667
678
|
ready: [context: TresContext];
|
|
668
679
|
pointermissed: [event: TresPointerEvent];
|
|
669
680
|
render: [context: TresContext];
|
|
670
681
|
beforeLoop: [context: TresContextWithClock];
|
|
671
682
|
loop: [context: TresContextWithClock];
|
|
672
683
|
} & { [key in TresPointerEventName]: [event: TresPointerEvent] };
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/components/TresCanvas.vue.d.ts
|
|
686
|
+
type TresCanvasEmits = ContextEmits;
|
|
687
|
+
type TresCanvasProps = ContextProps;
|
|
688
|
+
interface TresCanvasInstance {
|
|
689
|
+
get context(): TresContext | undefined;
|
|
676
690
|
dispose: () => void;
|
|
677
|
-
}
|
|
691
|
+
}
|
|
692
|
+
type __VLS_Slots = {
|
|
693
|
+
default: () => any;
|
|
694
|
+
};
|
|
695
|
+
declare const __VLS_base: vue8.DefineComponent<ContextProps, TresCanvasInstance, {}, {}, {}, vue8.ComponentOptionsMixin, vue8.ComponentOptionsMixin, {
|
|
678
696
|
click: (event: TresPointerEvent) => any;
|
|
679
697
|
contextmenu: (event: TresPointerEvent) => any;
|
|
680
698
|
pointermove: (event: TresPointerEvent) => any;
|
|
@@ -693,7 +711,7 @@ declare const __VLS_export: __VLS_WithSlots<vue10.DefineComponent<TresCanvasProp
|
|
|
693
711
|
render: (context: TresContext) => any;
|
|
694
712
|
beforeLoop: (context: TresContextWithClock) => any;
|
|
695
713
|
loop: (context: TresContextWithClock) => any;
|
|
696
|
-
}, string,
|
|
714
|
+
}, string, vue8.PublicProps, Readonly<ContextProps> & Readonly<{
|
|
697
715
|
onClick?: ((event: TresPointerEvent) => any) | undefined;
|
|
698
716
|
onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
|
|
699
717
|
onPointermove?: ((event: TresPointerEvent) => any) | undefined;
|
|
@@ -729,9 +747,9 @@ declare const __VLS_export: __VLS_WithSlots<vue10.DefineComponent<TresCanvasProp
|
|
|
729
747
|
shadowMapType: THREE.ShadowMapType;
|
|
730
748
|
useLegacyLights: boolean;
|
|
731
749
|
renderMode: "always" | "on-demand" | "manual";
|
|
732
|
-
}, {}, {}, {}, string,
|
|
733
|
-
|
|
734
|
-
|
|
750
|
+
}, {}, {}, {}, string, vue8.ComponentProvideOptions, false, {}, any>;
|
|
751
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
752
|
+
declare const _default: typeof __VLS_export;
|
|
735
753
|
type __VLS_WithSlots<T, S> = T & {
|
|
736
754
|
new (): {
|
|
737
755
|
$slots: S;
|
|
@@ -1063,4 +1081,4 @@ interface TresPlugin {
|
|
|
1063
1081
|
}
|
|
1064
1082
|
declare const plugin: TresPlugin;
|
|
1065
1083
|
//#endregion
|
|
1066
|
-
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 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 };
|
|
1084
|
+
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, TresComponents, type TresContext, TresContextWithClock, TresControl, type TresCustomRendererOptions, 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.
|
|
4
|
-
* (c)
|
|
3
|
+
* version: v5.3.0
|
|
4
|
+
* (c) 2026
|
|
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, camelize, computed, createBlock, createCommentVNode, createElementBlock, createRenderer, defineComponent, getCurrentInstance, h, isRef, mergeProps, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, provide, reactive, readonly, ref, renderSlot, shallowRef, toHandlerKey, toRef, 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,7 +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 version = "5.
|
|
17
|
+
var version = "5.3.0";
|
|
18
18
|
|
|
19
19
|
//#endregion
|
|
20
20
|
//#region src/utils/makeMap.ts
|
|
@@ -826,9 +826,8 @@ function useRendererManager({ scene, canvas, options, contextParts: { sizes, cam
|
|
|
826
826
|
}
|
|
827
827
|
invalidateOnDemand();
|
|
828
828
|
}, { immediate: true });
|
|
829
|
-
const { pixelRatio } = useDevicePixelRatio();
|
|
830
829
|
watchEffect(() => {
|
|
831
|
-
setPixelRatio(renderer, pixelRatio.value, toValue(options.dpr));
|
|
830
|
+
setPixelRatio(renderer, sizes.pixelRatio.value, toValue(options.dpr));
|
|
832
831
|
});
|
|
833
832
|
if (toValue(options.renderMode) === "on-demand") invalidate();
|
|
834
833
|
if (toValue(options.renderMode) === "manual") useTimeout(100, { callback: advance });
|
|
@@ -895,12 +894,14 @@ function useRendererManager({ scene, canvas, options, contextParts: { sizes, cam
|
|
|
895
894
|
//#endregion
|
|
896
895
|
//#region src/composables/useSizes/index.ts
|
|
897
896
|
function useSizes(windowSize, canvas, debounceMs = 10) {
|
|
897
|
+
const { pixelRatio } = useDevicePixelRatio();
|
|
898
898
|
const reactiveSize = toValue(windowSize) ? useWindowSize() : useElementSize(computed(() => toValue(canvas).parentElement));
|
|
899
899
|
const debouncedReactiveWidth = readonly(refDebounced(reactiveSize.width, debounceMs));
|
|
900
900
|
const debouncedReactiveHeight = readonly(refDebounced(reactiveSize.height, debounceMs));
|
|
901
901
|
return {
|
|
902
|
-
height: debouncedReactiveHeight,
|
|
903
902
|
width: debouncedReactiveWidth,
|
|
903
|
+
height: debouncedReactiveHeight,
|
|
904
|
+
pixelRatio,
|
|
904
905
|
aspectRatio: computed(() => debouncedReactiveWidth.value / debouncedReactiveHeight.value)
|
|
905
906
|
};
|
|
906
907
|
}
|
|
@@ -1071,7 +1072,7 @@ const isSupportedPointerEvent = (event) => supportedPointerEvents.includes(event
|
|
|
1071
1072
|
|
|
1072
1073
|
//#endregion
|
|
1073
1074
|
//#region src/core/nodeOps.ts
|
|
1074
|
-
const nodeOps = (context) => {
|
|
1075
|
+
const nodeOps = ({ context, options = { primitivePrefix: "" } }) => {
|
|
1075
1076
|
const scene = context.scene.value;
|
|
1076
1077
|
function createElement(tag, _isSVG, _anchor, props) {
|
|
1077
1078
|
if (!props) props = {};
|
|
@@ -1080,7 +1081,7 @@ const nodeOps = (context) => {
|
|
|
1080
1081
|
if (tag.includes("-")) tag = tag.replace(/-([a-z])/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
|
|
1081
1082
|
let name = tag.replace("Tres", "");
|
|
1082
1083
|
let obj;
|
|
1083
|
-
if (tag === "primitive
|
|
1084
|
+
if (tag === `${options?.primitivePrefix ?? ""}primitive`) {
|
|
1084
1085
|
if (!isObject(props.object) || isRef(props.object)) logError("Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>");
|
|
1085
1086
|
name = props.object.type;
|
|
1086
1087
|
const __tres = {};
|
|
@@ -1808,10 +1809,9 @@ function registerTresDevtools(app, tres) {
|
|
|
1808
1809
|
}
|
|
1809
1810
|
|
|
1810
1811
|
//#endregion
|
|
1811
|
-
//#region src/components/
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
__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",
|
|
1815
1815
|
props: {
|
|
1816
1816
|
camera: {
|
|
1817
1817
|
type: null,
|
|
@@ -1819,28 +1819,27 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1819
1819
|
},
|
|
1820
1820
|
windowSize: {
|
|
1821
1821
|
type: Boolean,
|
|
1822
|
-
required: false
|
|
1823
|
-
default: void 0
|
|
1822
|
+
required: false
|
|
1824
1823
|
},
|
|
1825
1824
|
enableProvideBridge: {
|
|
1826
1825
|
type: Boolean,
|
|
1827
|
-
required: false
|
|
1828
|
-
|
|
1826
|
+
required: false
|
|
1827
|
+
},
|
|
1828
|
+
customRendererOptions: {
|
|
1829
|
+
type: Object,
|
|
1830
|
+
required: false
|
|
1829
1831
|
},
|
|
1830
1832
|
antialias: {
|
|
1831
1833
|
type: Boolean,
|
|
1832
|
-
required: false
|
|
1833
|
-
default: true
|
|
1834
|
+
required: false
|
|
1834
1835
|
},
|
|
1835
1836
|
stencil: {
|
|
1836
1837
|
type: Boolean,
|
|
1837
|
-
required: false
|
|
1838
|
-
default: void 0
|
|
1838
|
+
required: false
|
|
1839
1839
|
},
|
|
1840
1840
|
depth: {
|
|
1841
1841
|
type: Boolean,
|
|
1842
|
-
required: false
|
|
1843
|
-
default: void 0
|
|
1842
|
+
required: false
|
|
1844
1843
|
},
|
|
1845
1844
|
precision: {
|
|
1846
1845
|
type: String,
|
|
@@ -1848,13 +1847,11 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1848
1847
|
},
|
|
1849
1848
|
logarithmicDepthBuffer: {
|
|
1850
1849
|
type: Boolean,
|
|
1851
|
-
required: false
|
|
1852
|
-
default: void 0
|
|
1850
|
+
required: false
|
|
1853
1851
|
},
|
|
1854
1852
|
preserveDrawingBuffer: {
|
|
1855
1853
|
type: Boolean,
|
|
1856
|
-
required: false
|
|
1857
|
-
default: void 0
|
|
1854
|
+
required: false
|
|
1858
1855
|
},
|
|
1859
1856
|
powerPreference: {
|
|
1860
1857
|
type: null,
|
|
@@ -1862,8 +1859,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1862
1859
|
},
|
|
1863
1860
|
alpha: {
|
|
1864
1861
|
type: Boolean,
|
|
1865
|
-
required: false
|
|
1866
|
-
default: void 0
|
|
1862
|
+
required: false
|
|
1867
1863
|
},
|
|
1868
1864
|
premultipliedAlpha: {
|
|
1869
1865
|
type: Boolean,
|
|
@@ -1871,8 +1867,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1871
1867
|
},
|
|
1872
1868
|
failIfMajorPerformanceCaveat: {
|
|
1873
1869
|
type: Boolean,
|
|
1874
|
-
required: false
|
|
1875
|
-
default: void 0
|
|
1870
|
+
required: false
|
|
1876
1871
|
},
|
|
1877
1872
|
clearColor: {
|
|
1878
1873
|
type: [
|
|
@@ -1880,33 +1875,27 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1880
1875
|
String,
|
|
1881
1876
|
Number
|
|
1882
1877
|
],
|
|
1883
|
-
required: false
|
|
1884
|
-
default: "#000000"
|
|
1878
|
+
required: false
|
|
1885
1879
|
},
|
|
1886
1880
|
clearAlpha: {
|
|
1887
1881
|
type: Number,
|
|
1888
|
-
required: false
|
|
1889
|
-
default: 1
|
|
1882
|
+
required: false
|
|
1890
1883
|
},
|
|
1891
1884
|
shadows: {
|
|
1892
1885
|
type: Boolean,
|
|
1893
|
-
required: false
|
|
1894
|
-
default: void 0
|
|
1886
|
+
required: false
|
|
1895
1887
|
},
|
|
1896
1888
|
toneMapping: {
|
|
1897
1889
|
type: null,
|
|
1898
|
-
required: false
|
|
1899
|
-
default: ACESFilmicToneMapping
|
|
1890
|
+
required: false
|
|
1900
1891
|
},
|
|
1901
1892
|
shadowMapType: {
|
|
1902
1893
|
type: null,
|
|
1903
|
-
required: false
|
|
1904
|
-
default: PCFSoftShadowMap
|
|
1894
|
+
required: false
|
|
1905
1895
|
},
|
|
1906
1896
|
useLegacyLights: {
|
|
1907
1897
|
type: Boolean,
|
|
1908
|
-
required: false
|
|
1909
|
-
default: void 0
|
|
1898
|
+
required: false
|
|
1910
1899
|
},
|
|
1911
1900
|
outputColorSpace: {
|
|
1912
1901
|
type: null,
|
|
@@ -1918,8 +1907,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1918
1907
|
},
|
|
1919
1908
|
renderMode: {
|
|
1920
1909
|
type: String,
|
|
1921
|
-
required: false
|
|
1922
|
-
default: "always"
|
|
1910
|
+
required: false
|
|
1923
1911
|
},
|
|
1924
1912
|
dpr: {
|
|
1925
1913
|
type: [Number, Array],
|
|
@@ -1928,6 +1916,10 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1928
1916
|
renderer: {
|
|
1929
1917
|
type: Function,
|
|
1930
1918
|
required: false
|
|
1919
|
+
},
|
|
1920
|
+
canvas: {
|
|
1921
|
+
type: null,
|
|
1922
|
+
required: true
|
|
1931
1923
|
}
|
|
1932
1924
|
},
|
|
1933
1925
|
emits: [
|
|
@@ -1954,7 +1946,6 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1954
1946
|
const props = __props;
|
|
1955
1947
|
const emit = __emit;
|
|
1956
1948
|
const slots = useSlots();
|
|
1957
|
-
const canvasRef = ref();
|
|
1958
1949
|
const scene = shallowRef(new Scene());
|
|
1959
1950
|
const instance = getCurrentInstance();
|
|
1960
1951
|
extend(THREE);
|
|
@@ -1980,7 +1971,10 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1980
1971
|
} });
|
|
1981
1972
|
const mountCustomRenderer = (context$1, empty = false) => {
|
|
1982
1973
|
const InternalComponent = createInternalComponent(context$1, empty);
|
|
1983
|
-
const { render } = createRenderer(nodeOps(
|
|
1974
|
+
const { render } = createRenderer(nodeOps({
|
|
1975
|
+
context: context$1,
|
|
1976
|
+
options: props.customRendererOptions
|
|
1977
|
+
}));
|
|
1984
1978
|
render(h(InternalComponent), scene.value);
|
|
1985
1979
|
};
|
|
1986
1980
|
const dispose = (context$1, force = false) => {
|
|
@@ -1994,7 +1988,12 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1994
1988
|
}
|
|
1995
1989
|
scene.value.__tres = { root: context$1 };
|
|
1996
1990
|
};
|
|
1997
|
-
const context = shallowRef(
|
|
1991
|
+
const context = shallowRef(useTresContextProvider({
|
|
1992
|
+
scene: scene.value,
|
|
1993
|
+
canvas: props.canvas,
|
|
1994
|
+
windowSize: props.windowSize ?? false,
|
|
1995
|
+
rendererOptions: props
|
|
1996
|
+
}));
|
|
1998
1997
|
__expose({
|
|
1999
1998
|
context,
|
|
2000
1999
|
dispose: () => dispose(context.value, true)
|
|
@@ -2007,71 +2006,301 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2007
2006
|
dispose(context.value);
|
|
2008
2007
|
mountCustomRenderer(context.value, true);
|
|
2009
2008
|
};
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
const
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
camera$1.position.set(3, 3, 3);
|
|
2024
|
-
camera$1.lookAt(0, 0, 0);
|
|
2025
|
-
registerCamera(camera$1);
|
|
2026
|
-
const unwatch = watchEffect(() => {
|
|
2027
|
-
if (cameras.value.length >= 2) {
|
|
2028
|
-
camera$1.removeFromParent();
|
|
2029
|
-
deregisterCamera(camera$1);
|
|
2030
|
-
unwatch?.();
|
|
2031
|
-
}
|
|
2032
|
-
});
|
|
2033
|
-
};
|
|
2034
|
-
context.value.events.onPointerMissed((event) => {
|
|
2035
|
-
emit("pointermissed", event);
|
|
2036
|
-
});
|
|
2037
|
-
watch(() => props.camera, (newCamera, oldCamera) => {
|
|
2038
|
-
if (newCamera) registerCamera(toValue(newCamera), true);
|
|
2039
|
-
if (oldCamera) {
|
|
2040
|
-
toValue(oldCamera).removeFromParent();
|
|
2041
|
-
deregisterCamera(toValue(oldCamera));
|
|
2009
|
+
const { camera, renderer } = context.value;
|
|
2010
|
+
const { registerCamera, cameras, activeCamera, deregisterCamera } = camera;
|
|
2011
|
+
mountCustomRenderer(context.value);
|
|
2012
|
+
const addDefaultCamera = () => {
|
|
2013
|
+
const camera$1 = new PerspectiveCamera(45, window.innerWidth / window.innerHeight, .1, 1e3);
|
|
2014
|
+
camera$1.position.set(3, 3, 3);
|
|
2015
|
+
camera$1.lookAt(0, 0, 0);
|
|
2016
|
+
registerCamera(camera$1);
|
|
2017
|
+
const unwatch = watchEffect(() => {
|
|
2018
|
+
if (cameras.value.length >= 2) {
|
|
2019
|
+
camera$1.removeFromParent();
|
|
2020
|
+
deregisterCamera(camera$1);
|
|
2021
|
+
unwatch?.();
|
|
2042
2022
|
}
|
|
2043
|
-
}, { immediate: true });
|
|
2044
|
-
if (!activeCamera.value) addDefaultCamera();
|
|
2045
|
-
renderer.onRender(() => {
|
|
2046
|
-
if (context.value) emit("render", context.value);
|
|
2047
|
-
});
|
|
2048
|
-
renderer.loop.onLoop((loopContext) => {
|
|
2049
|
-
if (context.value) emit("loop", {
|
|
2050
|
-
...context.value,
|
|
2051
|
-
...loopContext
|
|
2052
|
-
});
|
|
2053
2023
|
});
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2024
|
+
};
|
|
2025
|
+
context.value.events.onPointerMissed((event) => {
|
|
2026
|
+
emit("pointermissed", event);
|
|
2027
|
+
});
|
|
2028
|
+
watch(() => props.camera, (newCamera, oldCamera) => {
|
|
2029
|
+
if (newCamera) registerCamera(toValue(newCamera), true);
|
|
2030
|
+
if (oldCamera) {
|
|
2031
|
+
toValue(oldCamera).removeFromParent();
|
|
2032
|
+
deregisterCamera(toValue(oldCamera));
|
|
2033
|
+
}
|
|
2034
|
+
}, { immediate: true });
|
|
2035
|
+
if (!activeCamera.value) addDefaultCamera();
|
|
2036
|
+
renderer.onRender(() => {
|
|
2037
|
+
if (context.value) emit("render", context.value);
|
|
2038
|
+
});
|
|
2039
|
+
renderer.loop.onLoop((loopContext) => {
|
|
2040
|
+
if (context.value) emit("loop", {
|
|
2041
|
+
...context.value,
|
|
2042
|
+
...loopContext
|
|
2059
2043
|
});
|
|
2060
|
-
|
|
2061
|
-
|
|
2044
|
+
});
|
|
2045
|
+
renderer.loop.onBeforeLoop((loopContext) => {
|
|
2046
|
+
if (context.value) emit("beforeLoop", {
|
|
2047
|
+
...context.value,
|
|
2048
|
+
...loopContext
|
|
2062
2049
|
});
|
|
2063
|
-
if (import.meta.hot && context.value) import.meta.hot.on("vite:afterUpdate", () => handleHMR(context.value));
|
|
2064
2050
|
});
|
|
2051
|
+
renderer.onReady(() => {
|
|
2052
|
+
emit("ready", context.value);
|
|
2053
|
+
});
|
|
2054
|
+
if (import.meta.hot) import.meta.hot.on("vite:afterUpdate", () => handleHMR(context.value));
|
|
2065
2055
|
onMounted(async () => {
|
|
2066
2056
|
await promiseTimeout(3e3);
|
|
2067
|
-
if (
|
|
2057
|
+
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.`);
|
|
2068
2058
|
});
|
|
2069
2059
|
onUnmounted(unmountCanvas);
|
|
2060
|
+
return () => {};
|
|
2061
|
+
}
|
|
2062
|
+
});
|
|
2063
|
+
|
|
2064
|
+
//#endregion
|
|
2065
|
+
//#region src/components/Context.vue
|
|
2066
|
+
var Context_default = Context_vue_vue_type_script_setup_true_lang_default;
|
|
2067
|
+
|
|
2068
|
+
//#endregion
|
|
2069
|
+
//#region src/composables/useForwardProps/index.ts
|
|
2070
|
+
/**
|
|
2071
|
+
* The `useForwardProps` function in TypeScript takes in a set of props and returns a computed value
|
|
2072
|
+
* that combines default props with assigned props from the current instance.
|
|
2073
|
+
* @param {T} props - The `props` parameter is an object that represents the props passed to a
|
|
2074
|
+
* component.
|
|
2075
|
+
* @returns computed value that combines the default props, preserved props, and assigned props.
|
|
2076
|
+
*/
|
|
2077
|
+
const useForwardProps = (props) => {
|
|
2078
|
+
const vm = getCurrentInstance();
|
|
2079
|
+
const defaultProps = Object.keys(vm?.type.props ?? {}).reduce((prev, curr) => {
|
|
2080
|
+
const defaultValue = (vm?.type.props[curr]).default;
|
|
2081
|
+
if (defaultValue !== void 0) prev[curr] = defaultValue;
|
|
2082
|
+
return prev;
|
|
2083
|
+
}, {});
|
|
2084
|
+
const refProps = toRef(props);
|
|
2085
|
+
return computed(() => {
|
|
2086
|
+
const preservedProps = {};
|
|
2087
|
+
const assignedProps = vm?.vnode.props ?? {};
|
|
2088
|
+
Object.keys(assignedProps).forEach((key) => {
|
|
2089
|
+
preservedProps[camelize(key)] = assignedProps[key];
|
|
2090
|
+
});
|
|
2091
|
+
return Object.keys({
|
|
2092
|
+
...defaultProps,
|
|
2093
|
+
...preservedProps
|
|
2094
|
+
}).reduce((prev, curr) => {
|
|
2095
|
+
if (refProps.value[curr] !== void 0) prev[curr] = refProps.value[curr];
|
|
2096
|
+
return prev;
|
|
2097
|
+
}, {});
|
|
2098
|
+
});
|
|
2099
|
+
};
|
|
2100
|
+
/**
|
|
2101
|
+
* The `useEmitAsProps` function is a TypeScript utility that converts emitted events into props for a
|
|
2102
|
+
* Vue component.
|
|
2103
|
+
* @param emit - The `emit` parameter is a function that is used to emit events from a component. It
|
|
2104
|
+
* takes two parameters: `name` which is the name of the event to be emitted, and `...args` which are
|
|
2105
|
+
* the arguments to be passed along with the event.
|
|
2106
|
+
* @returns The function `useEmitAsProps` returns an object that maps event names to functions that
|
|
2107
|
+
* call the `emit` function with the corresponding event name and arguments.
|
|
2108
|
+
*/
|
|
2109
|
+
const useEmitAsProps = (emit) => {
|
|
2110
|
+
const vm = getCurrentInstance();
|
|
2111
|
+
const events = vm?.type.emits;
|
|
2112
|
+
const result = {};
|
|
2113
|
+
if (!events?.length) console.warn(`No emitted event found. Please check component: ${vm?.type.__name}`);
|
|
2114
|
+
events?.forEach((ev) => {
|
|
2115
|
+
result[toHandlerKey(camelize(ev))] = (...arg) => emit(ev, ...arg);
|
|
2116
|
+
});
|
|
2117
|
+
return result;
|
|
2118
|
+
};
|
|
2119
|
+
/**
|
|
2120
|
+
* The function `useForwardPropsEmits` takes in props and an optional emit function, and returns a
|
|
2121
|
+
* computed object that combines the parsed props and emits as props.
|
|
2122
|
+
* @param {T} props - The `props` parameter is of type `T`, which is a generic type that extends the
|
|
2123
|
+
* parameters of the `useForwardProps` function. It represents the props object that is passed to the
|
|
2124
|
+
* `useForwardProps` function.
|
|
2125
|
+
* @param [emit] - The `emit` parameter is a function that can be used to emit events. It takes two
|
|
2126
|
+
* arguments: `name`, which is the name of the event to be emitted, and `args`, which are the arguments
|
|
2127
|
+
* to be passed along with the event.
|
|
2128
|
+
* @returns a computed property that combines the parsed
|
|
2129
|
+
* props and emits as props.
|
|
2130
|
+
*/
|
|
2131
|
+
const useForwardPropsEmits = (props, emit) => {
|
|
2132
|
+
const parsedProps = useForwardProps(props);
|
|
2133
|
+
const emitsAsProps = emit ? useEmitAsProps(emit) : {};
|
|
2134
|
+
return computed(() => ({
|
|
2135
|
+
...parsedProps.value,
|
|
2136
|
+
...emitsAsProps
|
|
2137
|
+
}));
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
//#endregion
|
|
2141
|
+
//#region src/components/TresCanvas.vue?vue&type=script&setup=true&lang.ts
|
|
2142
|
+
const _hoisted_1 = ["data-scene", "data-tres"];
|
|
2143
|
+
var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
2144
|
+
__name: "TresCanvas",
|
|
2145
|
+
props: {
|
|
2146
|
+
camera: {
|
|
2147
|
+
type: null,
|
|
2148
|
+
required: false
|
|
2149
|
+
},
|
|
2150
|
+
windowSize: {
|
|
2151
|
+
type: Boolean,
|
|
2152
|
+
required: false,
|
|
2153
|
+
default: void 0
|
|
2154
|
+
},
|
|
2155
|
+
enableProvideBridge: {
|
|
2156
|
+
type: Boolean,
|
|
2157
|
+
required: false,
|
|
2158
|
+
default: true
|
|
2159
|
+
},
|
|
2160
|
+
customRendererOptions: {
|
|
2161
|
+
type: Object,
|
|
2162
|
+
required: false
|
|
2163
|
+
},
|
|
2164
|
+
antialias: {
|
|
2165
|
+
type: Boolean,
|
|
2166
|
+
required: false,
|
|
2167
|
+
default: true
|
|
2168
|
+
},
|
|
2169
|
+
stencil: {
|
|
2170
|
+
type: Boolean,
|
|
2171
|
+
required: false,
|
|
2172
|
+
default: void 0
|
|
2173
|
+
},
|
|
2174
|
+
depth: {
|
|
2175
|
+
type: Boolean,
|
|
2176
|
+
required: false,
|
|
2177
|
+
default: void 0
|
|
2178
|
+
},
|
|
2179
|
+
precision: {
|
|
2180
|
+
type: String,
|
|
2181
|
+
required: false
|
|
2182
|
+
},
|
|
2183
|
+
logarithmicDepthBuffer: {
|
|
2184
|
+
type: Boolean,
|
|
2185
|
+
required: false,
|
|
2186
|
+
default: void 0
|
|
2187
|
+
},
|
|
2188
|
+
preserveDrawingBuffer: {
|
|
2189
|
+
type: Boolean,
|
|
2190
|
+
required: false,
|
|
2191
|
+
default: void 0
|
|
2192
|
+
},
|
|
2193
|
+
powerPreference: {
|
|
2194
|
+
type: null,
|
|
2195
|
+
required: false
|
|
2196
|
+
},
|
|
2197
|
+
alpha: {
|
|
2198
|
+
type: Boolean,
|
|
2199
|
+
required: false,
|
|
2200
|
+
default: void 0
|
|
2201
|
+
},
|
|
2202
|
+
premultipliedAlpha: {
|
|
2203
|
+
type: Boolean,
|
|
2204
|
+
required: false
|
|
2205
|
+
},
|
|
2206
|
+
failIfMajorPerformanceCaveat: {
|
|
2207
|
+
type: Boolean,
|
|
2208
|
+
required: false,
|
|
2209
|
+
default: void 0
|
|
2210
|
+
},
|
|
2211
|
+
clearColor: {
|
|
2212
|
+
type: [
|
|
2213
|
+
Object,
|
|
2214
|
+
String,
|
|
2215
|
+
Number
|
|
2216
|
+
],
|
|
2217
|
+
required: false,
|
|
2218
|
+
default: "#000000"
|
|
2219
|
+
},
|
|
2220
|
+
clearAlpha: {
|
|
2221
|
+
type: Number,
|
|
2222
|
+
required: false,
|
|
2223
|
+
default: 1
|
|
2224
|
+
},
|
|
2225
|
+
shadows: {
|
|
2226
|
+
type: Boolean,
|
|
2227
|
+
required: false,
|
|
2228
|
+
default: void 0
|
|
2229
|
+
},
|
|
2230
|
+
toneMapping: {
|
|
2231
|
+
type: null,
|
|
2232
|
+
required: false,
|
|
2233
|
+
default: ACESFilmicToneMapping
|
|
2234
|
+
},
|
|
2235
|
+
shadowMapType: {
|
|
2236
|
+
type: null,
|
|
2237
|
+
required: false,
|
|
2238
|
+
default: PCFSoftShadowMap
|
|
2239
|
+
},
|
|
2240
|
+
useLegacyLights: {
|
|
2241
|
+
type: Boolean,
|
|
2242
|
+
required: false,
|
|
2243
|
+
default: void 0
|
|
2244
|
+
},
|
|
2245
|
+
outputColorSpace: {
|
|
2246
|
+
type: null,
|
|
2247
|
+
required: false
|
|
2248
|
+
},
|
|
2249
|
+
toneMappingExposure: {
|
|
2250
|
+
type: Number,
|
|
2251
|
+
required: false
|
|
2252
|
+
},
|
|
2253
|
+
renderMode: {
|
|
2254
|
+
type: String,
|
|
2255
|
+
required: false,
|
|
2256
|
+
default: "always"
|
|
2257
|
+
},
|
|
2258
|
+
dpr: {
|
|
2259
|
+
type: [Number, Array],
|
|
2260
|
+
required: false
|
|
2261
|
+
},
|
|
2262
|
+
renderer: {
|
|
2263
|
+
type: Function,
|
|
2264
|
+
required: false
|
|
2265
|
+
}
|
|
2266
|
+
},
|
|
2267
|
+
emits: [
|
|
2268
|
+
"ready",
|
|
2269
|
+
"pointermissed",
|
|
2270
|
+
"render",
|
|
2271
|
+
"beforeLoop",
|
|
2272
|
+
"loop",
|
|
2273
|
+
"click",
|
|
2274
|
+
"contextmenu",
|
|
2275
|
+
"pointermove",
|
|
2276
|
+
"pointerenter",
|
|
2277
|
+
"pointerleave",
|
|
2278
|
+
"pointerover",
|
|
2279
|
+
"pointerout",
|
|
2280
|
+
"dblclick",
|
|
2281
|
+
"pointerdown",
|
|
2282
|
+
"pointerup",
|
|
2283
|
+
"pointercancel",
|
|
2284
|
+
"lostpointercapture",
|
|
2285
|
+
"wheel"
|
|
2286
|
+
],
|
|
2287
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2288
|
+
const props = __props;
|
|
2289
|
+
const emit = __emit;
|
|
2290
|
+
const canvasRef = ref();
|
|
2291
|
+
const contextRef = shallowRef();
|
|
2292
|
+
__expose({
|
|
2293
|
+
get context() {
|
|
2294
|
+
return contextRef.value?.context;
|
|
2295
|
+
},
|
|
2296
|
+
dispose: () => contextRef.value?.dispose()
|
|
2297
|
+
});
|
|
2298
|
+
const forwardedPropsEmits = useForwardPropsEmits(props, emit);
|
|
2070
2299
|
return (_ctx, _cache) => {
|
|
2071
2300
|
return openBlock(), createElementBlock("canvas", {
|
|
2072
2301
|
ref_key: "canvasRef",
|
|
2073
2302
|
ref: canvasRef,
|
|
2074
|
-
"data-scene": scene.value.uuid,
|
|
2303
|
+
"data-scene": contextRef.value?.context?.scene.value.uuid,
|
|
2075
2304
|
class: normalizeClass(_ctx.$attrs.class),
|
|
2076
2305
|
"data-tres": `tresjs ${unref(version)}`,
|
|
2077
2306
|
style: normalizeStyle({
|
|
@@ -2085,7 +2314,15 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2085
2314
|
touchAction: "none",
|
|
2086
2315
|
..._ctx.$attrs.style
|
|
2087
2316
|
})
|
|
2088
|
-
},
|
|
2317
|
+
}, [canvasRef.value ? (openBlock(), createBlock(Context_default, mergeProps({
|
|
2318
|
+
key: 0,
|
|
2319
|
+
ref_key: "contextRef",
|
|
2320
|
+
ref: contextRef,
|
|
2321
|
+
canvas: canvasRef.value
|
|
2322
|
+
}, unref(forwardedPropsEmits)), {
|
|
2323
|
+
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
2324
|
+
_: 3
|
|
2325
|
+
}, 16, ["canvas"])) : createCommentVNode("v-if", true)], 14, _hoisted_1);
|
|
2089
2326
|
};
|
|
2090
2327
|
}
|
|
2091
2328
|
});
|
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.3.0",
|
|
5
5
|
"description": "Declarative ThreeJS using Vue Components",
|
|
6
6
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"rollup-plugin-copy": "^3.5.0",
|
|
68
68
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
69
69
|
"three": "^0.180.0",
|
|
70
|
-
"tsdown": "0.
|
|
70
|
+
"tsdown": "0.18.3",
|
|
71
71
|
"typescript": "^5.8.3",
|
|
72
72
|
"vite": "^7.1.9",
|
|
73
73
|
"vite-plugin-banner": "^0.8.1",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"vitest": "3.2.4",
|
|
77
77
|
"vue": "^3.5.22",
|
|
78
78
|
"vue-demi": "^0.14.10",
|
|
79
|
-
"vue-tsc": "^3.
|
|
79
|
+
"vue-tsc": "^3.2.1",
|
|
80
80
|
"@tresjs/eslint-config": "1.5.1"
|
|
81
81
|
},
|
|
82
82
|
"nx": {
|
package/dist/chunk-DADVwcMf.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* name: @tresjs/core
|
|
3
|
-
* version: v5.2.0
|
|
4
|
-
* (c) 2025
|
|
5
|
-
* description: Declarative ThreeJS using Vue Components
|
|
6
|
-
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
|
-
*/
|
|
8
|
-
//#region rolldown:runtime
|
|
9
|
-
var __create = Object.create;
|
|
10
|
-
var __defProp = Object.defineProperty;
|
|
11
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
12
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
13
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
14
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
-
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
17
|
-
key = keys[i];
|
|
18
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
-
get: ((k) => from[k]).bind(null, key),
|
|
20
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
-
value: mod,
|
|
27
|
-
enumerable: true
|
|
28
|
-
}) : target, mod));
|
|
29
|
-
|
|
30
|
-
//#endregion
|