@tresjs/core 5.2.1 → 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 +40 -26
- package/dist/tres.js +92 -27
- package/package.json +3 -3
- package/dist/chunk-BRx1-uMz.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";
|
|
@@ -312,7 +312,7 @@ declare function useRendererManager({
|
|
|
312
312
|
onReady: _vueuse_core0.EventHookOn<TresRenderer>;
|
|
313
313
|
onRender: _vueuse_core0.EventHookOn<TresRenderer>;
|
|
314
314
|
invalidate: (amountOfFramesToInvalidate?: number) => void;
|
|
315
|
-
canBeInvalidated:
|
|
315
|
+
canBeInvalidated: vue8.ComputedRef<boolean>;
|
|
316
316
|
mode: "always" | "on-demand" | "manual" | undefined;
|
|
317
317
|
replaceRenderFunction: (fn: RenderFunction) => void;
|
|
318
318
|
};
|
|
@@ -363,10 +363,10 @@ type AttachFnType = (parent: any, self: TresInstance) => () => void;
|
|
|
363
363
|
type AttachType = string | AttachFnType;
|
|
364
364
|
type DisposeType = ((self: TresInstance) => void) | boolean | 'default';
|
|
365
365
|
type ConstructorRepresentation = new (...args: any[]) => any;
|
|
366
|
-
type NonFunctionKeys<P
|
|
367
|
-
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;
|
|
368
368
|
type Properties<T> = Pick<T, NonFunctionKeys<T>>;
|
|
369
|
-
type Mutable<P
|
|
369
|
+
type Mutable<P> = { [K in keyof P]: P[K] | Readonly<P[K]> };
|
|
370
370
|
type Args<T> = T extends ConstructorRepresentation ? ConstructorParameters<T> : any[];
|
|
371
371
|
interface TresCatalogue {
|
|
372
372
|
[name: string]: ConstructorRepresentation;
|
|
@@ -378,8 +378,8 @@ type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
|
378
378
|
* @template T - The type of the object.
|
|
379
379
|
* @template P - The type of the arguments.
|
|
380
380
|
*/
|
|
381
|
-
interface InstanceProps<T = any, P
|
|
382
|
-
args?: Args<P
|
|
381
|
+
interface InstanceProps<T = any, P = any> {
|
|
382
|
+
args?: Args<P>;
|
|
383
383
|
object?: T;
|
|
384
384
|
visible?: boolean;
|
|
385
385
|
dispose?: null;
|
|
@@ -456,17 +456,17 @@ type TresContextWithClock = TresContext & {
|
|
|
456
456
|
delta: number;
|
|
457
457
|
elapsed: number;
|
|
458
458
|
};
|
|
459
|
-
type WithMathProps<P
|
|
459
|
+
type WithMathProps<P> = { [K in keyof P]: P[K] extends MathRepresentation | THREE.Euler ? MathType<P[K]> : P[K] };
|
|
460
460
|
interface RaycastableRepresentation {
|
|
461
461
|
raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
|
|
462
462
|
}
|
|
463
|
-
type EventProps<P
|
|
463
|
+
type EventProps<P> = P extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
|
|
464
464
|
interface VueProps {
|
|
465
465
|
children?: VNode[];
|
|
466
466
|
ref?: VNodeRef;
|
|
467
467
|
key?: string | number | symbol;
|
|
468
468
|
}
|
|
469
|
-
type ElementProps<T extends ConstructorRepresentation, P
|
|
469
|
+
type ElementProps<T extends ConstructorRepresentation, P = InstanceType<T>> = Partial<Overwrite<P, WithMathProps<P> & VueProps & EventProps<P>>>;
|
|
470
470
|
type ThreeElement<T extends ConstructorRepresentation> = Mutable<Overwrite<ElementProps<T>, Omit<InstanceProps<InstanceType<T>, T>, 'object'>>>;
|
|
471
471
|
type ThreeExports = typeof THREE;
|
|
472
472
|
type ThreeInstancesImpl = { [K in keyof ThreeExports as Uncapitalize<K>]: ThreeExports[K] extends ConstructorRepresentation ? ThreeElement<ThreeExports[K]> : never };
|
|
@@ -499,7 +499,7 @@ declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
|
|
|
499
499
|
//#endregion
|
|
500
500
|
//#region src/composables/useLoader/component.vue.d.ts
|
|
501
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<{
|
|
502
|
-
props: __VLS_PrettifyLocal<{
|
|
502
|
+
props: vue8.PublicProps & __VLS_PrettifyLocal<{
|
|
503
503
|
/**
|
|
504
504
|
* The THREE.js loader to use
|
|
505
505
|
*/
|
|
@@ -515,27 +515,27 @@ declare const __VLS_export$1: <T extends TresObjectMap>(__VLS_props: NonNullable
|
|
|
515
515
|
} & {
|
|
516
516
|
onLoaded?: ((result: T) => any) | undefined;
|
|
517
517
|
onError?: ((error: unknown) => any) | undefined;
|
|
518
|
-
}> &
|
|
518
|
+
}> & (typeof globalThis extends {
|
|
519
519
|
__VLS_PROPS_FALLBACK: infer P;
|
|
520
520
|
} ? P : {});
|
|
521
521
|
expose: (exposed: {}) => void;
|
|
522
522
|
attrs: any;
|
|
523
523
|
slots: {
|
|
524
524
|
default?: (props: {
|
|
525
|
-
state:
|
|
525
|
+
state: vue8.UnwrapRef<T>;
|
|
526
526
|
isLoading: boolean;
|
|
527
527
|
error: unknown;
|
|
528
528
|
}) => any;
|
|
529
529
|
};
|
|
530
530
|
emit: ((evt: "loaded", result: T) => void) & ((evt: "error", error: unknown) => void);
|
|
531
|
-
}>) =>
|
|
531
|
+
}>) => vue8.VNode & {
|
|
532
532
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
533
533
|
};
|
|
534
534
|
declare const _default$1: typeof __VLS_export$1;
|
|
535
535
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
536
536
|
//#endregion
|
|
537
537
|
//#region src/composables/useGraph/index.d.ts
|
|
538
|
-
declare const useGraph: (object: MaybeRef$1<TresObject | undefined>) =>
|
|
538
|
+
declare const useGraph: (object: MaybeRef$1<TresObject | undefined>) => vue8.ComputedRef<TresObjectMap | undefined>;
|
|
539
539
|
//#endregion
|
|
540
540
|
//#region src/utils/createPriorityEventHook.d.ts
|
|
541
541
|
type Callback<T> = Parameters<EventHookOff<T>>[0];
|
|
@@ -586,12 +586,17 @@ type LoopContext = RafLoopContext & TresPartialContext;
|
|
|
586
586
|
declare const useLoop: () => {
|
|
587
587
|
stop: () => void;
|
|
588
588
|
start: () => void;
|
|
589
|
-
isActive: Readonly<
|
|
589
|
+
isActive: Readonly<vue8.ShallowRef<boolean>>;
|
|
590
590
|
onBeforeRender: PriorityEventHookOn<LoopContext>;
|
|
591
591
|
onRender: PriorityEventHookOn<LoopContext>;
|
|
592
592
|
render: (fn: RenderFunction) => void;
|
|
593
593
|
};
|
|
594
594
|
//#endregion
|
|
595
|
+
//#region src/core/nodeOps.d.ts
|
|
596
|
+
interface TresCustomRendererOptions {
|
|
597
|
+
primitivePrefix?: string;
|
|
598
|
+
}
|
|
599
|
+
//#endregion
|
|
595
600
|
//#region src/utils/logger.d.ts
|
|
596
601
|
/**
|
|
597
602
|
* Logger utility for TresJS
|
|
@@ -644,8 +649,8 @@ declare const templateCompilerOptions: {
|
|
|
644
649
|
};
|
|
645
650
|
};
|
|
646
651
|
//#endregion
|
|
647
|
-
//#region src/components/
|
|
648
|
-
interface
|
|
652
|
+
//#region src/components/Context.vue.d.ts
|
|
653
|
+
interface ContextProps extends RendererOptions {
|
|
649
654
|
/**
|
|
650
655
|
* Custom camera instance to use as main camera
|
|
651
656
|
* If not provided, a default PerspectiveCamera will be created
|
|
@@ -663,14 +668,23 @@ interface TresCanvasProps extends RendererOptions {
|
|
|
663
668
|
* @default true
|
|
664
669
|
*/
|
|
665
670
|
enableProvideBridge?: boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Options for the TresJS custom renderer
|
|
673
|
+
*
|
|
674
|
+
*/
|
|
675
|
+
customRendererOptions?: TresCustomRendererOptions;
|
|
666
676
|
}
|
|
667
|
-
type
|
|
677
|
+
type ContextEmits = {
|
|
668
678
|
ready: [context: TresContext];
|
|
669
679
|
pointermissed: [event: TresPointerEvent];
|
|
670
680
|
render: [context: TresContext];
|
|
671
681
|
beforeLoop: [context: TresContextWithClock];
|
|
672
682
|
loop: [context: TresContextWithClock];
|
|
673
683
|
} & { [key in TresPointerEventName]: [event: TresPointerEvent] };
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/components/TresCanvas.vue.d.ts
|
|
686
|
+
type TresCanvasEmits = ContextEmits;
|
|
687
|
+
type TresCanvasProps = ContextProps;
|
|
674
688
|
interface TresCanvasInstance {
|
|
675
689
|
get context(): TresContext | undefined;
|
|
676
690
|
dispose: () => void;
|
|
@@ -678,7 +692,7 @@ interface TresCanvasInstance {
|
|
|
678
692
|
type __VLS_Slots = {
|
|
679
693
|
default: () => any;
|
|
680
694
|
};
|
|
681
|
-
declare const __VLS_base:
|
|
695
|
+
declare const __VLS_base: vue8.DefineComponent<ContextProps, TresCanvasInstance, {}, {}, {}, vue8.ComponentOptionsMixin, vue8.ComponentOptionsMixin, {
|
|
682
696
|
click: (event: TresPointerEvent) => any;
|
|
683
697
|
contextmenu: (event: TresPointerEvent) => any;
|
|
684
698
|
pointermove: (event: TresPointerEvent) => any;
|
|
@@ -697,7 +711,7 @@ declare const __VLS_base: vue0.DefineComponent<TresCanvasProps, TresCanvasInstan
|
|
|
697
711
|
render: (context: TresContext) => any;
|
|
698
712
|
beforeLoop: (context: TresContextWithClock) => any;
|
|
699
713
|
loop: (context: TresContextWithClock) => any;
|
|
700
|
-
}, string,
|
|
714
|
+
}, string, vue8.PublicProps, Readonly<ContextProps> & Readonly<{
|
|
701
715
|
onClick?: ((event: TresPointerEvent) => any) | undefined;
|
|
702
716
|
onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
|
|
703
717
|
onPointermove?: ((event: TresPointerEvent) => any) | undefined;
|
|
@@ -718,6 +732,7 @@ declare const __VLS_base: vue0.DefineComponent<TresCanvasProps, TresCanvasInstan
|
|
|
718
732
|
onLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
719
733
|
}>, {
|
|
720
734
|
windowSize: boolean;
|
|
735
|
+
enableProvideBridge: boolean;
|
|
721
736
|
antialias: boolean;
|
|
722
737
|
stencil: boolean;
|
|
723
738
|
depth: boolean;
|
|
@@ -732,8 +747,7 @@ declare const __VLS_base: vue0.DefineComponent<TresCanvasProps, TresCanvasInstan
|
|
|
732
747
|
shadowMapType: THREE.ShadowMapType;
|
|
733
748
|
useLegacyLights: boolean;
|
|
734
749
|
renderMode: "always" | "on-demand" | "manual";
|
|
735
|
-
|
|
736
|
-
}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
|
|
750
|
+
}, {}, {}, {}, string, vue8.ComponentProvideOptions, false, {}, any>;
|
|
737
751
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
738
752
|
declare const _default: typeof __VLS_export;
|
|
739
753
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1067,4 +1081,4 @@ interface TresPlugin {
|
|
|
1067
1081
|
}
|
|
1068
1082
|
declare const plugin: TresPlugin;
|
|
1069
1083
|
//#endregion
|
|
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 };
|
|
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, 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";
|
|
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
|
|
@@ -1072,7 +1072,7 @@ const isSupportedPointerEvent = (event) => supportedPointerEvents.includes(event
|
|
|
1072
1072
|
|
|
1073
1073
|
//#endregion
|
|
1074
1074
|
//#region src/core/nodeOps.ts
|
|
1075
|
-
const nodeOps = (context) => {
|
|
1075
|
+
const nodeOps = ({ context, options = { primitivePrefix: "" } }) => {
|
|
1076
1076
|
const scene = context.scene.value;
|
|
1077
1077
|
function createElement(tag, _isSVG, _anchor, props) {
|
|
1078
1078
|
if (!props) props = {};
|
|
@@ -1081,7 +1081,7 @@ const nodeOps = (context) => {
|
|
|
1081
1081
|
if (tag.includes("-")) tag = tag.replace(/-([a-z])/g, (_, c) => c.toUpperCase()).replace(/^[a-z]/, (c) => c.toUpperCase());
|
|
1082
1082
|
let name = tag.replace("Tres", "");
|
|
1083
1083
|
let obj;
|
|
1084
|
-
if (tag === "primitive
|
|
1084
|
+
if (tag === `${options?.primitivePrefix ?? ""}primitive`) {
|
|
1085
1085
|
if (!isObject(props.object) || isRef(props.object)) logError("Tres primitives need an 'object' prop, whose value is an object or shallowRef<object>");
|
|
1086
1086
|
name = props.object.type;
|
|
1087
1087
|
const __tres = {};
|
|
@@ -1825,6 +1825,10 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
1825
1825
|
type: Boolean,
|
|
1826
1826
|
required: false
|
|
1827
1827
|
},
|
|
1828
|
+
customRendererOptions: {
|
|
1829
|
+
type: Object,
|
|
1830
|
+
required: false
|
|
1831
|
+
},
|
|
1828
1832
|
antialias: {
|
|
1829
1833
|
type: Boolean,
|
|
1830
1834
|
required: false
|
|
@@ -1967,7 +1971,10 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
1967
1971
|
} });
|
|
1968
1972
|
const mountCustomRenderer = (context$1, empty = false) => {
|
|
1969
1973
|
const InternalComponent = createInternalComponent(context$1, empty);
|
|
1970
|
-
const { render } = createRenderer(nodeOps(
|
|
1974
|
+
const { render } = createRenderer(nodeOps({
|
|
1975
|
+
context: context$1,
|
|
1976
|
+
options: props.customRendererOptions
|
|
1977
|
+
}));
|
|
1971
1978
|
render(h(InternalComponent), scene.value);
|
|
1972
1979
|
};
|
|
1973
1980
|
const dispose = (context$1, force = false) => {
|
|
@@ -2058,6 +2065,78 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
2058
2065
|
//#region src/components/Context.vue
|
|
2059
2066
|
var Context_default = Context_vue_vue_type_script_setup_true_lang_default;
|
|
2060
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
|
+
|
|
2061
2140
|
//#endregion
|
|
2062
2141
|
//#region src/components/TresCanvas.vue?vue&type=script&setup=true&lang.ts
|
|
2063
2142
|
const _hoisted_1 = ["data-scene", "data-tres"];
|
|
@@ -2078,6 +2157,10 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2078
2157
|
required: false,
|
|
2079
2158
|
default: true
|
|
2080
2159
|
},
|
|
2160
|
+
customRendererOptions: {
|
|
2161
|
+
type: Object,
|
|
2162
|
+
required: false
|
|
2163
|
+
},
|
|
2081
2164
|
antialias: {
|
|
2082
2165
|
type: Boolean,
|
|
2083
2166
|
required: false,
|
|
@@ -2212,6 +2295,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2212
2295
|
},
|
|
2213
2296
|
dispose: () => contextRef.value?.dispose()
|
|
2214
2297
|
});
|
|
2298
|
+
const forwardedPropsEmits = useForwardPropsEmits(props, emit);
|
|
2215
2299
|
return (_ctx, _cache) => {
|
|
2216
2300
|
return openBlock(), createElementBlock("canvas", {
|
|
2217
2301
|
ref_key: "canvasRef",
|
|
@@ -2235,26 +2319,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2235
2319
|
ref_key: "contextRef",
|
|
2236
2320
|
ref: contextRef,
|
|
2237
2321
|
canvas: canvasRef.value
|
|
2238
|
-
},
|
|
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
|
-
}), {
|
|
2322
|
+
}, unref(forwardedPropsEmits)), {
|
|
2258
2323
|
default: withCtx(() => [renderSlot(_ctx.$slots, "default")]),
|
|
2259
2324
|
_: 3
|
|
2260
2325
|
}, 16, ["canvas"])) : createCommentVNode("v-if", true)], 14, _hoisted_1);
|
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-BRx1-uMz.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* name: @tresjs/core
|
|
3
|
-
* version: v5.2.1
|
|
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
|