@openglobus/og 1.0.0-rc29 → 1.0.0-rc30

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.
@@ -1,20 +1,18 @@
1
- import { Control, type IControlParams } from "../Control";
2
- import { EntityEditorScene, type EditModeName } from "./EntityEditorScene";
1
+ import { EntityGizmo, type IEntityGizmoParams } from "../entityGizmo/EntityGizmo";
3
2
  import { EntityEditorDialog } from "./EntityEditorDialog";
4
- import { Entity } from "../../entity/Entity";
5
3
  import { Dialog } from "../../ui";
6
- export interface IEntityEditorParams extends IControlParams {
7
- editMode?: EditModeName;
4
+ export interface IEntityEditorParams extends Omit<IEntityGizmoParams, "tools"> {
8
5
  }
9
- export declare class EntityEditor extends Control {
10
- protected _entityEditorScene: EntityEditorScene;
6
+ /**
7
+ * Entity properties editor. Combines the {@link EntityGizmo} on-map transform mechanism
8
+ * with the "Entity Properties" dialog.
9
+ * @class
10
+ * @extends {EntityGizmo}
11
+ */
12
+ export declare class EntityEditor extends EntityGizmo {
11
13
  protected _dialog: EntityEditorDialog;
12
14
  constructor(options?: IEntityEditorParams);
13
15
  oninit(): void;
14
- onactivate(): void;
15
16
  ondeactivate(): void;
16
- selectEntity(entity: Entity): void;
17
17
  positionDialogLeftOf(anchor: Dialog<unknown>): void;
18
- unselectEntity(): void;
19
- getSelectedEntity(): Entity | null;
20
18
  }
@@ -1,14 +1,14 @@
1
1
  import { Dialog, type IDialogParams } from "../../ui/Dialog";
2
- import { EntityEditorScene } from "./EntityEditorScene";
2
+ import { EntityGizmoScene } from "../entityGizmo/EntityGizmoScene";
3
3
  import { Entity } from "../../entity/Entity";
4
4
  import { Vec3 } from "../../math/Vec3";
5
5
  import { CameraEditorView } from "./CameraEditorView";
6
6
  import { EntityEditorView } from "./EntityEditorView";
7
7
  import { ProjectorEditorView } from "./ProjectorEditorView";
8
8
  interface IEntityEditorDialog extends IDialogParams {
9
- model: EntityEditorScene;
9
+ model: EntityGizmoScene;
10
10
  }
11
- export declare class EntityEditorDialog extends Dialog<EntityEditorScene> {
11
+ export declare class EntityEditorDialog extends Dialog<EntityGizmoScene> {
12
12
  protected _entityView: EntityEditorView | null;
13
13
  protected _cameraView: CameraEditorView | null;
14
14
  protected _projectorView: ProjectorEditorView | null;
@@ -4,12 +4,12 @@ import { Input } from "../../ui/Input";
4
4
  import { Slider } from "../../ui/Slider";
5
5
  import { TitleBarView } from "../../ui/TitleBarView";
6
6
  import { View, type IViewParams } from "../../ui/View";
7
- import { EntityEditorScene } from "./EntityEditorScene";
7
+ import { EntityGizmoScene } from "../entityGizmo/EntityGizmoScene";
8
8
  interface IEntityEditorViewParams extends IViewParams {
9
- model: EntityEditorScene;
9
+ model: EntityGizmoScene;
10
10
  entity?: Entity;
11
11
  }
12
- export declare class EntityEditorView extends View<EntityEditorScene> {
12
+ export declare class EntityEditorView extends View<EntityGizmoScene> {
13
13
  protected _entity: Entity | null;
14
14
  protected _titleBarView: TitleBarView;
15
15
  protected _bodyEl: HTMLElement | null;
@@ -0,0 +1,103 @@
1
+ import { Control, type IControlParams } from "../Control";
2
+ import { type EventsHandler } from "../../Events";
3
+ import { Entity } from "../../entity/Entity";
4
+ import { EntityGizmoScene, type EditModeName, type GizmoTools, type IGizmoTransformEvent } from "./EntityGizmoScene";
5
+ export interface IEntityGizmoParams extends IControlParams {
6
+ tools?: GizmoTools;
7
+ editMode?: EditModeName;
8
+ autoSelect?: boolean;
9
+ }
10
+ type EntityGizmoEventsList = [
11
+ "select",
12
+ "unselect",
13
+ "transformstart",
14
+ "transformchange",
15
+ "transformend",
16
+ "transformcancel"
17
+ ];
18
+ /**
19
+ * On-map gizmo for translating and rotating entities.
20
+ * @class
21
+ * @extends {Control}
22
+ * @param {IEntityGizmoParams} [options] - Gizmo options:
23
+ * @param {GizmoTools} [options.tools] - Gizmo tool set, i.e. which handles are shown. `translate`
24
+ * shows move axes and planes only, `full` adds rotation rings. Orthogonal to `editMode`.
25
+ * @param {EditModeName} [options.editMode] - Rotation mode. `native` rotates in the entity's own
26
+ * frame, `yaw` rotates in the local horizon frame. Affects the rotation rings only, so it does
27
+ * nothing with `tools: "translate"`.
28
+ * @param {boolean} [options.autoSelect] - When `false`, a left click on a map entity does not
29
+ * change the gizmo selection, so the host application stays the only source of the selection.
30
+ * Default is `true`.
31
+ */
32
+ export declare class EntityGizmo extends Control {
33
+ events: EventsHandler<EntityGizmoEventsList>;
34
+ protected _scene: EntityGizmoScene;
35
+ constructor(options?: IEntityGizmoParams);
36
+ oninit(): void;
37
+ onactivate(): void;
38
+ ondeactivate(): void;
39
+ onremove(): void;
40
+ /**
41
+ * Gizmo tool set: which handles are shown.
42
+ * @public
43
+ */
44
+ get tools(): GizmoTools;
45
+ set tools(tools: GizmoTools);
46
+ /**
47
+ * Rotation mode of the rotation rings. Does nothing with `tools: "translate"`.
48
+ * @public
49
+ */
50
+ get editMode(): EditModeName;
51
+ set editMode(editMode: EditModeName);
52
+ /**
53
+ * When `false`, a left click on a map entity does not change the gizmo selection.
54
+ * @public
55
+ */
56
+ get autoSelect(): boolean;
57
+ set autoSelect(autoSelect: boolean);
58
+ /**
59
+ * Shows the gizmo on the given entity. Activates the control when it is inactive.
60
+ * Changing the selection cancels any running gesture on the previously selected entity.
61
+ * @public
62
+ * @param {Entity} entity - Entity to transform.
63
+ */
64
+ selectEntity(entity: Entity): void;
65
+ /**
66
+ * Hides the gizmo and drops the selection. Cancels a running gesture.
67
+ * @public
68
+ */
69
+ unselectEntity(): void;
70
+ /**
71
+ * Returns the selected entity or `null`.
72
+ * @public
73
+ * @returns {Entity | null}
74
+ */
75
+ getSelectedEntity(): Entity | null;
76
+ /**
77
+ * Returns `true` while a drag gesture is running.
78
+ * @public
79
+ * @returns {boolean}
80
+ */
81
+ isTransforming(): boolean;
82
+ /**
83
+ * Returns the running gesture description or `null`.
84
+ * @public
85
+ * @returns {IGizmoTransformEvent | null}
86
+ */
87
+ getActiveTransform(): IGizmoTransformEvent | null;
88
+ /**
89
+ * Cancels the current gesture and restores the entity transform when possible.
90
+ * @public
91
+ * @returns {boolean} Whether a gesture was cancelled.
92
+ */
93
+ cancelTransform(): boolean;
94
+ protected _bindSceneEvents(): void;
95
+ protected _unbindSceneEvents(): void;
96
+ protected _onSelect: (entity: Entity) => void;
97
+ protected _onUnselect: (entity: Entity | null) => void;
98
+ protected _onTransformStart: (e: IGizmoTransformEvent) => void;
99
+ protected _onTransformChange: (e: IGizmoTransformEvent) => void;
100
+ protected _onTransformEnd: (e: IGizmoTransformEvent) => void;
101
+ protected _onTransformCancel: (e: IGizmoTransformEvent) => void;
102
+ }
103
+ export {};
@@ -12,16 +12,45 @@ import { MovePlaneEntity } from "./MovePlaneEntity";
12
12
  import { RotateEntity } from "./RotateEntity";
13
13
  import { AxisTrackEntity } from "./AxisTrackEntity";
14
14
  import { EntityCollection } from "../../entity/EntityCollection";
15
- export interface IEntityEditorSceneParams {
15
+ export interface IEntityGizmoSceneParams {
16
16
  planet?: Planet;
17
17
  name?: string;
18
18
  editMode?: EditModeName;
19
+ tools?: GizmoTools;
20
+ autoSelect?: boolean;
19
21
  }
20
22
  export declare const NATIVE_MODE = 0;
21
23
  export declare const YAW_MODE = 1;
24
+ /** Rotation mode: the frame the rotation rings are built in and written back through. */
22
25
  export type EditMode = typeof NATIVE_MODE | typeof YAW_MODE;
23
26
  export type EditModeName = "native" | "yaw";
24
- type EntityEditorSceneEventsList = [
27
+ /**
28
+ * Gizmo tool set, i.e. which handles are shown. Orthogonal to the rotation {@link EditModeName}.
29
+ * `translate` - move axes and planes only.
30
+ * `full` - move axes, planes and rotation rings.
31
+ */
32
+ export type GizmoTools = "translate" | "full";
33
+ /** Gizmo handle names. Each handle belongs to exactly one {@link GizmoTransformKind}. */
34
+ export type GizmoTransformHandle = "move_x" | "move_y" | "move_z" | "move_xz" | "move_xy" | "move_zy" | "rotate_pitch" | "rotate_yaw" | "rotate_roll";
35
+ /** Kind of transformation a gesture performs. */
36
+ export type GizmoTransformKind = "translate" | "rotate";
37
+ /** Payload of `transformstart`, `transformchange`, `transformend` and `transformcancel`. */
38
+ export interface IGizmoTransformEvent {
39
+ entity: Entity;
40
+ kind: GizmoTransformKind;
41
+ handle: GizmoTransformHandle;
42
+ }
43
+ interface IGizmoGesture {
44
+ entity: Entity;
45
+ handle: GizmoTransformHandle;
46
+ kind: GizmoTransformKind;
47
+ started: boolean;
48
+ cartesian: Vec3;
49
+ pitch: number;
50
+ yaw: number;
51
+ roll: number;
52
+ }
53
+ type EntityGizmoSceneEventsList = [
25
54
  "mousemove",
26
55
  "mouseenter",
27
56
  "mouseleave",
@@ -54,10 +83,20 @@ type EntityEditorSceneEventsList = [
54
83
  "pitch",
55
84
  "yaw",
56
85
  "roll",
57
- "scale"
86
+ "scale",
87
+ "transformstart",
88
+ "transformchange",
89
+ "transformend",
90
+ "transformcancel"
58
91
  ];
59
- declare class EntityEditorScene extends Scene {
60
- events: EventsHandler<EntityEditorSceneEventsList>;
92
+ /**
93
+ * Scene for translating and rotating entities with a gizmo.
94
+ * @class
95
+ * @extends {Scene}
96
+ * @param {IEntityGizmoSceneParams} [options] - Gizmo scene options.
97
+ */
98
+ declare class EntityGizmoScene extends Scene {
99
+ events: EventsHandler<EntityGizmoSceneEventsList>;
61
100
  protected _planet: Planet | null;
62
101
  protected _startPos: Vec2 | null;
63
102
  protected _startClick: Vec2;
@@ -76,15 +115,28 @@ declare class EntityEditorScene extends Scene {
76
115
  protected _planeEntity: MovePlaneEntity;
77
116
  protected _rotateEntity: RotateEntity;
78
117
  protected _axisTrackEntity: AxisTrackEntity;
79
- protected _selectedMove: string | null;
118
+ protected _selectedMove: GizmoTransformHandle | null;
80
119
  protected _ops: Record<string, (mouseState: IMouseState) => void>;
81
120
  protected _axisTrackVisibility: boolean;
82
121
  protected _editMode: EditMode;
83
- constructor(options?: IEntityEditorSceneParams);
122
+ protected _tools: GizmoTools;
123
+ protected _autoSelect: boolean;
124
+ protected _visibility: boolean;
125
+ protected _isActivated: boolean;
126
+ protected _gesture: IGizmoGesture | null;
127
+ protected _suspendedNavigation: string[];
128
+ constructor(options?: IEntityGizmoSceneParams);
84
129
  get ellipsoid(): Ellipsoid | undefined;
85
130
  get planet(): Planet | null;
86
131
  get editMode(): EditMode;
87
132
  set editMode(mode: EditMode);
133
+ /** Gizmo tool set: which handles are shown. */
134
+ get tools(): GizmoTools;
135
+ set tools(tools: GizmoTools);
136
+ /** When `false`, a left click on a map entity does not change the gizmo selection. */
137
+ get autoSelect(): boolean;
138
+ set autoSelect(autoSelect: boolean);
139
+ protected get _rotateEnabled(): boolean;
88
140
  bindPlanet(planet: Planet): void;
89
141
  protected _parseEditMode(mode: EditModeName | undefined): EditMode;
90
142
  init(): void;
@@ -92,36 +144,82 @@ declare class EntityEditorScene extends Scene {
92
144
  protected _addAxisLayers(): void;
93
145
  protected _onAxisLayerMouseEnter: (e: IMouseState) => void;
94
146
  protected _onAxisLayerMouseLeave: (e: IMouseState) => void;
95
- protected _navActivate(): void;
96
- protected _navDeactivate(): void;
97
- protected _onAxisLayerLUp: (e: IMouseState) => void;
147
+ /**
148
+ * Suspends the navigation controls that are active right now, so that a drag gesture
149
+ * does not fight with the camera. The suspended set is remembered and restored by
150
+ * {@link EntityGizmoScene._navRestore}, which keeps controls that were already
151
+ * deactivated beforehand deactivated.
152
+ * @protected
153
+ */
154
+ protected _navSuspend(): void;
155
+ protected _navRestore(): void;
98
156
  protected _onAxisLayerLDown: (e: IMouseState) => void;
99
157
  protected _onPlaneLayerMouseEnter: (e: IMouseState) => void;
100
158
  protected _onPlaneLayerMouseLeave: (e: IMouseState) => void;
101
- protected _onPlaneLayerLUp: (e: IMouseState) => void;
102
159
  protected _onPlaneLayerLDown: (e: IMouseState) => void;
103
160
  protected _onRotateLayerMouseEnter: (e: IMouseState) => void;
104
161
  protected _onRotateLayerMouseLeave: (e: IMouseState) => void;
105
- protected _onRotateLayerLUp: (e: IMouseState) => void;
106
162
  protected _onRotateLayerLDown: (e: IMouseState) => void;
107
163
  protected _onMouseMove: (e: IMouseState) => void;
108
164
  protected _removeAxisLayers(): void;
109
165
  activate(): void;
110
- protected deactivate(): void;
166
+ deactivate(): void;
111
167
  protected _setAxisTrackVisibility(visibility: boolean): void;
112
168
  setVisibility(visibility: boolean): void;
169
+ protected _applyVisibility(): void;
113
170
  readyToEdit(entity: Entity): boolean;
114
171
  select(entity: Entity): void;
115
172
  unselect(): void;
116
173
  protected _onLclick: (e: IMouseState) => void;
117
174
  clear(): void;
118
175
  protected _onForwardpass: () => void;
176
+ /**
177
+ * Returns `true` when a drag gesture is running right now.
178
+ * @public
179
+ */
180
+ isTransforming(): boolean;
181
+ /**
182
+ * Returns the running gesture description or `null`.
183
+ * @public
184
+ */
185
+ getActiveTransform(): IGizmoTransformEvent | null;
186
+ /**
187
+ * Cancels the current gesture and restores the entity transform when possible.
188
+ * @public
189
+ * @returns {boolean} Whether a gesture was cancelled.
190
+ */
191
+ cancelTransform(): boolean;
192
+ protected _gestureEvent(gesture: IGizmoGesture): IGizmoTransformEvent;
193
+ protected _beginGesture(handle: GizmoTransformHandle): void;
194
+ /**
195
+ * Dispatches `transformstart` right before the very first entity change of the gesture.
196
+ * @protected
197
+ */
198
+ protected _beginChange(): void;
199
+ protected _afterChange(): void;
200
+ protected _endGesture(): void;
201
+ protected _restoreGesture(gesture: IGizmoGesture): void;
202
+ protected _isEntityAttached(entity: Entity): boolean;
203
+ protected _bindGestureListeners(): void;
204
+ protected _unbindGestureListeners(): void;
205
+ protected _onWindowPointerUp: () => void;
206
+ protected _onWindowPointerCancel: () => void;
207
+ protected _onWindowBlur: () => void;
208
+ protected _onLUp: () => void;
209
+ protected _onTouchCancel: () => void;
119
210
  protected _moveX: (e: IMouseState) => void;
120
211
  protected _moveY: (e: IMouseState) => void;
121
212
  protected _moveZ: (e: IMouseState) => void;
122
213
  protected _moveXZ: (e: IMouseState) => void;
123
214
  protected _moveXY: (e: IMouseState) => void;
124
215
  protected _moveZY: (e: IMouseState) => void;
216
+ /**
217
+ * Applies a new absolute position to the selected entity and emits the gesture events
218
+ * around the change. The `position` event receives the applied `pos` and the entity.
219
+ * @protected
220
+ * @param {Vec3} pos - New absolute cartesian position.
221
+ */
222
+ protected _applyPosition(pos: Vec3): void;
125
223
  getFrameRotation(cartesian: Vec3): Quat;
126
224
  protected _isPlanetEntity(entity: Entity): boolean;
127
225
  protected _isYawMode(): boolean;
@@ -140,4 +238,4 @@ declare class EntityEditorScene extends Scene {
140
238
  lockView(): void;
141
239
  unlockView(): void;
142
240
  }
143
- export { EntityEditorScene };
241
+ export { EntityGizmoScene };
@@ -26,6 +26,8 @@ export * from "./selection/Selection";
26
26
  export * from "./timeline/TimelineControl";
27
27
  export * from "./elevationProfile/ElevationProfileControl";
28
28
  export * from "./atmosphere/AtmosphereConfig";
29
+ export * from "./entityGizmo/EntityGizmo";
30
+ export * from "./entityGizmo/EntityGizmoScene";
29
31
  export * from "./entityEditor/EntityEditor";
30
32
  export * from "./CameraLock";
31
33
  export * from "./object3dManager/Object3dManager";
package/lib/index.d.ts CHANGED
@@ -27,6 +27,10 @@ export type { IDepthCameraParams } from "./control/depthCamera/DepthCamera";
27
27
  export { DepthCamera } from "./control/depthCamera/DepthCamera";
28
28
  export type { IDepthCameraHandlerParams } from "./control/depthCamera/DepthCameraHandler";
29
29
  export { DepthCameraHandler } from "./control/depthCamera/DepthCameraHandler";
30
+ export type { IEntityGizmoParams } from "./control/entityGizmo/EntityGizmo";
31
+ export { EntityGizmo } from "./control/entityGizmo/EntityGizmo";
32
+ export type { EditMode, EditModeName, GizmoTools, GizmoTransformHandle, GizmoTransformKind, IEntityGizmoSceneParams, IGizmoTransformEvent } from "./control/entityGizmo/EntityGizmoScene";
33
+ export { EntityGizmoScene } from "./control/entityGizmo/EntityGizmoScene";
30
34
  export { PhongDeferredShading } from "./renderer/PhongDeferredShading";
31
35
  export { AtmosphereDeferredShading } from "./renderer/AtmosphereDeferredShading";
32
36
  export { WOITPass } from "./renderer/WOITPass";
@@ -60,7 +64,7 @@ import { EarthQuadTreeStrategy, EquiQuadTreeStrategy, QuadTreeStrategy, quadTree
60
64
  import { Object3d } from "./Object3d";
61
65
  import { Handler, ShaderProgram, Framebuffer, Multisample } from "./webgl/index";
62
66
  import { EmptyTerrain, GlobusTerrain, RgbTerrain, BilTerrain, GlobusRgbTerrain, MapterhornTerrain, rgbToHeightByEncoding, rgbToHeightRgb, rgbToHeightTerrarium, resolveRgbToHeightFunc } from "./terrain/index";
63
- import { MoveAxisEntity } from "./control/entityEditor/MoveAxisEntity";
67
+ import { MoveAxisEntity } from "./control/entityGizmo/MoveAxisEntity";
64
68
  import { Gltf } from "./utils/gltf/gltfParser";
65
69
  import { Easing } from "./utils/easing";
66
70
  import type { EasingFunction } from "./utils/easing";