@tresjs/core 5.0.0-next.0 → 5.0.0-next.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.
Files changed (28) hide show
  1. package/dist/src/components/TresCanvas.vue.d.ts +66 -64
  2. package/dist/src/composables/index.d.ts +4 -9
  3. package/dist/src/composables/useCamera/index.d.ts +42 -8555
  4. package/dist/src/composables/useEventManager/index.d.ts +10 -0
  5. package/dist/src/composables/useLoader/index.d.ts +1 -0
  6. package/dist/src/composables/useRenderer/useRendererManager.d.ts +187 -0
  7. package/dist/src/composables/useTres/index.d.ts +37 -0
  8. package/dist/src/composables/useTresContextProvider/index.d.ts +10 -60
  9. package/dist/src/core/loop.d.ts +0 -2
  10. package/dist/src/devtools/inspectorHandlers.d.ts +60 -0
  11. package/dist/src/devtools/plugin.d.ts +3 -7
  12. package/dist/src/devtools/setupDevtools.d.ts +13 -1
  13. package/dist/src/devtools/types.d.ts +90 -0
  14. package/dist/src/types/index.d.ts +3 -69
  15. package/dist/src/utils/createPriorityEventHook.d.ts +1 -1
  16. package/dist/src/utils/is.d.ts +47 -3
  17. package/dist/src/utils/pointerEvents.d.ts +10 -0
  18. package/dist/tres.js +2582 -1998
  19. package/package.json +6 -3
  20. package/dist/src/composables/useRaycaster/index.d.ts +0 -16
  21. package/dist/src/composables/useRenderer/const.d.ts +0 -18
  22. package/dist/src/composables/useRenderer/index.d.ts +0 -91
  23. package/dist/src/composables/useSeek/index.d.ts +0 -20
  24. package/dist/src/composables/useTexture/component.vue.d.ts +0 -29
  25. package/dist/src/composables/useTexture/index.d.ts +0 -103
  26. package/dist/src/composables/useTresEventManager/index.d.ts +0 -25
  27. package/dist/src/composables/useTresReady/createReadyEventHook/index.d.ts +0 -4
  28. package/dist/src/composables/useTresReady/index.d.ts +0 -7
@@ -0,0 +1,10 @@
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, loop }, }: {
6
+ canvas: MaybeRef<HTMLCanvasElement>;
7
+ contextParts: Pick<TresContext, 'scene' | 'camera' | 'loop'>;
8
+ }): {
9
+ onPointerMissed: import('@vueuse/core').EventHookOn<PointerEvent<MouseEvent> & Event<"click", Object3D<Object3DEventMap & PointerEventsMap>>>;
10
+ };
@@ -14,6 +14,7 @@ export type LoaderProto<T> = new (manager?: LoadingManager) => TresLoader<T>;
14
14
  export interface TresLoaderOptions<T, Shallow extends boolean> {
15
15
  manager?: LoadingManager;
16
16
  extensions?: (loader: TresLoader<T>) => void;
17
+ initialValue?: T;
17
18
  asyncOptions?: UseAsyncStateOptions<Shallow, any | null>;
18
19
  }
19
20
  /**
@@ -0,0 +1,187 @@
1
+ import { RendererLoop } from './../../core/loop';
2
+ import { ColorRepresentation, ColorSpace, ShadowMapType, ToneMapping, WebGLRenderer } from 'three';
3
+ import { TresContext } from '../useTresContextProvider';
4
+ import { MaybeRef, ShallowRef } from 'vue';
5
+ import { Renderer } from 'three/webgpu';
6
+ import { SizesType } from '../useSizes';
7
+ import { UseCameraReturn } from '../useCamera';
8
+ import { TresScene } from '../../types';
9
+ /**
10
+ * If set to 'on-demand', the scene will only be rendered when the current frame is invalidated
11
+ * If set to 'manual', the scene will only be rendered when advance() is called
12
+ * If set to 'always', the scene will be rendered every frame
13
+ */
14
+ export type RenderMode = 'always' | 'on-demand' | 'manual';
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
+ loop: RendererLoop;
170
+ canvas: MaybeRef<HTMLCanvasElement>;
171
+ }
172
+ export interface UseRendererOptions {
173
+ scene: ShallowRef<TresScene>;
174
+ canvas: MaybeRef<HTMLCanvasElement>;
175
+ options: RendererOptions;
176
+ contextParts: Pick<TresContext, 'sizes' | 'camera' | 'loop'>;
177
+ }
178
+ export declare function useRendererManager({ scene, canvas, options, contextParts: { sizes, loop, camera }, }: UseRendererOptions): {
179
+ instance: TresRenderer;
180
+ advance: () => void;
181
+ onRender: import('@vueuse/core').EventHookOn<TresRenderer>;
182
+ onReady: import('@vueuse/core').EventHookOn<TresRenderer>;
183
+ invalidate: (amountOfFramesToInvalidate?: number) => void;
184
+ canBeInvalidated: import('vue').ComputedRef<boolean>;
185
+ frames: import('vue').Ref<number, number>;
186
+ };
187
+ export type UseRendererManagerReturn = ReturnType<typeof useRendererManager>;
@@ -0,0 +1,37 @@
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;
@@ -1,74 +1,24 @@
1
- import { Camera, WebGLRenderer, Raycaster } from 'three';
2
- import { ComputedRef, DeepReadonly, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
1
+ import { MaybeRef, MaybeRefOrGetter, Ref, ShallowRef } from 'vue';
3
2
  import { RendererLoop } from '../../core/loop';
4
- import { EmitEventFn, TresControl, TresObject, TresScene } from '../../types';
5
- import { UseRendererOptions } from '../useRenderer';
3
+ import { TresControl, TresScene } from '../../types';
4
+ import { RendererOptions, UseRendererManagerReturn } from '../useRenderer/useRendererManager';
5
+ import { UseCameraReturn } from '../useCamera/';
6
6
  import { SizesType } from '../useSizes';
7
- 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
- }
7
+ import { useEventManager } from '../useEventManager';
37
8
  export interface TresContext {
38
9
  scene: ShallowRef<TresScene>;
39
10
  sizes: SizesType;
40
11
  extend: (objects: any) => void;
41
- camera: ComputedRef<Camera | undefined>;
42
- cameras: DeepReadonly<Ref<Camera[]>>;
12
+ camera: UseCameraReturn;
43
13
  controls: Ref<TresControl | null>;
44
- renderer: ShallowRef<WebGLRenderer>;
45
- raycaster: ShallowRef<Raycaster>;
46
- perf: PerformanceState;
47
- render: RenderState;
14
+ renderer: UseRendererManagerReturn;
48
15
  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
- eventManager?: TresEventManager;
61
- registerObjectAtPointerEventHandler?: (object: TresObject) => void;
62
- deregisterObjectAtPointerEventHandler?: (object: TresObject) => void;
63
- registerBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
64
- deregisterBlockingObjectAtPointerEventHandler?: (object: TresObject) => void;
16
+ events: ReturnType<typeof useEventManager>;
65
17
  }
66
- export declare function useTresContextProvider({ scene, canvas, windowSize, rendererOptions, emit, }: {
18
+ export declare function useTresContextProvider({ scene, canvas, windowSize, rendererOptions, }: {
67
19
  scene: TresScene;
68
20
  canvas: MaybeRef<HTMLCanvasElement>;
69
21
  windowSize: MaybeRefOrGetter<boolean>;
70
- rendererOptions: UseRendererOptions;
71
- emit: EmitEventFn;
22
+ rendererOptions: RendererOptions;
72
23
  }): TresContext;
73
24
  export declare function useTresContext(): TresContext;
74
- export declare const useTres: typeof useTresContext;
@@ -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,14 +1,10 @@
1
1
  import { TresContext } from '../composables';
2
+ import { App } from 'vue';
2
3
  export interface Tags {
3
4
  label: string;
4
5
  textColor: number;
5
6
  backgroundColor: number;
6
7
  tooltip?: string;
7
8
  }
8
- export interface SceneGraphObject {
9
- id: string;
10
- label: string;
11
- children: SceneGraphObject[];
12
- tags: Tags[];
13
- }
14
- export declare function registerTresDevtools(app: any, tres: TresContext): void;
9
+ export declare const INSPECTOR_ID = "tres:inspector";
10
+ export declare function registerTresDevtools(app: App, tres: TresContext): void;
@@ -1,2 +1,14 @@
1
1
  import { TresContext } from '../composables';
2
- export declare function setupDevtools(ctx: TresContext): void;
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
+ }
@@ -1,5 +1,6 @@
1
1
  import { DefineComponent, VNode, VNodeRef } from 'vue';
2
2
  import { TresContext } from '../composables/useTresContextProvider';
3
+ import { PointerEventHandlers } from '../utils/pointerEvents';
3
4
  import type * as THREE from 'three';
4
5
  export type AttachFnType = (parent: any, self: TresInstance) => () => void;
5
6
  export type AttachType = string | AttachFnType;
@@ -17,8 +18,6 @@ export type Args<T> = T extends ConstructorRepresentation ? ConstructorParameter
17
18
  export interface TresCatalogue {
18
19
  [name: string]: ConstructorRepresentation;
19
20
  }
20
- export type EmitEventName = 'render' | 'ready' | '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 EmitEventFn = (event: EmitEventName, ...args: any[]) => void;
22
21
  export type TresCamera = THREE.OrthographicCamera | THREE.PerspectiveCamera;
23
22
  /**
24
23
  * Represents the properties of an instance.
@@ -40,9 +39,7 @@ interface TresBaseObject {
40
39
  }
41
40
  export interface LocalState {
42
41
  type: string;
43
- eventCount: number;
44
42
  root: TresContext;
45
- handlers: Partial<EventHandlers>;
46
43
  memoizedProps: {
47
44
  [key: string]: any;
48
45
  };
@@ -72,69 +69,6 @@ export interface TresScene extends THREE.Scene {
72
69
  root: TresContext;
73
70
  };
74
71
  }
75
- export interface Intersection extends THREE.Intersection {
76
- /** The event source (the object which registered the handler) */
77
- eventObject: TresObject;
78
- }
79
- export interface IntersectionEvent<TSourceEvent> extends Intersection {
80
- /** The event source (the object which registered the handler) */
81
- eventObject: TresObject;
82
- /** An array of intersections */
83
- intersections: Intersection[];
84
- /** vec3.set(pointer.x, pointer.y, 0).unproject(camera) */
85
- unprojectedPoint: THREE.Vector3;
86
- /** Normalized event coordinates */
87
- pointer: THREE.Vector2;
88
- /** Delta between first click and this event */
89
- delta: number;
90
- /** The ray that pierced it */
91
- ray: THREE.Ray;
92
- /** The camera that was used by the raycaster */
93
- camera: TresCamera;
94
- /** stopPropagation will stop underlying handlers from firing */
95
- stopPropagation: () => void;
96
- /** The original host event */
97
- nativeEvent: TSourceEvent;
98
- /** If the event was stopped by calling stopPropagation */
99
- stopped: boolean;
100
- }
101
- export type ThreeEvent<TEvent> = IntersectionEvent<TEvent> & Properties<TEvent>;
102
- export type DomEvent = PointerEvent | MouseEvent | WheelEvent;
103
- export interface TresEvent {
104
- eventObject: TresObject;
105
- event: DomEvent;
106
- stopPropagation: () => void;
107
- stopPropagating: boolean;
108
- intersections: Intersection[];
109
- intersects: Intersection[];
110
- }
111
- export interface Events {
112
- onClick: EventListener;
113
- onContextMenu: EventListener;
114
- onDoubleClick: EventListener;
115
- onWheel: EventListener;
116
- onPointerDown: EventListener;
117
- onPointerUp: EventListener;
118
- onPointerLeave: EventListener;
119
- onPointerMove: EventListener;
120
- onPointerCancel: EventListener;
121
- onLostPointerCapture: EventListener;
122
- }
123
- export interface EventHandlers {
124
- onClick?: (event: ThreeEvent<MouseEvent>) => void;
125
- onContextMenu?: (event: ThreeEvent<MouseEvent>) => void;
126
- onDoubleClick?: (event: ThreeEvent<MouseEvent>) => void;
127
- onPointerUp?: (event: ThreeEvent<PointerEvent>) => void;
128
- onPointerDown?: (event: ThreeEvent<PointerEvent>) => void;
129
- onPointerOver?: (event: ThreeEvent<PointerEvent>) => void;
130
- onPointerOut?: (event: ThreeEvent<PointerEvent>) => void;
131
- onPointerEnter?: (event: ThreeEvent<PointerEvent>) => void;
132
- onPointerLeave?: (event: ThreeEvent<PointerEvent>) => void;
133
- onPointerMove?: (event: ThreeEvent<PointerEvent>) => void;
134
- onPointerMissed?: (event: MouseEvent) => void;
135
- onPointerCancel?: (event: ThreeEvent<PointerEvent>) => void;
136
- onWheel?: (event: ThreeEvent<WheelEvent>) => void;
137
- }
138
72
  interface MathRepresentation {
139
73
  set(...args: number[] | [THREE.ColorRepresentation]): any;
140
74
  }
@@ -165,7 +99,8 @@ export type WithMathProps<P> = {
165
99
  interface RaycastableRepresentation {
166
100
  raycast: (raycaster: THREE.Raycaster, intersects: THREE.Intersection[]) => void;
167
101
  }
168
- type EventProps<P> = P extends RaycastableRepresentation ? Partial<EventHandlers> : unknown;
102
+ type EventProps<P> = P extends RaycastableRepresentation ? Partial<PointerEventHandlers> : unknown;
103
+ export type { TresPointerEvent } from '../utils/pointerEvents';
169
104
  export interface VueProps {
170
105
  children?: VNode[];
171
106
  ref?: VNodeRef;
@@ -190,4 +125,3 @@ declare module 'vue' {
190
125
  primitive: DefineComponent<TresPrimitive>;
191
126
  }
192
127
  }
193
- export {};
@@ -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: EventHookOff<T>;
12
+ off: (fn: Callback<T>) => void;
13
13
  trigger: PriorityEventHookTrigger<T>;
14
14
  dispose: () => void;
15
15
  count: number;