vim-web 0.5.1 → 0.6.0-dev.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.
Files changed (45) hide show
  1. package/dist/types/core-viewers/shared/index.d.ts +2 -0
  2. package/dist/types/core-viewers/shared/inputAdapter.d.ts +1 -1
  3. package/dist/types/core-viewers/shared/loadResult.d.ts +55 -0
  4. package/dist/types/core-viewers/shared/mouseHandler.d.ts +1 -1
  5. package/dist/types/core-viewers/shared/raycaster.d.ts +5 -5
  6. package/dist/types/core-viewers/shared/vimCollection.d.ts +25 -0
  7. package/dist/types/core-viewers/ultra/loadRequest.d.ts +6 -28
  8. package/dist/types/core-viewers/ultra/viewer.d.ts +1 -1
  9. package/dist/types/core-viewers/ultra/vimCollection.d.ts +15 -11
  10. package/dist/types/core-viewers/webgl/index.d.ts +0 -1
  11. package/dist/types/core-viewers/webgl/loader/index.d.ts +3 -3
  12. package/dist/types/core-viewers/webgl/loader/materials/index.d.ts +1 -0
  13. package/dist/types/core-viewers/webgl/loader/materials/pickingMaterial.d.ts +42 -0
  14. package/dist/types/core-viewers/webgl/loader/progressive/insertableGeometry.d.ts +6 -1
  15. package/dist/types/core-viewers/webgl/loader/progressive/insertableMesh.d.ts +2 -1
  16. package/dist/types/core-viewers/webgl/loader/progressive/instancedMeshFactory.d.ts +8 -1
  17. package/dist/types/core-viewers/webgl/loader/progressive/legacyMeshFactory.d.ts +4 -1
  18. package/dist/types/core-viewers/webgl/loader/progressive/loadRequest.d.ts +21 -0
  19. package/dist/types/core-viewers/webgl/loader/progressive/subsetBuilder.d.ts +2 -1
  20. package/dist/types/core-viewers/webgl/loader/progressive/subsetRequest.d.ts +3 -2
  21. package/dist/types/core-viewers/webgl/loader/vim.d.ts +7 -2
  22. package/dist/types/core-viewers/webgl/loader/vimCollection.d.ts +78 -0
  23. package/dist/types/core-viewers/webgl/loader/vimSettings.d.ts +11 -4
  24. package/dist/types/core-viewers/webgl/viewer/camera/cameraMovement.d.ts +8 -0
  25. package/dist/types/core-viewers/webgl/viewer/gizmos/gizmoOrbit.d.ts +22 -17
  26. package/dist/types/core-viewers/webgl/viewer/raycaster.d.ts +3 -1
  27. package/dist/types/core-viewers/webgl/viewer/rendering/gpuPicker.d.ts +127 -0
  28. package/dist/types/core-viewers/webgl/viewer/rendering/renderScene.d.ts +2 -2
  29. package/dist/types/core-viewers/webgl/viewer/rendering/renderingSection.d.ts +4 -0
  30. package/dist/types/core-viewers/webgl/viewer/settings/viewerSettings.d.ts +11 -6
  31. package/dist/types/core-viewers/webgl/viewer/viewer.d.ts +11 -1
  32. package/dist/types/react-viewers/helpers/loadRequest.d.ts +15 -16
  33. package/dist/types/react-viewers/panels/loadingBox.d.ts +1 -1
  34. package/dist/types/react-viewers/webgl/loading.d.ts +17 -22
  35. package/dist/types/react-viewers/webgl/viewerRef.d.ts +20 -3
  36. package/dist/types/utils/asyncQueue.d.ts +15 -0
  37. package/dist/types/utils/index.d.ts +1 -1
  38. package/dist/vim-web.iife.js +48666 -48532
  39. package/dist/vim-web.iife.js.map +1 -1
  40. package/dist/vim-web.js +48427 -48293
  41. package/dist/vim-web.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/types/core-viewers/webgl/loader/progressive/open.d.ts +0 -12
  44. package/dist/types/core-viewers/webgl/loader/progressive/vimRequest.d.ts +0 -44
  45. package/dist/types/utils/result.d.ts +0 -13
@@ -1,4 +1,5 @@
1
1
  export * from './inputHandler';
2
+ export * from './loadResult';
2
3
  export { PointerMode } from './inputHandler';
3
4
  export type * from './baseInputHandler';
4
5
  export type * from './keyboardHandler';
@@ -7,3 +8,4 @@ export type * from './raycaster';
7
8
  export type * from './selection';
8
9
  export type * from './touchHandler';
9
10
  export type * from './vim';
11
+ export type * from './vimCollection';
@@ -18,5 +18,5 @@ export interface IInputAdapter {
18
18
  mouseMove: (pos: THREE.Vector2) => void;
19
19
  selectAtPointer: (pos: THREE.Vector2, add: boolean) => void;
20
20
  frameAtPointer: (pos: THREE.Vector2) => void;
21
- zoom: (value: number) => void;
21
+ zoom: (value: number, pos?: THREE.Vector2) => void;
22
22
  }
@@ -0,0 +1,55 @@
1
+ export interface ILoadSuccess<T> {
2
+ readonly isSuccess: true;
3
+ readonly isError: false;
4
+ readonly vim: T;
5
+ }
6
+ export interface ILoadError {
7
+ readonly isSuccess: false;
8
+ readonly isError: true;
9
+ readonly error: string;
10
+ readonly details?: string;
11
+ }
12
+ export type ProgressType = 'bytes' | 'percent';
13
+ export interface IProgress {
14
+ type: ProgressType;
15
+ current: number;
16
+ total?: number;
17
+ }
18
+ export type LoadResult<TValue, TError extends ILoadError = ILoadError> = ILoadSuccess<TValue> | TError;
19
+ export declare class LoadSuccess<T> implements ILoadSuccess<T> {
20
+ readonly vim: T;
21
+ readonly isSuccess: true;
22
+ readonly isError: false;
23
+ constructor(vim: T);
24
+ }
25
+ export declare class LoadError implements ILoadError {
26
+ readonly error: string;
27
+ readonly details?: string;
28
+ readonly isSuccess: false;
29
+ readonly isError: true;
30
+ constructor(error: string, details?: string);
31
+ }
32
+ /**
33
+ * Interface for load requests that can be used as a type constraint.
34
+ */
35
+ export interface ILoadRequest<TVim, TError extends ILoadError = ILoadError> {
36
+ readonly isCompleted: boolean;
37
+ getProgress(): AsyncGenerator<IProgress>;
38
+ getResult(): Promise<LoadResult<TVim, TError>>;
39
+ abort(): void;
40
+ }
41
+ /**
42
+ * Base class for loading requests that provides progress tracking via AsyncQueue.
43
+ * Both WebGL and Ultra extend this class with their specific loading logic.
44
+ */
45
+ export declare class LoadRequest<TVim, TError extends ILoadError = ILoadError> implements ILoadRequest<TVim, TError> {
46
+ private _progressQueue;
47
+ private _result;
48
+ private _resultPromise;
49
+ get isCompleted(): boolean;
50
+ getProgress(): AsyncGenerator<IProgress>;
51
+ getResult(): Promise<LoadResult<TVim, TError>>;
52
+ pushProgress(progress: IProgress): void;
53
+ complete(result: LoadResult<TVim, TError>): void;
54
+ abort(): void;
55
+ }
@@ -13,7 +13,7 @@ export declare class MouseHandler extends BaseInputHandler {
13
13
  onDrag: DragCallback;
14
14
  onClick: (position: THREE.Vector2, ctrl: boolean) => void;
15
15
  onDoubleClick: (position: THREE.Vector2) => void;
16
- onWheel: (value: number, ctrl: boolean) => void;
16
+ onWheel: (value: number, ctrl: boolean, pos: THREE.Vector2) => void;
17
17
  onContextMenu: (position: THREE.Vector2) => void;
18
18
  constructor(canvas: HTMLCanvasElement);
19
19
  protected addListeners(): void;
@@ -15,13 +15,13 @@ export interface IRaycaster<T> {
15
15
  /**
16
16
  * Raycasts from camera to the screen position to find the first object hit.
17
17
  * @param position - The screen position to raycast from.
18
- * @returns A promise that resolves to the raycast result.
18
+ * @returns A promise that resolves to the raycast result, or undefined if no hit.
19
19
  */
20
- raycastFromScreen(position: THREE.Vector2): Promise<IRaycastResult<T>>;
20
+ raycastFromScreen(position: THREE.Vector2): Promise<IRaycastResult<T> | undefined>;
21
21
  /**
22
22
  * Raycasts from camera to world position to find the first object hit.
23
- * @param position - The world position to raycast from.
24
- * @returns A promise that resolves to the raycast result.
23
+ * @param position - The world position to raycast through.
24
+ * @returns A promise that resolves to the raycast result, or undefined if no hit.
25
25
  */
26
- raycastFromWorld(position: THREE.Vector3): Promise<IRaycastResult<T>>;
26
+ raycastFromWorld(position: THREE.Vector3): Promise<IRaycastResult<T> | undefined>;
27
27
  }
@@ -0,0 +1,25 @@
1
+ import { ISignal } from 'ste-signals';
2
+ import { IVim, IVimElement } from './vim';
3
+ /**
4
+ * Readonly interface for a collection of vims.
5
+ */
6
+ export interface IReadonlyVimCollection<T extends IVim<IVimElement>> {
7
+ /** Number of vims in the collection */
8
+ readonly count: number;
9
+ /** Signal dispatched when collection changes */
10
+ readonly onChanged: ISignal;
11
+ /** Get vim by its stable ID */
12
+ getFromId(id: number): T | undefined;
13
+ /** Get all vims as an array */
14
+ getAll(): ReadonlyArray<T>;
15
+ /** Check if vim is in collection */
16
+ has(vim: T): boolean;
17
+ }
18
+ /**
19
+ * Mutable interface for a collection of vims.
20
+ */
21
+ export interface IVimCollection<T extends IVim<IVimElement>> extends IReadonlyVimCollection<T> {
22
+ add(vim: T): void;
23
+ remove(vim: T): void;
24
+ clear(): void;
25
+ }
@@ -1,35 +1,13 @@
1
1
  import { Vim } from './vim';
2
- export type LoadRequestResult = LoadSuccess | LoadError;
3
- export declare class LoadSuccess {
4
- readonly isError = false;
5
- readonly isSuccess = true;
6
- readonly vim: Vim;
7
- constructor(vim: Vim);
8
- }
9
- export declare class LoadError {
10
- error: VimRequestErrorType;
11
- readonly isError = true;
12
- readonly isSuccess = false;
2
+ import { LoadRequest as BaseLoadRequest, ILoadRequest as BaseILoadRequest, IProgress, LoadError as SharedLoadError } from '../shared/loadResult';
3
+ export type VimRequestErrorType = 'loadingError' | 'downloadingError' | 'serverDisconnected' | 'unknown' | 'cancelled';
4
+ export declare class LoadError extends SharedLoadError {
13
5
  readonly type: VimRequestErrorType;
14
- readonly details: string | undefined;
15
6
  constructor(error: VimRequestErrorType, details?: string);
16
7
  }
17
- export interface ILoadRequest {
18
- get isCompleted(): boolean;
19
- getProgress(): AsyncGenerator<number>;
20
- getResult(): Promise<LoadError | LoadSuccess>;
21
- abort(): void;
22
- }
23
- export type VimRequestErrorType = 'loadingError' | 'downloadingError' | 'serverDisconnected' | 'unknown' | 'cancelled';
24
- export declare class LoadRequest implements ILoadRequest {
25
- private _progress;
26
- private _progressPromise;
27
- private _completionPromise;
28
- private _result;
29
- get isCompleted(): boolean;
30
- getProgress(): AsyncGenerator<number, void, unknown>;
31
- getResult(): Promise<LoadError | LoadSuccess>;
32
- onProgress(progress: number): void;
8
+ export type ILoadRequest = BaseILoadRequest<Vim, LoadError>;
9
+ export declare class LoadRequest extends BaseLoadRequest<Vim, LoadError> {
10
+ onProgress(progress: IProgress): void;
33
11
  success(vim: Vim): this;
34
12
  error(error: VimRequestErrorType, details?: string): this;
35
13
  abort(): void;
@@ -3,7 +3,7 @@ import type { InputHandler } from '../shared';
3
3
  import { ICamera } from './camera';
4
4
  import { ColorManager } from './colorManager';
5
5
  import { IDecoder } from './decoder';
6
- import { ILoadRequest } from './loadRequest';
6
+ import { type ILoadRequest } from './loadRequest';
7
7
  import { ILogger } from './logger';
8
8
  import { IUltraRaycaster } from './raycaster';
9
9
  import { IRenderer } from './renderer';
@@ -1,13 +1,11 @@
1
- import { ISignal } from "ste-signals";
2
- import { Vim } from "./vim";
3
- export interface IReadonlyVimCollection {
4
- getFromHandle(handle: number): Vim | undefined;
5
- getAll(): ReadonlyArray<Vim>;
1
+ import { ISignal } from 'ste-signals';
2
+ import { IReadonlyVimCollection as ISharedReadonlyVimCollection, IVimCollection } from '../shared/vimCollection';
3
+ import { Vim } from './vim';
4
+ export interface IReadonlyVimCollection extends ISharedReadonlyVimCollection<Vim> {
5
+ /** Get vim at a specific index */
6
6
  getAt(index: number): Vim | undefined;
7
- count: number;
8
- onChanged: ISignal;
9
7
  }
10
- export declare class VimCollection implements IReadonlyVimCollection {
8
+ export declare class VimCollection implements IVimCollection<Vim>, IReadonlyVimCollection {
11
9
  private _vims;
12
10
  private _onChanged;
13
11
  get onChanged(): ISignal;
@@ -24,11 +22,17 @@ export declare class VimCollection implements IReadonlyVimCollection {
24
22
  */
25
23
  remove(vim: Vim): void;
26
24
  /**
27
- * Gets a Vim instance by its handle.
28
- * @param handle - The handle of the Vim instance.
25
+ * Gets a Vim instance by its stable ID.
26
+ * @param id - The ID of the Vim instance.
29
27
  * @returns The Vim instance or undefined if not found.
30
28
  */
31
- getFromHandle(handle: number): Vim | undefined;
29
+ getFromId(id: number): Vim | undefined;
30
+ /**
31
+ * Checks if a vim is in the collection.
32
+ * @param vim - The Vim instance to check.
33
+ * @returns True if the vim is in the collection.
34
+ */
35
+ has(vim: Vim): boolean;
32
36
  /**
33
37
  * Gets a Vim instance at a specific index.
34
38
  * @param index - The index of the Vim instance.
@@ -1,6 +1,5 @@
1
1
  import './style.css';
2
2
  import { BFastSource } from 'vim-format';
3
3
  export type VimSource = BFastSource;
4
- export { IProgressLogs } from 'vim-format';
5
4
  export * from './loader';
6
5
  export * from './viewer';
@@ -1,5 +1,6 @@
1
- export * from './vimSettings';
2
- export { requestVim as request, type RequestSource, type VimRequest } from './progressive/vimRequest';
1
+ export type { VimSettings, VimPartialSettings } from './vimSettings';
2
+ export * from './vimCollection';
3
+ export type { RequestSource, LoadRequest, ILoadRequest } from './progressive/loadRequest';
3
4
  export * as Materials from './materials';
4
5
  export type { Transparency } from './geometry';
5
6
  export type * from './webglAttribute';
@@ -9,7 +10,6 @@ export type * from './elementMapping';
9
10
  export type * from './mesh';
10
11
  export type * from './scene';
11
12
  export type * from './vim';
12
- export type * from './progressive/vimx';
13
13
  export type * from './progressive/g3dOffsets';
14
14
  export type * from './progressive/g3dSubset';
15
15
  export type * from './progressive/insertableGeometry';
@@ -3,6 +3,7 @@ export * from './maskMaterial';
3
3
  export * from './materials';
4
4
  export * from './mergeMaterial';
5
5
  export * from './outlineMaterial';
6
+ export * from './pickingMaterial';
6
7
  export * from './simpleMaterial';
7
8
  export * from './skyboxMaterial';
8
9
  export * from './standardMaterial';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @module vim-loader/materials
3
+ * Material for GPU picking that outputs element index, depth, and surface normal in a single pass.
4
+ */
5
+ import * as THREE from 'three';
6
+ /**
7
+ * Creates a material for GPU picking that outputs packed IDs, depth, and surface normal.
8
+ *
9
+ * Expects a `packedId` uint attribute pre-packed during mesh building as: (vimIndex << 24) | elementIndex
10
+ *
11
+ * Output format (Float32 RGBA):
12
+ * - R = packed uint as float bits - supports 256 vims × 16M elements
13
+ * - G = depth (distance along camera direction, 0 = miss)
14
+ * - B = normal.x (surface normal X component)
15
+ * - A = normal.y (surface normal Y component)
16
+ *
17
+ * Normal.z is reconstructed as: sqrt(1 - x² - y²), always positive since normal faces camera.
18
+ *
19
+ * @returns A custom shader material for GPU picking.
20
+ */
21
+ export declare function createPickingMaterial(): THREE.ShaderMaterial;
22
+ /**
23
+ * PickingMaterial class that wraps the shader material with camera update functionality.
24
+ */
25
+ export declare class PickingMaterial {
26
+ readonly material: THREE.ShaderMaterial;
27
+ constructor();
28
+ /**
29
+ * Updates the camera uniforms for depth calculation.
30
+ * Must be called before rendering.
31
+ */
32
+ updateCamera(camera: THREE.Camera): void;
33
+ /**
34
+ * Gets or sets the clipping planes for section box support.
35
+ */
36
+ get clippingPlanes(): THREE.Plane[];
37
+ set clippingPlanes(planes: THREE.Plane[]);
38
+ /**
39
+ * Disposes of the material resources.
40
+ */
41
+ dispose(): void;
42
+ }
@@ -5,6 +5,7 @@ import * as THREE from 'three';
5
5
  import { G3d, G3dMesh, G3dMaterial } from 'vim-format';
6
6
  import { Scene } from '../scene';
7
7
  import { G3dMeshOffsets } from './g3dOffsets';
8
+ import { ElementMapping } from '../elementMapping';
8
9
  export declare class GeometrySubmesh {
9
10
  instance: number;
10
11
  start: number;
@@ -23,10 +24,13 @@ export declare class InsertableGeometry {
23
24
  private _indexAttribute;
24
25
  private _vertexAttribute;
25
26
  private _colorAttribute;
27
+ private _packedIdAttribute;
28
+ private _mapping;
29
+ private _vimIndex;
26
30
  private _updateStartMesh;
27
31
  private _updateEndMesh;
28
32
  private _meshToUpdate;
29
- constructor(offsets: G3dMeshOffsets, materials: G3dMaterial, transparent: boolean);
33
+ constructor(offsets: G3dMeshOffsets, materials: G3dMaterial, transparent: boolean, mapping?: ElementMapping, vimIndex?: number);
30
34
  get progress(): number;
31
35
  insert(mesh: G3dMesh, at: number): number[];
32
36
  float32ArraysAreEqual(array1: Float32Array, array2: Float32Array): boolean;
@@ -34,6 +38,7 @@ export declare class InsertableGeometry {
34
38
  private setIndex;
35
39
  private setVertex;
36
40
  private setColor;
41
+ private setPackedId;
37
42
  private expandBox;
38
43
  flushUpdate(): void;
39
44
  update(): void;
@@ -8,6 +8,7 @@ import { InsertableSubmesh } from './insertableSubmesh';
8
8
  import { G3dMeshOffsets } from './g3dOffsets';
9
9
  import { Vim } from '../vim';
10
10
  import { ModelMaterial } from '../materials/materials';
11
+ import { ElementMapping } from '../elementMapping';
11
12
  export declare class InsertableMesh {
12
13
  offsets: G3dMeshOffsets;
13
14
  mesh: THREE.Mesh;
@@ -33,7 +34,7 @@ export declare class InsertableMesh {
33
34
  */
34
35
  private _material;
35
36
  geometry: InsertableGeometry;
36
- constructor(offsets: G3dMeshOffsets, materials: G3dMaterial, transparent: boolean);
37
+ constructor(offsets: G3dMeshOffsets, materials: G3dMaterial, transparent: boolean, mapping?: ElementMapping, vimIndex?: number);
37
38
  get progress(): number;
38
39
  insert(g3d: G3dMesh, mesh: number): void;
39
40
  insertFromVim(g3d: G3d, mesh: number): void;
@@ -3,9 +3,12 @@
3
3
  */
4
4
  import { G3d, G3dMesh, G3dMaterial, MeshSection } from 'vim-format';
5
5
  import { InstancedMesh } from './instancedMesh';
6
+ import { ElementMapping } from '../elementMapping';
6
7
  export declare class InstancedMeshFactory {
7
8
  materials: G3dMaterial;
8
- constructor(materials: G3dMaterial);
9
+ private _mapping;
10
+ private _vimIndex;
11
+ constructor(materials: G3dMaterial, mapping?: ElementMapping, vimIndex?: number);
9
12
  createTransparent(mesh: G3dMesh, instances: number[]): InstancedMesh;
10
13
  createOpaque(mesh: G3dMesh, instances: number[]): InstancedMesh;
11
14
  createOpaqueFromVim(g3d: G3d, mesh: number, instances: number[]): InstancedMesh;
@@ -17,4 +20,8 @@ export declare class InstancedMeshFactory {
17
20
  private computeVertices;
18
21
  private computeColors;
19
22
  private setMatricesFromVimx;
23
+ /**
24
+ * Adds per-instance packed ID attribute for GPU picking.
25
+ */
26
+ private setPackedIds;
20
27
  }
@@ -4,6 +4,7 @@
4
4
  import { Scene } from '../scene';
5
5
  import { G3dMaterial, G3d } from 'vim-format';
6
6
  import { G3dSubset } from './g3dSubset';
7
+ import { ElementMapping } from '../elementMapping';
7
8
  /**
8
9
  * Mesh factory to load a standard vim using the progressive pipeline.
9
10
  */
@@ -12,7 +13,9 @@ export declare class VimMeshFactory {
12
13
  private _materials;
13
14
  private _instancedFactory;
14
15
  private _scene;
15
- constructor(g3d: G3d, materials: G3dMaterial, scene: Scene);
16
+ private _mapping;
17
+ private _vimIndex;
18
+ constructor(g3d: G3d, materials: G3dMaterial, scene: Scene, mapping: ElementMapping, vimIndex?: number);
16
19
  /**
17
20
  * Adds all instances from subset to the scene
18
21
  */
@@ -0,0 +1,21 @@
1
+ import { VimPartialSettings } from '../vimSettings';
2
+ import { Vim } from '../vim';
3
+ import { LoadRequest as BaseLoadRequest, ILoadRequest as BaseILoadRequest } from '../../../shared/loadResult';
4
+ import { VimSource } from '../..';
5
+ export type RequestSource = {
6
+ url?: string;
7
+ buffer?: ArrayBuffer;
8
+ headers?: Record<string, string>;
9
+ };
10
+ export type ILoadRequest = BaseILoadRequest<Vim>;
11
+ /**
12
+ * A request to load a VIM file. Extends the base LoadRequest to add BFast abort handling.
13
+ * Loading starts immediately upon construction.
14
+ */
15
+ export declare class LoadRequest extends BaseLoadRequest<Vim> {
16
+ private _bfast;
17
+ constructor(source: VimSource, settings: VimPartialSettings, vimIndex: number);
18
+ private startRequest;
19
+ private loadFromVim;
20
+ abort(): void;
21
+ }
@@ -41,11 +41,12 @@ export declare class VimSubsetBuilder implements SubsetBuilder {
41
41
  export declare class VimxSubsetBuilder {
42
42
  private _localVimx;
43
43
  private _scene;
44
+ private _vimIndex;
44
45
  private _set;
45
46
  private _onUpdate;
46
47
  get onUpdate(): ISignal;
47
48
  get isLoading(): boolean;
48
- constructor(localVimx: Vimx, scene: Scene);
49
+ constructor(localVimx: Vimx, scene: Scene, vimIndex?: number);
49
50
  getFullSet(): G3dSubset;
50
51
  loadSubset(subset: G3dSubset, settings?: LoadPartialSettings): Promise<void>;
51
52
  clear(): void;
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * @module vim-loader
3
3
  */
4
- import { Vimx, Scene } from '../..';
4
+ import { Scene } from '../scene';
5
+ import { Vimx } from './vimx';
5
6
  import { G3dSubset } from './g3dSubset';
6
7
  export type LoadSettings = {
7
8
  /** Delay in ms between each rendering list update. @default: 400ms */
@@ -27,7 +28,7 @@ export declare class SubsetRequest {
27
28
  private _started;
28
29
  private _scene;
29
30
  getBoundingBox(): import("three").Box3;
30
- constructor(scene: Scene, localVimx: Vimx, subset: G3dSubset);
31
+ constructor(scene: Scene, localVimx: Vimx, subset: G3dSubset, vimIndex?: number);
31
32
  dispose(): void;
32
33
  start(settings: LoadPartialSettings): Promise<void>;
33
34
  private nextFrame;
@@ -23,6 +23,11 @@ export declare class Vim implements IVim<Element3D> {
23
23
  * Useful for distinguishing between different viewer types in a multi-viewer application.
24
24
  */
25
25
  readonly type = "webgl";
26
+ /**
27
+ * The stable ID of this vim in the scene's vim collection (0-255).
28
+ * Used for GPU picking to identify which vim an element belongs to.
29
+ */
30
+ readonly vimIndex: number;
26
31
  /**
27
32
  * Indicates whether the vim was opened from a vim or vimx file.
28
33
  */
@@ -81,13 +86,13 @@ export declare class Vim implements IVim<Element3D> {
81
86
  * @param {G3d | undefined} g3d - The G3d object, if available.
82
87
  * @param {Scene} scene - The scene containing the vim's geometry.
83
88
  * @param {VimSettings} settings - The settings used to open this vim.
89
+ * @param {number} vimIndex - The stable ID of this vim (0-255) for GPU picking.
84
90
  * @param {ElementMapping | ElementNoMapping | ElementMapping2} map - The element mapping.
85
91
  * @param {SubsetBuilder} builder - The subset builder for constructing subsets of the Vim object.
86
92
  * @param {string} source - The source of the Vim object.
87
93
  * @param {VimFormat} format - The format of the Vim object.
88
- * @param {boolean} isLegacy - Indicates whether the Vim object uses a legacy loading pipeline.
89
94
  */
90
- constructor(header: VimHeader | undefined, document: VimDocument, g3d: G3d | undefined, scene: Scene, settings: VimSettings, map: ElementMapping | ElementNoMapping | ElementMapping2, builder: SubsetBuilder, source: string, format: VimFormat);
95
+ constructor(header: VimHeader | undefined, document: VimDocument, g3d: G3d | undefined, scene: Scene, settings: VimSettings, vimIndex: number, map: ElementMapping | ElementNoMapping | ElementMapping2, builder: SubsetBuilder, source: string, format: VimFormat);
91
96
  getBoundingBox(): Promise<THREE.Box3>;
92
97
  /**
93
98
  * Retrieves the matrix representation of the Vim object's position, rotation, and scale.
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @module vim-loader
3
+ */
4
+ import { ISignal } from 'ste-signals';
5
+ import { IVimCollection } from '../../shared/vimCollection';
6
+ import { Vim } from './vim';
7
+ /**
8
+ * Maximum number of vims that can be loaded simultaneously.
9
+ * Limited by the 8-bit vimIndex in GPU picking (256 values: 0-255).
10
+ */
11
+ export declare const MAX_VIMS = 256;
12
+ /**
13
+ * Manages a collection of Vim objects with stable IDs for GPU picking.
14
+ *
15
+ * Each vim is assigned a stable ID (0-255) that persists for its lifetime.
16
+ * IDs are allocated sequentially and only reused after all 256 have been used.
17
+ * This ensures GPU picker can correctly identify vims even after removals.
18
+ */
19
+ export declare class VimCollection implements IVimCollection<Vim> {
20
+ private _vimsById;
21
+ private _nextId;
22
+ private _freedIds;
23
+ private _count;
24
+ private _onChanged;
25
+ /**
26
+ * Signal dispatched when collection changes (add/remove/clear).
27
+ */
28
+ get onChanged(): ISignal;
29
+ /**
30
+ * Allocates a stable ID for a new vim.
31
+ * Fresh IDs are allocated sequentially (0, 1, 2, ..., 255).
32
+ * Freed IDs are only reused after all 256 have been allocated once.
33
+ * @returns The allocated ID, or undefined if all 256 IDs are in use
34
+ */
35
+ allocateId(): number | undefined;
36
+ /**
37
+ * Whether the collection has reached maximum capacity (256 vims).
38
+ */
39
+ get isFull(): boolean;
40
+ /**
41
+ * The number of vims currently in the collection.
42
+ */
43
+ get count(): number;
44
+ /**
45
+ * Adds a vim to the collection using its vimIndex as the ID.
46
+ * The vim's vimIndex should have been allocated via allocateId().
47
+ * @param vim The vim to add
48
+ * @throws Error if the vim's vimIndex slot is already occupied
49
+ */
50
+ add(vim: Vim): void;
51
+ /**
52
+ * Removes a vim from the collection and frees its ID for reuse.
53
+ * @param vim The vim to remove
54
+ * @throws Error if the vim is not in the collection
55
+ */
56
+ remove(vim: Vim): void;
57
+ /**
58
+ * Gets a vim by its stable ID.
59
+ * @param id The stable ID (0-255)
60
+ * @returns The vim at that ID, or undefined if empty
61
+ */
62
+ getFromId(id: number): Vim | undefined;
63
+ /**
64
+ * Checks if a vim is in the collection.
65
+ * @param vim The vim to check
66
+ * @returns True if the vim is in the collection
67
+ */
68
+ has(vim: Vim): boolean;
69
+ /**
70
+ * Returns all vims as a packed array (for iteration).
71
+ * @returns Array of all vims currently in the collection
72
+ */
73
+ getAll(): Vim[];
74
+ /**
75
+ * Clears all vims from the collection and resets ID allocation.
76
+ */
77
+ clear(): void;
78
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Transparency } from './geometry';
5
5
  import * as THREE from 'three';
6
- export type FileType = 'vim' | 'vimx' | undefined;
6
+ type FileType = 'vim' | 'vimx' | undefined;
7
7
  /**
8
8
  * Represents settings for configuring the behavior and rendering of a vim object.
9
9
  */
@@ -33,6 +33,12 @@ export type VimSettings = {
33
33
  * Set to true to enable verbose HTTP logging.
34
34
  */
35
35
  verboseHttp: boolean;
36
+ };
37
+ /**
38
+ * Internal settings type that includes vimx-specific fields.
39
+ * Used internally for loading vimx files.
40
+ */
41
+ export type VimSettingsFull = VimSettings & {
36
42
  /**
37
43
  * Specifies the file type (vim or vimx) if it cannot or should not be inferred from the file extension.
38
44
  */
@@ -49,7 +55,7 @@ export type VimSettings = {
49
55
  /**
50
56
  * Default configuration settings for a vim object.
51
57
  */
52
- export declare function getDefaultVimSettings(): VimSettings;
58
+ export declare function getDefaultVimSettings(): VimSettingsFull;
53
59
  /**
54
60
  * Represents a partial configuration of settings for a vim object.
55
61
  */
@@ -57,6 +63,7 @@ export type VimPartialSettings = Partial<VimSettings>;
57
63
  /**
58
64
  * Wraps Vim options, converting values to related THREE.js types and providing default values.
59
65
  * @param {VimPartialSettings} [options] - Optional partial settings for the Vim object.
60
- * @returns {VimSettings} The complete settings for the Vim object, including defaults.
66
+ * @returns {VimSettingsFull} The complete settings for the Vim object, including defaults.
61
67
  */
62
- export declare function createVimSettings(options?: VimPartialSettings): VimSettings;
68
+ export declare function createVimSettings(options?: VimPartialSettings): VimSettingsFull;
69
+ export {};
@@ -39,6 +39,14 @@ export declare abstract class CameraMovement {
39
39
  * @param {number} amount - The factor by which to change the distance (e.g., 0.5 for halving the distance, 2 for doubling the distance).
40
40
  */
41
41
  abstract zoom(amount: number): void;
42
+ /**
43
+ * Zooms toward a specific point, making it the new orbit target.
44
+ * Preserves the camera's forward direction while moving closer/farther from the point.
45
+ * If point is undefined, falls back to regular zoom.
46
+ * @param {THREE.Vector3 | undefined} point - The world position to zoom toward, or undefined for regular zoom
47
+ * @param {number} amount - The zoom factor (< 1 zooms in, > 1 zooms out)
48
+ */
49
+ zoomTo(point: THREE.Vector3 | undefined, amount: number): void;
42
50
  /**
43
51
  * Sets the distance between the camera and its target to the specified value.
44
52
  * @param {number} dist - The new distance between the camera and its target.