@inweb/client 25.2.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.
- package/LICENSE +20 -0
- package/README.md +70 -0
- package/dist/client.js +21126 -0
- package/dist/client.js.map +1 -0
- package/dist/client.min.js +1 -0
- package/dist/client.module.js +7151 -0
- package/dist/client.module.js.map +1 -0
- package/lib/Api/Assembly.d.ts +339 -0
- package/lib/Api/ClashTest.d.ts +176 -0
- package/lib/Api/Client.d.ts +452 -0
- package/lib/Api/ClientEvents.d.ts +29 -0
- package/lib/Api/File.d.ts +568 -0
- package/lib/Api/HttpClient.d.ts +13 -0
- package/lib/Api/IAssembly.d.ts +14 -0
- package/lib/Api/IFile.d.ts +46 -0
- package/lib/Api/IHttpClient.d.ts +11 -0
- package/lib/Api/IUser.d.ts +11 -0
- package/lib/Api/Job.d.ts +142 -0
- package/lib/Api/Member.d.ts +85 -0
- package/lib/Api/Model.d.ts +147 -0
- package/lib/Api/Permission.d.ts +93 -0
- package/lib/Api/Project.d.ts +247 -0
- package/lib/Api/Role.d.ts +82 -0
- package/lib/Api/User.d.ts +197 -0
- package/lib/Api/impl/FetchError.d.ts +18 -0
- package/lib/Api/impl/Utils.d.ts +33 -0
- package/lib/Api/impl/http.d.ts +67 -0
- package/lib/ConvetMath.d.ts +29 -0
- package/lib/Viewer/CanvasEvents.d.ts +2 -0
- package/lib/Viewer/Commands/ApplyModelTransform.d.ts +2 -0
- package/lib/Viewer/Commands/ClearMarkup.d.ts +2 -0
- package/lib/Viewer/Commands/ClearSlices.d.ts +2 -0
- package/lib/Viewer/Commands/CreatePreview.d.ts +2 -0
- package/lib/Viewer/Commands/Explode.d.ts +2 -0
- package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +2 -0
- package/lib/Viewer/Commands/GetModels.d.ts +2 -0
- package/lib/Viewer/Commands/GetSelected.d.ts +2 -0
- package/lib/Viewer/Commands/HideSelected.d.ts +2 -0
- package/lib/Viewer/Commands/IsolateSelected.d.ts +2 -0
- package/lib/Viewer/Commands/RegenerateAll.d.ts +2 -0
- package/lib/Viewer/Commands/ResetView.d.ts +2 -0
- package/lib/Viewer/Commands/SelectModel.d.ts +2 -0
- package/lib/Viewer/Commands/SetActiveDragger.d.ts +2 -0
- package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +2 -0
- package/lib/Viewer/Commands/SetMarkupColor.d.ts +2 -0
- package/lib/Viewer/Commands/SetSelected.d.ts +2 -0
- package/lib/Viewer/Commands/ShowAll.d.ts +2 -0
- package/lib/Viewer/Commands/Unselect.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToExtents.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToObjects.d.ts +2 -0
- package/lib/Viewer/Commands/ZoomToSelected.d.ts +2 -0
- package/lib/Viewer/Commands.d.ts +3 -0
- package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +22 -0
- package/lib/Viewer/Draggers/Actions/PanAction.d.ts +18 -0
- package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +8 -0
- package/lib/Viewer/Draggers/Common/Geometry.d.ts +115 -0
- package/lib/Viewer/Draggers/Common/GestureManager.d.ts +41 -0
- package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +54 -0
- package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +30 -0
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +31 -0
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +20 -0
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +24 -0
- package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +27 -0
- package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +8 -0
- package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +8 -0
- package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +8 -0
- package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +15 -0
- package/lib/Viewer/Draggers/OdPanDragger.d.ts +12 -0
- package/lib/Viewer/Draggers/OdZoomDragger.d.ts +12 -0
- package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +11 -0
- package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +19 -0
- package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +14 -0
- package/lib/Viewer/Draggers/OdaLineDragger.d.ts +15 -0
- package/lib/Viewer/Draggers/OdaTextDragger.d.ts +16 -0
- package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +30 -0
- package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +19 -0
- package/lib/Viewer/EventEmitter2.d.ts +54 -0
- package/lib/Viewer/ICommands.d.ts +25 -0
- package/lib/Viewer/IEventEmitter2.d.ts +13 -0
- package/lib/Viewer/IViewer.d.ts +27 -0
- package/lib/Viewer/Loaders/BaseLoader.d.ts +11 -0
- package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
- package/lib/Viewer/Loaders/TCSLoader.d.ts +5 -0
- package/lib/Viewer/Loaders/UpdaterController.d.ts +15 -0
- package/lib/Viewer/Loaders/VsfXLoader.d.ts +5 -0
- package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +5 -0
- package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +12 -0
- package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +5 -0
- package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +11 -0
- package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +12 -0
- package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupText.d.ts +13 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +32 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +32 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
- package/lib/Viewer/Markup/IMarkup.d.ts +38 -0
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +63 -0
- package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +19 -0
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
- package/lib/Viewer/Markup/MarkupFactory.d.ts +7 -0
- package/lib/Viewer/Options.d.ts +228 -0
- package/lib/Viewer/OptionsEvents.d.ts +26 -0
- package/lib/Viewer/Viewer.d.ts +353 -0
- package/lib/Viewer/ViewerCommands.d.ts +23 -0
- package/lib/Viewer/ViewerEvents.d.ts +601 -0
- package/lib/Viewer/utils.d.ts +4 -0
- package/lib/index.d.ts +24 -0
- package/package.json +32 -0
- package/src/Api/Assembly.ts +678 -0
- package/src/Api/ClashTest.ts +290 -0
- package/src/Api/Client.ts +816 -0
- package/src/Api/ClientEvents.ts +31 -0
- package/src/Api/File.ts +962 -0
- package/src/Api/HttpClient.ts +73 -0
- package/src/Api/IAssembly.ts +37 -0
- package/src/Api/IFile.ts +74 -0
- package/src/Api/IHttpClient.ts +50 -0
- package/src/Api/IUser.ts +33 -0
- package/src/Api/Job.ts +253 -0
- package/src/Api/Member.ts +161 -0
- package/src/Api/Model.ts +259 -0
- package/src/Api/Permission.ts +173 -0
- package/src/Api/Project.ts +479 -0
- package/src/Api/Role.ts +158 -0
- package/src/Api/User.ts +357 -0
- package/src/Api/impl/FetchError.ts +48 -0
- package/src/Api/impl/Utils.ts +367 -0
- package/src/Api/impl/http.ts +92 -0
- package/src/ConvetMath.ts +372 -0
- package/src/Viewer/CanvasEvents.ts +41 -0
- package/src/Viewer/Commands/ApplyModelTransform.ts +70 -0
- package/src/Viewer/Commands/ClearMarkup.ts +28 -0
- package/src/Viewer/Commands/ClearSlices.ts +27 -0
- package/src/Viewer/Commands/CreatePreview.ts +33 -0
- package/src/Viewer/Commands/Explode.ts +38 -0
- package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
- package/src/Viewer/Commands/GetModels.ts +43 -0
- package/src/Viewer/Commands/GetSelected.ts +58 -0
- package/src/Viewer/Commands/HideSelected.ts +37 -0
- package/src/Viewer/Commands/IsolateSelected.ts +37 -0
- package/src/Viewer/Commands/RegenerateAll.ts +37 -0
- package/src/Viewer/Commands/ResetView.ts +43 -0
- package/src/Viewer/Commands/SelectModel.ts +52 -0
- package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
- package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
- package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
- package/src/Viewer/Commands/SetSelected.ts +47 -0
- package/src/Viewer/Commands/ShowAll.ts +37 -0
- package/src/Viewer/Commands/Unselect.ts +37 -0
- package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
- package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
- package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
- package/src/Viewer/Commands.ts +81 -0
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
- package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
- package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
- package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
- package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
- package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
- package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
- package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
- package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
- package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
- package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
- package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
- package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
- package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
- package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
- package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
- package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
- package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
- package/src/Viewer/EventEmitter2.ts +116 -0
- package/src/Viewer/ICommands.ts +53 -0
- package/src/Viewer/IEventEmitter2.ts +36 -0
- package/src/Viewer/IViewer.ts +55 -0
- package/src/Viewer/Loaders/BaseLoader.ts +40 -0
- package/src/Viewer/Loaders/LoaderFactory.ts +44 -0
- package/src/Viewer/Loaders/TCSLoader.ts +82 -0
- package/src/Viewer/Loaders/UpdaterController.ts +36 -0
- package/src/Viewer/Loaders/VsfXLoader.ts +87 -0
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
- package/src/Viewer/Markup/Api/IMarkupArrow.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
- package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupLine.ts +10 -0
- package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +119 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +113 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +121 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +99 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +113 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +104 -0
- package/src/Viewer/Markup/IMarkup.ts +39 -0
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +872 -0
- package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +273 -0
- package/src/Viewer/Markup/MarkupFactory.ts +32 -0
- package/src/Viewer/Options.ts +502 -0
- package/src/Viewer/OptionsEvents.ts +28 -0
- package/src/Viewer/Viewer.ts +1109 -0
- package/src/Viewer/ViewerCommands.ts +45 -0
- package/src/Viewer/ViewerEvents.ts +700 -0
- package/src/Viewer/utils.ts +74 -0
- package/src/index.ts +48 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
import { Viewer } from "../Viewer";
|
|
24
|
+
import { Point2d, Vector3 } from "./Common/Geometry";
|
|
25
|
+
import { OdBaseDragger } from "./Common/OdBaseDragger";
|
|
26
|
+
|
|
27
|
+
const FocalLengthConst = 42.0;
|
|
28
|
+
|
|
29
|
+
const calcFocalLength = (lensLength: number, fieldWidth: number, fieldHeight: number): number => {
|
|
30
|
+
return (lensLength / FocalLengthConst) * Math.sqrt(fieldWidth * fieldWidth + fieldHeight * fieldHeight);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export class OdaWalkDragger extends OdBaseDragger {
|
|
34
|
+
protected lastCoord: Point2d;
|
|
35
|
+
protected speed: number;
|
|
36
|
+
protected delta: number;
|
|
37
|
+
protected keyPressMap: Set<string>;
|
|
38
|
+
protected oldWCSEnableValue: boolean;
|
|
39
|
+
protected viewParams: any;
|
|
40
|
+
protected cameraId: any;
|
|
41
|
+
protected cameraWalker: any;
|
|
42
|
+
protected viewer: any;
|
|
43
|
+
protected multiplier: number;
|
|
44
|
+
protected lastFrameTS: number;
|
|
45
|
+
protected animationId: any;
|
|
46
|
+
protected deltaAngle: number;
|
|
47
|
+
protected enableZoomWheelPreviousValue: boolean;
|
|
48
|
+
|
|
49
|
+
constructor(subject: Viewer) {
|
|
50
|
+
super(subject);
|
|
51
|
+
this.viewer = undefined;
|
|
52
|
+
|
|
53
|
+
this.multiplier = 5;
|
|
54
|
+
this.speed = 1;
|
|
55
|
+
|
|
56
|
+
this.keyPressMap = new Set();
|
|
57
|
+
this.keydown = this.keydown.bind(this);
|
|
58
|
+
this.keyup = this.keyup.bind(this);
|
|
59
|
+
|
|
60
|
+
this.lastFrameTS = 0;
|
|
61
|
+
this.animationId = undefined;
|
|
62
|
+
this.processMovement = this.processMovement.bind(this);
|
|
63
|
+
|
|
64
|
+
this.deltaAngle = Math.PI / 3600;
|
|
65
|
+
this.autoSelect = true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
override initialize() {
|
|
69
|
+
super.initialize();
|
|
70
|
+
this.viewer = this.getViewer();
|
|
71
|
+
|
|
72
|
+
window.addEventListener("keydown", this.keydown, false);
|
|
73
|
+
window.addEventListener("keyup", this.keyup, false);
|
|
74
|
+
|
|
75
|
+
this.oldWCSEnableValue = this.viewer.getEnableWCS();
|
|
76
|
+
this.viewer.setEnableWCS(false);
|
|
77
|
+
|
|
78
|
+
const view = this.viewer.activeView;
|
|
79
|
+
const maxDimension = this.getMaxDimension(view);
|
|
80
|
+
this.speed = maxDimension / 30000;
|
|
81
|
+
|
|
82
|
+
this.subject.emitEvent({ type: "walkstart" });
|
|
83
|
+
|
|
84
|
+
this.viewParams = this.getViewParams();
|
|
85
|
+
//this.viewParams.lensLength = view.lensLength;
|
|
86
|
+
|
|
87
|
+
this.setViewParams(this.viewParams);
|
|
88
|
+
//view.lensLength = (view.lensLength * 42) / 120;
|
|
89
|
+
|
|
90
|
+
const model = this.viewer.getActiveModel();
|
|
91
|
+
this.cameraId = model.appendCamera("Camera0");
|
|
92
|
+
this.setupCamera(view);
|
|
93
|
+
model.delete();
|
|
94
|
+
|
|
95
|
+
//pCamera.setAdjustLensLength(true);
|
|
96
|
+
this.cameraWalker = new this.m_module.OdTvCameraWalker();
|
|
97
|
+
this.cameraWalker.setCamera(this.cameraId);
|
|
98
|
+
|
|
99
|
+
this.subject.update();
|
|
100
|
+
this.enableZoomWheelPreviousValue = this.subject.options.enableZoomWheel;
|
|
101
|
+
this.subject.options.enableZoomWheel = false;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
override dispose() {
|
|
105
|
+
this.oldWCSEnableValue =
|
|
106
|
+
this.oldWCSEnableValue !== undefined ? this.oldWCSEnableValue : this.subject.options.showWCS;
|
|
107
|
+
this.viewer.setEnableWCS(this.oldWCSEnableValue);
|
|
108
|
+
|
|
109
|
+
super.dispose();
|
|
110
|
+
|
|
111
|
+
this.keyPressMap.clear();
|
|
112
|
+
|
|
113
|
+
window.removeEventListener("keydown", this.keydown);
|
|
114
|
+
window.removeEventListener("keyup", this.keyup);
|
|
115
|
+
|
|
116
|
+
if (this.animationId) {
|
|
117
|
+
window.cancelAnimationFrame(this.animationId);
|
|
118
|
+
this.animationId = undefined;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.cameraId) {
|
|
122
|
+
const model = this.viewer.getActiveModel();
|
|
123
|
+
model.removeEntity(this.cameraId);
|
|
124
|
+
model.delete();
|
|
125
|
+
this.cameraWalker?.delete();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (this.viewParams) {
|
|
129
|
+
this.setViewParams(this.viewParams);
|
|
130
|
+
|
|
131
|
+
const avp = this.viewer.activeView;
|
|
132
|
+
//avp.lensLength = this.viewParams.lensLength;
|
|
133
|
+
avp.delete();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.subject.update();
|
|
137
|
+
this.subject.options.enableZoomWheel = this.enableZoomWheelPreviousValue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
keydown(ev) {
|
|
141
|
+
switch (ev.code) {
|
|
142
|
+
case "NumpadSubtract":
|
|
143
|
+
case "Minus":
|
|
144
|
+
if (this.multiplier > 1) {
|
|
145
|
+
this.multiplier = this.multiplier - 1;
|
|
146
|
+
this.subject.emitEvent({ type: "walkspeedchange", data: this.multiplier });
|
|
147
|
+
}
|
|
148
|
+
break;
|
|
149
|
+
case "NumpadAdd":
|
|
150
|
+
case "Equal":
|
|
151
|
+
if (this.multiplier < 10) {
|
|
152
|
+
this.multiplier = this.multiplier + 1;
|
|
153
|
+
this.subject.emitEvent({ type: "walkspeedchange", data: this.multiplier });
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "KeyW":
|
|
157
|
+
case "KeyA":
|
|
158
|
+
case "KeyS":
|
|
159
|
+
case "KeyD":
|
|
160
|
+
case "KeyQ":
|
|
161
|
+
case "KeyE":
|
|
162
|
+
this.keyPressMap.add(ev.code);
|
|
163
|
+
if (!this.animationId) this.processMovement(0);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
keyup(ev) {
|
|
169
|
+
this.keyPressMap.delete(ev.code);
|
|
170
|
+
if (this.keyPressMap.size < 1 && this.animationId) {
|
|
171
|
+
window.cancelAnimationFrame(this.animationId);
|
|
172
|
+
this.animationId = undefined;
|
|
173
|
+
this.lastFrameTS = 0;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
processMovement(timestamp) {
|
|
178
|
+
this.animationId = requestAnimationFrame(this.processMovement);
|
|
179
|
+
|
|
180
|
+
if (this.lastFrameTS !== 0) {
|
|
181
|
+
const deltaTS = timestamp - this.lastFrameTS;
|
|
182
|
+
const currentDelta = this.multiplier * deltaTS * this.speed;
|
|
183
|
+
|
|
184
|
+
for (const keyCode of this.keyPressMap) {
|
|
185
|
+
switch (keyCode) {
|
|
186
|
+
case "KeyW":
|
|
187
|
+
this.cameraWalker.moveForward(currentDelta);
|
|
188
|
+
break;
|
|
189
|
+
case "KeyS":
|
|
190
|
+
this.cameraWalker.moveBackward(currentDelta);
|
|
191
|
+
break;
|
|
192
|
+
case "KeyA":
|
|
193
|
+
this.cameraWalker.moveLeft(currentDelta);
|
|
194
|
+
break;
|
|
195
|
+
case "KeyD":
|
|
196
|
+
this.cameraWalker.moveRight(currentDelta);
|
|
197
|
+
break;
|
|
198
|
+
case "KeyQ":
|
|
199
|
+
this.cameraWalker.moveUp(currentDelta);
|
|
200
|
+
break;
|
|
201
|
+
case "KeyE":
|
|
202
|
+
this.cameraWalker.moveDown(currentDelta);
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
this.subject.update();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this.lastFrameTS = timestamp;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
override drag(x, y, dltX, dltY) {
|
|
213
|
+
if (this.cameraId && this.isDragging) {
|
|
214
|
+
if (dltX !== 0.0) this.turnLeft(-dltX * this.deltaAngle);
|
|
215
|
+
if (dltY !== 0.0) this.cameraWalker.turnDown(dltY * this.deltaAngle);
|
|
216
|
+
this.subject.update();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
turnLeft(angle) {
|
|
221
|
+
//TODO: migrate to VisualizeJS
|
|
222
|
+
const pCamera = this.cameraWalker.camera().openObjectAsCamera();
|
|
223
|
+
const dir = this.toVector(pCamera.direction());
|
|
224
|
+
const up = this.toVector(pCamera.upVector());
|
|
225
|
+
|
|
226
|
+
const pos = pCamera.position();
|
|
227
|
+
|
|
228
|
+
const rotMatrix = this.createMatrix3d();
|
|
229
|
+
const zAxisVector: Vector3 = [0, 0, 1];
|
|
230
|
+
rotMatrix.setToRotation(angle, zAxisVector, pos);
|
|
231
|
+
dir.transformBy(rotMatrix);
|
|
232
|
+
up.transformBy(rotMatrix);
|
|
233
|
+
pCamera.setupCameraByDirection(pos, dir.toArray(), up.toArray());
|
|
234
|
+
pCamera.delete();
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
setupCamera(view) {
|
|
238
|
+
const pCamera = this.cameraId.openObjectAsCamera();
|
|
239
|
+
const target = view.viewTarget;
|
|
240
|
+
|
|
241
|
+
pCamera.setDisplayGlyph(false);
|
|
242
|
+
pCamera.setDisplayTarget(false);
|
|
243
|
+
pCamera.setAutoAdjust(true);
|
|
244
|
+
pCamera.setupCamera(view.viewPosition, target, view.upVector);
|
|
245
|
+
pCamera.setNearClip(false, 1.0);
|
|
246
|
+
pCamera.setFarClip(false, 0);
|
|
247
|
+
pCamera.setViewParameters(view.viewFieldWidth, view.viewFieldHeight, true);
|
|
248
|
+
|
|
249
|
+
const focalL = calcFocalLength(view.lensLength, view.viewFieldWidth, view.viewFieldHeight);
|
|
250
|
+
|
|
251
|
+
const pTarget = this.toPoint(view.viewTarget);
|
|
252
|
+
const viewDir = this.toPoint(view.viewPosition);
|
|
253
|
+
const viewDirSub = viewDir.sub(pTarget);
|
|
254
|
+
const viewDirVec = viewDirSub.asVector();
|
|
255
|
+
const viewDirVecNormal = viewDirVec.normalize();
|
|
256
|
+
|
|
257
|
+
const geViewDir = this.toGeVector(viewDirVecNormal);
|
|
258
|
+
const newGeViewDir = [geViewDir[0] * focalL, geViewDir[1] * focalL, geViewDir[2] * focalL];
|
|
259
|
+
|
|
260
|
+
const pTarget2 = this.toPoint(view.viewTarget);
|
|
261
|
+
const newGeViewDirPt = this.toPoint(newGeViewDir);
|
|
262
|
+
|
|
263
|
+
const newPos = pTarget2.add(newGeViewDirPt);
|
|
264
|
+
pCamera.setupCamera(this.toGePoint(newPos), view.viewTarget, view.upVector);
|
|
265
|
+
|
|
266
|
+
this.deleteAll([pTarget, viewDir, viewDirSub, viewDirVec, viewDirVecNormal, pTarget2, newGeViewDirPt, newPos]);
|
|
267
|
+
|
|
268
|
+
pCamera.assignView(view);
|
|
269
|
+
pCamera.delete();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
getMaxDimension(view) {
|
|
273
|
+
const [xmax, ymax, zmax] = view.sceneExtents.max();
|
|
274
|
+
const [xmin, ymin, zmin] = view.sceneExtents.min();
|
|
275
|
+
const volume = [xmax - xmin, ymax - ymin, zmax - zmin];
|
|
276
|
+
return Math.max(...volume);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
/* eslint-disable no-unused-vars */
|
|
24
|
+
import { Viewer } from "../Viewer";
|
|
25
|
+
import { Point2d } from "./Common/Geometry";
|
|
26
|
+
import { ViewParams } from "./Common/OdaGeAction";
|
|
27
|
+
import { OdBaseDragger } from "./Common/OdBaseDragger";
|
|
28
|
+
|
|
29
|
+
export class OrbitAroundBuildingDragger extends OdBaseDragger {
|
|
30
|
+
protected maxPolarAngle: number;
|
|
31
|
+
protected minPolarAngle: number;
|
|
32
|
+
protected m_viewCenter: any;
|
|
33
|
+
protected m_startPoint: Point2d;
|
|
34
|
+
protected startCameraParams: ViewParams;
|
|
35
|
+
protected m_delta: number;
|
|
36
|
+
|
|
37
|
+
constructor(viewer: Viewer) {
|
|
38
|
+
super(viewer);
|
|
39
|
+
this.autoSelect = true;
|
|
40
|
+
this.press = false;
|
|
41
|
+
this.maxPolarAngle = Math.PI / 2;
|
|
42
|
+
this.minPolarAngle = 0; // radians
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override start(x: number, y: number): void {
|
|
46
|
+
this.press = true;
|
|
47
|
+
|
|
48
|
+
this.m_viewCenter = this.getCenter();
|
|
49
|
+
this.m_startPoint = { x, y };
|
|
50
|
+
|
|
51
|
+
const view = this.getViewer().activeView;
|
|
52
|
+
|
|
53
|
+
this.startCameraParams = this.getViewParams();
|
|
54
|
+
|
|
55
|
+
const corners = view.vportRect;
|
|
56
|
+
|
|
57
|
+
this.m_delta = Math.max(corners[1] - corners[0], corners[2] - corners[3]);
|
|
58
|
+
|
|
59
|
+
this.beginInteractivity();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setDefaultViewParams(): void {
|
|
63
|
+
this.setViewParams(this.startCameraParams);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override drag(x: number, y: number, dltX: number, dltY: number): void {
|
|
67
|
+
if (this.press) {
|
|
68
|
+
let dX = x - this.m_startPoint.x;
|
|
69
|
+
let dY = y - this.m_startPoint.y;
|
|
70
|
+
|
|
71
|
+
dX *= Math.PI / this.m_delta;
|
|
72
|
+
dY *= Math.PI / this.m_delta;
|
|
73
|
+
|
|
74
|
+
this.setDefaultViewParams();
|
|
75
|
+
|
|
76
|
+
const { Vector3d, Matrix3d } = this.m_module;
|
|
77
|
+
|
|
78
|
+
const target = Vector3d.createFromArray(this.startCameraParams.target);
|
|
79
|
+
const offset = Vector3d.createFromArray(this.startCameraParams.position).sub(target);
|
|
80
|
+
const dir = offset.normalize();
|
|
81
|
+
|
|
82
|
+
const zMatrix = new Matrix3d();
|
|
83
|
+
zMatrix.setToIdentity();
|
|
84
|
+
const xMatrix = new Matrix3d();
|
|
85
|
+
xMatrix.setToIdentity();
|
|
86
|
+
|
|
87
|
+
// ---- restore start rotation ----
|
|
88
|
+
|
|
89
|
+
const yAxis = Vector3d.createFromArray([dir.x, dir.y, dir.z]);
|
|
90
|
+
const zAxis = Vector3d.createFromArray(this.startCameraParams.upVector);
|
|
91
|
+
const xAxis = yAxis.crossProduct(zAxis);
|
|
92
|
+
|
|
93
|
+
// ----------- zAxis rotation restore -----------
|
|
94
|
+
let xyDir = Vector3d.createFromArray([yAxis.x, yAxis.y, 0]);
|
|
95
|
+
|
|
96
|
+
if (xyDir.length() <= 0.00001) {
|
|
97
|
+
xyDir.set(-xAxis.y, xAxis.x, 0);
|
|
98
|
+
} else {
|
|
99
|
+
xyDir = xyDir.normalize();
|
|
100
|
+
}
|
|
101
|
+
const xyAngle =
|
|
102
|
+
Math.sign(xyDir.dotProduct(Vector3d.createFromArray([-1, 0, 0]))) *
|
|
103
|
+
xyDir.angleTo(Vector3d.createFromArray([0, 1, 0]));
|
|
104
|
+
dX -= xyAngle;
|
|
105
|
+
// ----------- zAxis rotation restore -----------
|
|
106
|
+
|
|
107
|
+
// ----------- xAxis rotation restore -----------
|
|
108
|
+
let yzDir = Vector3d.createFromArray([dir.x, dir.y, 0]);
|
|
109
|
+
let yzAngle = 0;
|
|
110
|
+
if (yzDir.length() <= 0.00001) {
|
|
111
|
+
yzAngle = (-dir.z * Math.PI) / 2;
|
|
112
|
+
} else {
|
|
113
|
+
yzDir = yzDir.normalize();
|
|
114
|
+
yzAngle = -yzDir.angleTo(dir);
|
|
115
|
+
}
|
|
116
|
+
dY -= yzAngle;
|
|
117
|
+
// ----------- xAxis rotation restore -----------
|
|
118
|
+
|
|
119
|
+
// ---- restore start rotation ----
|
|
120
|
+
|
|
121
|
+
zMatrix.setToRotation(-dX, [0, 0, 1], [0, 0, 0]);
|
|
122
|
+
|
|
123
|
+
const xAngle = Math.max(this.minPolarAngle, Math.min(this.maxPolarAngle, dY));
|
|
124
|
+
xMatrix.setToRotation(xAngle, [1, 0, 0], [0, 0, 0]);
|
|
125
|
+
|
|
126
|
+
const endMatrix = zMatrix.postMultBy(xMatrix);
|
|
127
|
+
|
|
128
|
+
let pos = Vector3d.createFromArray([0, 1, 0]).transformBy(endMatrix);
|
|
129
|
+
const up = Vector3d.createFromArray([0, 0, 1]).transformBy(endMatrix);
|
|
130
|
+
|
|
131
|
+
pos.setLength(offset.length());
|
|
132
|
+
pos = target.add(pos);
|
|
133
|
+
|
|
134
|
+
const current = this.getViewParams();
|
|
135
|
+
|
|
136
|
+
current.position = pos.toArray();
|
|
137
|
+
current.upVector = up.toArray();
|
|
138
|
+
|
|
139
|
+
this.setViewParams(current);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
override end(): void {
|
|
144
|
+
this.press = false;
|
|
145
|
+
this.endInteractivity();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
getCenter(): any {
|
|
149
|
+
const viewer = this.getViewer();
|
|
150
|
+
|
|
151
|
+
let ext = viewer.getActiveExtents();
|
|
152
|
+
|
|
153
|
+
const pSet = viewer.getSelected();
|
|
154
|
+
if (!pSet.isNull() && pSet.numItems() !== 0) {
|
|
155
|
+
const itr = pSet.getIterator();
|
|
156
|
+
const entId = itr.getEntity();
|
|
157
|
+
|
|
158
|
+
if (entId.getType() === 1) {
|
|
159
|
+
const obj = entId.openObject();
|
|
160
|
+
|
|
161
|
+
ext.delete();
|
|
162
|
+
ext = obj.getExtents();
|
|
163
|
+
|
|
164
|
+
obj.delete();
|
|
165
|
+
} else if (entId.getType() === 2) {
|
|
166
|
+
const obj = entId.openObjectAsInsert();
|
|
167
|
+
const extTuple = obj.getExtents();
|
|
168
|
+
|
|
169
|
+
ext.delete();
|
|
170
|
+
ext = extTuple.ext;
|
|
171
|
+
|
|
172
|
+
extTuple.delete();
|
|
173
|
+
obj.delete();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
itr.delete();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const center = ext.center();
|
|
180
|
+
|
|
181
|
+
ext.delete();
|
|
182
|
+
return center;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { IEvent, IEventEmitter } from "./IEventEmitter2";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The minimal basic Event that can be emitted by a {@link EventEmitter2}.
|
|
28
|
+
*/
|
|
29
|
+
export interface Event<T extends string = string> extends IEvent {
|
|
30
|
+
type: T;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Event emitter for custom objects.
|
|
35
|
+
*/
|
|
36
|
+
export class EventEmitter2<EventMap extends Record<string, any> = Record<string, any>> implements IEventEmitter {
|
|
37
|
+
private _listeners = undefined;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Registers a new listener for an event type.
|
|
41
|
+
*
|
|
42
|
+
* @param type - The type of event to listen to.
|
|
43
|
+
* @param listener - The function that gets called when the event is fired.
|
|
44
|
+
*/
|
|
45
|
+
addEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {
|
|
46
|
+
if (this._listeners === undefined) this._listeners = {};
|
|
47
|
+
if (this._listeners[type] === undefined) this._listeners[type] = [];
|
|
48
|
+
this._listeners[type].push(listener);
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Removes the listener from an event type.
|
|
54
|
+
*
|
|
55
|
+
* @param type - The type of the listener that gets removed.
|
|
56
|
+
* @param listener - The listener function that gets removed.
|
|
57
|
+
*/
|
|
58
|
+
removeEventListener<T extends keyof EventMap>(type: T, listener: (event: EventMap[T]) => void): this {
|
|
59
|
+
if (this._listeners === undefined) return this;
|
|
60
|
+
if (this._listeners[type] === undefined) return this;
|
|
61
|
+
const listeners = this._listeners[type].filter((x) => x !== listener);
|
|
62
|
+
this._listeners[type] = listeners.length === 0 ? undefined : listeners;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* If `type` is specified, removes all registered listeners for type, otherwise removes all
|
|
68
|
+
* registered listeners.
|
|
69
|
+
*
|
|
70
|
+
* @param type - The type of the listener that gets removed.
|
|
71
|
+
*/
|
|
72
|
+
removeAllListeners<T extends keyof EventMap>(type?: T): this {
|
|
73
|
+
if (type) this._listeners[type] = undefined;
|
|
74
|
+
else this._listeners = undefined;
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Fires the event. Calls each of the listeners registered for the event type `event.type`,
|
|
80
|
+
* in the order they were registered.
|
|
81
|
+
*
|
|
82
|
+
* @param event - The event that gets fired.
|
|
83
|
+
*/
|
|
84
|
+
emitEvent<T extends keyof EventMap>(event: Event<Extract<T, string>> & EventMap[T]): boolean {
|
|
85
|
+
if (this._listeners === undefined) return false;
|
|
86
|
+
if (this._listeners[event.type] === undefined) return false;
|
|
87
|
+
const invoke = this._listeners[event.type].slice();
|
|
88
|
+
invoke.forEach((listener) => listener.call(this, event));
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Node.js style, to emit custom events
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Alias to {@link EventEmitter2.addEventListener()}
|
|
96
|
+
*/
|
|
97
|
+
on(type: string, listener: (event: object) => void): this {
|
|
98
|
+
return this.addEventListener(type as any, listener as any);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Alias to {@link EventEmitter2.removeEventListener()}.
|
|
103
|
+
*/
|
|
104
|
+
off(type: string, listener: (event: object) => void): this {
|
|
105
|
+
return this.removeEventListener(type as any, listener as any);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Alias to {@link EventEmitter2.emitEvent()}.
|
|
110
|
+
*/
|
|
111
|
+
emit(event: string | object, ...args: any[]): boolean {
|
|
112
|
+
if (typeof event === "string") return this.emitEvent({ type: event, args } as any);
|
|
113
|
+
else if (typeof event === "object") return this.emitEvent(event as any);
|
|
114
|
+
else return false;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2023, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { IViewer } from "./IViewer";
|
|
25
|
+
|
|
26
|
+
export interface ICommandService {
|
|
27
|
+
executeCommand(id: string, ...args: any[]): any;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ICommandsMap = Map<string, ICommand>;
|
|
31
|
+
|
|
32
|
+
export interface ICommandHandler {
|
|
33
|
+
(viewer: any, ...args: any[]): any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ICommand {
|
|
37
|
+
id: string;
|
|
38
|
+
handler: ICommandHandler;
|
|
39
|
+
thisArg?: any;
|
|
40
|
+
description?: ICommandDescription;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ICommandDescription {
|
|
44
|
+
readonly description: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ICommands {
|
|
48
|
+
registerCommand(id: string, handler: ICommandHandler, description?: ICommandDescription, thisArg?: any): void;
|
|
49
|
+
registerCommandAlias(id: string, alias: string): void;
|
|
50
|
+
getCommands(): ICommandsMap;
|
|
51
|
+
getCommand(id: string): ICommand | undefined;
|
|
52
|
+
executeCommand(id: string, viewer: IViewer, ...args: any[]): any;
|
|
53
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
export interface IEvent {
|
|
25
|
+
type: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IEventEmitter {
|
|
29
|
+
addEventListener(type: string, listener: (event: IEvent) => void): this;
|
|
30
|
+
removeEventListener(type: string, listener: (event: IEvent) => void): this;
|
|
31
|
+
removeAllListeners(type?: string): this;
|
|
32
|
+
emitEvent(event: IEvent): boolean;
|
|
33
|
+
on(type: string, listener: (event: object) => void): this;
|
|
34
|
+
off(type: string, listener: (event: object) => void): this;
|
|
35
|
+
emit(event: string | object, ...args: any[]): boolean;
|
|
36
|
+
}
|