@tresjs/core 4.3.5 → 5.0.0-next.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/src/components/TresCanvas.vue.d.ts +31 -31
- package/dist/src/composables/index.d.ts +5 -8
- package/dist/src/composables/useCamera/index.d.ts +41 -8554
- package/dist/src/composables/useGraph/index.d.ts +4 -0
- package/dist/src/composables/useLoader/component.vue.d.ts +31 -17
- package/dist/src/composables/useLoader/index.d.ts +44 -37
- package/dist/src/composables/useRaycaster/index.d.ts +1 -1
- package/dist/src/composables/useRenderer/{index.d.ts → useRendererManager.d.ts} +19 -11
- package/dist/src/composables/useTres/index.d.ts +36 -0
- package/dist/src/composables/useTresContextProvider/index.d.ts +8 -52
- package/dist/src/composables/useTresEventManager/index.d.ts +5 -2
- package/dist/src/core/loop.d.ts +0 -2
- package/dist/src/devtools/inspectorHandlers.d.ts +60 -0
- package/dist/src/devtools/plugin.d.ts +3 -8
- package/dist/src/devtools/setupDevtools.d.ts +14 -0
- package/dist/src/devtools/types.d.ts +90 -0
- package/dist/src/index.d.ts +2 -0
- package/dist/src/types/index.d.ts +8 -3
- package/dist/src/utils/createPriorityEventHook.d.ts +1 -1
- package/dist/src/utils/graph.d.ts +14 -0
- package/dist/src/utils/index.d.ts +1 -4
- package/dist/src/utils/is.d.ts +283 -24
- package/dist/src/utils/logger.d.ts +25 -0
- package/dist/src/utils/perf.d.ts +1 -0
- package/dist/tres.js +4652 -1318
- package/package.json +7 -6
- package/dist/src/composables/useLogger.d.ts +0 -11
- package/dist/src/composables/useSeek/index.d.ts +0 -20
- package/dist/src/composables/useTexture/component.vue.d.ts +0 -29
- package/dist/src/composables/useTexture/index.d.ts +0 -103
- package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -4
- package/dist/src/composables/useTresReady/index.d.ts +0 -7
- package/dist/tres.umd.cjs +0 -8
|
@@ -1,24 +1,38 @@
|
|
|
1
|
+
import { LoadingManager } from 'three';
|
|
1
2
|
import { LoaderProto } from './index';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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>, "onLoaded" | "onError"> & {
|
|
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;
|
|
8
24
|
slots: {
|
|
9
25
|
default?(_: {
|
|
10
|
-
|
|
26
|
+
state: import('vue').UnwrapRef<T>;
|
|
27
|
+
isLoading: boolean;
|
|
28
|
+
error: unknown;
|
|
11
29
|
}): any;
|
|
12
30
|
};
|
|
13
|
-
|
|
14
|
-
|
|
31
|
+
emit: ((evt: "loaded", result: T) => void) & ((evt: "error", error: unknown) => void);
|
|
32
|
+
}>) => import('vue').VNode & {
|
|
33
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
15
34
|
};
|
|
16
|
-
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
17
|
-
declare const __VLS_component: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
18
|
-
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
19
35
|
export default _default;
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
};
|
|
36
|
+
type __VLS_PrettifyLocal<T> = {
|
|
37
|
+
[K in keyof T]: T[K];
|
|
38
|
+
} & {};
|
|
@@ -1,44 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
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
|
+
};
|
|
6
13
|
export type LoaderProto<T> = new (manager?: LoadingManager) => TresLoader<T>;
|
|
7
|
-
export
|
|
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
|
+
}
|
|
8
20
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
13
|
-
* @return { [key: string]: any }
|
|
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
|
|
14
25
|
*/
|
|
15
|
-
export
|
|
16
|
-
|
|
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
|
+
};
|
|
17
43
|
};
|
|
18
|
-
export type Extensions<T extends {
|
|
19
|
-
prototype: LoaderProto<any>;
|
|
20
|
-
}> = (loader: T['prototype']) => void;
|
|
21
44
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
*
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { useLoader } from '@tresjs/core'
|
|
29
|
-
* import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'
|
|
30
|
-
*
|
|
31
|
-
* const { scene } = await useLoader(THREE.GLTFLoader, 'path/to/asset.gltf')
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @export
|
|
35
|
-
* @template LoaderProto<T>
|
|
36
|
-
* @template string | string[],
|
|
37
|
-
* @param {LoaderProto<T>} Loader
|
|
38
|
-
* @param {string | string[],} url
|
|
39
|
-
* @param {Extensions<TresLoader<T>>} [extensions]
|
|
40
|
-
* @param {(event: ProgressEvent<EventTarget>) => void} [onProgress]
|
|
41
|
-
* @param {(proto: TresLoader<T>) => void} [cb]
|
|
42
|
-
* @return {*}
|
|
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
|
|
43
50
|
*/
|
|
44
|
-
export declare function useLoader<T>(Loader: LoaderProto<T>,
|
|
51
|
+
export declare function useLoader<T, Shallow extends boolean = false>(Loader: LoaderProto<T>, path: MaybeRef<string>, options?: TresLoaderOptions<T, Shallow>): UseLoaderReturn<T, Shallow>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TresEvent, TresInstance } from 'src/types';
|
|
2
1
|
import { Intersection, Object3D, Object3DEventMap } from 'three';
|
|
3
2
|
import { ShallowRef } from 'vue';
|
|
3
|
+
import { TresEvent, TresInstance } from '../../types';
|
|
4
4
|
import { TresContext } from '../useTresContextProvider';
|
|
5
5
|
export declare const useRaycaster: (objectsWithEvents: ShallowRef<TresInstance[]>, ctx: TresContext) => {
|
|
6
6
|
intersects: ShallowRef<Intersection<Object3D<Object3DEventMap>>[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColorSpace, Scene, ShadowMapType, ToneMapping, WebGLRendererParameters, WebGLRenderer } from 'three';
|
|
2
|
-
import {
|
|
2
|
+
import { TresColor } from '../../types';
|
|
3
3
|
import { TresContext } from '../useTresContextProvider';
|
|
4
4
|
import { RendererPresetsType } from './const';
|
|
5
5
|
import { MaybeRefOrGetter } from '@vueuse/core';
|
|
@@ -7,6 +7,12 @@ import { MaybeRef } from 'vue';
|
|
|
7
7
|
type TransformToMaybeRefOrGetter<T> = {
|
|
8
8
|
[K in keyof T]: MaybeRefOrGetter<T[K]> | MaybeRefOrGetter<T[K]>;
|
|
9
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* If set to 'on-demand', the scene will only be rendered when the current frame is invalidated
|
|
12
|
+
* If set to 'manual', the scene will only be rendered when advance() is called
|
|
13
|
+
* If set to 'always', the scene will be rendered every frame
|
|
14
|
+
*/
|
|
15
|
+
export type RenderMode = 'always' | 'on-demand' | 'manual';
|
|
10
16
|
export interface UseRendererOptions extends TransformToMaybeRefOrGetter<WebGLRendererParameters> {
|
|
11
17
|
/**
|
|
12
18
|
* Enable shadows in the Renderer
|
|
@@ -68,24 +74,26 @@ export interface UseRendererOptions extends TransformToMaybeRefOrGetter<WebGLRen
|
|
|
68
74
|
clearColor?: MaybeRefOrGetter<TresColor>;
|
|
69
75
|
windowSize?: MaybeRefOrGetter<boolean | string>;
|
|
70
76
|
preset?: MaybeRefOrGetter<RendererPresetsType>;
|
|
71
|
-
renderMode?:
|
|
77
|
+
renderMode?: MaybeRef<RenderMode>;
|
|
72
78
|
/**
|
|
73
79
|
* A `number` sets the renderer's device pixel ratio.
|
|
74
80
|
* `[number, number]` clamp's the renderer's device pixel ratio.
|
|
75
81
|
*/
|
|
76
82
|
dpr?: MaybeRefOrGetter<number | [number, number]>;
|
|
77
83
|
}
|
|
78
|
-
export declare function
|
|
79
|
-
canvas: MaybeRef<HTMLCanvasElement>;
|
|
84
|
+
export declare function useRendererManager({ scene, canvas, options, contextParts: { sizes, loop, camera }, }: {
|
|
80
85
|
scene: Scene;
|
|
86
|
+
canvas: MaybeRef<HTMLCanvasElement>;
|
|
81
87
|
options: UseRendererOptions;
|
|
82
|
-
|
|
83
|
-
contextParts: Pick<TresContext, 'sizes' | 'camera' | 'render'> & {
|
|
84
|
-
invalidate: () => void;
|
|
85
|
-
advance: () => void;
|
|
86
|
-
};
|
|
88
|
+
contextParts: Pick<TresContext, 'sizes' | 'camera' | 'loop'>;
|
|
87
89
|
}): {
|
|
88
|
-
|
|
90
|
+
instance: import('vue').ShallowRef<WebGLRenderer, WebGLRenderer>;
|
|
91
|
+
isReady: Readonly<import('vue').Ref<boolean, boolean>>;
|
|
92
|
+
advance: () => void;
|
|
93
|
+
onRender: import('@vueuse/core').EventHook<WebGLRenderer>;
|
|
94
|
+
invalidate: (amountOfFramesToInvalidate?: number) => void;
|
|
95
|
+
canBeInvalidated: import('vue').ComputedRef<boolean>;
|
|
96
|
+
amountOfFramesToRender: import('vue').Ref<number, number>;
|
|
89
97
|
};
|
|
90
|
-
export type
|
|
98
|
+
export type UseRendererManagerReturn = ReturnType<typeof useRendererManager>;
|
|
91
99
|
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComputedRef } from 'vue';
|
|
2
|
+
import { TresContext } from '../useTresContextProvider';
|
|
3
|
+
import { Camera, WebGLRenderer } from 'three';
|
|
4
|
+
export interface TresPartialContext extends Omit<TresContext, 'renderer' | 'camera'> {
|
|
5
|
+
/**
|
|
6
|
+
* The renderer instance
|
|
7
|
+
*
|
|
8
|
+
* @type {WebGLRenderer}
|
|
9
|
+
* @memberof TresPartialContext
|
|
10
|
+
*/
|
|
11
|
+
renderer: WebGLRenderer;
|
|
12
|
+
/**
|
|
13
|
+
* The current active camera
|
|
14
|
+
*
|
|
15
|
+
* @type {ComputedRef<Camera | undefined>}
|
|
16
|
+
* @memberof TresPartialContext
|
|
17
|
+
*/
|
|
18
|
+
camera: ComputedRef<Camera | undefined>;
|
|
19
|
+
/**
|
|
20
|
+
* Marks the scene as needing an update in the next frame.
|
|
21
|
+
* This is used in on-demand rendering mode to schedule a render.
|
|
22
|
+
*
|
|
23
|
+
* @type {() => void}
|
|
24
|
+
* @memberof TresPartialContext
|
|
25
|
+
*/
|
|
26
|
+
invalidate: () => void;
|
|
27
|
+
/**
|
|
28
|
+
* Manually advances the render loop by one frame.
|
|
29
|
+
* This is particularly useful in manual rendering mode where you want explicit control over when frames are rendered.
|
|
30
|
+
*
|
|
31
|
+
* @type {() => void}
|
|
32
|
+
* @memberof TresPartialContext
|
|
33
|
+
*/
|
|
34
|
+
advance: () => void;
|
|
35
|
+
}
|
|
36
|
+
export declare function useTres(): TresPartialContext;
|
|
@@ -1,74 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Raycaster } from 'three';
|
|
2
|
+
import { MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
|
|
3
3
|
import { RendererLoop } from '../../core/loop';
|
|
4
|
-
import {
|
|
5
|
-
import { UseRendererOptions } from '../useRenderer';
|
|
4
|
+
import { TresControl, TresObject, TresScene } from '../../types';
|
|
5
|
+
import { UseRendererManagerReturn, UseRendererOptions } from '../useRenderer/useRendererManager';
|
|
6
|
+
import { UseCameraReturn } from '../useCamera/';
|
|
6
7
|
import { SizesType } from '../useSizes';
|
|
7
8
|
import { TresEventManager } from '../useTresEventManager';
|
|
8
|
-
export interface InternalState {
|
|
9
|
-
priority: Ref<number>;
|
|
10
|
-
frames: Ref<number>;
|
|
11
|
-
maxFrames: number;
|
|
12
|
-
}
|
|
13
|
-
export interface RenderState {
|
|
14
|
-
/**
|
|
15
|
-
* If set to 'on-demand', the scene will only be rendered when the current frame is invalidated
|
|
16
|
-
* If set to 'manual', the scene will only be rendered when advance() is called
|
|
17
|
-
* If set to 'always', the scene will be rendered every frame
|
|
18
|
-
*/
|
|
19
|
-
mode: Ref<'always' | 'on-demand' | 'manual'>;
|
|
20
|
-
priority: Ref<number>;
|
|
21
|
-
frames: Ref<number>;
|
|
22
|
-
maxFrames: number;
|
|
23
|
-
canBeInvalidated: ComputedRef<boolean>;
|
|
24
|
-
}
|
|
25
|
-
export interface PerformanceState {
|
|
26
|
-
maxFrames: number;
|
|
27
|
-
fps: {
|
|
28
|
-
value: number;
|
|
29
|
-
accumulator: number[];
|
|
30
|
-
};
|
|
31
|
-
memory: {
|
|
32
|
-
currentMem: number;
|
|
33
|
-
allocatedMem: number;
|
|
34
|
-
accumulator: number[];
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
9
|
export interface TresContext {
|
|
38
10
|
scene: ShallowRef<TresScene>;
|
|
39
11
|
sizes: SizesType;
|
|
40
12
|
extend: (objects: any) => void;
|
|
41
|
-
camera:
|
|
42
|
-
cameras: DeepReadonly<Ref<Camera[]>>;
|
|
13
|
+
camera: UseCameraReturn;
|
|
43
14
|
controls: Ref<TresControl | null>;
|
|
44
|
-
renderer:
|
|
15
|
+
renderer: UseRendererManagerReturn;
|
|
45
16
|
raycaster: ShallowRef<Raycaster>;
|
|
46
|
-
perf: PerformanceState;
|
|
47
|
-
render: RenderState;
|
|
48
17
|
loop: RendererLoop;
|
|
49
|
-
/**
|
|
50
|
-
* Invalidates the current frame when renderMode === 'on-demand'
|
|
51
|
-
*/
|
|
52
|
-
invalidate: () => void;
|
|
53
|
-
/**
|
|
54
|
-
* Advance one frame when renderMode === 'manual'
|
|
55
|
-
*/
|
|
56
|
-
advance: () => void;
|
|
57
|
-
registerCamera: (maybeCamera: unknown) => void;
|
|
58
|
-
setCameraActive: (cameraOrUuid: Camera | string) => void;
|
|
59
|
-
deregisterCamera: (maybeCamera: unknown) => void;
|
|
60
18
|
eventManager?: TresEventManager;
|
|
61
19
|
registerObjectAtPointerEventHandler?: (object: TresObject) => void;
|
|
62
20
|
deregisterObjectAtPointerEventHandler?: (object: TresObject) => void;
|
|
63
21
|
registerBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
|
|
64
22
|
deregisterBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
|
|
65
23
|
}
|
|
66
|
-
export declare function useTresContextProvider({ scene, canvas, windowSize, rendererOptions,
|
|
24
|
+
export declare function useTresContextProvider({ scene, canvas, windowSize, rendererOptions, }: {
|
|
67
25
|
scene: TresScene;
|
|
68
26
|
canvas: MaybeRef<HTMLCanvasElement>;
|
|
69
27
|
windowSize: MaybeRefOrGetter<boolean>;
|
|
70
28
|
rendererOptions: UseRendererOptions;
|
|
71
|
-
emit: EmitEventFn;
|
|
72
29
|
}): TresContext;
|
|
73
30
|
export declare function useTresContext(): TresContext;
|
|
74
|
-
export declare const useTres: typeof useTresContext;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TresPointerEvent } from 'src/types';
|
|
2
2
|
import { Scene } from 'three';
|
|
3
3
|
import { TresContext } from '../useTresContextProvider';
|
|
4
|
+
import { EventHookOff } from '@vueuse/core';
|
|
4
5
|
export interface TresEventManager {
|
|
6
|
+
onEvent: EventHookOff<TresPointerEvent>;
|
|
5
7
|
/**
|
|
6
8
|
* Forces the event system to refire events with the previous mouse event
|
|
7
9
|
*/
|
|
@@ -16,7 +18,8 @@ export interface TresEventManager {
|
|
|
16
18
|
registerPointerMissedObject: (object: unknown) => void;
|
|
17
19
|
deregisterPointerMissedObject: (object: unknown) => void;
|
|
18
20
|
}
|
|
19
|
-
export declare function useTresEventManager(scene: Scene, context: TresContext
|
|
21
|
+
export declare function useTresEventManager(scene: Scene, context: TresContext): {
|
|
22
|
+
onEvent: import('@vueuse/core').EventHookOn<TresPointerEvent>;
|
|
20
23
|
forceUpdate: () => void;
|
|
21
24
|
registerObject: (maybeTresObject: unknown) => void;
|
|
22
25
|
deregisterObject: (maybeTresObject: unknown) => void;
|
package/dist/src/core/loop.d.ts
CHANGED
|
@@ -15,8 +15,6 @@ export interface LoopCallbackWithCtx extends LoopCallback {
|
|
|
15
15
|
controls: Ref<(EventDispatcher<object> & {
|
|
16
16
|
enabled: boolean;
|
|
17
17
|
}) | null>;
|
|
18
|
-
invalidate: Fn;
|
|
19
|
-
advance: Fn;
|
|
20
18
|
}
|
|
21
19
|
export type LoopCallbackFn = (params: LoopCallbackWithCtx) => void;
|
|
22
20
|
export interface RendererLoop {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Mesh } from 'three';
|
|
2
|
+
import { TresObject } from '../types';
|
|
3
|
+
import { SceneGraphObject } from './types';
|
|
4
|
+
import { TresContext } from '../composables/useTresContextProvider';
|
|
5
|
+
/**
|
|
6
|
+
* Creates a node representation of a Three.js object for the inspector tree
|
|
7
|
+
* @param object - The Three.js object to create a node for
|
|
8
|
+
* @returns A SceneGraphObject representing the Three.js object with relevant metadata
|
|
9
|
+
*/
|
|
10
|
+
export declare const createNode: (object: TresObject) => SceneGraphObject;
|
|
11
|
+
/**
|
|
12
|
+
* Creates a context node for the inspector tree
|
|
13
|
+
* @param key - The key identifier for the context node
|
|
14
|
+
* @param uuid - The unique identifier for the context
|
|
15
|
+
* @param parentKey - Optional parent key for nested context nodes
|
|
16
|
+
* @returns A SceneGraphObject representing the context node
|
|
17
|
+
*/
|
|
18
|
+
export declare function createContextNode(key: string, uuid: string, parentKey?: string): SceneGraphObject;
|
|
19
|
+
/**
|
|
20
|
+
* Recursively builds a graph representation of Three.js objects for the inspector
|
|
21
|
+
* @param object - The root Three.js object to build the graph from
|
|
22
|
+
* @param node - The current node in the graph being built
|
|
23
|
+
* @param filter - Optional filter string to filter objects by type or name
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildGraph(object: TresObject, node: SceneGraphObject, filter?: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Recursively builds a graph representation of context objects for the inspector
|
|
28
|
+
* @param object - The root object to build the context graph from
|
|
29
|
+
* @param node - The current node in the graph being built
|
|
30
|
+
* @param visited - WeakSet to track visited objects and prevent circular references
|
|
31
|
+
* @param depth - Current depth in the object tree
|
|
32
|
+
* @param maxDepth - Maximum depth to traverse
|
|
33
|
+
* @param contextUuid - Optional UUID for the context
|
|
34
|
+
* @param parentKey - Optional parent key for nested objects
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildContextGraph(object: any, node: SceneGraphObject, visited?: WeakSet<WeakKey>, depth?: number, maxDepth?: number, contextUuid?: string, parentKey?: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Handler for inspector tree updates
|
|
39
|
+
* @param tres - The TresContext instance
|
|
40
|
+
* @returns A function that handles inspector tree payload updates
|
|
41
|
+
*/
|
|
42
|
+
export declare const inspectorTreeHandler: (tres: TresContext) => (payload: any) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Handler for inspector state updates
|
|
45
|
+
* @param tres - The TresContext instance
|
|
46
|
+
* @param options - Options for the handler
|
|
47
|
+
* @param options.highlightMesh - The currently highlighted mesh
|
|
48
|
+
* @param options.prevInstance - The previously selected instance
|
|
49
|
+
* @returns A function that handles inspector state payload updates
|
|
50
|
+
*/
|
|
51
|
+
export declare const inspectorStateHandler: (tres: TresContext, { highlightMesh, prevInstance }: {
|
|
52
|
+
highlightMesh: Mesh | null;
|
|
53
|
+
prevInstance: TresObject | null;
|
|
54
|
+
}) => (payload: any) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Handler for inspector state edits
|
|
57
|
+
* @param tres - The TresContext instance
|
|
58
|
+
* @returns A function that handles inspector state edit payload updates
|
|
59
|
+
*/
|
|
60
|
+
export declare const inspectorEditStateHandler: (tres: TresContext) => (payload: any) => void;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { App as DevtoolsApp } from '@vue/devtools-api';
|
|
2
1
|
import { TresContext } from '../composables';
|
|
2
|
+
import { App } from 'vue';
|
|
3
3
|
export interface Tags {
|
|
4
4
|
label: string;
|
|
5
5
|
textColor: number;
|
|
6
6
|
backgroundColor: number;
|
|
7
7
|
tooltip?: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
label: string;
|
|
12
|
-
children: SceneGraphObject[];
|
|
13
|
-
tags: Tags[];
|
|
14
|
-
}
|
|
15
|
-
export declare function registerTresDevtools(app: DevtoolsApp, tres: TresContext): void;
|
|
9
|
+
export declare const INSPECTOR_ID = "tres:inspector";
|
|
10
|
+
export declare function registerTresDevtools(app: App, tres: TresContext): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TresContext } from '../composables';
|
|
2
|
+
export interface PerformanceState {
|
|
3
|
+
maxFrames: number;
|
|
4
|
+
fps: {
|
|
5
|
+
value: number;
|
|
6
|
+
accumulator: number[];
|
|
7
|
+
};
|
|
8
|
+
memory: {
|
|
9
|
+
currentMem: number;
|
|
10
|
+
allocatedMem: number;
|
|
11
|
+
accumulator: number[];
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export declare function setupTresDevtools(ctx: TresContext): void;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a tag that can be displayed in the inspector UI
|
|
3
|
+
* @interface Tags
|
|
4
|
+
*/
|
|
5
|
+
export interface Tags {
|
|
6
|
+
/** The text to display in the tag */
|
|
7
|
+
label: string;
|
|
8
|
+
/** The color of the text in hexadecimal format (e.g., 0xFFFFFF) */
|
|
9
|
+
textColor: number;
|
|
10
|
+
/** The background color of the tag in hexadecimal format (e.g., 0x000000) */
|
|
11
|
+
backgroundColor: number;
|
|
12
|
+
/** Optional tooltip text to show on hover */
|
|
13
|
+
tooltip?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a node in the scene graph that can be displayed in the inspector
|
|
17
|
+
* @interface SceneGraphObject
|
|
18
|
+
*/
|
|
19
|
+
export interface SceneGraphObject {
|
|
20
|
+
/** Unique identifier for the node */
|
|
21
|
+
id: string;
|
|
22
|
+
/** Display name of the node */
|
|
23
|
+
label: string;
|
|
24
|
+
/** Array of child nodes */
|
|
25
|
+
children: SceneGraphObject[];
|
|
26
|
+
/** Array of tags associated with the node */
|
|
27
|
+
tags: Tags[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Represents memory usage statistics for Three.js resources
|
|
31
|
+
* @interface MemoryStats
|
|
32
|
+
*/
|
|
33
|
+
export interface MemoryStats {
|
|
34
|
+
/** Map of geometry names to their memory usage in bytes */
|
|
35
|
+
geometries: Map<string, number>;
|
|
36
|
+
/** Map of material names to their memory usage in bytes */
|
|
37
|
+
materials: Map<string, number>;
|
|
38
|
+
/** Map of texture names to their memory usage in bytes */
|
|
39
|
+
textures: Map<string, number>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Represents a property in the inspector state
|
|
43
|
+
* @interface InspectorStateProperty
|
|
44
|
+
*/
|
|
45
|
+
export interface InspectorStateProperty {
|
|
46
|
+
/** The name of the property */
|
|
47
|
+
key: string;
|
|
48
|
+
/** The value of the property */
|
|
49
|
+
value: unknown;
|
|
50
|
+
/** Whether the property can be edited in the inspector */
|
|
51
|
+
editable: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Represents the state of an inspector panel
|
|
55
|
+
* @interface InspectorState
|
|
56
|
+
*/
|
|
57
|
+
export interface InspectorState {
|
|
58
|
+
/** Array of properties to display in the inspector */
|
|
59
|
+
object: InspectorStateProperty[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Represents the internal state of the devtools
|
|
63
|
+
* @interface DevtoolsState
|
|
64
|
+
*/
|
|
65
|
+
export interface DevtoolsState {
|
|
66
|
+
/** The current scene graph representation */
|
|
67
|
+
sceneGraph: SceneGraphObject | null;
|
|
68
|
+
/** Timestamp of the last update */
|
|
69
|
+
lastUpdate: number;
|
|
70
|
+
/** Minimum time between updates in milliseconds */
|
|
71
|
+
updateThreshold: number;
|
|
72
|
+
/** Current memory usage statistics */
|
|
73
|
+
memoryStats: MemoryStats;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Represents a payload sent to or received from the devtools
|
|
77
|
+
* @interface DevtoolsPayload
|
|
78
|
+
*/
|
|
79
|
+
export interface DevtoolsPayload {
|
|
80
|
+
/** The ID of the inspector panel */
|
|
81
|
+
inspectorId: string;
|
|
82
|
+
/** The ID of the node being inspected */
|
|
83
|
+
nodeId: string;
|
|
84
|
+
/** Optional filter string for searching */
|
|
85
|
+
filter?: string;
|
|
86
|
+
/** Optional state to update */
|
|
87
|
+
state?: InspectorState;
|
|
88
|
+
/** Optional path to the property being edited */
|
|
89
|
+
path?: string[];
|
|
90
|
+
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export * from './core/catalogue';
|
|
|
8
8
|
export * from './core/loop';
|
|
9
9
|
export * from './directives';
|
|
10
10
|
export * from './types';
|
|
11
|
+
export * from './utils/graph';
|
|
12
|
+
export * from './utils/logger';
|
|
11
13
|
export interface TresOptions {
|
|
12
14
|
extends?: Record<string, unknown>;
|
|
13
15
|
}
|
|
@@ -17,8 +17,13 @@ export type Args<T> = T extends ConstructorRepresentation ? ConstructorParameter
|
|
|
17
17
|
export interface TresCatalogue {
|
|
18
18
|
[name: string]: ConstructorRepresentation;
|
|
19
19
|
}
|
|
20
|
-
export
|
|
21
|
-
export type
|
|
20
|
+
export declare const pointerEventTypes: readonly ["click", "double-click", "context-menu", "pointer-move", "pointer-up", "pointer-down", "pointer-enter", "pointer-leave", "pointer-over", "pointer-out", "pointer-missed", "wheel"];
|
|
21
|
+
export type PointerEventType = typeof pointerEventTypes[number];
|
|
22
|
+
export interface TresPointerEvent {
|
|
23
|
+
type: PointerEventType;
|
|
24
|
+
event: TresEvent;
|
|
25
|
+
intersection?: Intersection;
|
|
26
|
+
}
|
|
22
27
|
export type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
|
|
23
28
|
/**
|
|
24
29
|
* Represents the properties of an instance.
|
|
@@ -90,7 +95,7 @@ export interface IntersectionEvent<TSourceEvent> extends Intersection {
|
|
|
90
95
|
/** The ray that pierced it */
|
|
91
96
|
ray: THREE.Ray;
|
|
92
97
|
/** The camera that was used by the raycaster */
|
|
93
|
-
camera:
|
|
98
|
+
camera: THREE.Camera;
|
|
94
99
|
/** stopPropagation will stop underlying handlers from firing */
|
|
95
100
|
stopPropagation: () => void;
|
|
96
101
|
/** The original host event */
|
|
@@ -9,7 +9,7 @@ export type PriorityEventHookOff<T> = EventHookOff<T>;
|
|
|
9
9
|
export type PriorityEventHookTrigger<T = any> = (param?: T) => void;
|
|
10
10
|
export interface PriorityEventHook<T = any> {
|
|
11
11
|
on: PriorityEventHookOn<T>;
|
|
12
|
-
off:
|
|
12
|
+
off: (fn: Callback<T>) => void;
|
|
13
13
|
trigger: PriorityEventHookTrigger<T>;
|
|
14
14
|
dispose: () => void;
|
|
15
15
|
count: number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Material, Mesh, Object3D, Scene } from 'three';
|
|
2
|
+
export interface TresObjectMap {
|
|
3
|
+
nodes: {
|
|
4
|
+
[name: string]: Object3D;
|
|
5
|
+
};
|
|
6
|
+
materials: {
|
|
7
|
+
[name: string]: Material;
|
|
8
|
+
};
|
|
9
|
+
meshes: {
|
|
10
|
+
[name: string]: Mesh;
|
|
11
|
+
};
|
|
12
|
+
scene?: Scene;
|
|
13
|
+
}
|
|
14
|
+
export declare function buildGraph(object: Object3D): TresObjectMap;
|
|
@@ -2,6 +2,7 @@ import { nodeOps } from 'src/core/nodeOps';
|
|
|
2
2
|
import { AttachType, LocalState, TresInstance, TresObject, TresPrimitive } from 'src/types';
|
|
3
3
|
import { Material, Mesh, MeshBasicMaterial, Scene, Vector3 } from 'three';
|
|
4
4
|
import { TresContext } from '../composables/useTresContextProvider';
|
|
5
|
+
export * from './logger';
|
|
5
6
|
export declare function toSetMethodName(key: string): string;
|
|
6
7
|
export declare const merge: (target: any, source: any) => any;
|
|
7
8
|
export declare const isHTMLTag: (key: string) => boolean;
|
|
@@ -14,10 +15,6 @@ export declare const get: <T>(obj: any, path: string | string[]) => T | undefine
|
|
|
14
15
|
export declare const set: (obj: any, path: string | string[], value: any) => void;
|
|
15
16
|
export declare function deepEqual(a: any, b: any): boolean;
|
|
16
17
|
export declare function deepArrayEqual(arr1: any[], arr2: any[]): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* TypeSafe version of Array.isArray
|
|
19
|
-
*/
|
|
20
|
-
export declare const isArray: (a: any) => a is any[] | readonly any[];
|
|
21
18
|
export declare function editSceneObject(scene: Scene, objectUuid: string, propertyPath: string[], value: any): void;
|
|
22
19
|
export declare function createHighlightMaterial(): MeshBasicMaterial;
|
|
23
20
|
export declare function animateHighlight(highlightMesh: Mesh, startTime: number): void;
|