@configura/babylon-view 2.0.0-alpha.9 → 2.1.0-alpha.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/.eslintrc.json +1 -14
- package/dist/camera/CfgOrbitalCamera.d.ts +4 -1
- package/dist/camera/CfgOrbitalCamera.js +25 -4
- package/dist/camera/CfgOrbitalCameraControlProps.d.ts +8 -5
- package/dist/camera/CfgOrbitalCameraControlProps.js +3 -2
- package/dist/io/CfgHistoryToCameraConfConnector.d.ts +4 -2
- package/dist/io/CfgHistoryToCameraConfConnector.js +20 -10
- package/dist/io/CfgIOCameraConfConnector.d.ts +5 -5
- package/dist/io/CfgIOCameraConfConnector.js +22 -21
- package/dist/view/SingleProductDefaultCameraView.d.ts +2 -1
- package/dist/view/SingleProductDefaultCameraView.js +10 -6
- package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +8 -6
- package/package.json +5 -5
package/.eslintrc.json
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"parser": "@typescript-eslint/parser",
|
|
3
3
|
"plugins": ["@typescript-eslint"],
|
|
4
|
-
"extends": [
|
|
5
|
-
"eslint:recommended",
|
|
6
|
-
"plugin:@typescript-eslint/recommended",
|
|
7
|
-
"prettier"
|
|
8
|
-
|
|
9
|
-
// TODO: Type-checking rules require a proper tsconfig-file to work,
|
|
10
|
-
// pointed at by the parserOption.project setting.
|
|
11
|
-
//
|
|
12
|
-
//"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
13
|
-
]
|
|
14
|
-
//"rules": { "@typescript-eslint/no-floating-promises": "error" }
|
|
15
|
-
//"parserOptions": {
|
|
16
|
-
// "project": "./tsconfig.json"
|
|
17
|
-
//}
|
|
4
|
+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"]
|
|
18
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;
|
|
@@ -54,8 +55,10 @@ export declare class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
54
55
|
set radius(r: number);
|
|
55
56
|
get radius(): number;
|
|
56
57
|
private get _orbitalCameraControlProps();
|
|
57
|
-
private
|
|
58
|
+
private _boundCameraListener;
|
|
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,26 @@ 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
|
-
this.
|
|
42
|
+
this._boundCameraListener = () => {
|
|
43
|
+
// This is a cheap operation, so it's acceptable to do it
|
|
44
|
+
// for every update (even if no radius-change has happened)
|
|
45
|
+
this._applyNoSneakPeeking();
|
|
46
|
+
this._notifyCameraControlListeners();
|
|
47
|
+
};
|
|
48
|
+
this._pointerUpDownCallback = (p, s) => {
|
|
49
|
+
if (p.type === PointerEventTypes.POINTERUP) {
|
|
50
|
+
this._pointerDown = false;
|
|
51
|
+
this._notifyCameraControlListeners();
|
|
52
|
+
}
|
|
53
|
+
if (p.type === PointerEventTypes.POINTERDOWN) {
|
|
54
|
+
this._pointerDown = true;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
41
57
|
this.attachControl(_canvas, // This parameters is not actually used for anything. But still required.
|
|
42
58
|
false, // No panning with keyboard
|
|
43
59
|
false // No panning with mouse
|
|
@@ -58,11 +74,13 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
58
74
|
this.fov = this._config.fov;
|
|
59
75
|
this.inertia = this._config.inertia;
|
|
60
76
|
this.angularSensibilityX = this.angularSensibilityY = this._config.pointerSpeedFactor;
|
|
61
|
-
|
|
77
|
+
scene.onPointerObservable.add(this._pointerUpDownCallback, PointerEventTypes.POINTERUP | PointerEventTypes.POINTERDOWN);
|
|
78
|
+
this.onViewMatrixChangedObservable.add(this._boundCameraListener);
|
|
62
79
|
}
|
|
63
80
|
dispose() {
|
|
64
81
|
this.detachControl(this._canvas);
|
|
65
|
-
this.onViewMatrixChangedObservable.removeCallback(this.
|
|
82
|
+
this.onViewMatrixChangedObservable.removeCallback(this._boundCameraListener);
|
|
83
|
+
this._scene.onPointerObservable.removeCallback(this._pointerUpDownCallback);
|
|
66
84
|
super.dispose();
|
|
67
85
|
}
|
|
68
86
|
set disableSubFloorCam(v) {
|
|
@@ -103,6 +121,7 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
103
121
|
yaw: normalizeAngle(this.alpha),
|
|
104
122
|
pitch: this.beta,
|
|
105
123
|
distanceWasAutoSet: this.radius === this._currentMinDistanceToFitModelInView,
|
|
124
|
+
committed: !(this._isMoving || this._pointerDown),
|
|
106
125
|
};
|
|
107
126
|
}
|
|
108
127
|
frameRenderNeeded() {
|
|
@@ -110,8 +129,10 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
|
110
129
|
if (externalControlHasHappened) {
|
|
111
130
|
this._externalControlHasHappened = false;
|
|
112
131
|
}
|
|
132
|
+
return this._isMoving || externalControlHasHappened;
|
|
133
|
+
}
|
|
134
|
+
get _isMoving() {
|
|
113
135
|
return (this.useAutoRotationBehavior ||
|
|
114
|
-
externalControlHasHappened ||
|
|
115
136
|
this.inertialAlphaOffset !== 0 ||
|
|
116
137
|
this.inertialBetaOffset !== 0 ||
|
|
117
138
|
this.inertialPanningX !== 0 ||
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
+
export interface CfgOrbitalCameraBasicProps {
|
|
2
|
+
distance?: number;
|
|
3
|
+
yaw?: number;
|
|
4
|
+
pitch?: number;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* @param distanceWasAutoSet Indicates that the camera distance was auto set. If true when setting
|
|
3
8
|
* camera settings @param distance will be ignored.
|
|
4
9
|
*/
|
|
5
|
-
export interface CfgOrbitalCameraControlProps {
|
|
6
|
-
distance?: number;
|
|
7
|
-
yaw?: number;
|
|
8
|
-
pitch?: number;
|
|
10
|
+
export interface CfgOrbitalCameraControlProps extends CfgOrbitalCameraBasicProps {
|
|
9
11
|
distanceWasAutoSet?: boolean;
|
|
12
|
+
committed?: boolean;
|
|
10
13
|
}
|
|
11
|
-
export declare function orbitalCameraControlPropsEquals(left: CfgOrbitalCameraControlProps, right: CfgOrbitalCameraControlProps): boolean;
|
|
14
|
+
export declare function orbitalCameraControlPropsEquals(left: CfgOrbitalCameraControlProps, right: CfgOrbitalCameraControlProps, ignoreCommitted?: boolean): boolean;
|
|
12
15
|
//# 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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CfgHistoryManager, CfgHistoryManagerSendData } from "@configura/web-api";
|
|
1
|
+
import { CfgHistoryManager, CfgHistoryManagerSendData, HistoryMode } from "@configura/web-api";
|
|
2
2
|
import { Observable } from "@configura/web-utilities";
|
|
3
3
|
import { CfgOrbitalCameraControlProps } from "../camera/CfgOrbitalCameraControlProps.js";
|
|
4
4
|
import { CfgCameraConfMessage, CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
|
|
@@ -9,18 +9,20 @@ import { CfgCameraConfMessage, CfgIOCameraConfConnector } from "./CfgIOCameraCon
|
|
|
9
9
|
*/
|
|
10
10
|
export declare class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector<CfgHistoryManagerSendData<CfgCameraConfMessage>> {
|
|
11
11
|
private readonly defaults;
|
|
12
|
+
private readonly _mode;
|
|
12
13
|
private readonly _qsKeyYaw;
|
|
13
14
|
private readonly _qsKeyPitch;
|
|
14
15
|
private readonly _qsKeyDistance;
|
|
15
16
|
/**
|
|
16
17
|
* @param defaults The default camera settings.
|
|
17
18
|
* @param cameraControl Connects with the Camera.
|
|
19
|
+
* @param mode
|
|
18
20
|
* @param qsKeyYaw The Query String key for Yaw.
|
|
19
21
|
* @param qsKeyPitch The Query String key for Pitch.
|
|
20
22
|
* @param qsKeyDistance The Query String key for Distance.
|
|
21
23
|
* @returns The instance and the initial camera orientation.
|
|
22
24
|
*/
|
|
23
|
-
static make(manager: CfgHistoryManager, defaults: CfgOrbitalCameraControlProps, cameraControl: Observable<CfgOrbitalCameraControlProps>, qsKeyYaw?: string, qsKeyPitch?: string, qsKeyDistance?: string): {
|
|
25
|
+
static make(manager: CfgHistoryManager, defaults: CfgOrbitalCameraControlProps, cameraControl: Observable<CfgOrbitalCameraControlProps>, mode: HistoryMode, qsKeyYaw?: string, qsKeyPitch?: string, qsKeyDistance?: string): {
|
|
24
26
|
instance: CfgHistoryToCameraConfConnector;
|
|
25
27
|
initial: CfgOrbitalCameraControlProps;
|
|
26
28
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CfgHistoryManager } from "@configura/web-api";
|
|
2
2
|
import { degToRad, radToDeg } from "@configura/web-utilities";
|
|
3
|
-
import { CfgIOCameraConfConnector } from "./CfgIOCameraConfConnector.js";
|
|
3
|
+
import { CfgIOCameraConfConnector, STAGE_CAMERA_CONF_MESSAGE_KEY, } from "./CfgIOCameraConfConnector.js";
|
|
4
4
|
const YAW_QS_KEY = "stageyaw";
|
|
5
5
|
const PITCH_QS_KEY = "stagepitch";
|
|
6
6
|
const DISTANCE_QS_KEY = "stagedistance";
|
|
@@ -38,9 +38,10 @@ const radToDegOrUndefined = (v) => v && radToDeg(v);
|
|
|
38
38
|
* to the history stack.
|
|
39
39
|
*/
|
|
40
40
|
export class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
41
|
-
constructor(manager, defaults, initial, cameraControl, _qsKeyYaw, _qsKeyPitch, _qsKeyDistance) {
|
|
41
|
+
constructor(manager, defaults, initial, cameraControl, _mode, _qsKeyYaw, _qsKeyPitch, _qsKeyDistance) {
|
|
42
42
|
super(manager, initial, cameraControl);
|
|
43
43
|
this.defaults = defaults;
|
|
44
|
+
this._mode = _mode;
|
|
44
45
|
this._qsKeyYaw = _qsKeyYaw;
|
|
45
46
|
this._qsKeyPitch = _qsKeyPitch;
|
|
46
47
|
this._qsKeyDistance = _qsKeyDistance;
|
|
@@ -48,20 +49,29 @@ export class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
|
48
49
|
/**
|
|
49
50
|
* @param defaults The default camera settings.
|
|
50
51
|
* @param cameraControl Connects with the Camera.
|
|
52
|
+
* @param mode
|
|
51
53
|
* @param qsKeyYaw The Query String key for Yaw.
|
|
52
54
|
* @param qsKeyPitch The Query String key for Pitch.
|
|
53
55
|
* @param qsKeyDistance The Query String key for Distance.
|
|
54
56
|
* @returns The instance and the initial camera orientation.
|
|
55
57
|
*/
|
|
56
|
-
static make(manager, defaults, cameraControl, qsKeyYaw = YAW_QS_KEY, qsKeyPitch = PITCH_QS_KEY, qsKeyDistance = DISTANCE_QS_KEY) {
|
|
58
|
+
static make(manager, defaults, cameraControl, mode, qsKeyYaw = YAW_QS_KEY, qsKeyPitch = PITCH_QS_KEY, qsKeyDistance = DISTANCE_QS_KEY) {
|
|
57
59
|
var _a, _b;
|
|
58
60
|
const qsKeyValues = CfgHistoryManager.currentQsKeyValues();
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
// First try to use the state, if that doesn't work use the query string
|
|
62
|
+
let initial;
|
|
63
|
+
const initialMessage = CfgHistoryManager.getMessageFromCurrentHistoryState(STAGE_CAMERA_CONF_MESSAGE_KEY);
|
|
64
|
+
if (initialMessage !== undefined) {
|
|
65
|
+
initial = initialMessage.cameraConf;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
initial = {
|
|
69
|
+
yaw: (_a = degToRadOrUndefined(qsAsNumber(qsKeyValues, qsKeyYaw))) !== null && _a !== void 0 ? _a : defaults.yaw,
|
|
70
|
+
pitch: (_b = degToRadOrUndefined(qsAsNumber(qsKeyValues, qsKeyPitch))) !== null && _b !== void 0 ? _b : defaults.pitch,
|
|
71
|
+
distance: qsAsNumber(qsKeyValues, qsKeyDistance !== null && qsKeyDistance !== void 0 ? qsKeyDistance : defaults.distance),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const instance = new CfgHistoryToCameraConfConnector(manager, defaults, initial, cameraControl, mode, qsKeyYaw, qsKeyPitch, qsKeyDistance);
|
|
65
75
|
return { instance, initial };
|
|
66
76
|
}
|
|
67
77
|
makeSendData(cameraConf, initial) {
|
|
@@ -74,7 +84,7 @@ export class CfgHistoryToCameraConfConnector extends CfgIOCameraConfConnector {
|
|
|
74
84
|
return {
|
|
75
85
|
message: CfgIOCameraConfConnector.makeMessage(cameraConf, initial),
|
|
76
86
|
qsKeyValues,
|
|
77
|
-
|
|
87
|
+
mode: this._mode,
|
|
78
88
|
};
|
|
79
89
|
}
|
|
80
90
|
}
|
|
@@ -15,12 +15,12 @@ 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>, initial: 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
26
|
static makeMessage(cameraConf: CfgOrbitalCameraControlProps, initial: boolean): CfgCameraConfMessage;
|
|
@@ -7,40 +7,41 @@ 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, initial,
|
|
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.
|
|
35
|
+
this._sendWithoutDuplicates(initial, true);
|
|
31
36
|
this._stopListenToMessage = CfgIOCameraConfConnector.listenForMessage((message) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
|
|
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 = CfgIOCameraConfConnector.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
|
-
}), _cameraControl);
|
|
43
|
+
this._sendWithoutDuplicates(cameraConf, false);
|
|
44
|
+
}), cameraControl);
|
|
44
45
|
}
|
|
45
46
|
static makeMessage(cameraConf, initial) {
|
|
46
47
|
return {
|
|
@@ -19,7 +19,8 @@ export declare class SingleProductDefaultCameraView<T extends SingleProductDefau
|
|
|
19
19
|
private _orbitalCameraConfigurationObservable;
|
|
20
20
|
private _previousOrbitalCameraConf;
|
|
21
21
|
constructor(options: SingleProductDefaultCameraViewConstructorOptions);
|
|
22
|
-
private
|
|
22
|
+
private _cameraDefaults;
|
|
23
|
+
private initOrResetCamera;
|
|
23
24
|
resetCamera(): void;
|
|
24
25
|
setConfiguration(configuration: SingleProductDefaultCameraViewConfiguration): void;
|
|
25
26
|
addEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
@@ -10,11 +10,11 @@ const CONTENT_TO_LIGHT_RIG_SCALE_FACTOR = 1;
|
|
|
10
10
|
export class SingleProductDefaultCameraView extends SingleProductView {
|
|
11
11
|
constructor(options) {
|
|
12
12
|
super(Object.assign(Object.assign({}, options), { cameraCreator: getDefaultCamera }));
|
|
13
|
-
this.
|
|
13
|
+
this._cameraDefaults = {};
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
initOrResetCamera(props) {
|
|
16
16
|
this.handleSizing(true);
|
|
17
|
-
const { distance, pitch, yaw } =
|
|
17
|
+
const { distance, pitch, yaw } = props;
|
|
18
18
|
let change = false;
|
|
19
19
|
if (distance !== undefined) {
|
|
20
20
|
this._camera.forceRadius(distance);
|
|
@@ -34,15 +34,19 @@ export class SingleProductDefaultCameraView extends SingleProductView {
|
|
|
34
34
|
this._camera.getViewMatrix();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
+
resetCamera() {
|
|
38
|
+
this.initOrResetCamera(this._cameraDefaults);
|
|
39
|
+
}
|
|
37
40
|
setConfiguration(configuration) {
|
|
41
|
+
var _a;
|
|
38
42
|
super.setConfiguration(configuration);
|
|
39
43
|
const cameraConf = configuration.camera || {};
|
|
40
44
|
this._camera.disableAutomaticSizing = cameraConf.disableAutomaticSizing === true;
|
|
41
45
|
this._camera.disableZoom = cameraConf.disableZoom === true;
|
|
42
46
|
this._camera.disableSubFloorCam = cameraConf.disableSubFloorCam === true;
|
|
43
47
|
this._camera.lowestAllowedCameraHeight = cameraConf.lowestAllowedCameraHeight;
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
48
|
+
this._cameraDefaults = cameraConf;
|
|
49
|
+
this.initOrResetCamera((_a = cameraConf.initial) !== null && _a !== void 0 ? _a : cameraConf);
|
|
46
50
|
const { autoRotate } = cameraConf;
|
|
47
51
|
if (autoRotate !== undefined) {
|
|
48
52
|
this._camera.useAutoRotationBehavior = true;
|
|
@@ -127,7 +131,7 @@ export class SingleProductDefaultCameraView extends SingleProductView {
|
|
|
127
131
|
? new CfgBoundingBox()
|
|
128
132
|
: currentProductNode.boundingBox;
|
|
129
133
|
boundingBox.applyMatrix(CET_TO_BABYLON_MATRIX);
|
|
130
|
-
const initialCameraDistanceSetPreventsInitialAutoSizingSet = this.isFirstLoad && this.
|
|
134
|
+
const initialCameraDistanceSetPreventsInitialAutoSizingSet = this.isFirstLoad && this._cameraDefaults.distance !== undefined;
|
|
131
135
|
this._camera.setContentBoundingBox(boundingBox, initialCameraDistanceSetPreventsInitialAutoSizingSet ? false : force ? true : undefined);
|
|
132
136
|
if (!boundingBox.isEmpty) {
|
|
133
137
|
this._lightRig.scale =
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { EventListener } from "@configura/web-utilities";
|
|
2
|
-
import {
|
|
2
|
+
import { CfgOrbitalCameraBasicProps } from "../camera/CfgOrbitalCameraControlProps.js";
|
|
3
3
|
import { CameraConfigurationProps } from "./BaseViewConfiguration.js";
|
|
4
4
|
import { SingleProductViewConfiguration, SingleProductViewEventMap } from "./SingleProductViewConfiguration.js";
|
|
5
5
|
/**
|
|
6
|
-
* @param
|
|
6
|
+
* @param yaw Horizontal angle for the camera. Range -π to π radians. The camera will reset to this angle.
|
|
7
|
+
* @param pitch Vertical angle for the camera. Range 0 to π radians, measured from the north pole. The camera will reset to this angle.
|
|
8
|
+
* @param distance Only works if disableAutomaticSizing is set
|
|
9
|
+
* @param initial If set these values are used for the initial configuration of the camera. If not set yaw, pitch and distance are used.
|
|
10
|
+
* @param disableZoom Don't let the camera dolly in and out. Zoom is strictly speaking not correct, we only dolly the camera.
|
|
7
11
|
* @param disableAutomaticSizing Turn off automatic adaption of camera distance and light rig size.
|
|
8
12
|
* @param disableSubFloorCam It is common that catalogue models are designed to never be shown from below. This limits camera polar angle.
|
|
9
13
|
* @param lowestAllowedCameraHeight Relative to the size of the viewed model, the lowest height the camera can reach. Setting this to 0 is the same as disableSubFloorCam. 1 means the camera can not move lower than the height of the model. Any numeric value is allowed.
|
|
10
|
-
* @param distance Only works if disableAutomaticSizing is set
|
|
11
|
-
* @param yaw Horisontal angle for the camera. Range -π to π radians.
|
|
12
|
-
* @param pitch Vertical angle for the camera. Range 0 to π radians, measured from the north pole.
|
|
13
14
|
* @param autoRotate See babylon-documentation for parameter-documentation
|
|
14
15
|
*/
|
|
15
16
|
export interface SingleProductDefaultCameraViewConfiguration extends SingleProductViewConfiguration {
|
|
16
|
-
camera?:
|
|
17
|
+
camera?: CfgOrbitalCameraBasicProps & {
|
|
18
|
+
initial?: CfgOrbitalCameraBasicProps;
|
|
17
19
|
disableZoom?: boolean;
|
|
18
20
|
disableAutomaticSizing?: boolean;
|
|
19
21
|
disableSubFloorCam?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/babylon-view",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0-alpha.0",
|
|
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.
|
|
20
|
-
"@configura/web-utilities": "2.
|
|
19
|
+
"@configura/web-core": "2.1.0-alpha.0",
|
|
20
|
+
"@configura/web-utilities": "2.1.0-alpha.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@configura/web-api": "2.
|
|
23
|
+
"@configura/web-api": "2.1.0-alpha.0",
|
|
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": "883ad6e31a55f05124dd0a6b2047c36ef6e6cea1"
|
|
31
31
|
}
|