vim-web 0.3.44-dev.42 → 0.3.44-dev.45

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.
@@ -11,7 +11,7 @@ export * from '../shared/coreInputHandler';
11
11
  export * from './viewer/settings/viewerSettings';
12
12
  export * from './viewer/settings/viewerSettingsParsing';
13
13
  export * from './viewer/settings/defaultViewerSettings';
14
- export { RaycastResult as HitTestResult, InputAction } from './viewer/raycaster';
14
+ export { RaycastResult as HitTestResult } from './viewer/raycaster';
15
15
  export { type SelectableObject, Selection } from './viewer/selection';
16
16
  export * from './loader/progressive/insertableMesh';
17
17
  export * from './loader/progressive/g3dSubset';
@@ -28,10 +28,8 @@ export declare class BoxInputs {
28
28
  private _raycaster;
29
29
  /** The box state before the current drag. */
30
30
  private _lastBox;
31
- /** A collection of unregister callbacks for event listeners. */
32
- private _unregisters;
33
- /** The ID of the pointer that is captured, if any. */
34
- private _capturedPointerId;
31
+ /** A callback to restore the original input listeners after unregistering. */
32
+ private _restoreOriginalInputs;
35
33
  /**
36
34
  * Called when the pointer enters or leaves a handle face.
37
35
  * @param normal - The normal (forward) vector of the hovered handle, or a zero vector if none.
@@ -65,35 +63,6 @@ export declare class BoxInputs {
65
63
  * and resetting drag state.
66
64
  */
67
65
  unregister(): void;
68
- /**
69
- * Indicates if a pointer is currently captured for dragging.
70
- */
71
- get pointerCaptured(): boolean;
72
- /**
73
- * A helper method to attach an event listener and store its unregister callback.
74
- *
75
- * @param handler - The DOM element or Window to attach the listener to.
76
- * @param type - The pointer event type, e.g. 'pointerdown'.
77
- * @param listener - The event handler function.
78
- */
79
- private reg;
80
- /**
81
- * Called when the pointer leaves the canvas. If not dragging,
82
- * invokes {@link onFaceEnter} to indicate no active handle is hovered.
83
- *
84
- * @param event - The pointerleave event.
85
- */
86
- private onPointerLeave;
87
- /**
88
- * Sets pointer capture on the canvas for a specific pointer (ID).
89
- *
90
- * @param pointerId - The pointer ID to capture.
91
- */
92
- private capturePointer;
93
- /**
94
- * Releases any captured pointer on the canvas, if present.
95
- */
96
- private releasePointer;
97
66
  /**
98
67
  * Handles pointer movement events.
99
68
  * - If dragging, calls {@link onDrag}.
@@ -4,26 +4,26 @@
4
4
  import * as THREE from 'three';
5
5
  import { Object3D } from '../loader/object3D';
6
6
  import { RenderScene } from './rendering/renderScene';
7
- import { Viewport } from './viewport';
8
7
  import { Camera } from './camera/camera';
9
8
  import { Renderer } from './rendering/renderer';
10
9
  import { GizmoMarker } from './gizmos/markers/gizmoMarker';
11
10
  /**
12
- * Type alias for THREE intersection array
11
+ * Type alias for an array of THREE.Intersection objects.
13
12
  */
14
13
  export type ThreeIntersectionList = THREE.Intersection<THREE.Object3D<THREE.Object3DEventMap>>[];
15
14
  export type ActionType = 'main' | 'double' | 'idle';
16
15
  export type ActionModifier = 'none' | 'shift' | 'ctrl';
17
16
  /**
18
- * Highlevel aggregate of information about a raycast result
17
+ * Aggregates detailed information about a raycasting result,
18
+ * including the intersected object and the hit details.
19
19
  */
20
20
  export declare class RaycastResult {
21
21
  object: Object3D | GizmoMarker | undefined;
22
22
  intersections: ThreeIntersectionList;
23
23
  firstHit: THREE.Intersection | undefined;
24
24
  constructor(intersections: ThreeIntersectionList);
25
- private GetFirstVimHit;
26
- private GetFirstMarkerHit;
25
+ private getFirstVimHit;
26
+ private getFirstMarkerHit;
27
27
  private getVimObjectFromHit;
28
28
  get isHit(): boolean;
29
29
  get distance(): number;
@@ -32,58 +32,47 @@ export declare class RaycastResult {
32
32
  get faceIndex(): number;
33
33
  }
34
34
  export declare class Raycaster {
35
- private _viewport;
36
35
  private _camera;
37
36
  private _scene;
38
37
  private _renderer;
39
38
  private _raycaster;
40
- constructor(viewport: Viewport, camera: Camera, scene: RenderScene, renderer: Renderer);
39
+ constructor(camera: Camera, scene: RenderScene, renderer: Renderer);
41
40
  /**
42
- * Performs a raycast by projecting a ray from the camera position to a screen position.
43
- * @param {THREE.Vector2} position - The screen position for raycasting.
41
+ * Performs a raycast from the camera using normalized screen coordinates.
42
+ * Coordinates must be within [0, 1] for both x and y.
43
+ * If the coordinates are out of bounds, an error is logged and an empty result is returned.
44
+ *
45
+ * @param {THREE.Vector2} position - The normalized screen position for raycasting.
44
46
  */
45
- raycast2(position: THREE.Vector2): RaycastResult;
47
+ raycastFromScreen(position: THREE.Vector2): RaycastResult;
46
48
  private filterHits;
47
49
  /**
48
- * Performs a raycast by projecting a ray from the camera position to a world position.
49
- * @param {THREE.Vector3} position - The world position for raycasting.
50
+ * Performs a raycast from the camera towards a specified world position.
51
+ *
52
+ * @param {THREE.Vector3} position - The target world position for raycasting.
50
53
  */
51
- raycast3(position: THREE.Vector3): RaycastResult;
54
+ raycastFromWorld(position: THREE.Vector3): RaycastResult;
52
55
  /**
53
- * Performs a raycast by projecting a ray from the camera center.
56
+ * Performs a raycast starting from the camera's current target position.
54
57
  */
55
58
  raycastForward(): RaycastResult;
56
59
  /**
57
- * Returns a THREE.Raycaster projecting a ray from camera position to screen position
60
+ * Creates and returns a THREE.Raycaster that casts a ray from the camera's position
61
+ * through the provided normalized screen coordinate (x and y in the range [0, 1]).
62
+ *
63
+ * @param {THREE.Vector2} position - The normalized screen position for raycasting.
64
+ * @param {THREE.Raycaster} target - Optional existing raycaster instance to update.
65
+ * @returns {THREE.Raycaster} A configured raycaster for performing raycasting.
58
66
  */
59
67
  fromPoint2(position: THREE.Vector2, target?: THREE.Raycaster): THREE.Raycaster;
60
68
  /**
61
- * Returns a THREE.Raycaster projecting a ray from the camera position to a screen position.
62
- * @param {THREE.Vector2} position - The screen position for raycasting.
63
- * @returns {THREE.Raycaster} A raycaster object for performing raycasting.
69
+ * Creates and returns a THREE.Raycaster that casts a ray from the camera's position
70
+ * towards the specified world position.
71
+ * The ray's direction is computed as the normalized vector from the camera position to the target position.
72
+ *
73
+ * @param {THREE.Vector3} position - The world position for raycasting.
74
+ * @param {THREE.Raycaster} target - Optional existing raycaster instance to update.
75
+ * @returns {THREE.Raycaster} A configured raycaster for performing raycasting.
64
76
  */
65
77
  fromPoint3(position: THREE.Vector3, target?: THREE.Raycaster): THREE.Raycaster;
66
78
  }
67
- /**
68
- * Represents an input action with its position and modifiers.
69
- */
70
- export declare class InputAction {
71
- readonly position: THREE.Vector2;
72
- readonly modifier: ActionModifier;
73
- readonly type: ActionType;
74
- private _raycaster;
75
- constructor(type: ActionType, modifier: ActionModifier, position: THREE.Vector2, raycaster: Raycaster);
76
- private _raycast;
77
- /**
78
- * A THREE.Raycaster object for custom raycasting.
79
- */
80
- get raycaster(): THREE.Raycaster;
81
- /**
82
- * Performs raycasting for VIM objects at the current point. This operation can be computationally expensive.
83
- */
84
- get raycast(): RaycastResult;
85
- /**
86
- * Returns the object at the current point. This operation can cause a computationally expensive raycast evaluation.
87
- */
88
- get object(): Object3D | GizmoMarker;
89
- }
@@ -1,3 +1,3 @@
1
1
  import { CoreInputHandler } from "../../shared/coreInputHandler";
2
2
  import { Viewer } from "./viewer";
3
- export declare function webglInputAdapter(viewer: Viewer): CoreInputHandler;
3
+ export declare function webglInputHandler(viewer: Viewer): CoreInputHandler;
@@ -1,40 +1,264 @@
1
+ /**
2
+ * @module state-action-refs
3
+ *
4
+ * This module exports various React hooks and TypeScript interfaces to create references for state,
5
+ * actions, and functions. These references allow you to store and manipulate values and functions,
6
+ * as well as dynamically inject additional behavior (using prepend and append methods) into their call chains.
7
+ *
8
+ * The provided hooks include:
9
+ * - useStateRef: A state reference with event dispatching and validation.
10
+ * - useActionRef: A reference for an action (a function with no arguments).
11
+ * - useArgActionRef: A reference for an action that accepts an argument.
12
+ * - useFuncRef: A reference for a function returning a value.
13
+ * - useAsyncFuncRef: A reference for an asynchronous function.
14
+ * - useArgFuncRef: A reference for a function that accepts an argument and returns a value.
15
+ */
16
+ /**
17
+ * Interface for a state reference.
18
+ * Provides methods to get, set, and confirm the current state.
19
+ */
1
20
  export interface StateRef<T> {
21
+ /**
22
+ * Returns the current state value.
23
+ */
2
24
  get(): T;
25
+ /**
26
+ * Updates the state to the provided value.
27
+ * @param value - The new state value.
28
+ */
3
29
  set(value: T): void;
30
+ /**
31
+ * Confirms the current state (potentially applying a confirmation transformation).
32
+ */
4
33
  confirm(): void;
5
34
  }
35
+ /**
36
+ * A custom hook that creates a state reference.
37
+ * The reference provides access to the state, along with event dispatching, validation, and confirmation logic.
38
+ *
39
+ * @param initialValue - The initial state value.
40
+ * @returns An object implementing StateRef along with additional helper hooks.
41
+ */
6
42
  export declare function useStateRef<T>(initialValue: T): {
43
+ /**
44
+ * Returns the current state value.
45
+ */
7
46
  get(): T;
8
47
  set: (value: T) => void;
48
+ /**
49
+ * Confirms the current state by applying the confirm function and updating the state.
50
+ */
9
51
  confirm(): void;
10
- useOnChange(on: (value: T) => (void | (() => void))): void;
52
+ /**
53
+ * Registers a callback to be invoked when the state changes.
54
+ * @param on - The callback function that receives the new state value.
55
+ */
56
+ useOnChange(on: (value: T) => void | (() => void)): void;
57
+ /**
58
+ * Memoizes a value based on the current state and additional dependencies.
59
+ * @param on - A function that computes a value based on the current state.
60
+ * @param deps - Optional additional dependencies.
61
+ * @returns The memoized value.
62
+ */
11
63
  useMemo<TOut>(on: (value: T) => TOut, deps?: any[]): TOut;
64
+ /**
65
+ * Sets a validation function to process any new state value before updating.
66
+ * @param on - A function that validates (and optionally transforms) the new state value.
67
+ */
12
68
  useValidate(on: (value: T) => T): void;
69
+ /**
70
+ * Sets a confirmation function to process the state value during confirmation.
71
+ * @param on - A function that confirms (and optionally transforms) the current state value.
72
+ */
13
73
  useConfirm(on: (value: T) => T): void;
14
74
  };
75
+ /**
76
+ * Interface for an action reference (a function with no arguments).
77
+ * Provides methods to call, get, set, and inject code before or after the stored function.
78
+ */
15
79
  export interface ActionRef {
80
+ /**
81
+ * Invokes the stored action.
82
+ */
16
83
  call(): void;
84
+ /**
85
+ * Retrieves the current action function.
86
+ * @returns The stored action function.
87
+ */
17
88
  get(): () => void;
18
- set(func: () => void): void;
89
+ /**
90
+ * Sets the stored action function.
91
+ * @param fn - The new action function.
92
+ */
93
+ set(fn: () => void): void;
94
+ /**
95
+ * Prepends a function to be executed before the stored action.
96
+ * @param fn - The function to run before the original action.
97
+ */
98
+ prepend(fn: () => void): void;
99
+ /**
100
+ * Appends a function to be executed after the stored action.
101
+ * @param fn - The function to run after the original action.
102
+ */
103
+ append(fn: () => void): void;
19
104
  }
105
+ /**
106
+ * Custom hook to create an action reference.
107
+ *
108
+ * @param action - The initial action function.
109
+ * @returns An object implementing ActionRef.
110
+ */
20
111
  export declare function useActionRef(action: () => void): ActionRef;
112
+ /**
113
+ * Interface for an action reference that accepts an argument.
114
+ * Provides methods to call with an argument, get, set, and inject code before or after the stored function.
115
+ */
21
116
  export interface ArgActionRef<T> {
117
+ /**
118
+ * Invokes the stored action with the provided argument.
119
+ * @param arg - The argument to pass to the action.
120
+ */
22
121
  call(arg: T): void;
23
- set(func: (arg: T) => void): void;
122
+ /**
123
+ * Retrieves the current action function.
124
+ * @returns The stored action function.
125
+ */
126
+ get(): (arg: T) => void;
127
+ /**
128
+ * Sets the stored action function.
129
+ * @param fn - The new action function.
130
+ */
131
+ set(fn: (arg: T) => void): void;
132
+ /**
133
+ * Prepends a function to be executed before the stored action.
134
+ * @param fn - The function to run before the original action.
135
+ */
136
+ prepend(fn: (arg: T) => void): void;
137
+ /**
138
+ * Appends a function to be executed after the stored action.
139
+ * @param fn - The function to run after the original action.
140
+ */
141
+ append(fn: (arg: T) => void): void;
24
142
  }
143
+ /**
144
+ * Custom hook to create an argument-based action reference.
145
+ *
146
+ * @param action - The initial action function that accepts an argument.
147
+ * @returns An object implementing ArgActionRef.
148
+ */
25
149
  export declare function useArgActionRef<T>(action: (arg: T) => void): ArgActionRef<T>;
150
+ /**
151
+ * Interface for a function reference that returns a value.
152
+ * Provides methods to call, get, set, and inject code before or after the stored function.
153
+ */
26
154
  export interface FuncRef<T> {
155
+ /**
156
+ * Invokes the stored function and returns its value.
157
+ * @returns The result of the function call.
158
+ */
27
159
  call(): T;
28
- set(func: () => T): void;
160
+ /**
161
+ * Retrieves the current function.
162
+ * @returns The stored function.
163
+ */
164
+ get(): () => T;
165
+ /**
166
+ * Sets the stored function.
167
+ * @param fn - The new function.
168
+ */
169
+ set(fn: () => T): void;
170
+ /**
171
+ * Prepends a function to be executed before the stored function.
172
+ * @param fn - The function to run before the original function.
173
+ */
174
+ prepend(fn: () => void): void;
175
+ /**
176
+ * Appends a function to be executed after the stored function.
177
+ * @param fn - The function to run after the original function.
178
+ */
179
+ append(fn: () => void): void;
29
180
  }
30
- export declare function useFuncRef<T>(func: () => T): FuncRef<T>;
181
+ /**
182
+ * Custom hook to create a function reference.
183
+ *
184
+ * @param fn - The initial function.
185
+ * @returns An object implementing FuncRef.
186
+ */
187
+ export declare function useFuncRef<T>(fn: () => T): FuncRef<T>;
188
+ /**
189
+ * Interface for an asynchronous function reference.
190
+ * Provides methods to call, get, set, and inject code before or after the stored async function.
191
+ */
31
192
  export interface AsyncFuncRef<T> {
193
+ /**
194
+ * Invokes the stored asynchronous function and returns a promise of its result.
195
+ * @returns A promise resolving to the result of the async function.
196
+ */
32
197
  call(): Promise<T>;
33
- set(func: () => Promise<T>): void;
198
+ /**
199
+ * Retrieves the current asynchronous function.
200
+ * @returns The stored async function.
201
+ */
202
+ get(): () => Promise<T>;
203
+ /**
204
+ * Sets the stored asynchronous function.
205
+ * @param fn - The new async function.
206
+ */
207
+ set(fn: () => Promise<T>): void;
208
+ /**
209
+ * Prepends a function to be executed before the stored async function.
210
+ * @param fn - The function to run before the original async function.
211
+ */
212
+ prepend(fn: () => Promise<void> | void): void;
213
+ /**
214
+ * Appends a function to be executed after the stored async function.
215
+ * @param fn - The function to run after the original async function.
216
+ */
217
+ append(fn: () => Promise<void> | void): void;
34
218
  }
35
- export declare function useAsyncFuncRef<T>(func: () => Promise<T>): AsyncFuncRef<T>;
219
+ /**
220
+ * Custom hook to create an asynchronous function reference.
221
+ *
222
+ * @param fn - The initial asynchronous function.
223
+ * @returns An object implementing AsyncFuncRef.
224
+ */
225
+ export declare function useAsyncFuncRef<T>(fn: () => Promise<T>): AsyncFuncRef<T>;
226
+ /**
227
+ * Interface for a function reference that accepts an argument and returns a result.
228
+ * Provides methods to call, get, set, and inject code before or after the stored function.
229
+ */
36
230
  export interface ArgFuncRef<TArg, TResult> {
231
+ /**
232
+ * Invokes the stored function with the provided argument.
233
+ * @param arg - The argument to pass to the function.
234
+ * @returns The result of the function call.
235
+ */
37
236
  call(arg: TArg): TResult;
38
- set(func: (arg: TArg) => TResult): void;
237
+ /**
238
+ * Retrieves the current function.
239
+ * @returns The stored function.
240
+ */
241
+ get(): (arg: TArg) => TResult;
242
+ /**
243
+ * Sets the stored function.
244
+ * @param fn - The new function.
245
+ */
246
+ set(fn: (arg: TArg) => TResult): void;
247
+ /**
248
+ * Prepends a function to be executed before the stored function.
249
+ * @param fn - The function to run before the original function.
250
+ */
251
+ prepend(fn: (arg: TArg) => void): void;
252
+ /**
253
+ * Appends a function to be executed after the stored function.
254
+ * @param fn - The function to run after the original function.
255
+ */
256
+ append(fn: (arg: TArg) => void): void;
39
257
  }
40
- export declare function useArgFuncRef<TArg, TResult>(func: (arg: TArg) => TResult): ArgFuncRef<TArg, TResult>;
258
+ /**
259
+ * Custom hook to create an argument-based function reference.
260
+ *
261
+ * @param fn - The initial function that accepts an argument and returns a result.
262
+ * @returns An object implementing ArgFuncRef.
263
+ */
264
+ export declare function useArgFuncRef<TArg, TResult>(fn: (arg: TArg) => TResult): ArgFuncRef<TArg, TResult>;
@@ -1,25 +1,23 @@
1
1
  /**
2
2
  * @module viw-webgl-react
3
3
  */
4
- import { THREE } from '../../index';
4
+ import { SectionBoxRef, THREE } from '../../index';
5
5
  import { ActionRef, AsyncFuncRef, StateRef } from '../helpers/reactUtils';
6
6
  import { ISignal } from 'ste-signals';
7
7
  export interface CameraRef {
8
8
  autoCamera: StateRef<boolean>;
9
9
  reset: ActionRef;
10
- getSelectionBox: AsyncFuncRef<THREE.Box3 | undefined>;
11
- getSceneBox: AsyncFuncRef<THREE.Box3 | undefined>;
12
10
  frameSelection: AsyncFuncRef<void>;
13
11
  frameScene: AsyncFuncRef<void>;
12
+ getSelectionBox: AsyncFuncRef<THREE.Box3 | undefined>;
13
+ getSceneBox: AsyncFuncRef<THREE.Box3 | undefined>;
14
14
  }
15
15
  interface ICameraAdapter {
16
16
  onSelectionChanged: ISignal;
17
17
  frameCamera: (box: THREE.Box3, duration: number) => void;
18
18
  resetCamera: (duration: number) => void;
19
19
  getSelectionBox: () => Promise<THREE.Box3 | undefined>;
20
- getSceneBox: () => Promise<THREE.Box3>;
21
- getSectionBox: () => THREE.Box3;
22
- isSectionBoxEnabled: () => boolean;
20
+ getSceneBox: () => Promise<THREE.Box3 | undefined>;
23
21
  }
24
- export declare function useCamera(adapter: ICameraAdapter): CameraRef;
22
+ export declare function useCamera(adapter: ICameraAdapter, section: SectionBoxRef): CameraRef;
25
23
  export {};
@@ -12,21 +12,23 @@ export interface SectionBoxRef {
12
12
  visible: StateRef<boolean>;
13
13
  auto: StateRef<boolean>;
14
14
  sectionSelection: AsyncFuncRef<void>;
15
- sectionReset: AsyncFuncRef<void>;
15
+ sectionScene: AsyncFuncRef<void>;
16
16
  sectionBox: ArgActionRef<THREE.Box3>;
17
17
  getBox: () => THREE.Box3;
18
18
  showOffsetPanel: StateRef<boolean>;
19
19
  topOffset: StateRef<string>;
20
20
  sideOffset: StateRef<string>;
21
21
  bottomOffset: StateRef<string>;
22
+ getSelectionBox: AsyncFuncRef<THREE.Box3 | undefined>;
23
+ getSceneBox: AsyncFuncRef<THREE.Box3>;
22
24
  }
23
25
  export interface SectionBoxAdapter {
24
26
  setClip: (b: boolean) => void;
25
27
  setVisible: (visible: boolean) => void;
26
28
  getBox: () => THREE.Box3;
27
29
  setBox: (box: THREE.Box3) => void;
28
- getSelectionBox: () => Promise<THREE.Box3 | undefined>;
29
- getRendererBox: () => Promise<THREE.Box3>;
30
30
  onSelectionChanged: ISignal;
31
+ getSelectionBox: () => Promise<THREE.Box3 | undefined>;
32
+ getSceneBox: () => Promise<THREE.Box3>;
31
33
  }
32
34
  export declare function useSectionBox(adapter: SectionBoxAdapter): SectionBoxRef;