@x-viewer/core 0.21.13 → 0.21.15
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/chunks/libredwg-web-wsfHeJkP.js +9 -0
- package/dist/index.esm.js +970 -966
- package/dist/types/core/Configs.d.ts +7 -0
- package/dist/types/core/Constants.d.ts +23 -0
- package/dist/types/core/controls/TransformControls.d.ts +292 -0
- package/dist/types/core/controls/TransformGizmo.d.ts +92 -0
- package/dist/types/core/controls/index.d.ts +2 -0
- package/dist/types/core/dxf/DxfLoader.d.ts +0 -11
- package/dist/types/core/dxf-parser/DxfParser.d.ts +2 -423
- package/dist/types/core/effect/EffectManager.d.ts +28 -2
- package/dist/types/core/loaders/BaseModelLoader.d.ts +16 -0
- package/dist/types/core/loaders/GltfLoader.d.ts +4 -3
- package/dist/types/core/loaders/ModelLoaderManager.d.ts +12 -5
- package/dist/types/core/model/Model3d.d.ts +5 -0
- package/dist/types/core/utils/GeometryUtils.d.ts +45 -0
- package/dist/types/core/utils/TextureUtils.d.ts +9 -0
- package/dist/types/core/viewers/BaseViewer.d.ts +12 -40
- package/dist/types/core/viewers/Viewer2d.d.ts +0 -42
- package/dist/types/core/viewers/Viewer3d.d.ts +57 -4
- package/dist/types/core/viewers/ViewerEvent.d.ts +6 -1
- package/package.json +2 -2
- package/dist/chunks/libredwg-web-DpTeHuNl.js +0 -9
|
@@ -3,17 +3,16 @@ import { CSS2DRenderer } from "three/examples/jsm/renderers/CSS2DRenderer.js";
|
|
|
3
3
|
import { ViewerName } from "./Constants";
|
|
4
4
|
import type { Plugin } from "./Plugin";
|
|
5
5
|
import { ViewerEvent } from "./ViewerEvent";
|
|
6
|
-
import {
|
|
6
|
+
import { Spinner } from "../components";
|
|
7
7
|
import { BaseViewerConfig, CameraInfo, CameraProjection, ModelConfig, Viewpoint } from "../../core/Configs";
|
|
8
8
|
import { CameraManager } from "../../core/camera";
|
|
9
9
|
import { CanvasRender } from "../../core/canvas";
|
|
10
10
|
import { Container } from "../../core/components/Container";
|
|
11
11
|
import { EffectManager } from "../../core/effect";
|
|
12
12
|
import { FontManager } from "../../core/font";
|
|
13
|
-
import { ZoomToRectHelper } from "../../core/helpers";
|
|
14
13
|
import { InputManager } from "../../core/input-manager";
|
|
15
14
|
import { Interaction } from "../../core/interactions/Interaction";
|
|
16
|
-
import { BaseModelLoader
|
|
15
|
+
import { BaseModelLoader } from "../../core/loaders";
|
|
17
16
|
import { Model } from "../../core/model";
|
|
18
17
|
import { PickManager } from "../../core/pick";
|
|
19
18
|
import { SceneManager } from "../../core/scene/SceneManager";
|
|
@@ -24,30 +23,18 @@ type ViewerEvents = {
|
|
|
24
23
|
};
|
|
25
24
|
export declare abstract class BaseViewer<BaseViewerEvents extends ViewerEvents = Record<ViewerEvent, any>> extends Event<BaseViewerEvents> {
|
|
26
25
|
name: ViewerName;
|
|
27
|
-
|
|
28
|
-
protected targetMaxFps: number;
|
|
29
|
-
protected timeStamp: number;
|
|
26
|
+
container: Container;
|
|
30
27
|
/**
|
|
31
|
-
*
|
|
28
|
+
* A map to store model file and id.
|
|
32
29
|
*/
|
|
33
|
-
protected requestAnimationFrameHandle?: number;
|
|
34
|
-
container: Container;
|
|
35
|
-
protected plugins: Plugin[];
|
|
36
30
|
loadedModels: Model[];
|
|
37
|
-
protected homeView?: Viewpoint;
|
|
38
31
|
protected inputManager: InputManager;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
protected css2dRenderer: CSS2DRenderer;
|
|
46
|
-
protected spinner: Spinner;
|
|
47
|
-
protected progressBar?: ProgressBar;
|
|
48
|
-
protected loaderManager: ModelLoaderManager;
|
|
49
|
-
protected zoomToRectHelper?: ZoomToRectHelper;
|
|
50
|
-
protected interaction?: Interaction;
|
|
32
|
+
/**
|
|
33
|
+
* When true, mesh geometry is quantized after load for supported 3D formats (Viewer3d)
|
|
34
|
+
* when {@link ModelConfig.quantize} is omitted. Per-model `quantize` overrides this.
|
|
35
|
+
* Defaults to `false`; set at runtime (e.g. `viewer.enableQuantization = true`) or pass `quantize` on each {@link ModelConfig}.
|
|
36
|
+
*/
|
|
37
|
+
enableQuantization: boolean;
|
|
51
38
|
/**
|
|
52
39
|
* Enables selecting an object
|
|
53
40
|
*/
|
|
@@ -86,11 +73,6 @@ export declare abstract class BaseViewer<BaseViewerEvents extends ViewerEvents =
|
|
|
86
73
|
abstract clearHighlight(): void;
|
|
87
74
|
getRaycaster(): THREE.Raycaster;
|
|
88
75
|
getPickManager(): PickManager;
|
|
89
|
-
/**
|
|
90
|
-
* Post-processing (GLSL watermark, optional FXAA/SSAO, …). Shared by 2D and 3D viewers.
|
|
91
|
-
* Created on first access so construction never runs before {@link BaseViewer.cameraManager} exists.
|
|
92
|
-
*/
|
|
93
|
-
protected get effect(): EffectManager;
|
|
94
76
|
/** Visual effects / composer (same instance as {@link BaseViewer.effect}). */
|
|
95
77
|
get effectManager(): EffectManager;
|
|
96
78
|
getViewerConfig(): BaseViewerConfig;
|
|
@@ -107,13 +89,11 @@ export declare abstract class BaseViewer<BaseViewerEvents extends ViewerEvents =
|
|
|
107
89
|
* @hidden
|
|
108
90
|
*/
|
|
109
91
|
enableRender: (time?: number) => void;
|
|
110
|
-
protected animate(timeStamp?: number): void;
|
|
111
92
|
resize(): void;
|
|
112
93
|
/**
|
|
113
|
-
* @
|
|
114
|
-
* @hidden
|
|
94
|
+
* Fills {@link ModelConfig.quantize} from {@link enableQuantization} when omitted, without mutating `modelCfg`.
|
|
115
95
|
*/
|
|
116
|
-
|
|
96
|
+
protected modelConfigForLoader(modelCfg: ModelConfig): ModelConfig;
|
|
117
97
|
abstract loadModel(modelCfg: ModelConfig, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
118
98
|
addModel(model: Model): void;
|
|
119
99
|
removeModelById(modelId: string): void;
|
|
@@ -139,14 +119,6 @@ export declare abstract class BaseViewer<BaseViewerEvents extends ViewerEvents =
|
|
|
139
119
|
* ```
|
|
140
120
|
*/
|
|
141
121
|
zoomToRect(): void;
|
|
142
|
-
/**
|
|
143
|
-
* @hidden
|
|
144
|
-
*/
|
|
145
|
-
deactivateZoomRect(): void;
|
|
146
|
-
/**
|
|
147
|
-
* Gets an unique modelId in case the expected id is duplicated.
|
|
148
|
-
*/
|
|
149
|
-
protected getUniqueModelId(expectedModelId: string): string;
|
|
150
122
|
/**
|
|
151
123
|
* Gets all objects' bounding box.
|
|
152
124
|
*/
|
|
@@ -3,7 +3,6 @@ import { BaseViewer } from "./BaseViewer";
|
|
|
3
3
|
import { ViewerName } from "./Constants";
|
|
4
4
|
import { Model2dConfig, Viewer2dConfig } from "../../core/Configs";
|
|
5
5
|
import { DxfData, DxfLayer } from "../../core/dxf";
|
|
6
|
-
import { EventInfo } from "../../core/input-manager/InputManager";
|
|
7
6
|
import { Model2d } from "../../core/model";
|
|
8
7
|
export interface EntityData {
|
|
9
8
|
modelId: string;
|
|
@@ -157,10 +156,6 @@ export declare const GroundPlaneRenderOrder = -1000;
|
|
|
157
156
|
export declare class Viewer2d extends BaseViewer {
|
|
158
157
|
name: ViewerName;
|
|
159
158
|
loadedModels: Model2d[];
|
|
160
|
-
/**
|
|
161
|
-
* @hidden
|
|
162
|
-
*/
|
|
163
|
-
masterModelId: string;
|
|
164
159
|
groundPlane?: THREE.Mesh;
|
|
165
160
|
raycastableObjects?: THREE.Object3D[];
|
|
166
161
|
constructor(viewerCfg: Viewer2dConfig);
|
|
@@ -260,21 +255,6 @@ export declare class Viewer2d extends BaseViewer {
|
|
|
260
255
|
* Upper right coordinate: (1, 1)
|
|
261
256
|
*/
|
|
262
257
|
protected getHitResultByNdcCoordinate(coord: THREE.Vector2): THREE.Vector2 | undefined;
|
|
263
|
-
/**
|
|
264
|
-
* Gets mouse hit result in world coordinate
|
|
265
|
-
* @example
|
|
266
|
-
* ``` typescript
|
|
267
|
-
* document.addEventListener("click", (event) => {
|
|
268
|
-
* const result = viewer.getHitResult(event);
|
|
269
|
-
* const loc = result?.location;
|
|
270
|
-
* if (loc) {
|
|
271
|
-
* console.log(`Clicked at x: ${loc[0]}, y: ${loc[1]}`);
|
|
272
|
-
* }
|
|
273
|
-
* });
|
|
274
|
-
* ```
|
|
275
|
-
* @hidden
|
|
276
|
-
*/
|
|
277
|
-
getHitResult(event: MouseEvent | PointerEvent | EventInfo): THREE.Vector2 | undefined;
|
|
278
258
|
/**
|
|
279
259
|
* Returns the active layout name, or undefined if none.
|
|
280
260
|
* @example
|
|
@@ -299,12 +279,6 @@ export declare class Viewer2d extends BaseViewer {
|
|
|
299
279
|
* ```
|
|
300
280
|
*/
|
|
301
281
|
getLayers(): (DxfLayers | PdfLayers)[];
|
|
302
|
-
/**
|
|
303
|
-
* Sets model's (aka, a dxf file) visibility.
|
|
304
|
-
* @throws Throws exception if modelId doesn't exist.
|
|
305
|
-
* @hidden
|
|
306
|
-
*/
|
|
307
|
-
setModelVisibility(modelId: string, visible: boolean): void;
|
|
308
282
|
/**
|
|
309
283
|
* Sets visibility of a layer by name.
|
|
310
284
|
* @param layerName Layer to show or hide.
|
|
@@ -318,22 +292,6 @@ export declare class Viewer2d extends BaseViewer {
|
|
|
318
292
|
* ```
|
|
319
293
|
*/
|
|
320
294
|
setLayerVisibility(layerName: string, visible: boolean, modelId?: string): void;
|
|
321
|
-
/**
|
|
322
|
-
* Sets layer's opacity
|
|
323
|
-
* @hidden
|
|
324
|
-
*/
|
|
325
|
-
setLayerOpacity(layerName: string, opacity: number, modelId?: string): void;
|
|
326
|
-
/**
|
|
327
|
-
* Sets layer's color
|
|
328
|
-
* @throws Throws exception if layer doesn't exist.
|
|
329
|
-
* @hidden
|
|
330
|
-
*/
|
|
331
|
-
setLayerColor(layerName: string, color: number, modelId?: string): void;
|
|
332
|
-
/**
|
|
333
|
-
* Resets a layer's color.
|
|
334
|
-
* @hidden
|
|
335
|
-
*/
|
|
336
|
-
resetLayerColor(layerName: string, modelId?: string): void;
|
|
337
295
|
/**
|
|
338
296
|
* Enables small feature culling in order to improve performance.
|
|
339
297
|
*/
|
|
@@ -3,17 +3,32 @@ import { BaseViewer } from "./BaseViewer";
|
|
|
3
3
|
import { ViewerName } from "./Constants";
|
|
4
4
|
import { Model3d } from "../model";
|
|
5
5
|
import { Viewer3dConfig, ModelConfig, Viewpoint } from "../../core/Configs";
|
|
6
|
+
import { CoordinateSpace, TransformGizmo, type TransformGizmoCallbacks, TransformMode } from "../../core/controls/TransformGizmo";
|
|
6
7
|
export declare class Viewer3d extends BaseViewer {
|
|
7
8
|
name: ViewerName;
|
|
8
9
|
loadedModels: Model3d[];
|
|
9
|
-
|
|
10
|
-
private
|
|
10
|
+
private transformGizmo?;
|
|
11
|
+
private transformGizmoCallbacks;
|
|
12
|
+
/**
|
|
13
|
+
* 3D selection set (supports multi-select). Order is insertion order.
|
|
14
|
+
* For legacy single-select APIs, the "highlighted object" is the last selected.
|
|
15
|
+
*/
|
|
16
|
+
private selectedObjects;
|
|
11
17
|
constructor(viewerCfg: Viewer3dConfig, homeView?: Viewpoint);
|
|
12
|
-
protected setDefaultBackground(): void;
|
|
13
18
|
is3d(): boolean;
|
|
14
19
|
loadLocalModel(url: string, modelCfg: ModelConfig, manager?: THREE.LoadingManager, onProgress?: (event: ProgressEvent) => void): Promise<void>;
|
|
15
20
|
loadModel(modelCfg: ModelConfig, onProgress?: ((event: ProgressEvent<EventTarget>) => void) | undefined): Promise<void>;
|
|
16
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Drops cached model bounds for the tree containing {@link object} so {@link BaseViewer.getBBox}
|
|
23
|
+
* and camera helpers use up-to-date geometry after transforms.
|
|
24
|
+
*/
|
|
25
|
+
invalidateModelBBoxForObject(object: THREE.Object3D): void;
|
|
26
|
+
/**
|
|
27
|
+
* Called after any external transform applied to {@link object}:
|
|
28
|
+
* invalidates the model bbox cache and re-tunes camera near/far and orbit
|
|
29
|
+
* min/max distances based on the updated scene bounds.
|
|
30
|
+
*/
|
|
31
|
+
private onObjectTransformed;
|
|
17
32
|
addModel(model: Model3d): void;
|
|
18
33
|
/**
|
|
19
34
|
* Sets distance culling factor in order to improve performance.
|
|
@@ -95,6 +110,17 @@ export declare class Viewer3d extends BaseViewer {
|
|
|
95
110
|
*/
|
|
96
111
|
getHighlightedObject(): THREE.Object3D | undefined;
|
|
97
112
|
clearHighlight(): void;
|
|
113
|
+
/**
|
|
114
|
+
* Adds an object to the current selection set (multi-select).
|
|
115
|
+
* Does not clear existing selection.
|
|
116
|
+
*/
|
|
117
|
+
addObjectToSelection(object: THREE.Object3D): void;
|
|
118
|
+
/** Removes an object from current selection set (multi-select). */
|
|
119
|
+
removeObjectFromSelection(object: THREE.Object3D): void;
|
|
120
|
+
/** Returns a shallow copy of current selection set (multi-select). */
|
|
121
|
+
getSelectedObjects(): THREE.Object3D[];
|
|
122
|
+
/** True when {@link object} is in the current selection set. */
|
|
123
|
+
isObjectSelected(object: THREE.Object3D): boolean;
|
|
98
124
|
setDoubleSidedMaterials(): void;
|
|
99
125
|
revertDoubleSidedMaterials(): void;
|
|
100
126
|
clearSelection(): void;
|
|
@@ -134,4 +160,31 @@ export declare class Viewer3d extends BaseViewer {
|
|
|
134
160
|
*/
|
|
135
161
|
generateSmartUv1(object?: THREE.Object3D): void;
|
|
136
162
|
resize(): void;
|
|
163
|
+
/**
|
|
164
|
+
* Optional callbacks for transform gizmo drag lifecycle (e.g. disable camera navigation while dragging).
|
|
165
|
+
*/
|
|
166
|
+
setTransformGizmoCallbacks(callbacks: TransformGizmoCallbacks): void;
|
|
167
|
+
private getOrCreateTransformGizmo;
|
|
168
|
+
/**
|
|
169
|
+
* Lazily created transform gizmo instance, if any operation has run.
|
|
170
|
+
*/
|
|
171
|
+
getTransformGizmo(): TransformGizmo | undefined;
|
|
172
|
+
attachTransformGizmo(object: THREE.Object3D): void;
|
|
173
|
+
/**
|
|
174
|
+
* Notifies the viewer that an object's transform was changed externally
|
|
175
|
+
* (e.g. Property panel input fields): invalidates model bbox cache,
|
|
176
|
+
* re-tunes camera near/far and orbit distances, and refreshes gizmo handles.
|
|
177
|
+
*/
|
|
178
|
+
notifyObjectTransformed(object: THREE.Object3D): void;
|
|
179
|
+
/**
|
|
180
|
+
* Repositions transform gizmo handles when the attached object was moved from outside the gizmo
|
|
181
|
+
* (e.g. Property panel transform fields).
|
|
182
|
+
*/
|
|
183
|
+
refreshTransformGizmo(): void;
|
|
184
|
+
detachTransformGizmo(): void;
|
|
185
|
+
setTransformMode(mode: TransformMode): void;
|
|
186
|
+
getTransformMode(): TransformMode;
|
|
187
|
+
setTransformSpace(space: CoordinateSpace): void;
|
|
188
|
+
getTransformSpace(): CoordinateSpace | undefined;
|
|
189
|
+
destroy(): void;
|
|
137
190
|
}
|
|
@@ -105,5 +105,10 @@ export declare enum ViewerEvent {
|
|
|
105
105
|
/**
|
|
106
106
|
* Triggered when selected object changed.
|
|
107
107
|
*/
|
|
108
|
-
ObjectDeselected = "objectdeselected"
|
|
108
|
+
ObjectDeselected = "objectdeselected",
|
|
109
|
+
/**
|
|
110
|
+
* Triggered when a selected object's transform (position/rotation/scale) is changed,
|
|
111
|
+
* either by the transform gizmo or programmatically.
|
|
112
|
+
*/
|
|
113
|
+
ObjectTransformed = "objecttransformed"
|
|
109
114
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x-viewer/core",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.15",
|
|
4
4
|
"homepage": "https://dwg.thingraph.site/",
|
|
5
5
|
"description": "WebGL-based 2D/3D viewer engine built on Three.js. View DWG/DXF/PDF files in the browser with no server required. Supports glTF, OBJ, FBX, IFC, STL and BimTiles formats.",
|
|
6
6
|
"author": "Thingraph",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"2d-polygon-boolean": "^1.0.1",
|
|
71
71
|
"2d-polygon-self-intersections": "^1.3.1",
|
|
72
72
|
"3d-tiles-renderer": "0.3.32",
|
|
73
|
-
"@mlightcad/libredwg-web": "^0.
|
|
73
|
+
"@mlightcad/libredwg-web": "^0.7.1",
|
|
74
74
|
"camera-controls": "^1.37.4",
|
|
75
75
|
"clipper-lib": "^6.4.2",
|
|
76
76
|
"concaveman": "^1.2.1",
|