@tresjs/core 5.8.0 → 5.8.2
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/README.md +80 -0
- package/dist/template-compiler-options.d.mts +1 -1
- package/dist/template-compiler-options.mjs +1 -1
- package/dist/tres.d.ts +24 -23
- package/dist/tres.js +55 -96
- package/package.json +26 -24
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://npmx.dev/package/@tresjs/core"><img src="https://npmx.dev/api/registry/badge/version/@tresjs/core" alt="version"></a>
|
|
3
|
+
<a href="https://www.npmjs.com/package/@tresjs/core"><img src="https://img.shields.io/npm/dm/@tresjs/core?color=82DBA1" alt="npm downloads"></a>
|
|
4
|
+
<a href="https://tresjs.org/discord"><img src="https://img.shields.io/badge/chat-discord-purple?style=flat&logo=discord" alt="discord chat"></a>
|
|
5
|
+
</p>
|
|
6
|
+
<br/>
|
|
7
|
+
|
|
8
|
+
# TresJS Core
|
|
9
|
+
|
|
10
|
+
> Declarative ThreeJS using Vue Components
|
|
11
|
+
|
|
12
|
+
- 💡 Build 3D scenes with Vue components
|
|
13
|
+
- ⚡️ Powered by Vite
|
|
14
|
+
- 🎨 Vue custom renderer for Three.js
|
|
15
|
+
- 🥰 Always up-to-date with the latest Three.js features
|
|
16
|
+
- 🦾 Fully Typed
|
|
17
|
+
|
|
18
|
+
TresJS is a Vue custom renderer that lets you build Three.js scenes declaratively using Vue components. Any Three.js class can be used as a component by prefixing it with `Tres` (e.g., `<TresMesh>`, `<TresBoxGeometry>`).
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm i @tresjs/core three
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## TypeScript
|
|
27
|
+
|
|
28
|
+
Install Three.js type definitions:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm i @types/three -D
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Vite Configuration
|
|
35
|
+
|
|
36
|
+
Add the template compiler options to your `vite.config.ts` to make the custom renderer work and avoid console warnings:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { templateCompilerOptions } from '@tresjs/core'
|
|
40
|
+
import vue from '@vitejs/plugin-vue'
|
|
41
|
+
import { defineConfig } from 'vite'
|
|
42
|
+
|
|
43
|
+
export default defineConfig({
|
|
44
|
+
plugins: [
|
|
45
|
+
vue({
|
|
46
|
+
...templateCompilerOptions,
|
|
47
|
+
}),
|
|
48
|
+
],
|
|
49
|
+
})
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Docs
|
|
53
|
+
|
|
54
|
+
Checkout the [docs](https://docs.tresjs.org/)
|
|
55
|
+
|
|
56
|
+
### Build
|
|
57
|
+
|
|
58
|
+
To build the package run:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pnpm run build
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Test
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pnpm run test
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Playground
|
|
71
|
+
|
|
72
|
+
To run the playground:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pnpm run playground
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
[MIT](/LICENSE)
|
package/dist/tres.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v5.8.
|
|
3
|
+
* version: v5.8.2
|
|
4
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 vue14 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";
|
|
12
12
|
import * as _vueuse_core0 from "@vueuse/core";
|
|
13
|
-
import { EventHookOff,
|
|
13
|
+
import { EventHookOff, UseAsyncStateOptions, UseAsyncStateReturn } from "@vueuse/core";
|
|
14
14
|
import { PointerEvent, PointerEventsMap } from "@pmndrs/pointer-events";
|
|
15
15
|
import { Renderer } from "three/webgpu";
|
|
16
16
|
|
|
@@ -323,11 +323,11 @@ declare function useRendererManager({
|
|
|
323
323
|
onRender: _vueuse_core0.EventHookOn<TresRenderer>;
|
|
324
324
|
onError: _vueuse_core0.EventHookOn<TresRendererError>;
|
|
325
325
|
invalidate: (amountOfFramesToInvalidate?: number) => void;
|
|
326
|
-
canBeInvalidated:
|
|
326
|
+
canBeInvalidated: vue14.ComputedRef<boolean>;
|
|
327
327
|
mode: "always" | "on-demand" | "manual" | undefined;
|
|
328
328
|
replaceRenderFunction: (fn: RenderFunction) => void;
|
|
329
|
-
isInitialized:
|
|
330
|
-
error:
|
|
329
|
+
isInitialized: vue14.Ref<boolean, boolean>;
|
|
330
|
+
error: vue14.Ref<TresRendererError | null, TresRendererError | null>;
|
|
331
331
|
};
|
|
332
332
|
type UseRendererManagerReturn = ReturnType<typeof useRendererManager>;
|
|
333
333
|
//#endregion
|
|
@@ -515,7 +515,7 @@ declare function buildGraph(object: Object3D | TresObject): TresObjectMap;
|
|
|
515
515
|
//#endregion
|
|
516
516
|
//#region src/composables/useLoader/component.vue.d.ts
|
|
517
517
|
declare const __VLS_export$2: <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<{
|
|
518
|
-
props:
|
|
518
|
+
props: vue14.PublicProps & __VLS_PrettifyLocal<{
|
|
519
519
|
/**
|
|
520
520
|
* The THREE.js loader to use
|
|
521
521
|
*/
|
|
@@ -528,6 +528,7 @@ declare const __VLS_export$2: <T extends TresObjectMap>(__VLS_props: NonNullable
|
|
|
528
528
|
* Optional THREE.js LoadingManager
|
|
529
529
|
*/
|
|
530
530
|
manager?: LoadingManager;
|
|
531
|
+
extensions?: (res: T) => void;
|
|
531
532
|
} & {
|
|
532
533
|
onError?: ((error: unknown) => any) | undefined;
|
|
533
534
|
onLoaded?: ((result: T) => any) | undefined;
|
|
@@ -538,20 +539,20 @@ declare const __VLS_export$2: <T extends TresObjectMap>(__VLS_props: NonNullable
|
|
|
538
539
|
attrs: any;
|
|
539
540
|
slots: {
|
|
540
541
|
default?: (props: {
|
|
541
|
-
state:
|
|
542
|
+
state: vue14.UnwrapRef<T>;
|
|
542
543
|
isLoading: boolean;
|
|
543
544
|
error: unknown;
|
|
544
545
|
}) => any;
|
|
545
546
|
};
|
|
546
547
|
emit: ((evt: "error", error: unknown) => void) & ((evt: "loaded", result: T) => void);
|
|
547
|
-
}>) =>
|
|
548
|
+
}>) => vue14.VNode & {
|
|
548
549
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
549
550
|
};
|
|
550
551
|
declare const _default$2: typeof __VLS_export$2;
|
|
551
552
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
552
553
|
//#endregion
|
|
553
554
|
//#region src/composables/useGraph/index.d.ts
|
|
554
|
-
declare const useGraph: (object: MaybeRef
|
|
555
|
+
declare const useGraph: (object: MaybeRef<TresObject | undefined>) => vue14.ComputedRef<TresObjectMap | undefined>;
|
|
555
556
|
//#endregion
|
|
556
557
|
//#region src/utils/createPriorityEventHook.d.ts
|
|
557
558
|
type Callback<T> = Parameters<EventHookOff<T>>[0];
|
|
@@ -602,7 +603,7 @@ type LoopContext = RafLoopContext & TresPartialContext;
|
|
|
602
603
|
declare const useLoop: () => {
|
|
603
604
|
stop: () => void;
|
|
604
605
|
start: () => void;
|
|
605
|
-
isActive: Readonly<
|
|
606
|
+
isActive: Readonly<vue14.ShallowRef<boolean>>;
|
|
606
607
|
onBeforeRender: PriorityEventHookOn<LoopContext>;
|
|
607
608
|
onRender: PriorityEventHookOn<LoopContext>;
|
|
608
609
|
render: (fn: RenderFunction) => void;
|
|
@@ -709,10 +710,10 @@ type __VLS_Props = ContextProps & {
|
|
|
709
710
|
type __VLS_Slots$1 = {
|
|
710
711
|
default: () => any;
|
|
711
712
|
};
|
|
712
|
-
declare const __VLS_base$1:
|
|
713
|
-
context:
|
|
713
|
+
declare const __VLS_base$1: vue14.DefineComponent<__VLS_Props, {
|
|
714
|
+
context: vue14.ShallowRef<TresContext, TresContext>;
|
|
714
715
|
dispose: () => void;
|
|
715
|
-
}, {}, {}, {},
|
|
716
|
+
}, {}, {}, {}, vue14.ComponentOptionsMixin, vue14.ComponentOptionsMixin, {
|
|
716
717
|
click: (event: TresPointerEvent) => any;
|
|
717
718
|
contextmenu: (event: TresPointerEvent) => any;
|
|
718
719
|
pointermove: (event: TresPointerEvent) => any;
|
|
@@ -732,7 +733,7 @@ declare const __VLS_base$1: vue15.DefineComponent<__VLS_Props, {
|
|
|
732
733
|
render: (context: TresContext) => any;
|
|
733
734
|
beforeLoop: (context: TresContextWithClock) => any;
|
|
734
735
|
loop: (context: TresContextWithClock) => any;
|
|
735
|
-
}, string,
|
|
736
|
+
}, string, vue14.PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
736
737
|
onClick?: ((event: TresPointerEvent) => any) | undefined;
|
|
737
738
|
onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
|
|
738
739
|
onPointermove?: ((event: TresPointerEvent) => any) | undefined;
|
|
@@ -752,7 +753,7 @@ declare const __VLS_base$1: vue15.DefineComponent<__VLS_Props, {
|
|
|
752
753
|
onRender?: ((context: TresContext) => any) | undefined;
|
|
753
754
|
onBeforeLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
754
755
|
onLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
755
|
-
}>, {}, {}, {}, {}, string,
|
|
756
|
+
}>, {}, {}, {}, {}, string, vue14.ComponentProvideOptions, false, {}, any>;
|
|
756
757
|
declare const __VLS_export$1: __VLS_WithSlots$1<typeof __VLS_base$1, __VLS_Slots$1>;
|
|
757
758
|
declare const _default$1: typeof __VLS_export$1;
|
|
758
759
|
type __VLS_WithSlots$1<T, S> = T & {
|
|
@@ -771,7 +772,7 @@ interface TresCanvasInstance {
|
|
|
771
772
|
type __VLS_Slots = {
|
|
772
773
|
default: () => any;
|
|
773
774
|
};
|
|
774
|
-
declare const __VLS_base:
|
|
775
|
+
declare const __VLS_base: vue14.DefineComponent<ContextProps, TresCanvasInstance, {}, {}, {}, vue14.ComponentOptionsMixin, vue14.ComponentOptionsMixin, {
|
|
775
776
|
click: (event: TresPointerEvent) => any;
|
|
776
777
|
contextmenu: (event: TresPointerEvent) => any;
|
|
777
778
|
pointermove: (event: TresPointerEvent) => any;
|
|
@@ -791,7 +792,7 @@ declare const __VLS_base: vue15.DefineComponent<ContextProps, TresCanvasInstance
|
|
|
791
792
|
render: (context: TresContext) => any;
|
|
792
793
|
beforeLoop: (context: TresContextWithClock) => any;
|
|
793
794
|
loop: (context: TresContextWithClock) => any;
|
|
794
|
-
}, string,
|
|
795
|
+
}, string, vue14.PublicProps, Readonly<ContextProps> & Readonly<{
|
|
795
796
|
onClick?: ((event: TresPointerEvent) => any) | undefined;
|
|
796
797
|
onContextmenu?: ((event: TresPointerEvent) => any) | undefined;
|
|
797
798
|
onPointermove?: ((event: TresPointerEvent) => any) | undefined;
|
|
@@ -813,6 +814,7 @@ declare const __VLS_base: vue15.DefineComponent<ContextProps, TresCanvasInstance
|
|
|
813
814
|
onLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
814
815
|
}>, {
|
|
815
816
|
windowSize: boolean;
|
|
817
|
+
toneMapping: THREE.ToneMapping;
|
|
816
818
|
enableProvideBridge: boolean;
|
|
817
819
|
antialias: boolean;
|
|
818
820
|
stencil: boolean;
|
|
@@ -824,11 +826,10 @@ declare const __VLS_base: vue15.DefineComponent<ContextProps, TresCanvasInstance
|
|
|
824
826
|
clearColor: THREE.ColorRepresentation;
|
|
825
827
|
clearAlpha: number;
|
|
826
828
|
shadows: boolean;
|
|
827
|
-
toneMapping: THREE.ToneMapping;
|
|
828
829
|
shadowMapType: THREE.ShadowMapType;
|
|
829
830
|
useLegacyLights: boolean;
|
|
830
831
|
renderMode: "always" | "on-demand" | "manual";
|
|
831
|
-
}, {}, {}, {}, string,
|
|
832
|
+
}, {}, {}, {}, string, vue14.ComponentProvideOptions, false, {}, any>;
|
|
832
833
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
833
834
|
declare const _default: typeof __VLS_export;
|
|
834
835
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -965,7 +966,7 @@ declare const isObject3D: (value: unknown) => value is Object3D<THREE.Object3DEv
|
|
|
965
966
|
* // TypeScript knows value is Mesh here
|
|
966
967
|
* value.geometry // OK
|
|
967
968
|
*/
|
|
968
|
-
declare const isMesh: (value: unknown) => value is Mesh<BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, Material | Material[], THREE.Object3DEventMap>;
|
|
969
|
+
declare const isMesh: (value: unknown) => value is Mesh<BufferGeometry<THREE.NormalBufferAttributes, THREE.BufferGeometryEventMap>, Material<THREE.MaterialEventMap> | Material<THREE.MaterialEventMap>[], THREE.Object3DEventMap>;
|
|
969
970
|
/**
|
|
970
971
|
* Type guard to check if a value is a Three.js Camera
|
|
971
972
|
* @param value - The value to check
|
|
@@ -1043,7 +1044,7 @@ declare const isBufferGeometry: (value: unknown) => value is BufferGeometry<THRE
|
|
|
1043
1044
|
* }
|
|
1044
1045
|
* ```
|
|
1045
1046
|
*/
|
|
1046
|
-
declare const isMaterial: (value: unknown) => value is Material
|
|
1047
|
+
declare const isMaterial: (value: unknown) => value is Material<THREE.MaterialEventMap>;
|
|
1047
1048
|
/**
|
|
1048
1049
|
* Type guard to check if a value is a Three.js Light
|
|
1049
1050
|
* @param value - The value to check
|
|
@@ -1091,7 +1092,7 @@ declare const isFog: (value: unknown) => value is Fog;
|
|
|
1091
1092
|
* }
|
|
1092
1093
|
* ```
|
|
1093
1094
|
*/
|
|
1094
|
-
declare const isScene: (value: unknown) => value is Scene
|
|
1095
|
+
declare const isScene: (value: unknown) => value is Scene<THREE.Object3DEventMap>;
|
|
1095
1096
|
/**
|
|
1096
1097
|
* Type guard to check if a value is a Three.js Group
|
|
1097
1098
|
* @param value - The value to check
|
package/dist/tres.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/core
|
|
3
|
-
* version: v5.8.
|
|
3
|
+
* version: v5.8.2
|
|
4
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, nextTick, normalizeClass, normalizeStyle, onMounted, onUnmounted, openBlock, provide, reactive, readonly, ref, renderSlot, shallowRef, toValue, unref, useSlots, watch, watchEffect, withCtx } from "vue";
|
|
8
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createRenderer, defineComponent, getCurrentInstance, h, isRef, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, 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
|
-
import { ACESFilmicToneMapping, ArrowHelper,
|
|
10
|
+
import { ACESFilmicToneMapping, ArrowHelper, BufferAttribute, Color, DirectionalLightHelper, DoubleSide, HemisphereLightHelper, Layers, Material, MathUtils, Mesh, MeshBasicMaterial, PCFSoftShadowMap, PerspectiveCamera, PointLightHelper, REVISION, 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";
|
|
12
12
|
import { camel, isEqual, isFunction, isNumber, isObject, isString, isUndefined } from "radashi";
|
|
13
13
|
import { forwardHtmlEvents, getVoidObject } from "@pmndrs/pointer-events";
|
|
14
14
|
import { setupDevtoolsPlugin } from "@vue/devtools-api";
|
|
15
|
+
import { RectAreaLightHelper } from "three-stdlib";
|
|
15
16
|
|
|
16
17
|
//#region package.json
|
|
17
|
-
var version = "5.8.
|
|
18
|
+
var version = "5.8.2";
|
|
18
19
|
|
|
19
20
|
//#endregion
|
|
20
21
|
//#region src/utils/makeMap.ts
|
|
@@ -533,13 +534,20 @@ var component_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defi
|
|
|
533
534
|
manager: {
|
|
534
535
|
type: Object,
|
|
535
536
|
required: false
|
|
537
|
+
},
|
|
538
|
+
extensions: {
|
|
539
|
+
type: Function,
|
|
540
|
+
required: false
|
|
536
541
|
}
|
|
537
542
|
},
|
|
538
543
|
emits: ["loaded", "error"],
|
|
539
544
|
setup(__props, { emit: __emit }) {
|
|
540
545
|
const props = __props;
|
|
541
546
|
const emit = __emit;
|
|
542
|
-
const { state, isLoading, error } = useLoader(props.loader, props.path, {
|
|
547
|
+
const { state, isLoading, error } = useLoader(props.loader, props.path, {
|
|
548
|
+
manager: props.manager,
|
|
549
|
+
extensions: props.extensions
|
|
550
|
+
});
|
|
543
551
|
whenever(error, (err) => {
|
|
544
552
|
if (err) emit("error", err);
|
|
545
553
|
});
|
|
@@ -1397,6 +1405,15 @@ const nodeOps = ({ context, options = { primitivePrefix: "" } }) => {
|
|
|
1397
1405
|
};
|
|
1398
1406
|
};
|
|
1399
1407
|
|
|
1408
|
+
//#endregion
|
|
1409
|
+
//#region src/core/roots.ts
|
|
1410
|
+
const _roots = /* @__PURE__ */ new Map();
|
|
1411
|
+
const getRoot = (canvas) => _roots.get(canvas);
|
|
1412
|
+
const setRoot = (canvas, root) => {
|
|
1413
|
+
_roots.set(canvas, root);
|
|
1414
|
+
};
|
|
1415
|
+
const deleteRoot = (canvas) => _roots.delete(canvas);
|
|
1416
|
+
|
|
1400
1417
|
//#endregion
|
|
1401
1418
|
//#region src/devtools/DevtoolsMessenger.ts
|
|
1402
1419
|
const QUEUEABLE_MESSAGE_TYPES = ["asset-load"];
|
|
@@ -2071,7 +2088,7 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
2071
2088
|
const scene = shallowRef(new Scene());
|
|
2072
2089
|
const instance = getCurrentInstance();
|
|
2073
2090
|
extend(THREE);
|
|
2074
|
-
const createInternalComponent = (context$1,
|
|
2091
|
+
const createInternalComponent = (context$1, hmrTick) => defineComponent({ setup() {
|
|
2075
2092
|
const ctx = getCurrentInstance()?.appContext;
|
|
2076
2093
|
if (ctx) ctx.app = instance?.appContext.app;
|
|
2077
2094
|
const provides = {};
|
|
@@ -2089,15 +2106,27 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
2089
2106
|
provide(INJECTION_KEY, context$1);
|
|
2090
2107
|
provide("extend", extend);
|
|
2091
2108
|
if (typeof window !== "undefined" && ctx?.app) registerTresDevtools(ctx?.app, context$1);
|
|
2092
|
-
return () =>
|
|
2109
|
+
return () => {
|
|
2110
|
+
hmrTick.value;
|
|
2111
|
+
return h(Fragment, null, slots.default?.() ?? []);
|
|
2112
|
+
};
|
|
2093
2113
|
} });
|
|
2094
|
-
const mountCustomRenderer = (context$1
|
|
2095
|
-
const
|
|
2096
|
-
|
|
2114
|
+
const mountCustomRenderer = (context$1) => {
|
|
2115
|
+
const canvas = props.canvas;
|
|
2116
|
+
if (getRoot(canvas)) return;
|
|
2117
|
+
const hmrTick = ref(0);
|
|
2118
|
+
const internalComponent = createInternalComponent(context$1, hmrTick);
|
|
2119
|
+
const renderer$1 = createRenderer(nodeOps({
|
|
2097
2120
|
context: context$1,
|
|
2098
2121
|
options: props.customRendererOptions
|
|
2099
2122
|
}));
|
|
2100
|
-
render(h(
|
|
2123
|
+
renderer$1.render(h(internalComponent), scene.value);
|
|
2124
|
+
setRoot(canvas, {
|
|
2125
|
+
renderer: renderer$1,
|
|
2126
|
+
internalComponent,
|
|
2127
|
+
hmrTick,
|
|
2128
|
+
context: context$1
|
|
2129
|
+
});
|
|
2101
2130
|
};
|
|
2102
2131
|
const dispose = (context$1, force = false) => {
|
|
2103
2132
|
disposeObject3D(context$1.scene.value);
|
|
@@ -2125,14 +2154,18 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
2125
2154
|
context,
|
|
2126
2155
|
dispose: () => dispose(context.value, true)
|
|
2127
2156
|
});
|
|
2128
|
-
const handleHMR = (
|
|
2129
|
-
|
|
2157
|
+
const handleHMR = () => {
|
|
2158
|
+
const root = getRoot(props.canvas);
|
|
2159
|
+
if (root) root.hmrTick.value++;
|
|
2130
2160
|
};
|
|
2131
2161
|
const unmountCanvas = () => {
|
|
2162
|
+
const root = getRoot(props.canvas);
|
|
2163
|
+
if (!root) return;
|
|
2132
2164
|
const isTresScene = (value) => isScene(value) && "__tres" in value;
|
|
2133
2165
|
if (isTresScene(scene.value)) scene.value.__tres.isUnmounting = true;
|
|
2134
|
-
|
|
2166
|
+
root.renderer.render(null, scene.value);
|
|
2135
2167
|
dispose(context.value);
|
|
2168
|
+
deleteRoot(props.canvas);
|
|
2136
2169
|
};
|
|
2137
2170
|
const { camera, renderer } = context.value;
|
|
2138
2171
|
const { registerCamera, cameras, activeCamera, deregisterCamera } = camera;
|
|
@@ -2175,14 +2208,20 @@ var Context_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ define
|
|
|
2175
2208
|
});
|
|
2176
2209
|
});
|
|
2177
2210
|
renderer.onReady(() => {
|
|
2178
|
-
mountCustomRenderer(context.value
|
|
2211
|
+
mountCustomRenderer(context.value);
|
|
2179
2212
|
emit("ready", context.value);
|
|
2180
2213
|
if (!activeCamera.value) addDefaultCamera();
|
|
2181
2214
|
});
|
|
2182
2215
|
renderer.onError((error) => {
|
|
2183
2216
|
emit("error", error);
|
|
2184
2217
|
});
|
|
2185
|
-
if (import.meta.hot)
|
|
2218
|
+
if (import.meta.hot) {
|
|
2219
|
+
const hmrHandler = () => handleHMR();
|
|
2220
|
+
import.meta.hot.on("vite:afterUpdate", hmrHandler);
|
|
2221
|
+
onBeforeUnmount(() => {
|
|
2222
|
+
import.meta.hot?.off?.("vite:afterUpdate", hmrHandler);
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2186
2225
|
onMounted(async () => {
|
|
2187
2226
|
await promiseTimeout(3e3);
|
|
2188
2227
|
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.`);
|
|
@@ -2482,86 +2521,6 @@ const vDistanceTo = {
|
|
|
2482
2521
|
}
|
|
2483
2522
|
};
|
|
2484
2523
|
|
|
2485
|
-
//#endregion
|
|
2486
|
-
//#region ../../node_modules/.pnpm/three-stdlib@2.36.1_three@0.183.1/node_modules/three-stdlib/helpers/RectAreaLightHelper.js
|
|
2487
|
-
var RectAreaLightHelper = class extends Line {
|
|
2488
|
-
constructor(light, color) {
|
|
2489
|
-
const positions = [
|
|
2490
|
-
1,
|
|
2491
|
-
1,
|
|
2492
|
-
0,
|
|
2493
|
-
-1,
|
|
2494
|
-
1,
|
|
2495
|
-
0,
|
|
2496
|
-
-1,
|
|
2497
|
-
-1,
|
|
2498
|
-
0,
|
|
2499
|
-
1,
|
|
2500
|
-
-1,
|
|
2501
|
-
0,
|
|
2502
|
-
1,
|
|
2503
|
-
1,
|
|
2504
|
-
0
|
|
2505
|
-
];
|
|
2506
|
-
const geometry = new BufferGeometry();
|
|
2507
|
-
geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
|
|
2508
|
-
geometry.computeBoundingSphere();
|
|
2509
|
-
const material = new LineBasicMaterial({ fog: false });
|
|
2510
|
-
super(geometry, material);
|
|
2511
|
-
this.light = light;
|
|
2512
|
-
this.color = color;
|
|
2513
|
-
this.type = "RectAreaLightHelper";
|
|
2514
|
-
const positions2 = [
|
|
2515
|
-
1,
|
|
2516
|
-
1,
|
|
2517
|
-
0,
|
|
2518
|
-
-1,
|
|
2519
|
-
1,
|
|
2520
|
-
0,
|
|
2521
|
-
-1,
|
|
2522
|
-
-1,
|
|
2523
|
-
0,
|
|
2524
|
-
1,
|
|
2525
|
-
1,
|
|
2526
|
-
0,
|
|
2527
|
-
-1,
|
|
2528
|
-
-1,
|
|
2529
|
-
0,
|
|
2530
|
-
1,
|
|
2531
|
-
-1,
|
|
2532
|
-
0
|
|
2533
|
-
];
|
|
2534
|
-
const geometry2 = new BufferGeometry();
|
|
2535
|
-
geometry2.setAttribute("position", new Float32BufferAttribute(positions2, 3));
|
|
2536
|
-
geometry2.computeBoundingSphere();
|
|
2537
|
-
this.add(new Mesh(geometry2, new MeshBasicMaterial({
|
|
2538
|
-
side: BackSide,
|
|
2539
|
-
fog: false
|
|
2540
|
-
})));
|
|
2541
|
-
}
|
|
2542
|
-
updateMatrixWorld() {
|
|
2543
|
-
this.scale.set(.5 * this.light.width, .5 * this.light.height, 1);
|
|
2544
|
-
if (this.color !== void 0) {
|
|
2545
|
-
this.material.color.set(this.color);
|
|
2546
|
-
this.children[0].material.color.set(this.color);
|
|
2547
|
-
} else {
|
|
2548
|
-
this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);
|
|
2549
|
-
const c = this.material.color;
|
|
2550
|
-
const max = Math.max(c.r, c.g, c.b);
|
|
2551
|
-
if (max > 1) c.multiplyScalar(1 / max);
|
|
2552
|
-
this.children[0].material.color.copy(this.material.color);
|
|
2553
|
-
}
|
|
2554
|
-
this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld);
|
|
2555
|
-
this.children[0].matrixWorld.copy(this.matrixWorld);
|
|
2556
|
-
}
|
|
2557
|
-
dispose() {
|
|
2558
|
-
this.geometry.dispose();
|
|
2559
|
-
this.material.dispose();
|
|
2560
|
-
this.children[0].geometry.dispose();
|
|
2561
|
-
this.children[0].material.dispose();
|
|
2562
|
-
}
|
|
2563
|
-
};
|
|
2564
|
-
|
|
2565
2524
|
//#endregion
|
|
2566
2525
|
//#region src/directives/vLightHelper.ts
|
|
2567
2526
|
let CurrentHelper;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.8.
|
|
4
|
+
"version": "5.8.2",
|
|
5
5
|
"description": "Declarative ThreeJS using Vue Components",
|
|
6
6
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -45,39 +45,41 @@
|
|
|
45
45
|
"vue": ">=3.4"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@pmndrs/pointer-events": "^6.6.
|
|
49
|
-
"@vue/devtools-api": "^
|
|
50
|
-
"@vueuse/core": "^
|
|
51
|
-
"radashi": "^12.
|
|
48
|
+
"@pmndrs/pointer-events": "^6.6.30",
|
|
49
|
+
"@vue/devtools-api": "^8.1.2",
|
|
50
|
+
"@vueuse/core": "^14.3.0",
|
|
51
|
+
"radashi": "^12.9.1",
|
|
52
|
+
"three-stdlib": "^2.36.1"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@types/
|
|
55
|
-
"@
|
|
56
|
-
"@typescript-eslint/
|
|
57
|
-
"@
|
|
58
|
-
"@
|
|
59
|
-
"@vitest/
|
|
60
|
-
"@
|
|
61
|
-
"
|
|
62
|
-
"eslint
|
|
63
|
-
"
|
|
55
|
+
"@types/node": "^25.9.3",
|
|
56
|
+
"@types/three": "^0.184.1",
|
|
57
|
+
"@typescript-eslint/eslint-plugin": "^8.61.0",
|
|
58
|
+
"@typescript-eslint/parser": "^8.61.0",
|
|
59
|
+
"@vitejs/plugin-vue": "^6.0.7",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.8",
|
|
61
|
+
"@vitest/ui": "^4.1.8",
|
|
62
|
+
"@vue/test-utils": "^2.4.11",
|
|
63
|
+
"eslint": "^10.4.1",
|
|
64
|
+
"eslint-plugin-vue": "^10.9.2",
|
|
65
|
+
"jsdom": "^29.1.1",
|
|
64
66
|
"kolorist": "^1.8.0",
|
|
65
67
|
"pathe": "^2.0.3",
|
|
66
68
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
67
69
|
"rollup-plugin-copy": "^3.5.0",
|
|
68
|
-
"rollup-plugin-visualizer": "^
|
|
69
|
-
"three": "^0.
|
|
70
|
+
"rollup-plugin-visualizer": "^7.0.1",
|
|
71
|
+
"three": "^0.184.0",
|
|
70
72
|
"tsdown": "0.18.3",
|
|
71
|
-
"typescript": "^
|
|
72
|
-
"vite": "^
|
|
73
|
+
"typescript": "^6.0.3",
|
|
74
|
+
"vite": "^8.0.16",
|
|
73
75
|
"vite-plugin-banner": "^0.8.1",
|
|
74
76
|
"vite-plugin-dts": "4.5.4",
|
|
75
|
-
"vite-plugin-inspect": "^11.
|
|
76
|
-
"vitest": "
|
|
77
|
-
"vue": "^3.5.
|
|
77
|
+
"vite-plugin-inspect": "^11.4.1",
|
|
78
|
+
"vitest": "4.1.8",
|
|
79
|
+
"vue": "^3.5.38",
|
|
78
80
|
"vue-demi": "^0.14.10",
|
|
79
|
-
"vue-tsc": "^3.
|
|
80
|
-
"@tresjs/eslint-config": "1.
|
|
81
|
+
"vue-tsc": "^3.3.4",
|
|
82
|
+
"@tresjs/eslint-config": "1.6.0"
|
|
81
83
|
},
|
|
82
84
|
"nx": {
|
|
83
85
|
"implicitDependencies": [
|