@tresjs/core 5.1.0 → 5.1.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/chunk-QpvadvMP.js +30 -0
- package/dist/template-compiler-options.d.mts +17 -0
- package/dist/template-compiler-options.mjs +18 -0
- package/dist/tres.d.ts +1056 -0
- package/dist/tres.js +2349 -5573
- package/package.json +21 -26
- package/components.d.ts +0 -1
- package/composables.d.ts +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/src/components/TresCanvas.vue.d.ts +0 -94
- package/dist/src/components/index.d.ts +0 -2
- package/dist/src/composables/index.d.ts +0 -9
- package/dist/src/composables/useCamera/index.d.ts +0 -43
- package/dist/src/composables/useCreateRafLoop/index.d.ts +0 -14
- package/dist/src/composables/useEventManager/index.d.ts +0 -10
- package/dist/src/composables/useGraph/index.d.ts +0 -3
- package/dist/src/composables/useLoader/component.vue.d.ts +0 -38
- package/dist/src/composables/useLoader/index.d.ts +0 -51
- package/dist/src/composables/useLoop/index.d.ts +0 -14
- package/dist/src/composables/useRenderer/pixelRatio.d.ts +0 -4
- package/dist/src/composables/useRenderer/useRendererManager.d.ts +0 -194
- package/dist/src/composables/useSizes/index.d.ts +0 -11
- package/dist/src/composables/useTres/index.d.ts +0 -37
- package/dist/src/composables/useTresContextProvider/index.d.ts +0 -24
- package/dist/src/core/catalogue.d.ts +0 -9
- package/dist/src/core/nodeOps.d.ts +0 -4
- package/dist/src/core/revision.d.ts +0 -1
- package/dist/src/devtools/DevtoolsMessenger.d.ts +0 -53
- package/dist/src/devtools/highlight.d.ts +0 -7
- package/dist/src/devtools/index.d.ts +0 -2
- package/dist/src/devtools/inspectorHandlers.d.ts +0 -60
- package/dist/src/devtools/plugin.d.ts +0 -10
- package/dist/src/devtools/setupDevtools.d.ts +0 -14
- package/dist/src/devtools/types.d.ts +0 -90
- package/dist/src/devtools/utils.d.ts +0 -7
- package/dist/src/directives/index.d.ts +0 -4
- package/dist/src/directives/vDistanceTo.d.ts +0 -6
- package/dist/src/directives/vLightHelper.d.ts +0 -6
- package/dist/src/directives/vLog.d.ts +0 -6
- package/dist/src/index.d.ts +0 -25
- package/dist/src/types/index.d.ts +0 -137
- package/dist/src/utils/array.d.ts +0 -6
- package/dist/src/utils/createPriorityEventHook.d.ts +0 -15
- package/dist/src/utils/graph.d.ts +0 -15
- package/dist/src/utils/index.d.ts +0 -19
- package/dist/src/utils/is/dom.d.ts +0 -1
- package/dist/src/utils/is/index.d.ts +0 -4
- package/dist/src/utils/is/three.d.ts +0 -162
- package/dist/src/utils/is/tres.d.ts +0 -70
- package/dist/src/utils/is/typed.d.ts +0 -1
- package/dist/src/utils/is/util.d.ts +0 -1
- package/dist/src/utils/logger.d.ts +0 -25
- package/dist/src/utils/makeMap.d.ts +0 -9
- package/dist/src/utils/normalize.d.ts +0 -17
- package/dist/src/utils/perf.d.ts +0 -7
- package/dist/src/utils/pointerEvents.d.ts +0 -10
- package/dist/src/utils/primitive/createRetargetingProxy.d.ts +0 -1
- package/dist/src/utils/string.d.ts +0 -1
- package/dist/src/utils/template-compiler-options.d.ts +0 -8
- package/dist/src/utils/test-utils.d.ts +0 -2
- package/dist/src/utils/three.d.ts +0 -9
- package/types.d.ts +0 -1
- package/utils.d.ts +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.1",
|
|
5
5
|
"description": "Declarative ThreeJS using Vue Components",
|
|
6
6
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -19,27 +19,20 @@
|
|
|
19
19
|
],
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"exports": {
|
|
22
|
-
".":
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"default": "./dist/tres.js"
|
|
26
|
-
},
|
|
27
|
-
"./components": {
|
|
28
|
-
"types": "./dist/src/components/index.d.ts"
|
|
29
|
-
},
|
|
30
|
-
"./composables": {
|
|
31
|
-
"types": "./dist/src/composables/index.d.ts"
|
|
32
|
-
},
|
|
33
|
-
"./types": {
|
|
34
|
-
"types": "./dist/src/types/index.d.ts"
|
|
35
|
-
},
|
|
36
|
-
"./utils": {
|
|
37
|
-
"types": "./dist/src/utils/index.d.ts"
|
|
38
|
-
},
|
|
39
|
-
"./*": "./*"
|
|
22
|
+
".": "./dist/tres.js",
|
|
23
|
+
"./template-compiler-options": "./dist/template-compiler-options.mjs",
|
|
24
|
+
"./package.json": "./package.json"
|
|
40
25
|
},
|
|
26
|
+
"main": "./dist/tres.js",
|
|
41
27
|
"module": "./dist/tres.js",
|
|
42
|
-
"types": "./dist/
|
|
28
|
+
"types": "./dist/tres.d.ts",
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
"template-compiler-options": [
|
|
32
|
+
"dist/template-compiler-options.d.mts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
},
|
|
43
36
|
"files": [
|
|
44
37
|
"*.d.ts",
|
|
45
38
|
"dist"
|
|
@@ -55,7 +48,8 @@
|
|
|
55
48
|
"@pmndrs/pointer-events": "^6.6.17",
|
|
56
49
|
"@vue/devtools-api": "^7.7.2",
|
|
57
50
|
"@vueuse/core": "^13.9.0",
|
|
58
|
-
"radashi": "^12.6.2"
|
|
51
|
+
"radashi": "^12.6.2",
|
|
52
|
+
"typescript": "^5.8.3"
|
|
59
53
|
},
|
|
60
54
|
"devDependencies": {
|
|
61
55
|
"@types/three": "^0.180.0",
|
|
@@ -74,15 +68,16 @@
|
|
|
74
68
|
"rollup-plugin-copy": "^3.5.0",
|
|
75
69
|
"rollup-plugin-visualizer": "^6.0.3",
|
|
76
70
|
"three": "^0.180.0",
|
|
77
|
-
"
|
|
71
|
+
"tsdown": "0.16.1",
|
|
72
|
+
"vite": "^7.1.9",
|
|
78
73
|
"vite-plugin-banner": "^0.8.1",
|
|
79
74
|
"vite-plugin-dts": "4.5.4",
|
|
80
75
|
"vite-plugin-inspect": "^11.3.3",
|
|
81
76
|
"vitest": "3.2.4",
|
|
82
|
-
"vue": "^3.5.
|
|
77
|
+
"vue": "^3.5.22",
|
|
83
78
|
"vue-demi": "^0.14.10",
|
|
84
|
-
"vue-tsc": "^3.
|
|
85
|
-
"@tresjs/eslint-config": "1.5.
|
|
79
|
+
"vue-tsc": "^3.1.1",
|
|
80
|
+
"@tresjs/eslint-config": "1.5.1"
|
|
86
81
|
},
|
|
87
82
|
"nx": {
|
|
88
83
|
"implicitDependencies": [
|
|
@@ -90,7 +85,7 @@
|
|
|
90
85
|
]
|
|
91
86
|
},
|
|
92
87
|
"scripts": {
|
|
93
|
-
"build": "
|
|
88
|
+
"build": "tsdown",
|
|
94
89
|
"test": "vitest",
|
|
95
90
|
"test:ci": "vitest run",
|
|
96
91
|
"test:ui": "vitest --ui --coverage.enabled=true",
|
package/components.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/src/components/index.js'
|
package/composables.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../../dist/src/composables/index.js'
|
package/dist/index.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { TresCamera, TresContextWithClock } from '../types/';
|
|
2
|
-
import { PointerEvent } from '@pmndrs/pointer-events';
|
|
3
|
-
import { RendererOptions, TresContext } from '../composables';
|
|
4
|
-
import * as THREE from 'three';
|
|
5
|
-
export interface TresCanvasProps extends RendererOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Custom camera instance to use as main camera
|
|
8
|
-
* If not provided, a default PerspectiveCamera will be created
|
|
9
|
-
*/
|
|
10
|
-
camera?: TresCamera;
|
|
11
|
-
/**
|
|
12
|
-
* Whether the canvas should be sized to the window
|
|
13
|
-
* When true, canvas will be fixed positioned and full viewport size
|
|
14
|
-
* @default false
|
|
15
|
-
*/
|
|
16
|
-
windowSize?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Whether to enable the provide/inject bridge between Vue and TresJS
|
|
19
|
-
* When true, Vue's provide/inject will work across the TresJS boundary
|
|
20
|
-
* @default true
|
|
21
|
-
*/
|
|
22
|
-
enableProvideBridge?: boolean;
|
|
23
|
-
}
|
|
24
|
-
declare const _default: __VLS_WithTemplateSlots<import('vue').DefineComponent<TresCanvasProps, {
|
|
25
|
-
context: import('vue').ShallowRef<TresContext | null, TresContext | null>;
|
|
26
|
-
dispose: () => void;
|
|
27
|
-
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
28
|
-
render: (context: TresContext) => any;
|
|
29
|
-
pointermove: (event: PointerEvent<MouseEvent>) => any;
|
|
30
|
-
pointercancel: (event: PointerEvent<MouseEvent>) => any;
|
|
31
|
-
pointerdown: (event: PointerEvent<MouseEvent>) => any;
|
|
32
|
-
pointerup: (event: PointerEvent<MouseEvent>) => any;
|
|
33
|
-
pointerenter: (event: PointerEvent<MouseEvent>) => any;
|
|
34
|
-
pointerleave: (event: PointerEvent<MouseEvent>) => any;
|
|
35
|
-
pointerover: (event: PointerEvent<MouseEvent>) => any;
|
|
36
|
-
pointerout: (event: PointerEvent<MouseEvent>) => any;
|
|
37
|
-
click: (event: PointerEvent<MouseEvent>) => any;
|
|
38
|
-
dblclick: (event: PointerEvent<MouseEvent>) => any;
|
|
39
|
-
contextmenu: (event: PointerEvent<MouseEvent>) => any;
|
|
40
|
-
wheel: (event: PointerEvent<MouseEvent>) => any;
|
|
41
|
-
lostpointercapture: (event: PointerEvent<MouseEvent>) => any;
|
|
42
|
-
loop: (context: TresContextWithClock) => any;
|
|
43
|
-
ready: (context: TresContext) => any;
|
|
44
|
-
pointermissed: (event: PointerEvent<MouseEvent>) => any;
|
|
45
|
-
beforeLoop: (context: TresContextWithClock) => any;
|
|
46
|
-
}, string, import('vue').PublicProps, Readonly<TresCanvasProps> & Readonly<{
|
|
47
|
-
onRender?: ((context: TresContext) => any) | undefined;
|
|
48
|
-
onPointermove?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
49
|
-
onPointercancel?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
50
|
-
onPointerdown?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
51
|
-
onPointerup?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
52
|
-
onPointerenter?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
53
|
-
onPointerleave?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
54
|
-
onPointerover?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
55
|
-
onPointerout?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
56
|
-
onClick?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
57
|
-
onDblclick?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
58
|
-
onContextmenu?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
59
|
-
onWheel?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
60
|
-
onLostpointercapture?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
61
|
-
onLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
62
|
-
onReady?: ((context: TresContext) => any) | undefined;
|
|
63
|
-
onPointermissed?: ((event: PointerEvent<MouseEvent>) => any) | undefined;
|
|
64
|
-
onBeforeLoop?: ((context: TresContextWithClock) => any) | undefined;
|
|
65
|
-
}>, {
|
|
66
|
-
antialias: boolean;
|
|
67
|
-
stencil: boolean;
|
|
68
|
-
depth: boolean;
|
|
69
|
-
logarithmicDepthBuffer: boolean;
|
|
70
|
-
preserveDrawingBuffer: boolean;
|
|
71
|
-
alpha: boolean;
|
|
72
|
-
failIfMajorPerformanceCaveat: boolean;
|
|
73
|
-
clearColor: THREE.ColorRepresentation;
|
|
74
|
-
clearAlpha: number;
|
|
75
|
-
shadows: boolean;
|
|
76
|
-
toneMapping: THREE.ToneMapping;
|
|
77
|
-
shadowMapType: THREE.ShadowMapType;
|
|
78
|
-
useLegacyLights: boolean;
|
|
79
|
-
renderMode: "always" | "on-demand" | "manual";
|
|
80
|
-
windowSize: boolean;
|
|
81
|
-
enableProvideBridge: boolean;
|
|
82
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
83
|
-
canvasRef: HTMLCanvasElement;
|
|
84
|
-
}, HTMLCanvasElement>, Readonly<{
|
|
85
|
-
default: () => any;
|
|
86
|
-
}> & {
|
|
87
|
-
default: () => any;
|
|
88
|
-
}>;
|
|
89
|
-
export default _default;
|
|
90
|
-
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
91
|
-
new (): {
|
|
92
|
-
$slots: S;
|
|
93
|
-
};
|
|
94
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as UseLoader } from './useLoader/component.vue';
|
|
2
|
-
export * from './useCamera';
|
|
3
|
-
export * from './useGraph';
|
|
4
|
-
export * from './useLoader';
|
|
5
|
-
export * from './useLoop';
|
|
6
|
-
export * from './useRenderer/useRendererManager';
|
|
7
|
-
export * from './useTres';
|
|
8
|
-
export { type TresContext, useTresContext, useTresContextProvider } from './useTresContextProvider';
|
|
9
|
-
export { UseLoader };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { TresContext } from '../useTresContextProvider';
|
|
2
|
-
import { ComputedRef, Ref } from 'vue';
|
|
3
|
-
import { TresCamera } from '../../types';
|
|
4
|
-
/**
|
|
5
|
-
* Interface for the return value of the useCamera composable
|
|
6
|
-
*/
|
|
7
|
-
export interface UseCameraReturn {
|
|
8
|
-
activeCamera: ComputedRef<TresCamera>;
|
|
9
|
-
/**
|
|
10
|
-
* The list of cameras
|
|
11
|
-
*/
|
|
12
|
-
cameras: Ref<TresCamera[]>;
|
|
13
|
-
/**
|
|
14
|
-
* Register a camera
|
|
15
|
-
* @param camera - The camera to register
|
|
16
|
-
* @param active - Whether to set the camera as active
|
|
17
|
-
*/
|
|
18
|
-
registerCamera: (camera: TresCamera, active?: boolean) => void;
|
|
19
|
-
/**
|
|
20
|
-
* Deregister a camera
|
|
21
|
-
* @param camera - The camera to deregister
|
|
22
|
-
*/
|
|
23
|
-
deregisterCamera: (camera: TresCamera) => void;
|
|
24
|
-
/**
|
|
25
|
-
* Set the active camera
|
|
26
|
-
* @param cameraOrUuid - The camera or its UUID to set as active
|
|
27
|
-
*/
|
|
28
|
-
setActiveCamera: (cameraOrUuid: string | TresCamera) => void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Interface for the parameters of the useCamera composable
|
|
32
|
-
*/
|
|
33
|
-
interface UseCameraParams {
|
|
34
|
-
sizes: TresContext['sizes'];
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Composable for managing cameras in a Three.js scene
|
|
38
|
-
* @param params - The parameters for the composable
|
|
39
|
-
* @param params.sizes - The sizes object containing window dimensions
|
|
40
|
-
* @returns The camera management functions and state
|
|
41
|
-
*/
|
|
42
|
-
export declare const useCameraManager: ({ sizes }: UseCameraParams) => UseCameraReturn;
|
|
43
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface RafLoopContext {
|
|
2
|
-
delta: number;
|
|
3
|
-
elapsed: number;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* @param cycleFn the function that is called before the after event hook is triggered and after the before event hook is triggered.
|
|
7
|
-
*/
|
|
8
|
-
export declare const useCreateRafLoop: (cycleFn: () => void) => {
|
|
9
|
-
start: () => void;
|
|
10
|
-
stop: () => void;
|
|
11
|
-
isActive: Readonly<import('vue').ShallowRef<boolean>>;
|
|
12
|
-
onBeforeLoop: import('@vueuse/core').EventHookOn<RafLoopContext>;
|
|
13
|
-
onLoop: import('@vueuse/core').EventHookOn<RafLoopContext>;
|
|
14
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PointerEvent, PointerEventsMap } from '@pmndrs/pointer-events';
|
|
2
|
-
import { Event, Object3D, Object3DEventMap } from 'three';
|
|
3
|
-
import { MaybeRef } from 'vue';
|
|
4
|
-
import { TresContext } from '../useTresContextProvider';
|
|
5
|
-
export declare function useEventManager({ canvas, contextParts: { scene, camera, renderer }, }: {
|
|
6
|
-
canvas: MaybeRef<HTMLCanvasElement>;
|
|
7
|
-
contextParts: Pick<TresContext, 'scene' | 'camera' | 'renderer'>;
|
|
8
|
-
}): {
|
|
9
|
-
onPointerMissed: import('@vueuse/core').EventHookOn<PointerEvent<MouseEvent> & Event<"click", Object3D<Object3DEventMap & PointerEventsMap>>>;
|
|
10
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LoadingManager } from 'three';
|
|
2
|
-
import { LoaderProto } from './index';
|
|
3
|
-
import { TresObjectMap } from '../../utils/graph';
|
|
4
|
-
declare const _default: <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_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
|
-
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
|
|
6
|
-
readonly onLoaded?: ((result: T) => any) | undefined;
|
|
7
|
-
readonly onError?: ((error: unknown) => any) | undefined;
|
|
8
|
-
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onError" | "onLoaded"> & {
|
|
9
|
-
/**
|
|
10
|
-
* The THREE.js loader to use
|
|
11
|
-
*/
|
|
12
|
-
loader: LoaderProto<T>;
|
|
13
|
-
/**
|
|
14
|
-
* Path to resource
|
|
15
|
-
*/
|
|
16
|
-
path: string;
|
|
17
|
-
/**
|
|
18
|
-
* Optional THREE.js LoadingManager
|
|
19
|
-
*/
|
|
20
|
-
manager?: LoadingManager;
|
|
21
|
-
} & Partial<{}>> & import('vue').PublicProps;
|
|
22
|
-
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
23
|
-
attrs: any;
|
|
24
|
-
slots: {
|
|
25
|
-
default?(_: {
|
|
26
|
-
state: import('vue').UnwrapRef<T>;
|
|
27
|
-
isLoading: boolean;
|
|
28
|
-
error: unknown;
|
|
29
|
-
}): any;
|
|
30
|
-
};
|
|
31
|
-
emit: ((evt: "loaded", result: T) => void) & ((evt: "error", error: unknown) => void);
|
|
32
|
-
}>) => import('vue').VNode & {
|
|
33
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
34
|
-
};
|
|
35
|
-
export default _default;
|
|
36
|
-
type __VLS_PrettifyLocal<T> = {
|
|
37
|
-
[K in keyof T]: T[K];
|
|
38
|
-
} & {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { UseAsyncStateOptions, UseAsyncStateReturn } from '@vueuse/core';
|
|
2
|
-
import { Loader, LoadingManager } from 'three';
|
|
3
|
-
import { MaybeRef } from 'vue';
|
|
4
|
-
export interface LoaderMethods {
|
|
5
|
-
setDRACOLoader: (dracoLoader: any) => void;
|
|
6
|
-
setMeshoptDecoder: (meshoptDecoder: any) => void;
|
|
7
|
-
setKTX2Loader: (ktx2Loader: any) => void;
|
|
8
|
-
}
|
|
9
|
-
export type TresLoader<T> = Loader & Partial<LoaderMethods> & {
|
|
10
|
-
load: (url: string, onLoad: (result: T) => void, onProgress?: (event: ProgressEvent<EventTarget>) => void, onError?: (err: unknown) => void) => void;
|
|
11
|
-
loadAsync: (url: string, onProgress?: (event: ProgressEvent) => void) => Promise<T>;
|
|
12
|
-
};
|
|
13
|
-
export type LoaderProto<T> = new (manager?: LoadingManager) => TresLoader<T>;
|
|
14
|
-
export interface TresLoaderOptions<T, Shallow extends boolean> {
|
|
15
|
-
manager?: LoadingManager;
|
|
16
|
-
extensions?: (loader: TresLoader<T>) => void;
|
|
17
|
-
initialValue?: T;
|
|
18
|
-
asyncOptions?: UseAsyncStateOptions<Shallow, any | null>;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Return type for the useLoader composable
|
|
22
|
-
* @template T - The type of the loaded asset (e.g., GLTF, Texture, etc.)
|
|
23
|
-
* @template Shallow - Whether to use shallow reactivity for better performance
|
|
24
|
-
* @extends {UseAsyncStateReturn<T, [string], Shallow>} - Extends VueUse's useAsyncState return type
|
|
25
|
-
*/
|
|
26
|
-
export type UseLoaderReturn<T, Shallow extends boolean> = UseAsyncStateReturn<T, [string], Shallow> & {
|
|
27
|
-
/**
|
|
28
|
-
* Loads a new asset from the given path
|
|
29
|
-
* @param path - The URL or path to the asset to load
|
|
30
|
-
*/
|
|
31
|
-
load: (path: string) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Progress of the loading process
|
|
34
|
-
* @property loaded - The number of bytes loaded
|
|
35
|
-
* @property total - The total number of bytes to load
|
|
36
|
-
* @property percentage - The percentage of the loading process
|
|
37
|
-
*/
|
|
38
|
-
progress: {
|
|
39
|
-
loaded: number;
|
|
40
|
-
total: number;
|
|
41
|
-
percentage: number;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Vue composable for loading 3D models using Three.js loaders
|
|
46
|
-
* @param Loader - The Three.js loader constructor
|
|
47
|
-
* @param path - The path to the model file
|
|
48
|
-
* @param options - Optional configuration for the loader
|
|
49
|
-
* @returns UseAsyncState composable with the loaded model
|
|
50
|
-
*/
|
|
51
|
-
export declare function useLoader<T, Shallow extends boolean = false>(Loader: LoaderProto<T>, path: MaybeRef<string>, options?: TresLoaderOptions<T, Shallow>): UseLoaderReturn<T, Shallow>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { RafLoopContext } from '../useCreateRafLoop';
|
|
2
|
-
import { TresPartialContext } from '../useTres';
|
|
3
|
-
export type LoopContext = RafLoopContext & TresPartialContext;
|
|
4
|
-
/**
|
|
5
|
-
* Composable that provides control over the render loop and animation lifecycle.
|
|
6
|
-
*/
|
|
7
|
-
export declare const useLoop: () => {
|
|
8
|
-
stop: () => void;
|
|
9
|
-
start: () => void;
|
|
10
|
-
isActive: Readonly<import('vue').ShallowRef<boolean>>;
|
|
11
|
-
onBeforeRender: import('../../utils/createPriorityEventHook').PriorityEventHookOn<LoopContext>;
|
|
12
|
-
onRender: import('../../utils/createPriorityEventHook').PriorityEventHookOn<LoopContext>;
|
|
13
|
-
render: (fn: import('..').RenderFunction) => void;
|
|
14
|
-
};
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { ColorRepresentation, ColorSpace, ShadowMapType, ToneMapping, WebGLRenderer } from 'three';
|
|
2
|
-
import { TresContext } from '../useTresContextProvider';
|
|
3
|
-
import { MaybeRef, Reactive, ShallowRef } from 'vue';
|
|
4
|
-
import { Renderer } from 'three/webgpu';
|
|
5
|
-
import { SizesType } from '../useSizes';
|
|
6
|
-
import { UseCameraReturn } from '../useCamera';
|
|
7
|
-
import { TresScene } from '../../types';
|
|
8
|
-
/**
|
|
9
|
-
* If set to 'on-demand', the scene will only be rendered when the current frame is invalidated
|
|
10
|
-
* If set to 'manual', the scene will only be rendered when advance() is called
|
|
11
|
-
* If set to 'always', the scene will be rendered every frame
|
|
12
|
-
*/
|
|
13
|
-
export type RenderMode = 'always' | 'on-demand' | 'manual';
|
|
14
|
-
export type RenderFunction = (notifySuccess: () => void) => void;
|
|
15
|
-
export type TresRenderer = WebGLRenderer | Renderer;
|
|
16
|
-
export interface RendererOptions {
|
|
17
|
-
/**
|
|
18
|
-
* WebGL Context options (Readonly because they are passed to the renderer constructor)
|
|
19
|
-
* They can't be changed after the renderer is created because they are passed to the canvas context
|
|
20
|
-
*/
|
|
21
|
-
antialias?: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Enables stencil buffer with 8 bits.
|
|
24
|
-
* Required for stencil-based operations like shadow volumes or post-processing effects.
|
|
25
|
-
* @readonly
|
|
26
|
-
* @default true
|
|
27
|
-
*/
|
|
28
|
-
stencil?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Enables depth buffer with at least 16 bits.
|
|
31
|
-
* Required for proper 3D rendering and depth testing.
|
|
32
|
-
* @readonly
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
|
-
depth?: boolean;
|
|
36
|
-
/**
|
|
37
|
-
* Sets the shader precision of the renderer.
|
|
38
|
-
* @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
|
|
39
|
-
* @default 'highp'
|
|
40
|
-
*/
|
|
41
|
-
precision?: 'highp' | 'mediump' | 'lowp';
|
|
42
|
-
/**
|
|
43
|
-
* Enables logarithmic depth buffer. Useful for scenes with large differences in scale.
|
|
44
|
-
* Helps prevent z-fighting in scenes with objects very close and very far from the camera.
|
|
45
|
-
* @readonly
|
|
46
|
-
* @default false
|
|
47
|
-
*/
|
|
48
|
-
logarithmicDepthBuffer?: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Preserves the buffers until manually cleared or overwritten.
|
|
51
|
-
* Needed for screenshots or when reading pixels from the canvas.
|
|
52
|
-
* Warning: This may impact performance.
|
|
53
|
-
* @readonly
|
|
54
|
-
* @default false
|
|
55
|
-
*/
|
|
56
|
-
preserveDrawingBuffer?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Power preference for the renderer.
|
|
59
|
-
* Power preference for the renderer.
|
|
60
|
-
* - `default`: Automatically chooses the most suitable power setting.
|
|
61
|
-
* - `high-performance`: Prioritizes rendering performance.
|
|
62
|
-
* - `low-power`: Tries to reduce power usage.
|
|
63
|
-
* @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
|
|
64
|
-
* @default 'default'
|
|
65
|
-
* @readonly
|
|
66
|
-
*/
|
|
67
|
-
powerPreference?: WebGLPowerPreference;
|
|
68
|
-
/**
|
|
69
|
-
* Whether to create the WebGL context with an alpha buffer.
|
|
70
|
-
* This is a WebGL context option that must be set during context creation and cannot be changed later.
|
|
71
|
-
* When true, the canvas can be transparent, showing content behind it.
|
|
72
|
-
* @readonly
|
|
73
|
-
* @default false
|
|
74
|
-
*/
|
|
75
|
-
alpha?: boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Whether to premultiply the alpha of the canvas.
|
|
78
|
-
* @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
|
|
79
|
-
* @default true
|
|
80
|
-
*/
|
|
81
|
-
premultipliedAlpha?: boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Whether to fail if the major performance caveat is detected.
|
|
84
|
-
* @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
|
|
85
|
-
* @default false
|
|
86
|
-
*/
|
|
87
|
-
failIfMajorPerformanceCaveat?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* WebGL options with set methods
|
|
90
|
-
* @see {@link https://threejs.org/docs/#api/en/renderers/WebGLRenderer}
|
|
91
|
-
*/
|
|
92
|
-
/**
|
|
93
|
-
* Clear color for the canvas
|
|
94
|
-
* Can include alpha value (e.g. '#00808000' for fully transparent teal)
|
|
95
|
-
*/
|
|
96
|
-
clearColor?: ColorRepresentation;
|
|
97
|
-
/**
|
|
98
|
-
* The opacity of the clear color (0-1)
|
|
99
|
-
* Controls the transparency of the clear color
|
|
100
|
-
* @default 1
|
|
101
|
-
*/
|
|
102
|
-
clearAlpha?: number;
|
|
103
|
-
/**
|
|
104
|
-
* Enable shadow rendering in the scene
|
|
105
|
-
* @default false
|
|
106
|
-
*/
|
|
107
|
-
shadows?: boolean;
|
|
108
|
-
/**
|
|
109
|
-
* Tone mapping technique to use for the scene
|
|
110
|
-
* - `NoToneMapping`: No tone mapping is applied.
|
|
111
|
-
* - `LinearToneMapping`: Linear tone mapping.
|
|
112
|
-
* - `ReinhardToneMapping`: Reinhard tone mapping.
|
|
113
|
-
* - `CineonToneMapping`: Cineon tone mapping.
|
|
114
|
-
* - `ACESFilmicToneMapping`: ACES Filmic tone mapping.
|
|
115
|
-
* - `AgXToneMapping`: AgX tone mapping.
|
|
116
|
-
* - `NeutralToneMapping`: Neutral tone mapping.
|
|
117
|
-
* @see {@link https://threejs.org/docs/#api/en/constants/Renderer}
|
|
118
|
-
* @default ACESFilmicToneMapping (Opinionated default by TresJS)
|
|
119
|
-
*/
|
|
120
|
-
toneMapping?: ToneMapping;
|
|
121
|
-
/**
|
|
122
|
-
* Type of shadow map to use for shadow calculations
|
|
123
|
-
* - `BasicShadowMap`: Basic shadow map.
|
|
124
|
-
* - `PCFShadowMap`: Percentage-Closer Filtering shadow map.
|
|
125
|
-
* - `PCFSoftShadowMap`: Percentage-Closer Filtering soft shadow map.
|
|
126
|
-
* - `VSMShadowMap`: Variance shadow map.
|
|
127
|
-
* @see {@link https://threejs.org/docs/#api/en/constants/Renderer}
|
|
128
|
-
* @default PCFSoftShadowMap (Opinionated default by TresJS)
|
|
129
|
-
*/
|
|
130
|
-
shadowMapType?: ShadowMapType;
|
|
131
|
-
/**
|
|
132
|
-
* Whether to use legacy lights system instead of the new one
|
|
133
|
-
* @deprecated Use `useLegacyLights: false` for the new lighting system
|
|
134
|
-
*/
|
|
135
|
-
useLegacyLights?: boolean;
|
|
136
|
-
/**
|
|
137
|
-
* Color space for the output render
|
|
138
|
-
* @see {@link https://threejs.org/docs/#api/en/constants/Renderer}
|
|
139
|
-
*/
|
|
140
|
-
outputColorSpace?: ColorSpace;
|
|
141
|
-
/**
|
|
142
|
-
* Exposure level of tone mapping
|
|
143
|
-
* @default 1
|
|
144
|
-
*/
|
|
145
|
-
toneMappingExposure?: number;
|
|
146
|
-
/**
|
|
147
|
-
* Rendering mode for the canvas
|
|
148
|
-
* - 'always': Renders every frame
|
|
149
|
-
* - 'on-demand': Renders only when changes are detected
|
|
150
|
-
* - 'manual': Renders only when explicitly called
|
|
151
|
-
* @default 'always'
|
|
152
|
-
*/
|
|
153
|
-
renderMode?: 'always' | 'on-demand' | 'manual';
|
|
154
|
-
/**
|
|
155
|
-
* Device Pixel Ratio for the renderer
|
|
156
|
-
* Can be a single number or a tuple defining a range [min, max]
|
|
157
|
-
*/
|
|
158
|
-
dpr?: number | [number, number];
|
|
159
|
-
/**
|
|
160
|
-
* Custom WebGL renderer instance
|
|
161
|
-
* Allows using a pre-configured renderer instead of creating a new one
|
|
162
|
-
*/
|
|
163
|
-
renderer?: (ctx: TresRendererSetupContext) => TresRenderer;
|
|
164
|
-
}
|
|
165
|
-
export interface TresRendererSetupContext {
|
|
166
|
-
sizes: SizesType;
|
|
167
|
-
scene: ShallowRef<TresScene>;
|
|
168
|
-
camera: UseCameraReturn;
|
|
169
|
-
canvas: MaybeRef<HTMLCanvasElement>;
|
|
170
|
-
}
|
|
171
|
-
export interface UseRendererOptions {
|
|
172
|
-
scene: ShallowRef<TresScene>;
|
|
173
|
-
canvas: MaybeRef<HTMLCanvasElement>;
|
|
174
|
-
options: Reactive<RendererOptions>;
|
|
175
|
-
contextParts: Pick<TresContext, 'sizes' | 'camera'>;
|
|
176
|
-
}
|
|
177
|
-
export declare function useRendererManager({ scene, canvas, options, contextParts: { sizes, camera }, }: UseRendererOptions): {
|
|
178
|
-
loop: {
|
|
179
|
-
start: () => void;
|
|
180
|
-
stop: () => void;
|
|
181
|
-
isActive: Readonly<ShallowRef<boolean>>;
|
|
182
|
-
onBeforeLoop: import('@vueuse/core').EventHookOn<import('../useCreateRafLoop').RafLoopContext>;
|
|
183
|
-
onLoop: import('@vueuse/core').EventHookOn<import('../useCreateRafLoop').RafLoopContext>;
|
|
184
|
-
};
|
|
185
|
-
instance: TresRenderer;
|
|
186
|
-
advance: () => void;
|
|
187
|
-
onReady: import('@vueuse/core').EventHookOn<TresRenderer>;
|
|
188
|
-
onRender: import('@vueuse/core').EventHookOn<TresRenderer>;
|
|
189
|
-
invalidate: (amountOfFramesToInvalidate?: number) => void;
|
|
190
|
-
canBeInvalidated: import('vue').ComputedRef<boolean>;
|
|
191
|
-
mode: "always" | "on-demand" | "manual" | undefined;
|
|
192
|
-
replaceRenderFunction: (fn: RenderFunction) => void;
|
|
193
|
-
};
|
|
194
|
-
export type UseRendererManagerReturn = ReturnType<typeof useRendererManager>;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ComputedRef, MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
2
|
-
export interface SizesType {
|
|
3
|
-
height: Readonly<Ref<number>>;
|
|
4
|
-
width: Readonly<Ref<number>>;
|
|
5
|
-
aspectRatio: ComputedRef<number>;
|
|
6
|
-
}
|
|
7
|
-
export default function useSizes(windowSize: MaybeRefOrGetter<boolean>, canvas: MaybeRef<HTMLCanvasElement>, debounceMs?: number): {
|
|
8
|
-
height: Readonly<Ref<number, number>>;
|
|
9
|
-
width: Readonly<Ref<number, number>>;
|
|
10
|
-
aspectRatio: ComputedRef<number>;
|
|
11
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { ComputedRef } from 'vue';
|
|
2
|
-
import { TresContext } from '../useTresContextProvider';
|
|
3
|
-
import { Camera } from 'three';
|
|
4
|
-
import { TresRenderer } from '..';
|
|
5
|
-
export interface TresPartialContext extends Omit<TresContext, 'renderer' | 'camera'> {
|
|
6
|
-
/**
|
|
7
|
-
* The renderer instance
|
|
8
|
-
*
|
|
9
|
-
* @type {TresRenderer}
|
|
10
|
-
* @memberof TresPartialContext
|
|
11
|
-
*/
|
|
12
|
-
renderer: TresRenderer;
|
|
13
|
-
/**
|
|
14
|
-
* The current active camera
|
|
15
|
-
*
|
|
16
|
-
* @type {ComputedRef<Camera | undefined>}
|
|
17
|
-
* @memberof TresPartialContext
|
|
18
|
-
*/
|
|
19
|
-
camera: ComputedRef<Camera | undefined>;
|
|
20
|
-
/**
|
|
21
|
-
* Marks the scene as needing an update in the next frame.
|
|
22
|
-
* This is used in on-demand rendering mode to schedule a render.
|
|
23
|
-
*
|
|
24
|
-
* @type {() => void}
|
|
25
|
-
* @memberof TresPartialContext
|
|
26
|
-
*/
|
|
27
|
-
invalidate: () => void;
|
|
28
|
-
/**
|
|
29
|
-
* Manually advances the render loop by one frame.
|
|
30
|
-
* This is particularly useful in manual rendering mode where you want explicit control over when frames are rendered.
|
|
31
|
-
*
|
|
32
|
-
* @type {() => void}
|
|
33
|
-
* @memberof TresPartialContext
|
|
34
|
-
*/
|
|
35
|
-
advance: () => void;
|
|
36
|
-
}
|
|
37
|
-
export declare function useTres(): TresPartialContext;
|