@tresjs/core 5.2.0 → 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,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v5.2.
|
|
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 * as
|
|
8
|
+
import * as vue0 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: vue0.ComputedRef<boolean>;
|
|
315
316
|
mode: "always" | "on-demand" | "manual" | undefined;
|
|
316
317
|
replaceRenderFunction: (fn: RenderFunction) => void;
|
|
317
318
|
};
|
|
@@ -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
|
+
}> & vue0.PublicProps & (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: vue0.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
|
+
}>) => vue0.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>) => vue0.ComputedRef<TresObjectMap | undefined>;
|
|
538
539
|
//#endregion
|
|
539
540
|
//#region src/utils/createPriorityEventHook.d.ts
|
|
540
541
|
type Callback<T> = Parameters<EventHookOff<T>>[0];
|
|
@@ -585,7 +586,7 @@ type LoopContext = RafLoopContext & TresPartialContext;
|
|
|
585
586
|
declare const useLoop: () => {
|
|
586
587
|
stop: () => void;
|
|
587
588
|
start: () => void;
|
|
588
|
-
isActive: Readonly<
|
|
589
|
+
isActive: Readonly<vue0.ShallowRef<boolean>>;
|
|
589
590
|
onBeforeRender: PriorityEventHookOn<LoopContext>;
|
|
590
591
|
onRender: PriorityEventHookOn<LoopContext>;
|
|
591
592
|
render: (fn: RenderFunction) => void;
|
|
@@ -670,11 +671,14 @@ type TresCanvasEmits = {
|
|
|
670
671
|
beforeLoop: [context: TresContextWithClock];
|
|
671
672
|
loop: [context: TresContextWithClock];
|
|
672
673
|
} & { [key in TresPointerEventName]: [event: TresPointerEvent] };
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
context: vue10.ShallowRef<TresContext | null, TresContext | null>;
|
|
674
|
+
interface TresCanvasInstance {
|
|
675
|
+
get context(): TresContext | undefined;
|
|
676
676
|
dispose: () => void;
|
|
677
|
-
}
|
|
677
|
+
}
|
|
678
|
+
type __VLS_Slots = {
|
|
679
|
+
default: () => any;
|
|
680
|
+
};
|
|
681
|
+
declare const __VLS_base: vue0.DefineComponent<TresCanvasProps, TresCanvasInstance, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {
|
|
678
682
|
click: (event: TresPointerEvent) => any;
|
|
679
683
|
contextmenu: (event: TresPointerEvent) => any;
|
|
680
684
|
pointermove: (event: TresPointerEvent) => any;
|
|
@@ -693,7 +697,7 @@ declare const __VLS_export: __VLS_WithSlots<vue10.DefineComponent<TresCanvasProp
|
|
|
693
697
|
render: (context: TresContext) => any;
|
|
694
698
|
beforeLoop: (context: TresContextWithClock) => any;
|
|
695
699
|
loop: (context: TresContextWithClock) => any;
|
|
696
|
-
}, string,
|
|
700
|
+
}, string, vue0.PublicProps, Readonly<TresCanvasProps> & Readonly<{
|
|
697
701
|
onClick?: ((event: TresPointerEvent) => any) | undefined;
|
|
698
702
|
onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
|
|
699
703
|
onPointermove?: ((event: TresPointerEvent) => any) | undefined;
|
|
@@ -714,7 +718,6 @@ declare const __VLS_export: __VLS_WithSlots<vue10.DefineComponent<TresCanvasProp
|
|
|
714
718
|
onLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
715
719
|
}>, {
|
|
716
720
|
windowSize: boolean;
|
|
717
|
-
enableProvideBridge: boolean;
|
|
718
721
|
antialias: boolean;
|
|
719
722
|
stencil: boolean;
|
|
720
723
|
depth: boolean;
|
|
@@ -729,9 +732,10 @@ declare const __VLS_export: __VLS_WithSlots<vue10.DefineComponent<TresCanvasProp
|
|
|
729
732
|
shadowMapType: THREE.ShadowMapType;
|
|
730
733
|
useLegacyLights: boolean;
|
|
731
734
|
renderMode: "always" | "on-demand" | "manual";
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
+
enableProvideBridge: boolean;
|
|
736
|
+
}, {}, {}, {}, string, vue0.ComponentProvideOptions, false, {}, any>;
|
|
737
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
738
|
+
declare const _default: typeof __VLS_export;
|
|
735
739
|
type __VLS_WithSlots<T, S> = T & {
|
|
736
740
|
new (): {
|
|
737
741
|
$slots: S;
|
|
@@ -1063,4 +1067,4 @@ interface TresPlugin {
|
|
|
1063
1067
|
}
|
|
1064
1068
|
declare const plugin: TresPlugin;
|
|
1065
1069
|
//#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 };
|
|
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.2.
|
|
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,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.2.
|
|
17
|
+
var version = "5.2.1";
|
|
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
|
}
|
|
@@ -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,23 @@ 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
|
-
default: true
|
|
1826
|
+
required: false
|
|
1829
1827
|
},
|
|
1830
1828
|
antialias: {
|
|
1831
1829
|
type: Boolean,
|
|
1832
|
-
required: false
|
|
1833
|
-
default: true
|
|
1830
|
+
required: false
|
|
1834
1831
|
},
|
|
1835
1832
|
stencil: {
|
|
1836
1833
|
type: Boolean,
|
|
1837
|
-
required: false
|
|
1838
|
-
default: void 0
|
|
1834
|
+
required: false
|
|
1839
1835
|
},
|
|
1840
1836
|
depth: {
|
|
1841
1837
|
type: Boolean,
|
|
1842
|
-
required: false
|
|
1843
|
-
default: void 0
|
|
1838
|
+
required: false
|
|
1844
1839
|
},
|
|
1845
1840
|
precision: {
|
|
1846
1841
|
type: String,
|
|
@@ -1848,13 +1843,11 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1848
1843
|
},
|
|
1849
1844
|
logarithmicDepthBuffer: {
|
|
1850
1845
|
type: Boolean,
|
|
1851
|
-
required: false
|
|
1852
|
-
default: void 0
|
|
1846
|
+
required: false
|
|
1853
1847
|
},
|
|
1854
1848
|
preserveDrawingBuffer: {
|
|
1855
1849
|
type: Boolean,
|
|
1856
|
-
required: false
|
|
1857
|
-
default: void 0
|
|
1850
|
+
required: false
|
|
1858
1851
|
},
|
|
1859
1852
|
powerPreference: {
|
|
1860
1853
|
type: null,
|
|
@@ -1862,8 +1855,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1862
1855
|
},
|
|
1863
1856
|
alpha: {
|
|
1864
1857
|
type: Boolean,
|
|
1865
|
-
required: false
|
|
1866
|
-
default: void 0
|
|
1858
|
+
required: false
|
|
1867
1859
|
},
|
|
1868
1860
|
premultipliedAlpha: {
|
|
1869
1861
|
type: Boolean,
|
|
@@ -1871,8 +1863,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1871
1863
|
},
|
|
1872
1864
|
failIfMajorPerformanceCaveat: {
|
|
1873
1865
|
type: Boolean,
|
|
1874
|
-
required: false
|
|
1875
|
-
default: void 0
|
|
1866
|
+
required: false
|
|
1876
1867
|
},
|
|
1877
1868
|
clearColor: {
|
|
1878
1869
|
type: [
|
|
@@ -1880,33 +1871,27 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1880
1871
|
String,
|
|
1881
1872
|
Number
|
|
1882
1873
|
],
|
|
1883
|
-
required: false
|
|
1884
|
-
default: "#000000"
|
|
1874
|
+
required: false
|
|
1885
1875
|
},
|
|
1886
1876
|
clearAlpha: {
|
|
1887
1877
|
type: Number,
|
|
1888
|
-
required: false
|
|
1889
|
-
default: 1
|
|
1878
|
+
required: false
|
|
1890
1879
|
},
|
|
1891
1880
|
shadows: {
|
|
1892
1881
|
type: Boolean,
|
|
1893
|
-
required: false
|
|
1894
|
-
default: void 0
|
|
1882
|
+
required: false
|
|
1895
1883
|
},
|
|
1896
1884
|
toneMapping: {
|
|
1897
1885
|
type: null,
|
|
1898
|
-
required: false
|
|
1899
|
-
default: ACESFilmicToneMapping
|
|
1886
|
+
required: false
|
|
1900
1887
|
},
|
|
1901
1888
|
shadowMapType: {
|
|
1902
1889
|
type: null,
|
|
1903
|
-
required: false
|
|
1904
|
-
default: PCFSoftShadowMap
|
|
1890
|
+
required: false
|
|
1905
1891
|
},
|
|
1906
1892
|
useLegacyLights: {
|
|
1907
1893
|
type: Boolean,
|
|
1908
|
-
required: false
|
|
1909
|
-
default: void 0
|
|
1894
|
+
required: false
|
|
1910
1895
|
},
|
|
1911
1896
|
outputColorSpace: {
|
|
1912
1897
|
type: null,
|
|
@@ -1918,8 +1903,7 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1918
1903
|
},
|
|
1919
1904
|
renderMode: {
|
|
1920
1905
|
type: String,
|
|
1921
|
-
required: false
|
|
1922
|
-
default: "always"
|
|
1906
|
+
required: false
|
|
1923
1907
|
},
|
|
1924
1908
|
dpr: {
|
|
1925
1909
|
type: [Number, Array],
|
|
@@ -1928,6 +1912,10 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1928
1912
|
renderer: {
|
|
1929
1913
|
type: Function,
|
|
1930
1914
|
required: false
|
|
1915
|
+
},
|
|
1916
|
+
canvas: {
|
|
1917
|
+
type: null,
|
|
1918
|
+
required: true
|
|
1931
1919
|
}
|
|
1932
1920
|
},
|
|
1933
1921
|
emits: [
|
|
@@ -1954,7 +1942,6 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1954
1942
|
const props = __props;
|
|
1955
1943
|
const emit = __emit;
|
|
1956
1944
|
const slots = useSlots();
|
|
1957
|
-
const canvasRef = ref();
|
|
1958
1945
|
const scene = shallowRef(new Scene());
|
|
1959
1946
|
const instance = getCurrentInstance();
|
|
1960
1947
|
extend(THREE);
|
|
@@ -1994,7 +1981,12 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
1994
1981
|
}
|
|
1995
1982
|
scene.value.__tres = { root: context$1 };
|
|
1996
1983
|
};
|
|
1997
|
-
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
|
+
}));
|
|
1998
1990
|
__expose({
|
|
1999
1991
|
context,
|
|
2000
1992
|
dispose: () => dispose(context.value, true)
|
|
@@ -2007,71 +1999,224 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2007
1999
|
dispose(context.value);
|
|
2008
2000
|
mountCustomRenderer(context.value, true);
|
|
2009
2001
|
};
|
|
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));
|
|
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?.();
|
|
2042
2015
|
}
|
|
2043
|
-
}, { immediate: true });
|
|
2044
|
-
if (!activeCamera.value) addDefaultCamera();
|
|
2045
|
-
renderer.onRender(() => {
|
|
2046
|
-
if (context.value) emit("render", context.value);
|
|
2047
2016
|
});
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
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
|
|
2059
2036
|
});
|
|
2060
|
-
|
|
2061
|
-
|
|
2037
|
+
});
|
|
2038
|
+
renderer.loop.onBeforeLoop((loopContext) => {
|
|
2039
|
+
if (context.value) emit("beforeLoop", {
|
|
2040
|
+
...context.value,
|
|
2041
|
+
...loopContext
|
|
2062
2042
|
});
|
|
2063
|
-
if (import.meta.hot && context.value) import.meta.hot.on("vite:afterUpdate", () => handleHMR(context.value));
|
|
2064
2043
|
});
|
|
2044
|
+
renderer.onReady(() => {
|
|
2045
|
+
emit("ready", context.value);
|
|
2046
|
+
});
|
|
2047
|
+
if (import.meta.hot) import.meta.hot.on("vite:afterUpdate", () => handleHMR(context.value));
|
|
2065
2048
|
onMounted(async () => {
|
|
2066
2049
|
await promiseTimeout(3e3);
|
|
2067
|
-
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.`);
|
|
2068
2051
|
});
|
|
2069
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
|
+
});
|
|
2070
2215
|
return (_ctx, _cache) => {
|
|
2071
2216
|
return openBlock(), createElementBlock("canvas", {
|
|
2072
2217
|
ref_key: "canvasRef",
|
|
2073
2218
|
ref: canvasRef,
|
|
2074
|
-
"data-scene": scene.value.uuid,
|
|
2219
|
+
"data-scene": contextRef.value?.context?.scene.value.uuid,
|
|
2075
2220
|
class: normalizeClass(_ctx.$attrs.class),
|
|
2076
2221
|
"data-tres": `tresjs ${unref(version)}`,
|
|
2077
2222
|
style: normalizeStyle({
|
|
@@ -2085,7 +2230,34 @@ var TresCanvas_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ def
|
|
|
2085
2230
|
touchAction: "none",
|
|
2086
2231
|
..._ctx.$attrs.style
|
|
2087
2232
|
})
|
|
2088
|
-
},
|
|
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);
|
|
2089
2261
|
};
|
|
2090
2262
|
}
|
|
2091
2263
|
});
|
package/package.json
CHANGED