@vived/app 2.23.0 → 2.26.0
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/lib/Controllers/HoverLabelMouse.d.ts +10 -0
- package/lib/Controllers/HoverLabelMouse.js +23 -0
- package/lib/Controllers/HoverLabelTouch.d.ts +14 -0
- package/lib/Controllers/HoverLabelTouch.js +41 -0
- package/lib/Controllers/ToolHotkeys.d.ts +6 -0
- package/lib/Controllers/ToolHotkeys.js +25 -0
- package/lib/Controllers/index.d.ts +3 -0
- package/lib/Controllers/index.js +15 -0
- package/lib/Entities/HoverLabels.d.ts +42 -0
- package/lib/Entities/HoverLabels.js +82 -0
- package/lib/Entities/MessageSystem.d.ts +14 -0
- package/lib/Entities/MessageSystem.js +32 -0
- package/lib/Entities/Tool.d.ts +50 -17
- package/lib/Entities/Tool.js +68 -10
- package/lib/Entities/ToolRepository.d.ts +16 -16
- package/lib/Entities/ToolRepository.js +34 -29
- package/lib/Entities/index.d.ts +2 -0
- package/lib/Entities/index.js +2 -0
- package/lib/PresentationManagers/HoverLabelPM.d.ts +17 -0
- package/lib/PresentationManagers/HoverLabelPM.js +32 -0
- package/lib/PresentationManagers/HoverLabels/AllowHoverLabelPM.d.ts +9 -0
- package/lib/PresentationManagers/HoverLabels/AllowHoverLabelPM.js +19 -0
- package/lib/PresentationManagers/HoverLabels/HoverLabelPM.d.ts +17 -0
- package/lib/PresentationManagers/HoverLabels/HoverLabelPM.js +32 -0
- package/lib/PresentationManagers/HoverLabels/index.d.ts +2 -0
- package/lib/PresentationManagers/HoverLabels/index.js +14 -0
- package/lib/PresentationManagers/ToolPM.d.ts +4 -5
- package/lib/PresentationManagers/ToolPM.js +10 -18
- package/lib/PresentationManagers/index.d.ts +1 -0
- package/lib/PresentationManagers/index.js +1 -0
- package/lib/UseCases/HoverLabels/SerializeAllowHoverLabel.d.ts +14 -0
- package/lib/UseCases/HoverLabels/SerializeAllowHoverLabel.js +35 -0
- package/lib/UseCases/HoverLabels/trySetHoverLabel.d.ts +3 -0
- package/lib/UseCases/HoverLabels/trySetHoverLabel.js +11 -0
- package/lib/UseCases/index.d.ts +2 -0
- package/lib/UseCases/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Babylon, HoverLabels, MouseController, MouseInput, MouseInputEvent } from "../Entities";
|
|
2
|
+
import { Vector2 } from "../ValueObjects";
|
|
3
|
+
export declare class HoverLabelMouse implements MouseController {
|
|
4
|
+
private hoverLabels;
|
|
5
|
+
private currentTimeout;
|
|
6
|
+
tryHoverLabelUC: (position: Vector2) => void;
|
|
7
|
+
readonly hoverLabelDelay = 500;
|
|
8
|
+
onMove: (e: MouseInputEvent) => void;
|
|
9
|
+
constructor(hoverLabels: HoverLabels, mouseInput: MouseInput, babylon: Babylon);
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HoverLabelMouse = void 0;
|
|
4
|
+
const trySetHoverLabel_1 = require("../UseCases/HoverLabels/trySetHoverLabel");
|
|
5
|
+
class HoverLabelMouse {
|
|
6
|
+
constructor(hoverLabels, mouseInput, babylon) {
|
|
7
|
+
this.hoverLabels = hoverLabels;
|
|
8
|
+
this.hoverLabelDelay = 500;
|
|
9
|
+
this.onMove = (e) => {
|
|
10
|
+
this.hoverLabels.hideHoverLabel();
|
|
11
|
+
if (this.currentTimeout) {
|
|
12
|
+
clearTimeout(this.currentTimeout);
|
|
13
|
+
}
|
|
14
|
+
this.currentTimeout = setTimeout(() => {
|
|
15
|
+
this.tryHoverLabelUC(e.position);
|
|
16
|
+
this.currentTimeout = undefined;
|
|
17
|
+
}, this.hoverLabelDelay);
|
|
18
|
+
};
|
|
19
|
+
mouseInput.registerController(this);
|
|
20
|
+
this.tryHoverLabelUC = trySetHoverLabel_1.makeTrySetHoverLabel(hoverLabels, babylon);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.HoverLabelMouse = HoverLabelMouse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Babylon, HoverLabels, TouchController, TouchInput, TouchInputEvent } from "../Entities";
|
|
2
|
+
import { Vector2 } from "../ValueObjects";
|
|
3
|
+
export declare const touchLabelDragThreshold = 15;
|
|
4
|
+
export declare class HoverLabelTouch implements TouchController {
|
|
5
|
+
private hoverLabels;
|
|
6
|
+
private lastPosition;
|
|
7
|
+
private startPosition;
|
|
8
|
+
private touchStarted;
|
|
9
|
+
tryHoverLabelUC: (position: Vector2) => void;
|
|
10
|
+
onTouchStart: (e: TouchInputEvent) => void;
|
|
11
|
+
onTouchMove: (e: TouchInputEvent) => void;
|
|
12
|
+
onTouchEnd: () => void;
|
|
13
|
+
constructor(hoverLabels: HoverLabels, touchInput: TouchInput, babylon: Babylon);
|
|
14
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HoverLabelTouch = exports.touchLabelDragThreshold = void 0;
|
|
4
|
+
const UseCases_1 = require("../UseCases");
|
|
5
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
6
|
+
exports.touchLabelDragThreshold = 15;
|
|
7
|
+
class HoverLabelTouch {
|
|
8
|
+
constructor(hoverLabels, touchInput, babylon) {
|
|
9
|
+
this.hoverLabels = hoverLabels;
|
|
10
|
+
this.lastPosition = ValueObjects_1.Vector2.Zero();
|
|
11
|
+
this.startPosition = ValueObjects_1.Vector2.Zero();
|
|
12
|
+
this.touchStarted = false;
|
|
13
|
+
this.onTouchStart = (e) => {
|
|
14
|
+
this.hoverLabels.hideHoverLabel();
|
|
15
|
+
this.touchStarted = false;
|
|
16
|
+
if (e.touchCount !== 1)
|
|
17
|
+
return;
|
|
18
|
+
this.startPosition = e.touches[0].position;
|
|
19
|
+
this.lastPosition = e.touches[0].position;
|
|
20
|
+
this.touchStarted = true;
|
|
21
|
+
};
|
|
22
|
+
this.onTouchMove = (e) => {
|
|
23
|
+
if (!this.touchStarted)
|
|
24
|
+
return;
|
|
25
|
+
this.lastPosition = e.touches[0].position;
|
|
26
|
+
};
|
|
27
|
+
this.onTouchEnd = () => {
|
|
28
|
+
if (!this.touchStarted)
|
|
29
|
+
return;
|
|
30
|
+
const xDiff = this.lastPosition.x - this.startPosition.x;
|
|
31
|
+
const yDiff = this.lastPosition.y - this.startPosition.y;
|
|
32
|
+
const dist = Math.sqrt(xDiff * xDiff + yDiff * yDiff);
|
|
33
|
+
if (dist < exports.touchLabelDragThreshold) {
|
|
34
|
+
this.tryHoverLabelUC(this.lastPosition);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
touchInput.registerController(this);
|
|
38
|
+
this.tryHoverLabelUC = UseCases_1.makeTrySetHoverLabel(hoverLabels, babylon);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.HoverLabelTouch = HoverLabelTouch;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { KeyboardController, KeyboardInput, ToolRepository } from "../Entities";
|
|
2
|
+
export declare class ToolHotkeys<ToolTypes> implements KeyboardController {
|
|
3
|
+
private toolRepo;
|
|
4
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
5
|
+
constructor(toolRepo: ToolRepository<ToolTypes>, keyboardInput: KeyboardInput);
|
|
6
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolHotkeys = void 0;
|
|
4
|
+
class ToolHotkeys {
|
|
5
|
+
constructor(toolRepo, keyboardInput) {
|
|
6
|
+
this.toolRepo = toolRepo;
|
|
7
|
+
this.onKeyDown = (e) => {
|
|
8
|
+
if (e.repeat)
|
|
9
|
+
return;
|
|
10
|
+
const currentKey = {
|
|
11
|
+
keyCode: e.code,
|
|
12
|
+
alt: e.altKey,
|
|
13
|
+
control: e.ctrlKey,
|
|
14
|
+
meta: e.metaKey,
|
|
15
|
+
shift: e.shiftKey,
|
|
16
|
+
};
|
|
17
|
+
const tool = this.toolRepo.getToolForHotkey(currentKey);
|
|
18
|
+
if (!tool)
|
|
19
|
+
return;
|
|
20
|
+
this.toolRepo.triggerTool(tool.type);
|
|
21
|
+
};
|
|
22
|
+
keyboardInput.registerController(this);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ToolHotkeys = ToolHotkeys;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./ToolHotkeys"), exports);
|
|
14
|
+
__exportStar(require("./HoverLabelTouch"), exports);
|
|
15
|
+
__exportStar(require("./HoverLabelMouse"), exports);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Vector2 } from "../ValueObjects";
|
|
2
|
+
import { ObservableEntity } from "./ObservableEntity";
|
|
3
|
+
export declare abstract class HoverLabels extends ObservableEntity {
|
|
4
|
+
/**
|
|
5
|
+
* Should the label be shown
|
|
6
|
+
*/
|
|
7
|
+
abstract get show(): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Pixel coordinates of the label
|
|
10
|
+
*/
|
|
11
|
+
abstract get position(): Vector2;
|
|
12
|
+
/**
|
|
13
|
+
* String to display
|
|
14
|
+
*/
|
|
15
|
+
abstract get label(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Gets if hover labels should be allowed
|
|
18
|
+
*/
|
|
19
|
+
abstract get allowHoverLabels(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Sets if hover labels should be shown. Will notify
|
|
22
|
+
*/
|
|
23
|
+
abstract set allowHoverLabels(allow: boolean);
|
|
24
|
+
/**
|
|
25
|
+
* Sets up a label for a scene object by id
|
|
26
|
+
*/
|
|
27
|
+
abstract setLabelForSceneObject: (sceneObjectID: string, label: string) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Removes the labels for a scene object by id
|
|
30
|
+
*/
|
|
31
|
+
abstract removeLabelForSceneObject: (sceneObjectID: string) => void;
|
|
32
|
+
/**
|
|
33
|
+
* Tries to get a label for a scene object by id. Returns undefined if one does not exist
|
|
34
|
+
*/
|
|
35
|
+
abstract getLabelFroSceneObject: (sceneObjectID: string) => string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Sets up the system to show a label for a scene object at a given position
|
|
38
|
+
*/
|
|
39
|
+
abstract showLabelForSceneObject: (sceneObjectID: string, position: Vector2) => void;
|
|
40
|
+
abstract hideHoverLabel: () => void;
|
|
41
|
+
}
|
|
42
|
+
export declare function makeHoverLabels(): HoverLabels;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeHoverLabels = exports.HoverLabels = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
|
+
const MemoizedBoolean_1 = require("./MemoizedBoolean");
|
|
6
|
+
const ObservableEntity_1 = require("./ObservableEntity");
|
|
7
|
+
class HoverLabels extends ObservableEntity_1.ObservableEntity {
|
|
8
|
+
}
|
|
9
|
+
exports.HoverLabels = HoverLabels;
|
|
10
|
+
function makeHoverLabels() {
|
|
11
|
+
return new HoverLabelsImp();
|
|
12
|
+
}
|
|
13
|
+
exports.makeHoverLabels = makeHoverLabels;
|
|
14
|
+
class HoverLabelsImp extends HoverLabels {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.labelLookup = new Map();
|
|
18
|
+
this._show = false;
|
|
19
|
+
this._position = ValueObjects_1.Vector2.Zero();
|
|
20
|
+
this._label = "";
|
|
21
|
+
this.memoizedAllow = new MemoizedBoolean_1.MemoizedBoolean(true, this.notify);
|
|
22
|
+
this.setLabelForSceneObject = (sceneObjectID, label) => {
|
|
23
|
+
this.labelLookup.set(sceneObjectID, label);
|
|
24
|
+
};
|
|
25
|
+
this.removeLabelForSceneObject = (sceneObjectID) => {
|
|
26
|
+
this.labelLookup.delete(sceneObjectID);
|
|
27
|
+
};
|
|
28
|
+
this.getLabelFroSceneObject = (sceneObjectID) => {
|
|
29
|
+
return this.labelLookup.get(sceneObjectID);
|
|
30
|
+
};
|
|
31
|
+
this.showLabelForSceneObject = (sceneObjectID, position) => {
|
|
32
|
+
var _a;
|
|
33
|
+
if (this.labelLookup.has(sceneObjectID)) {
|
|
34
|
+
this.doShow((_a = this.labelLookup.get(sceneObjectID)) !== null && _a !== void 0 ? _a : "", position);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
this.hideHoverLabel();
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
this.hideHoverLabel = () => {
|
|
41
|
+
if (!this._show)
|
|
42
|
+
return;
|
|
43
|
+
this._show = false;
|
|
44
|
+
this._label = "";
|
|
45
|
+
this._position = ValueObjects_1.Vector2.Zero();
|
|
46
|
+
this.notify();
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
get show() {
|
|
50
|
+
return this._show;
|
|
51
|
+
}
|
|
52
|
+
get position() {
|
|
53
|
+
return this._position;
|
|
54
|
+
}
|
|
55
|
+
get label() {
|
|
56
|
+
return this._label;
|
|
57
|
+
}
|
|
58
|
+
get allowHoverLabels() {
|
|
59
|
+
return this.memoizedAllow.val;
|
|
60
|
+
}
|
|
61
|
+
set allowHoverLabels(allow) {
|
|
62
|
+
if (allow === this.memoizedAllow.val)
|
|
63
|
+
return;
|
|
64
|
+
this.memoizedAllow.val = allow;
|
|
65
|
+
if (allow === false) {
|
|
66
|
+
this.hideHoverLabel();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
doShow(label, pos) {
|
|
70
|
+
if (!this.allowHoverLabels)
|
|
71
|
+
return;
|
|
72
|
+
if (label === this._label &&
|
|
73
|
+
ValueObjects_1.Vector2.Equal(pos, this._position) &&
|
|
74
|
+
this.show) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this._label = label;
|
|
78
|
+
this._position = pos;
|
|
79
|
+
this._show = true;
|
|
80
|
+
this.notify();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Result } from "../ValueObjects";
|
|
2
|
+
export declare type MessageDataFile = {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
};
|
|
5
|
+
export interface MessageSystem {
|
|
6
|
+
setMessages: (messages: MessageDataFile) => void;
|
|
7
|
+
getMessage: (keyword: string) => Result<string, Error>;
|
|
8
|
+
}
|
|
9
|
+
export declare class MessageSystemImp implements MessageSystem {
|
|
10
|
+
private messages;
|
|
11
|
+
setMessages: (messages: MessageDataFile) => void;
|
|
12
|
+
getMessage: (keyword: string) => Result<string, Error>;
|
|
13
|
+
}
|
|
14
|
+
export declare function makeMessageSystem(): MessageSystem;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeMessageSystem = exports.MessageSystemImp = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
|
+
class MessageSystemImp {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.messages = new Map();
|
|
8
|
+
this.setMessages = (messages) => {
|
|
9
|
+
for (const keyword in messages) {
|
|
10
|
+
if (messages.hasOwnProperty(keyword)) {
|
|
11
|
+
const message = messages[keyword];
|
|
12
|
+
this.messages.set(keyword, message);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
this.getMessage = (keyword) => {
|
|
17
|
+
const message = this.messages.get(keyword);
|
|
18
|
+
if (message) {
|
|
19
|
+
return new ValueObjects_1.Resolved(message);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
const err = new Error("Message System cant find message from keyword: " + keyword);
|
|
23
|
+
return new ValueObjects_1.Rejected(err);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.MessageSystemImp = MessageSystemImp;
|
|
29
|
+
function makeMessageSystem() {
|
|
30
|
+
return new MessageSystemImp();
|
|
31
|
+
}
|
|
32
|
+
exports.makeMessageSystem = makeMessageSystem;
|
package/lib/Entities/Tool.d.ts
CHANGED
|
@@ -1,41 +1,52 @@
|
|
|
1
1
|
import { ObservableEntity } from "./ObservableEntity";
|
|
2
2
|
export declare enum ToolState {
|
|
3
|
-
HIDDEN =
|
|
4
|
-
DISABLED =
|
|
5
|
-
ENABLED =
|
|
6
|
-
ACTIVE =
|
|
3
|
+
HIDDEN = "HIDDEN",
|
|
4
|
+
DISABLED = "DISABLED",
|
|
5
|
+
ENABLED = "ENABLED",
|
|
6
|
+
ACTIVE = "ACTIVE"
|
|
7
7
|
}
|
|
8
|
-
export interface ToolData {
|
|
9
|
-
|
|
8
|
+
export interface ToolData<ToolTypes> {
|
|
9
|
+
type: ToolTypes;
|
|
10
10
|
isDefault: boolean;
|
|
11
11
|
label: string;
|
|
12
12
|
shortcutLabel: string;
|
|
13
|
+
hotkeys: HotKey[];
|
|
14
|
+
}
|
|
15
|
+
export interface HotKey {
|
|
13
16
|
keyCode: string;
|
|
17
|
+
control?: boolean;
|
|
18
|
+
shift?: boolean;
|
|
19
|
+
meta?: boolean;
|
|
20
|
+
alt?: boolean;
|
|
14
21
|
}
|
|
15
|
-
export declare abstract class Tool extends ObservableEntity {
|
|
22
|
+
export declare abstract class Tool<ToolTypes> extends ObservableEntity {
|
|
16
23
|
/**
|
|
17
|
-
* The tool's
|
|
24
|
+
* The tool's type
|
|
18
25
|
*/
|
|
19
|
-
abstract readonly
|
|
26
|
+
abstract readonly type: ToolTypes;
|
|
20
27
|
/**
|
|
21
|
-
*
|
|
22
|
-
* Example: 'KeyZ'
|
|
28
|
+
* Gets label for this tool. This will be human readable
|
|
23
29
|
*/
|
|
24
|
-
abstract
|
|
30
|
+
abstract get label(): string;
|
|
25
31
|
/**
|
|
26
|
-
*
|
|
32
|
+
* Sets label for this tool. This should be human readable. A change will notify
|
|
27
33
|
*/
|
|
28
|
-
abstract
|
|
34
|
+
abstract set label(toolLabel: string);
|
|
29
35
|
/**
|
|
30
36
|
* Is this the default tool? The default tool is what is initiall set Active and
|
|
31
37
|
* is what will be set active if the currently active tool is hidden or disabled.
|
|
32
38
|
*/
|
|
33
39
|
abstract readonly isDefault: boolean;
|
|
34
40
|
/**
|
|
35
|
-
*
|
|
41
|
+
* Gets the keyboard shorcut label. This will be displayed to the user via the tool tip
|
|
36
42
|
* Example 'z'
|
|
37
43
|
*/
|
|
38
|
-
abstract
|
|
44
|
+
abstract get shortcutLabel(): string;
|
|
45
|
+
/**
|
|
46
|
+
* Sets the keyboard shorcut label. This will be displayed to the user via the tool tip
|
|
47
|
+
* Example 'z'. This will notify when changed
|
|
48
|
+
*/
|
|
49
|
+
abstract set shortcutLabel(shorcut: string);
|
|
39
50
|
/**
|
|
40
51
|
* Get the current tool state
|
|
41
52
|
*/
|
|
@@ -44,5 +55,27 @@ export declare abstract class Tool extends ObservableEntity {
|
|
|
44
55
|
* Sets the current tool state. This will notify on change
|
|
45
56
|
*/
|
|
46
57
|
abstract set state(val: ToolState);
|
|
58
|
+
/**
|
|
59
|
+
* The keyboard shortcuts for this tool
|
|
60
|
+
*/
|
|
61
|
+
abstract readonly hotkeys: HotKey[];
|
|
62
|
+
/**
|
|
63
|
+
* Is this tool an action tool. In other words do you just click it and something should happen
|
|
64
|
+
*/
|
|
65
|
+
abstract get isAction(): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* If this is an action tool calling this will trigger any actions that have been registered
|
|
68
|
+
*/
|
|
69
|
+
abstract triggerActions(): void;
|
|
70
|
+
/**
|
|
71
|
+
* Registers an action with this tool. This action will be called when this tool is triggered
|
|
72
|
+
* @param action The action to call when this tool is triggered
|
|
73
|
+
*/
|
|
74
|
+
abstract registerAction(action: () => void): void;
|
|
75
|
+
/**
|
|
76
|
+
* Returns a true if the passed hotkey is in my hotkey list
|
|
77
|
+
* @param hotkey The Hotkey to chekc
|
|
78
|
+
*/
|
|
79
|
+
abstract isMyHotkey(hotkey: HotKey): boolean;
|
|
47
80
|
}
|
|
48
|
-
export declare function makeTool(data: ToolData): Tool
|
|
81
|
+
export declare function makeTool<ToolTypes>(data: ToolData<ToolTypes>): Tool<ToolTypes>;
|
package/lib/Entities/Tool.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeTool = exports.Tool = exports.ToolState = void 0;
|
|
4
|
-
const
|
|
4
|
+
const MemoizedString_1 = require("./MemoizedString");
|
|
5
5
|
const ObservableEntity_1 = require("./ObservableEntity");
|
|
6
6
|
var ToolState;
|
|
7
7
|
(function (ToolState) {
|
|
8
|
-
ToolState[
|
|
9
|
-
ToolState[
|
|
10
|
-
ToolState[
|
|
11
|
-
ToolState[
|
|
8
|
+
ToolState["HIDDEN"] = "HIDDEN";
|
|
9
|
+
ToolState["DISABLED"] = "DISABLED";
|
|
10
|
+
ToolState["ENABLED"] = "ENABLED";
|
|
11
|
+
ToolState["ACTIVE"] = "ACTIVE";
|
|
12
12
|
})(ToolState = exports.ToolState || (exports.ToolState = {}));
|
|
13
13
|
class Tool extends ObservableEntity_1.ObservableEntity {
|
|
14
14
|
}
|
|
@@ -20,12 +20,44 @@ exports.makeTool = makeTool;
|
|
|
20
20
|
class ToolImp extends Tool {
|
|
21
21
|
constructor(data) {
|
|
22
22
|
super();
|
|
23
|
-
this.memoizedState = new
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
23
|
+
this.memoizedState = new MemoizedString_1.MemoizedString(ToolState.ENABLED, this.notify);
|
|
24
|
+
this.actions = [];
|
|
25
|
+
this._isAction = false;
|
|
26
|
+
this.registerAction = (action) => {
|
|
27
|
+
this.actions.push(action);
|
|
28
|
+
this._isAction = true;
|
|
29
|
+
};
|
|
30
|
+
this.triggerActions = () => {
|
|
31
|
+
this.actions.forEach((action) => {
|
|
32
|
+
action();
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
this.isMyHotkey = (hotkey) => {
|
|
36
|
+
let isMine = false;
|
|
37
|
+
this.hotkeys.forEach((myHotkey) => {
|
|
38
|
+
if (this.hotkeysMatch(myHotkey, hotkey)) {
|
|
39
|
+
isMine = true;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return isMine;
|
|
43
|
+
};
|
|
44
|
+
this.type = data.type;
|
|
45
|
+
this.memoizedLabel = new MemoizedString_1.MemoizedString(data.label, this.notify);
|
|
27
46
|
this.isDefault = data.isDefault;
|
|
28
|
-
this.
|
|
47
|
+
this.memoizedShortcut = new MemoizedString_1.MemoizedString(data.shortcutLabel, this.notify);
|
|
48
|
+
this.hotkeys = data.hotkeys;
|
|
49
|
+
}
|
|
50
|
+
get label() {
|
|
51
|
+
return this.memoizedLabel.val;
|
|
52
|
+
}
|
|
53
|
+
set label(toolLabel) {
|
|
54
|
+
this.memoizedLabel.val = toolLabel;
|
|
55
|
+
}
|
|
56
|
+
get shortcutLabel() {
|
|
57
|
+
return this.memoizedShortcut.val;
|
|
58
|
+
}
|
|
59
|
+
set shortcutLabel(shorcut) {
|
|
60
|
+
this.memoizedShortcut.val = shorcut;
|
|
29
61
|
}
|
|
30
62
|
get state() {
|
|
31
63
|
return this.memoizedState.val;
|
|
@@ -33,4 +65,30 @@ class ToolImp extends Tool {
|
|
|
33
65
|
set state(val) {
|
|
34
66
|
this.memoizedState.val = val;
|
|
35
67
|
}
|
|
68
|
+
get isAction() {
|
|
69
|
+
return this._isAction;
|
|
70
|
+
}
|
|
71
|
+
hotkeysMatch(a, b) {
|
|
72
|
+
if (a.keyCode !== b.keyCode)
|
|
73
|
+
return false;
|
|
74
|
+
const aComplete = this.fillInMissingModifiers(a);
|
|
75
|
+
const bComplete = this.fillInMissingModifiers(b);
|
|
76
|
+
if (aComplete.alt !== bComplete.alt)
|
|
77
|
+
return false;
|
|
78
|
+
if (aComplete.control !== bComplete.control)
|
|
79
|
+
return false;
|
|
80
|
+
if (aComplete.meta !== bComplete.meta)
|
|
81
|
+
return false;
|
|
82
|
+
if (aComplete.shift !== bComplete.shift)
|
|
83
|
+
return false;
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
fillInMissingModifiers(hotkey) {
|
|
87
|
+
const rVal = Object.assign({}, hotkey);
|
|
88
|
+
rVal.alt = hotkey.alt === undefined ? false : hotkey.alt;
|
|
89
|
+
rVal.control = hotkey.control === undefined ? false : hotkey.control;
|
|
90
|
+
rVal.meta = hotkey.meta === undefined ? false : hotkey.meta;
|
|
91
|
+
rVal.shift = hotkey.shift === undefined ? false : hotkey.shift;
|
|
92
|
+
return rVal;
|
|
93
|
+
}
|
|
36
94
|
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import { ObservableEntity } from "./ObservableEntity";
|
|
2
|
-
import { Tool, ToolData } from "./Tool";
|
|
3
|
-
export declare abstract class ToolRepository extends ObservableEntity {
|
|
2
|
+
import { HotKey, Tool, ToolData } from "./Tool";
|
|
3
|
+
export declare abstract class ToolRepository<ToolTypes> extends ObservableEntity {
|
|
4
4
|
/**
|
|
5
5
|
* Retuns the active tool. If no tool is active it will return undefined.
|
|
6
6
|
*/
|
|
7
|
-
abstract get activeTool(): Tool | undefined;
|
|
7
|
+
abstract get activeTool(): Tool<ToolTypes> | undefined;
|
|
8
8
|
/**
|
|
9
9
|
* Returns all the tools.
|
|
10
10
|
*/
|
|
11
|
-
abstract get allTools(): Tool[];
|
|
11
|
+
abstract get allTools(): Tool<ToolTypes>[];
|
|
12
12
|
/**
|
|
13
13
|
* Set up the tools from a JSON data file. This should be called during construction.
|
|
14
14
|
* It is assumed this is only called once.
|
|
15
15
|
* @param toolData
|
|
16
16
|
*/
|
|
17
|
-
abstract setupToolsFromData(toolData: ToolData[]): void;
|
|
17
|
+
abstract setupToolsFromData(toolData: ToolData<ToolTypes>[]): void;
|
|
18
18
|
/**
|
|
19
|
-
* Get's a tool by it's
|
|
20
|
-
* @param
|
|
19
|
+
* Get's a tool by it's type. Retruns undefined if no tool could be found
|
|
20
|
+
* @param toolType The tool type
|
|
21
21
|
*/
|
|
22
|
-
abstract getTool(
|
|
22
|
+
abstract getTool(toolType: ToolTypes): Tool<ToolTypes> | undefined;
|
|
23
23
|
/**
|
|
24
24
|
* Returns the tool that has been assinged to a particular key code.
|
|
25
25
|
* Will return undefined of no tool is found
|
|
26
|
-
* @param
|
|
26
|
+
* @param hotkey Key Code
|
|
27
27
|
*/
|
|
28
|
-
abstract
|
|
28
|
+
abstract getToolForHotkey(hotkey: HotKey): Tool<ToolTypes> | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Call this to set the default tool as active
|
|
31
31
|
*/
|
|
32
32
|
abstract setDefaultToolActive(): void;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param
|
|
34
|
+
* Triggers a tool of type
|
|
35
|
+
* @param toolType Tool's type
|
|
36
36
|
*/
|
|
37
|
-
abstract
|
|
37
|
+
abstract triggerTool(toolType: ToolTypes): void;
|
|
38
38
|
/**
|
|
39
39
|
* Toggls a tool between Hidden and shown.
|
|
40
40
|
* If the tool is tool is currently Active, the default tool will be set active
|
|
41
41
|
* The Default Tool cannot be toggled
|
|
42
|
-
* @param
|
|
42
|
+
* @param toolType Tool's type
|
|
43
43
|
*/
|
|
44
|
-
abstract toggleToolVisibility(
|
|
44
|
+
abstract toggleToolVisibility(toolType: ToolTypes): void;
|
|
45
45
|
}
|
|
46
|
-
export declare function makeToolRepo(): ToolRepository
|
|
46
|
+
export declare function makeToolRepo<ToolTypes>(): ToolRepository<ToolTypes>;
|
|
@@ -14,15 +14,13 @@ class ToolRepositoryImp extends ToolRepository {
|
|
|
14
14
|
constructor() {
|
|
15
15
|
super(...arguments);
|
|
16
16
|
this.toolLookup = new Map();
|
|
17
|
-
this._defaultToolID = "";
|
|
18
|
-
this._activeToolID = "";
|
|
19
17
|
}
|
|
20
18
|
get allTools() {
|
|
21
19
|
return Array.from(this.toolLookup.values());
|
|
22
20
|
}
|
|
23
21
|
setDefaultToolActive() {
|
|
24
|
-
if (this.
|
|
25
|
-
this.
|
|
22
|
+
if (this._defaultToolType !== undefined) {
|
|
23
|
+
this.triggerTool(this._defaultToolType);
|
|
26
24
|
}
|
|
27
25
|
else {
|
|
28
26
|
console.warn(`[ToolRepository] No default tools has been specified`);
|
|
@@ -30,58 +28,65 @@ class ToolRepositoryImp extends ToolRepository {
|
|
|
30
28
|
}
|
|
31
29
|
setupToolsFromData(toolDatas) {
|
|
32
30
|
toolDatas.forEach((toolData) => {
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
const type = toolData.type;
|
|
32
|
+
if (this.toolLookup.has(type)) {
|
|
33
|
+
console.warn(`[ToolRepository] A tool with the ID ${toolData.type} already exists. Replacing`);
|
|
35
34
|
}
|
|
36
35
|
const tool = Tool_1.makeTool(toolData);
|
|
37
|
-
this.toolLookup.set(
|
|
36
|
+
this.toolLookup.set(type, tool);
|
|
38
37
|
if (toolData.isDefault) {
|
|
39
|
-
if (this.
|
|
38
|
+
if (this._defaultToolType) {
|
|
40
39
|
console.warn(`[ToolRepository] More than one tools is marked as default. Replacing`);
|
|
41
40
|
}
|
|
42
|
-
this.
|
|
41
|
+
this._defaultToolType = type;
|
|
43
42
|
}
|
|
44
43
|
});
|
|
45
|
-
if (!this.
|
|
44
|
+
if (!this._defaultToolType) {
|
|
46
45
|
console.warn(`[ToolRepository] No default tools was specified. Defaulting to the first tool in the list`);
|
|
47
|
-
this.
|
|
46
|
+
this._defaultToolType = Array.from(this.toolLookup.keys())[0];
|
|
47
|
+
}
|
|
48
|
+
if (this._defaultToolType) {
|
|
49
|
+
this.triggerTool(this._defaultToolType);
|
|
48
50
|
}
|
|
49
|
-
this.setToolActive(this._defaultToolID);
|
|
50
51
|
}
|
|
51
|
-
getTool(
|
|
52
|
-
return this.toolLookup.get(
|
|
52
|
+
getTool(type) {
|
|
53
|
+
return this.toolLookup.get(type);
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
getToolForHotkey(hotkey) {
|
|
55
56
|
let tool;
|
|
56
57
|
this.allTools.forEach((t) => {
|
|
57
|
-
if (t.
|
|
58
|
+
if (t.isMyHotkey(hotkey)) {
|
|
58
59
|
tool = t;
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
return tool;
|
|
62
63
|
}
|
|
63
64
|
get activeTool() {
|
|
64
|
-
|
|
65
|
+
if (!this._activeToolType)
|
|
66
|
+
return undefined;
|
|
67
|
+
return this.getTool(this._activeToolType);
|
|
65
68
|
}
|
|
66
|
-
|
|
67
|
-
if (this.
|
|
69
|
+
triggerTool(type) {
|
|
70
|
+
if (this._activeToolType === type)
|
|
68
71
|
return;
|
|
69
|
-
const newActiveTool = this.toolLookup.get(
|
|
72
|
+
const newActiveTool = this.toolLookup.get(type);
|
|
70
73
|
if (!newActiveTool) {
|
|
71
|
-
console.warn(`[ToolRepository] Unable to find tool ${
|
|
74
|
+
console.warn(`[ToolRepository] Unable to find tool ${type}`);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (newActiveTool.isAction) {
|
|
78
|
+
newActiveTool.triggerActions();
|
|
72
79
|
return;
|
|
73
80
|
}
|
|
74
81
|
if (newActiveTool.state === Tool_1.ToolState.DISABLED) {
|
|
75
|
-
console.warn(`[ToolRepository] ${newActiveTool.label} cannot be set active because it is disabled`);
|
|
76
82
|
return;
|
|
77
83
|
}
|
|
78
84
|
if (newActiveTool.state === Tool_1.ToolState.HIDDEN) {
|
|
79
|
-
console.warn(`[ToolRepository] ${newActiveTool.label} cannot be set active because it is hidden`);
|
|
80
85
|
return;
|
|
81
86
|
}
|
|
82
87
|
this.toolLookup.forEach((tool) => {
|
|
83
|
-
if (tool.
|
|
84
|
-
this.
|
|
88
|
+
if (tool.type === type) {
|
|
89
|
+
this._activeToolType = type;
|
|
85
90
|
tool.state = Tool_1.ToolState.ACTIVE;
|
|
86
91
|
}
|
|
87
92
|
else if (tool.state === Tool_1.ToolState.ACTIVE) {
|
|
@@ -90,13 +95,13 @@ class ToolRepositoryImp extends ToolRepository {
|
|
|
90
95
|
});
|
|
91
96
|
this.notify();
|
|
92
97
|
}
|
|
93
|
-
toggleToolVisibility(
|
|
94
|
-
const tool = this.getTool(
|
|
98
|
+
toggleToolVisibility(type) {
|
|
99
|
+
const tool = this.getTool(type);
|
|
95
100
|
if (!tool) {
|
|
96
|
-
console.warn(`[ToolRepository] Unable to find tool to toggle: ${
|
|
101
|
+
console.warn(`[ToolRepository] Unable to find tool to toggle: ${type}`);
|
|
97
102
|
return;
|
|
98
103
|
}
|
|
99
|
-
if (tool.
|
|
104
|
+
if (tool.type === this._defaultToolType) {
|
|
100
105
|
console.warn(`[ToolRepository] The default tool's visibility cannot be toggled`);
|
|
101
106
|
return;
|
|
102
107
|
}
|
package/lib/Entities/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export * from "./Babylon";
|
|
2
2
|
export * from "./BaseApp";
|
|
3
3
|
export * from "./DevicePreview";
|
|
4
|
+
export * from "./HoverLabels";
|
|
4
5
|
export * from "./KeyboardInput";
|
|
5
6
|
export * from "./MemoizedBoolean";
|
|
6
7
|
export * from "./MemoizedNumber";
|
|
7
8
|
export * from "./MemoizedString";
|
|
8
9
|
export * from "./MemoizedVector2";
|
|
9
10
|
export * from "./MemoizedVector3";
|
|
11
|
+
export * from "./MessageSystem";
|
|
10
12
|
export * from "./ObserverList";
|
|
11
13
|
export * from "./FocusCamera";
|
|
12
14
|
export * from "./StateMachine";
|
package/lib/Entities/index.js
CHANGED
|
@@ -13,12 +13,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
__exportStar(require("./Babylon"), exports);
|
|
14
14
|
__exportStar(require("./BaseApp"), exports);
|
|
15
15
|
__exportStar(require("./DevicePreview"), exports);
|
|
16
|
+
__exportStar(require("./HoverLabels"), exports);
|
|
16
17
|
__exportStar(require("./KeyboardInput"), exports);
|
|
17
18
|
__exportStar(require("./MemoizedBoolean"), exports);
|
|
18
19
|
__exportStar(require("./MemoizedNumber"), exports);
|
|
19
20
|
__exportStar(require("./MemoizedString"), exports);
|
|
20
21
|
__exportStar(require("./MemoizedVector2"), exports);
|
|
21
22
|
__exportStar(require("./MemoizedVector3"), exports);
|
|
23
|
+
__exportStar(require("./MessageSystem"), exports);
|
|
22
24
|
__exportStar(require("./ObserverList"), exports);
|
|
23
25
|
__exportStar(require("./FocusCamera"), exports);
|
|
24
26
|
__exportStar(require("./StateMachine"), exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HoverLabels } from "../Entities";
|
|
2
|
+
import { PresentionManager } from "./PresentationManager";
|
|
3
|
+
export interface HoverLabelVM {
|
|
4
|
+
show: boolean;
|
|
5
|
+
text: string;
|
|
6
|
+
position: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class HoverLabelPM extends PresentionManager {
|
|
12
|
+
private hoverLabel;
|
|
13
|
+
private updateView;
|
|
14
|
+
doUpdateView: () => void;
|
|
15
|
+
constructor(hoverLabel: HoverLabels, updateView: (vm: HoverLabelVM) => void);
|
|
16
|
+
static defaultHoverLabelVM: HoverLabelVM;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HoverLabelPM = void 0;
|
|
4
|
+
const PresentationManager_1 = require("./PresentationManager");
|
|
5
|
+
class HoverLabelPM extends PresentationManager_1.PresentionManager {
|
|
6
|
+
constructor(hoverLabel, updateView) {
|
|
7
|
+
super(hoverLabel);
|
|
8
|
+
this.hoverLabel = hoverLabel;
|
|
9
|
+
this.updateView = updateView;
|
|
10
|
+
this.doUpdateView = () => {
|
|
11
|
+
const vm = {
|
|
12
|
+
show: false,
|
|
13
|
+
text: "",
|
|
14
|
+
position: { x: 0, y: 0 },
|
|
15
|
+
};
|
|
16
|
+
if (this.hoverLabel.show) {
|
|
17
|
+
vm.show = true;
|
|
18
|
+
vm.text = this.hoverLabel.label;
|
|
19
|
+
vm.position.x = this.hoverLabel.position.x;
|
|
20
|
+
vm.position.y = this.hoverLabel.position.y;
|
|
21
|
+
}
|
|
22
|
+
this.updateView(vm);
|
|
23
|
+
};
|
|
24
|
+
this.doUpdateView();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.HoverLabelPM = HoverLabelPM;
|
|
28
|
+
HoverLabelPM.defaultHoverLabelVM = {
|
|
29
|
+
show: false,
|
|
30
|
+
text: "",
|
|
31
|
+
position: { x: 0, y: 0 },
|
|
32
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HoverLabels } from "../../Entities";
|
|
2
|
+
import { PresentionManager } from "../PresentationManager";
|
|
3
|
+
export declare class AllowHoverLabelPM extends PresentionManager {
|
|
4
|
+
private hoverLabel;
|
|
5
|
+
private updateView;
|
|
6
|
+
private lastState?;
|
|
7
|
+
doUpdateView: () => void;
|
|
8
|
+
constructor(hoverLabel: HoverLabels, updateView: (allow: boolean) => void);
|
|
9
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AllowHoverLabelPM = void 0;
|
|
4
|
+
const PresentationManager_1 = require("../PresentationManager");
|
|
5
|
+
class AllowHoverLabelPM extends PresentationManager_1.PresentionManager {
|
|
6
|
+
constructor(hoverLabel, updateView) {
|
|
7
|
+
super(hoverLabel);
|
|
8
|
+
this.hoverLabel = hoverLabel;
|
|
9
|
+
this.updateView = updateView;
|
|
10
|
+
this.doUpdateView = () => {
|
|
11
|
+
if (this.lastState === this.hoverLabel.allowHoverLabels)
|
|
12
|
+
return;
|
|
13
|
+
this.updateView(this.hoverLabel.allowHoverLabels);
|
|
14
|
+
this.lastState = this.hoverLabel.allowHoverLabels;
|
|
15
|
+
};
|
|
16
|
+
this.doUpdateView();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AllowHoverLabelPM = AllowHoverLabelPM;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HoverLabels } from "../../Entities";
|
|
2
|
+
import { PresentionManager } from "../PresentationManager";
|
|
3
|
+
export interface HoverLabelVM {
|
|
4
|
+
show: boolean;
|
|
5
|
+
text: string;
|
|
6
|
+
position: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare class HoverLabelPM extends PresentionManager {
|
|
12
|
+
private hoverLabel;
|
|
13
|
+
private updateView;
|
|
14
|
+
doUpdateView: () => void;
|
|
15
|
+
constructor(hoverLabel: HoverLabels, updateView: (vm: HoverLabelVM) => void);
|
|
16
|
+
static defaultHoverLabelVM: HoverLabelVM;
|
|
17
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HoverLabelPM = void 0;
|
|
4
|
+
const PresentationManager_1 = require("../PresentationManager");
|
|
5
|
+
class HoverLabelPM extends PresentationManager_1.PresentionManager {
|
|
6
|
+
constructor(hoverLabel, updateView) {
|
|
7
|
+
super(hoverLabel);
|
|
8
|
+
this.hoverLabel = hoverLabel;
|
|
9
|
+
this.updateView = updateView;
|
|
10
|
+
this.doUpdateView = () => {
|
|
11
|
+
const vm = {
|
|
12
|
+
show: false,
|
|
13
|
+
text: "",
|
|
14
|
+
position: { x: 0, y: 0 },
|
|
15
|
+
};
|
|
16
|
+
if (this.hoverLabel.show) {
|
|
17
|
+
vm.show = true;
|
|
18
|
+
vm.text = this.hoverLabel.label;
|
|
19
|
+
vm.position.x = this.hoverLabel.position.x;
|
|
20
|
+
vm.position.y = this.hoverLabel.position.y;
|
|
21
|
+
}
|
|
22
|
+
this.updateView(vm);
|
|
23
|
+
};
|
|
24
|
+
this.doUpdateView();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.HoverLabelPM = HoverLabelPM;
|
|
28
|
+
HoverLabelPM.defaultHoverLabelVM = {
|
|
29
|
+
show: false,
|
|
30
|
+
text: "",
|
|
31
|
+
position: { x: 0, y: 0 },
|
|
32
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./HoverLabelPM"), exports);
|
|
14
|
+
__exportStar(require("./AllowHoverLabelPM"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tool } from "../Entities";
|
|
2
2
|
import { PresentionManager } from "./PresentationManager";
|
|
3
|
-
export interface ToolVM {
|
|
4
|
-
|
|
3
|
+
export interface ToolVM<ToolType> {
|
|
4
|
+
type: ToolType;
|
|
5
5
|
label: string;
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
selected: boolean;
|
|
@@ -9,10 +9,9 @@ export interface ToolVM {
|
|
|
9
9
|
shortcutLabel: string;
|
|
10
10
|
tooltipLabel: string;
|
|
11
11
|
}
|
|
12
|
-
export declare class ToolPM extends PresentionManager {
|
|
12
|
+
export declare class ToolPM<ToolType> extends PresentionManager {
|
|
13
13
|
private tool;
|
|
14
14
|
private updateView;
|
|
15
15
|
doUpdateView: () => void;
|
|
16
|
-
constructor(tool: Tool
|
|
16
|
+
constructor(tool: Tool<ToolType>, updateView: (tools: ToolVM<ToolType>) => void);
|
|
17
17
|
}
|
|
18
|
-
export declare const defaultToolVM: ToolVM;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ToolPM = void 0;
|
|
4
4
|
const Entities_1 = require("../Entities");
|
|
5
5
|
const PresentationManager_1 = require("./PresentationManager");
|
|
6
6
|
class ToolPM extends PresentationManager_1.PresentionManager {
|
|
@@ -9,21 +9,22 @@ class ToolPM extends PresentationManager_1.PresentionManager {
|
|
|
9
9
|
this.tool = tool;
|
|
10
10
|
this.updateView = updateView;
|
|
11
11
|
this.doUpdateView = () => {
|
|
12
|
+
const { type, state, label, shortcutLabel } = this.tool;
|
|
12
13
|
let enabled = false;
|
|
13
|
-
if (
|
|
14
|
-
|
|
14
|
+
if (state === Entities_1.ToolState.ACTIVE ||
|
|
15
|
+
state === Entities_1.ToolState.ENABLED) {
|
|
15
16
|
enabled = true;
|
|
16
17
|
}
|
|
17
|
-
const selected =
|
|
18
|
-
const show =
|
|
19
|
-
const tooltipLabel = `${
|
|
18
|
+
const selected = state === Entities_1.ToolState.ACTIVE ? true : false;
|
|
19
|
+
const show = state === Entities_1.ToolState.HIDDEN ? false : true;
|
|
20
|
+
const tooltipLabel = `${label} [${shortcutLabel}]`;
|
|
20
21
|
const vm = {
|
|
21
|
-
|
|
22
|
+
type,
|
|
22
23
|
enabled,
|
|
23
|
-
label
|
|
24
|
+
label,
|
|
24
25
|
selected,
|
|
25
26
|
show,
|
|
26
|
-
shortcutLabel
|
|
27
|
+
shortcutLabel,
|
|
27
28
|
tooltipLabel,
|
|
28
29
|
};
|
|
29
30
|
this.updateView(vm);
|
|
@@ -32,12 +33,3 @@ class ToolPM extends PresentationManager_1.PresentionManager {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
exports.ToolPM = ToolPM;
|
|
35
|
-
exports.defaultToolVM = {
|
|
36
|
-
toolID: "",
|
|
37
|
-
enabled: false,
|
|
38
|
-
label: "",
|
|
39
|
-
selected: false,
|
|
40
|
-
shortcutLabel: "",
|
|
41
|
-
show: false,
|
|
42
|
-
tooltipLabel: "",
|
|
43
|
-
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HoverLabels, SerializedSystem, StateMachine } from "../../Entities";
|
|
2
|
+
export declare class SerializeAllowHoverLabel implements SerializedSystem {
|
|
3
|
+
private hoverLabels;
|
|
4
|
+
name: string;
|
|
5
|
+
seriliziationVersion: number;
|
|
6
|
+
getSystemState(): object;
|
|
7
|
+
applySystemState(state: object, version: number): void;
|
|
8
|
+
applyDefaultState(): void;
|
|
9
|
+
private applyDataV1;
|
|
10
|
+
constructor(hoverLabels: HoverLabels, stateMachine: StateMachine);
|
|
11
|
+
}
|
|
12
|
+
export interface AllowHoverLabelV1 {
|
|
13
|
+
allow: boolean;
|
|
14
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerializeAllowHoverLabel = void 0;
|
|
4
|
+
class SerializeAllowHoverLabel {
|
|
5
|
+
constructor(hoverLabels, stateMachine) {
|
|
6
|
+
this.hoverLabels = hoverLabels;
|
|
7
|
+
this.name = "allowHoverLabel";
|
|
8
|
+
this.seriliziationVersion = 1;
|
|
9
|
+
stateMachine.registerSerializedSystem(this);
|
|
10
|
+
}
|
|
11
|
+
getSystemState() {
|
|
12
|
+
const state = {
|
|
13
|
+
allow: this.hoverLabels.allowHoverLabels
|
|
14
|
+
};
|
|
15
|
+
return state;
|
|
16
|
+
}
|
|
17
|
+
applySystemState(state, version) {
|
|
18
|
+
if (state && version === 1) {
|
|
19
|
+
const castState = state;
|
|
20
|
+
this.applyDataV1(castState);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// Unsupported version
|
|
24
|
+
console.warn(`Unsupported data version ${version} for serialized system ${this.name}. Reverting to default state`);
|
|
25
|
+
this.applyDefaultState();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
applyDefaultState() {
|
|
29
|
+
this.hoverLabels.allowHoverLabels = true;
|
|
30
|
+
}
|
|
31
|
+
applyDataV1(data) {
|
|
32
|
+
this.hoverLabels.allowHoverLabels = data.allow;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.SerializeAllowHoverLabel = SerializeAllowHoverLabel;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTrySetHoverLabel = void 0;
|
|
4
|
+
function makeTrySetHoverLabel(hoverLabels, babylon) {
|
|
5
|
+
return function trySetHoverLabel(position) {
|
|
6
|
+
babylon.sceneObjectPick(position).then(sceneObjectID => {
|
|
7
|
+
hoverLabels.showLabelForSceneObject(sceneObjectID, position);
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.makeTrySetHoverLabel = makeTrySetHoverLabel;
|
package/lib/UseCases/index.d.ts
CHANGED
package/lib/UseCases/index.js
CHANGED
|
@@ -15,3 +15,5 @@ __exportStar(require("./FocusCamera"), exports);
|
|
|
15
15
|
__exportStar(require("./QuestionChallenge"), exports);
|
|
16
16
|
__exportStar(require("./LerpVector3"), exports);
|
|
17
17
|
__exportStar(require("./SceneRoot"), exports);
|
|
18
|
+
__exportStar(require("./HoverLabels/trySetHoverLabel"), exports);
|
|
19
|
+
__exportStar(require("./HoverLabels/SerializeAllowHoverLabel"), exports);
|