@configura/babylon-view 2.0.0-alpha.1 → 2.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/camera/CfgOrbitalCamera.d.ts +3 -0
- package/dist/camera/CfgOrbitalCamera.js +17 -1
- package/dist/camera/CfgOrbitalCameraControlProps.d.ts +2 -1
- package/dist/camera/CfgOrbitalCameraControlProps.js +3 -2
- package/dist/io/CfgHistoryToCameraConfConnector.js +1 -1
- package/dist/io/CfgIOCameraConfConnector.d.ts +9 -9
- package/dist/io/CfgIOCameraConfConnector.js +27 -28
- package/dist/io/CfgObservableStateToCameraConfConnector.js +1 -1
- package/dist/io/CfgWindowMessageToCameraConfConnector.js +1 -1
- package/package.json +5 -5
|
@@ -46,6 +46,7 @@ export declare class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
46
46
|
_lowestAllowedCameraHeight: number | undefined;
|
|
47
47
|
set lowestAllowedCameraHeight(v: number | undefined);
|
|
48
48
|
get lowestAllowedCameraHeight(): number | undefined;
|
|
49
|
+
private _pointerDown;
|
|
49
50
|
disableAutomaticSizing: boolean;
|
|
50
51
|
disableZoom: boolean;
|
|
51
52
|
private _externalControlHasHappened;
|
|
@@ -55,7 +56,9 @@ export declare class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
55
56
|
get radius(): number;
|
|
56
57
|
private get _orbitalCameraControlProps();
|
|
57
58
|
private _boundNotifyCameraControlListeners;
|
|
59
|
+
private _pointerUpDownCallback;
|
|
58
60
|
frameRenderNeeded(): boolean;
|
|
61
|
+
private get _isMoving();
|
|
59
62
|
private _notifyCameraControlListeners;
|
|
60
63
|
get cameraControlObservable(): Observable<CfgOrbitalCameraControlProps>;
|
|
61
64
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PointerEventTypes } from "@babylonjs/core";
|
|
1
2
|
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera.js";
|
|
2
3
|
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
3
4
|
import { degToRad, normalizeAngle, Observable } from "@configura/web-utilities";
|
|
@@ -33,11 +34,21 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
33
34
|
this._latestSignificantChangeBoundingBox = new CfgBoundingBox();
|
|
34
35
|
this._disableSubFloorCam = false;
|
|
35
36
|
this._lowestAllowedCameraHeight = undefined;
|
|
37
|
+
this._pointerDown = false;
|
|
36
38
|
this.disableAutomaticSizing = false;
|
|
37
39
|
this.disableZoom = false;
|
|
38
40
|
this._externalControlHasHappened = false;
|
|
39
41
|
this._radius = 0;
|
|
40
42
|
this._boundNotifyCameraControlListeners = () => this._notifyCameraControlListeners();
|
|
43
|
+
this._pointerUpDownCallback = (p, s) => {
|
|
44
|
+
if (p.type === PointerEventTypes.POINTERUP) {
|
|
45
|
+
this._pointerDown = false;
|
|
46
|
+
this._notifyCameraControlListeners();
|
|
47
|
+
}
|
|
48
|
+
if (p.type === PointerEventTypes.POINTERDOWN) {
|
|
49
|
+
this._pointerDown = true;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
41
52
|
this.attachControl(_canvas, // This parameters is not actually used for anything. But still required.
|
|
42
53
|
false, // No panning with keyboard
|
|
43
54
|
false // No panning with mouse
|
|
@@ -58,11 +69,13 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
58
69
|
this.fov = this._config.fov;
|
|
59
70
|
this.inertia = this._config.inertia;
|
|
60
71
|
this.angularSensibilityX = this.angularSensibilityY = this._config.pointerSpeedFactor;
|
|
72
|
+
scene.onPointerObservable.add(this._pointerUpDownCallback, PointerEventTypes.POINTERUP | PointerEventTypes.POINTERDOWN);
|
|
61
73
|
this.onViewMatrixChangedObservable.add(this._boundNotifyCameraControlListeners);
|
|
62
74
|
}
|
|
63
75
|
dispose() {
|
|
64
76
|
this.detachControl(this._canvas);
|
|
65
77
|
this.onViewMatrixChangedObservable.removeCallback(this._boundNotifyCameraControlListeners);
|
|
78
|
+
this._scene.onPointerObservable.removeCallback(this._pointerUpDownCallback);
|
|
66
79
|
super.dispose();
|
|
67
80
|
}
|
|
68
81
|
set disableSubFloorCam(v) {
|
|
@@ -103,6 +116,7 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
103
116
|
yaw: normalizeAngle(this.alpha),
|
|
104
117
|
pitch: this.beta,
|
|
105
118
|
distanceWasAutoSet: this.radius === this._currentMinDistanceToFitModelInView,
|
|
119
|
+
committed: !(this._isMoving || this._pointerDown),
|
|
106
120
|
};
|
|
107
121
|
}
|
|
108
122
|
frameRenderNeeded() {
|
|
@@ -110,8 +124,10 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
110
124
|
if (externalControlHasHappened) {
|
|
111
125
|
this._externalControlHasHappened = false;
|
|
112
126
|
}
|
|
127
|
+
return this._isMoving || externalControlHasHappened;
|
|
128
|
+
}
|
|
129
|
+
get _isMoving() {
|
|
113
130
|
return (this.useAutoRotationBehavior ||
|
|
114
|
-
externalControlHasHappened ||
|
|
115
131
|
this.inertialAlphaOffset !== 0 ||
|
|
116
132
|
this.inertialBetaOffset !== 0 ||
|
|
117
133
|
this.inertialPanningX !== 0 ||
|
|
@@ -7,6 +7,7 @@ export interface CfgOrbitalCameraControlProps {
|
|
|
7
7
|
yaw?: number;
|
|
8
8
|
pitch?: number;
|
|
9
9
|
distanceWasAutoSet?: boolean;
|
|
10
|
+
committed?: boolean;
|
|
10
11
|
}
|
|
11
|
-
export declare function orbitalCameraControlPropsEquals(left: CfgOrbitalCameraControlProps, right: CfgOrbitalCameraControlProps): boolean;
|
|
12
|
+
export declare function orbitalCameraControlPropsEquals(left: CfgOrbitalCameraControlProps, right: CfgOrbitalCameraControlProps, ignoreCommitted?: boolean): boolean;
|
|
12
13
|
//# sourceMappingURL=CfgOrbitalCameraControlProps.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export function orbitalCameraControlPropsEquals(left, right) {
|
|
1
|
+
export function orbitalCameraControlPropsEquals(left, right, ignoreCommitted = false) {
|
|
2
2
|
return (((left.distanceWasAutoSet && right.distanceWasAutoSet) ||
|
|
3
3
|
left.distance === right.distance) &&
|
|
4
4
|
left.yaw === right.yaw &&
|
|
5
|
-
left.pitch === right.pitch
|
|
5
|
+
left.pitch === right.pitch &&
|
|
6
|
+
(ignoreCommitted || left.committed === right.committed));
|
|
6
7
|
}
|
|
@@ -72,7 +72,7 @@ export class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
|
72
72
|
addToMapAndRound(qsKeyValues, this._qsKeyDistance, cameraConf.distanceWasAutoSet ? undefined : cameraConf.distance, this.defaults.distance);
|
|
73
73
|
}
|
|
74
74
|
return {
|
|
75
|
-
message:
|
|
75
|
+
message: CfgIOCameraConfConnector.makeMessage(cameraConf, initial),
|
|
76
76
|
qsKeyValues,
|
|
77
77
|
useHistoryPush: false,
|
|
78
78
|
};
|
|
@@ -15,22 +15,22 @@ declare type CameraConfCallback = (conf: CfgOrbitalCameraControlProps) => Promis
|
|
|
15
15
|
*/
|
|
16
16
|
export declare abstract class CfgIOCameraConfConnector<S> {
|
|
17
17
|
private readonly _ioManager;
|
|
18
|
-
private readonly
|
|
19
|
-
private
|
|
20
|
-
|
|
21
|
-
constructor(_ioManager: CfgIOManager<S>, initialCameraConf: CfgOrbitalCameraControlProps, _cameraControl: Observable<CfgOrbitalCameraControlProps>);
|
|
18
|
+
private readonly _stopListenToMessage;
|
|
19
|
+
private readonly _stopListenToCameraConf;
|
|
20
|
+
constructor(_ioManager: CfgIOManager<S>, initial: CfgOrbitalCameraControlProps, cameraControl: Observable<CfgOrbitalCameraControlProps>);
|
|
22
21
|
destroy: () => void;
|
|
23
|
-
private
|
|
22
|
+
private _latestSentData;
|
|
23
|
+
private _sendWithoutDuplicates;
|
|
24
24
|
private _send;
|
|
25
25
|
protected abstract makeSendData(cameraConf: CfgOrbitalCameraControlProps, initial: boolean): S;
|
|
26
|
-
makeMessage(cameraConf: CfgOrbitalCameraControlProps, initial: boolean): CfgCameraConfMessage;
|
|
27
|
-
makeMessageListener(callback: CameraConfMessageCallback): (message: unknown) => Promise<void>;
|
|
26
|
+
static makeMessage(cameraConf: CfgOrbitalCameraControlProps, initial: boolean): CfgCameraConfMessage;
|
|
27
|
+
static makeMessageListener(callback: CameraConfMessageCallback): (message: unknown) => Promise<void>;
|
|
28
28
|
/**
|
|
29
29
|
* Register the callback to listen for Product Configuration messages
|
|
30
30
|
* @returns A function which when called will cancel listening
|
|
31
31
|
*/
|
|
32
|
-
listenForMessage(callback: CameraConfMessageCallback): () => void;
|
|
33
|
-
listenForCamera(callback: CameraConfCallback): () => void;
|
|
32
|
+
static listenForMessage<S>(callback: CameraConfMessageCallback, ioManager: CfgIOManager<S>): () => void;
|
|
33
|
+
static listenForCamera(callback: CameraConfCallback, cameraControl: Observable<CfgOrbitalCameraControlProps>): () => void;
|
|
34
34
|
}
|
|
35
35
|
export {};
|
|
36
36
|
//# sourceMappingURL=CfgIOCameraConfConnector.d.ts.map
|
|
@@ -7,49 +7,50 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
// And message receivers probably don't want to get flooded either.
|
|
12
|
-
const THROTTLING_DELAY = 100;
|
|
10
|
+
import { orbitalCameraControlPropsEquals, } from "../camera/CfgOrbitalCameraControlProps.js";
|
|
13
11
|
export const STAGE_CAMERA_CONF_MESSAGE_KEY = "stagecameraconf";
|
|
14
12
|
export const STAGE_CAMERA_MESSAGE_VERSION = "1.0";
|
|
15
13
|
/**
|
|
16
14
|
* Base class for connecting the camera configuration to an IO channel
|
|
17
15
|
*/
|
|
18
16
|
export class CfgIOCameraConfConnector {
|
|
19
|
-
constructor(_ioManager,
|
|
17
|
+
constructor(_ioManager, initial, cameraControl) {
|
|
20
18
|
this._ioManager = _ioManager;
|
|
21
|
-
this._cameraControl = _cameraControl;
|
|
22
|
-
this._stopListenToMessage = undefined;
|
|
23
|
-
this._stopListenToProdConf = undefined;
|
|
24
19
|
this.destroy = () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
this._stopListenToMessage();
|
|
21
|
+
this._stopListenToCameraConf();
|
|
22
|
+
};
|
|
23
|
+
this._sendWithoutDuplicates = (cameraConf, initial) => {
|
|
24
|
+
const latestSentData = this._latestSentData;
|
|
25
|
+
if (latestSentData !== undefined) {
|
|
26
|
+
if (orbitalCameraControlPropsEquals(latestSentData.cameraConf, cameraConf) &&
|
|
27
|
+
latestSentData.initial === initial) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
this._latestSentData = { cameraConf, initial };
|
|
32
|
+
this._send(this.makeSendData(cameraConf, initial));
|
|
28
33
|
};
|
|
29
34
|
this._send = (data) => this._ioManager.send(STAGE_CAMERA_CONF_MESSAGE_KEY, data);
|
|
30
|
-
this.
|
|
31
|
-
this._stopListenToMessage =
|
|
32
|
-
|
|
35
|
+
this._sendWithoutDuplicates(initial, true);
|
|
36
|
+
this._stopListenToMessage = CfgIOCameraConfConnector.listenForMessage((message) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
cameraControl.notifyAll(message.cameraConf, this);
|
|
38
|
+
}), _ioManager);
|
|
39
|
+
this._stopListenToCameraConf = CfgIOCameraConfConnector.listenForCamera((cameraConf) => __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
if (!cameraConf.committed) {
|
|
33
41
|
return;
|
|
34
42
|
}
|
|
35
|
-
|
|
36
|
-
}));
|
|
37
|
-
this._stopListenToProdConf = this.listenForCamera((cameraConf) => __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
window.clearTimeout(this._delayId);
|
|
39
|
-
this._delayId = window.setTimeout(() => {
|
|
40
|
-
this._send(this.makeSendData(cameraConf, false));
|
|
41
|
-
this._delayId = undefined;
|
|
42
|
-
}, THROTTLING_DELAY);
|
|
43
|
-
}));
|
|
43
|
+
this._sendWithoutDuplicates(cameraConf, false);
|
|
44
|
+
}), cameraControl);
|
|
44
45
|
}
|
|
45
|
-
makeMessage(cameraConf, initial) {
|
|
46
|
+
static makeMessage(cameraConf, initial) {
|
|
46
47
|
return {
|
|
47
48
|
version: STAGE_CAMERA_MESSAGE_VERSION,
|
|
48
49
|
initial,
|
|
49
50
|
cameraConf,
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
makeMessageListener(callback) {
|
|
53
|
+
static makeMessageListener(callback) {
|
|
53
54
|
return (message) => __awaiter(this, void 0, void 0, function* () {
|
|
54
55
|
const cameraConfMessage = message;
|
|
55
56
|
const version = cameraConfMessage.version;
|
|
@@ -64,16 +65,14 @@ export class CfgIOCameraConfConnector {
|
|
|
64
65
|
* Register the callback to listen for Product Configuration messages
|
|
65
66
|
* @returns A function which when called will cancel listening
|
|
66
67
|
*/
|
|
67
|
-
listenForMessage(callback) {
|
|
68
|
-
const ioManager = this._ioManager;
|
|
68
|
+
static listenForMessage(callback, ioManager) {
|
|
69
69
|
const listener = this.makeMessageListener(callback);
|
|
70
70
|
ioManager.listenForMessage(listener, STAGE_CAMERA_CONF_MESSAGE_KEY);
|
|
71
71
|
return () => {
|
|
72
72
|
ioManager.stopListenForMessage(listener);
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
listenForCamera(callback) {
|
|
76
|
-
const cameraControl = this._cameraControl;
|
|
75
|
+
static listenForCamera(callback, cameraControl) {
|
|
77
76
|
cameraControl.listen(callback, this);
|
|
78
77
|
return () => {
|
|
79
78
|
cameraControl.stopListen(callback);
|
|
@@ -6,6 +6,6 @@ import { CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export class CfgObservableStateToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
8
8
|
makeSendData(cameraConf, initial) {
|
|
9
|
-
return
|
|
9
|
+
return CfgIOCameraConfConnector.makeMessage(cameraConf, initial);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -6,6 +6,6 @@ import { CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export class CfgWindowMessageToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
8
8
|
makeSendData(cameraConf, initial) {
|
|
9
|
-
return
|
|
9
|
+
return CfgIOCameraConfConnector.makeMessage(cameraConf, initial);
|
|
10
10
|
}
|
|
11
11
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/babylon-view",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.10",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babylonjs/core": "4.2.0",
|
|
19
|
-
"@configura/web-core": "2.0.0-alpha.
|
|
20
|
-
"@configura/web-utilities": "2.0.0-alpha.
|
|
19
|
+
"@configura/web-core": "2.0.0-alpha.10",
|
|
20
|
+
"@configura/web-utilities": "2.0.0-alpha.10"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@configura/web-api": "2.0.0-alpha.
|
|
23
|
+
"@configura/web-api": "2.0.0-alpha.10",
|
|
24
24
|
"del-cli": "^3.0.0",
|
|
25
25
|
"typescript": "4.2"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "77f9cbe7521be3fd58a139bdc93167a349ef384f"
|
|
31
31
|
}
|