@configura/babylon-view 1.4.0-alpha.4 → 1.4.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/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/animation/AnimatableObject.d.ts +8 -8
- package/dist/animation/AnimatableObject.js +3 -3
- package/dist/animation/animator/Animator.d.ts +33 -33
- package/dist/animation/animator/Animator.js +58 -58
- package/dist/animation/animator/AnimatorEasing.d.ts +16 -16
- package/dist/animation/animator/AnimatorEasing.js +31 -31
- package/dist/animation/animator/AnimatorEasingMatrix.d.ts +14 -14
- package/dist/animation/animator/AnimatorEasingMatrix.js +16 -16
- package/dist/animation/animator/AnimatorHighlight.d.ts +16 -16
- package/dist/animation/animator/AnimatorHighlight.js +32 -32
- package/dist/animation/animator/AnimatorPointToPoint.d.ts +8 -8
- package/dist/animation/animator/AnimatorPointToPoint.js +14 -14
- package/dist/animation/animator/AnimatorQueue.d.ts +13 -13
- package/dist/animation/animator/AnimatorQueue.js +57 -57
- package/dist/animation/animator/AnimatorScale.d.ts +8 -8
- package/dist/animation/animator/AnimatorScale.js +13 -13
- package/dist/animation/animator/AnimatorSpin.d.ts +10 -10
- package/dist/animation/animator/AnimatorSpin.js +13 -13
- package/dist/animation/animator/EasingFunctions.d.ts +35 -35
- package/dist/animation/animator/EasingFunctions.js +137 -137
- package/dist/animation/coordinator/Coordinator.d.ts +28 -28
- package/dist/animation/coordinator/Coordinator.js +47 -47
- package/dist/animation/coordinator/CoordinatorDropAndSpin.d.ts +22 -22
- package/dist/animation/coordinator/CoordinatorDropAndSpin.js +133 -133
- package/dist/animation/coordinator/CoordinatorIdentity.d.ts +11 -11
- package/dist/animation/coordinator/CoordinatorIdentity.js +12 -12
- package/dist/animation/coordinator/CoordinatorNodeQueues.d.ts +18 -18
- package/dist/animation/coordinator/CoordinatorNodeQueues.js +50 -50
- package/dist/animation/coordinator/CoordinatorPulse.d.ts +21 -21
- package/dist/animation/coordinator/CoordinatorPulse.js +47 -47
- package/dist/animation/coordinator/CoordinatorPulseBounce.d.ts +14 -14
- package/dist/animation/coordinator/CoordinatorPulseBounce.js +40 -40
- package/dist/animation/coordinator/CoordinatorPulseHighlight.d.ts +13 -13
- package/dist/animation/coordinator/CoordinatorPulseHighlight.js +34 -34
- package/dist/animation/coordinator/CoordinatorPulseInflate.d.ts +14 -14
- package/dist/animation/coordinator/CoordinatorPulseInflate.js +30 -30
- package/dist/camera/CameraCreator.d.ts +5 -5
- package/dist/camera/CameraCreator.js +4 -4
- package/dist/camera/CfgArcRotateCameraPointersInput.d.ts +26 -26
- package/dist/camera/CfgArcRotateCameraPointersInput.js +264 -264
- package/dist/camera/CfgOrbitalCamera.d.ts +68 -68
- package/dist/camera/CfgOrbitalCamera.js +250 -250
- package/dist/camera/CfgOrbitalCameraControlProps.d.ts +6 -6
- package/dist/camera/CfgOrbitalCameraControlProps.js +3 -3
- package/dist/camera/GradingApplier.d.ts +3 -3
- package/dist/camera/GradingApplier.js +48 -48
- package/dist/engine/EngineCreator.d.ts +3 -3
- package/dist/engine/EngineCreator.js +10 -10
- package/dist/geometry/CfgGeometry.d.ts +29 -29
- package/dist/geometry/CfgGeometry.js +146 -146
- package/dist/geometry/CfgMesh.d.ts +10 -10
- package/dist/geometry/CfgMesh.js +38 -38
- package/dist/geometry/geoSplitter.d.ts +8 -8
- package/dist/geometry/geoSplitter.js +192 -192
- package/dist/geometry/stretch/CfgMorphTarget.d.ts +15 -15
- package/dist/geometry/stretch/CfgMorphTarget.js +65 -65
- package/dist/geometry/stretch/CfgStretchData.d.ts +114 -114
- package/dist/geometry/stretch/CfgStretchData.js +340 -340
- package/dist/geometry/stretch/CfgStretchMorphGeometry.d.ts +16 -16
- package/dist/geometry/stretch/CfgStretchMorphGeometry.js +95 -95
- package/dist/index.d.ts +13 -13
- package/dist/index.js +13 -13
- package/dist/light/CfgDirectionalLight.d.ts +8 -8
- package/dist/light/CfgDirectionalLight.js +18 -18
- package/dist/light/CfgHemisphericLight.d.ts +7 -7
- package/dist/light/CfgHemisphericLight.js +17 -17
- package/dist/light/CfgPointLight.d.ts +8 -8
- package/dist/light/CfgPointLight.js +18 -18
- package/dist/light/DefaultLightRig.d.ts +19 -19
- package/dist/light/DefaultLightRig.js +77 -77
- package/dist/light/LightRigCreator.d.ts +9 -9
- package/dist/light/LightRigCreator.js +3 -3
- package/dist/material/CfgMaterial.d.ts +68 -68
- package/dist/material/CfgMaterial.js +482 -482
- package/dist/material/DummyMaterialCreator.d.ts +4 -4
- package/dist/material/DummyMaterialCreator.js +15 -15
- package/dist/material/material.d.ts +18 -18
- package/dist/material/material.js +128 -128
- package/dist/material/texture.d.ts +14 -14
- package/dist/material/texture.js +306 -306
- package/dist/nodes/CfgContentRootNode.d.ts +19 -19
- package/dist/nodes/CfgContentRootNode.js +75 -75
- package/dist/nodes/CfgDeferredMeshNode.d.ts +55 -55
- package/dist/nodes/CfgDeferredMeshNode.js +377 -377
- package/dist/nodes/CfgProductNode.d.ts +126 -126
- package/dist/nodes/CfgProductNode.js +578 -578
- package/dist/nodes/CfgSymNode.d.ts +50 -50
- package/dist/nodes/CfgSymNode.js +249 -249
- package/dist/nodes/CfgSymRootNode.d.ts +45 -45
- package/dist/nodes/CfgSymRootNode.js +220 -220
- package/dist/nodes/CfgTransformNode.d.ts +33 -33
- package/dist/nodes/CfgTransformNode.js +83 -83
- package/dist/scene/SceneCreator.d.ts +6 -6
- package/dist/scene/SceneCreator.js +22 -22
- package/dist/utilities/CfgBoundingBox.d.ts +21 -21
- package/dist/utilities/CfgBoundingBox.js +81 -81
- package/dist/utilities/anchor/anchor.d.ts +51 -51
- package/dist/utilities/anchor/anchor.js +136 -136
- package/dist/utilities/anchor/anchorMap.d.ts +20 -20
- package/dist/utilities/anchor/anchorMap.js +111 -111
- package/dist/utilities/utilities3D.d.ts +70 -70
- package/dist/utilities/utilities3D.js +265 -265
- package/dist/utilities/utilitiesColor.d.ts +18 -18
- package/dist/utilities/utilitiesColor.js +48 -48
- package/dist/utilities/utilitiesImage.d.ts +6 -6
- package/dist/utilities/utilitiesImage.js +107 -107
- package/dist/utilities/utilitiesSymRootIdentifier.d.ts +7 -7
- package/dist/utilities/utilitiesSymRootIdentifier.js +26 -26
- package/dist/view/BaseView.d.ts +78 -78
- package/dist/view/BaseView.js +297 -297
- package/dist/view/BaseViewConfiguration.d.ts +32 -32
- package/dist/view/BaseViewConfiguration.js +8 -8
- package/dist/view/RenderEnv.d.ts +43 -43
- package/dist/view/RenderEnv.js +7 -7
- package/dist/view/SingleProductDefaultCameraView.d.ts +33 -33
- package/dist/view/SingleProductDefaultCameraView.js +141 -141
- package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +46 -46
- package/dist/view/SingleProductDefaultCameraViewConfiguration.js +11 -11
- package/dist/view/SingleProductView.d.ts +42 -42
- package/dist/view/SingleProductView.js +206 -206
- package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
- package/dist/view/SingleProductViewConfiguration.js +19 -19
- package/package.json +5 -5
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera.js";
|
|
2
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
|
3
|
-
import { Observable } from "@configura/web-utilities";
|
|
4
|
-
import { CfgBoundingBox } from "../utilities/CfgBoundingBox.js";
|
|
5
|
-
import { CfgOrbitalCameraControlProps } from "./CfgOrbitalCameraControlProps.js";
|
|
6
|
-
export declare const MAX_UPPER_BETA_LIMIT: number;
|
|
7
|
-
export declare const MIN_LOWER_BETA_LIMIT = 0.1;
|
|
8
|
-
/**
|
|
9
|
-
* @param fov Field of view, in radians. Default value degToRad(30).
|
|
10
|
-
* @param mouseWheelSpeedFactor The higher the slower movement. Default value 200.
|
|
11
|
-
* @param pinchZoomFactor The higher the slower zoom (really dolly). Default value 100.
|
|
12
|
-
* @param keyboardSpeedFactor The higher the faster movement. Default value 0.002.
|
|
13
|
-
* @param pointerSpeedFactor The higher the slower movement. Default value 2000.
|
|
14
|
-
* @param inertia How fast does speed decline. Must be less than 1. Default value 0.93.
|
|
15
|
-
* @param keepCameraFromGettingTooCloseFactor How much further than closest corner is near limit. 1.5 means 50% further. Default value 1.5.
|
|
16
|
-
* @param significantBoundingBoxSizeChangeShrinkFactor How much shrink in size along any axis (X+, X-, Y+, Y-, Z+ or Z-) will make the the zoom reset. Default value 0.4 (40%).
|
|
17
|
-
* @param significantBoundingBoxSizeChangeGrowFactor How much growth in size along any axis (X+, X-, Y+, Y-, Z+ or Z-) will make the the zoom reset. Default value 0.1 (10%).
|
|
18
|
-
*/
|
|
19
|
-
export declare type CfgOrbitalCameraConfig = {
|
|
20
|
-
fov: number;
|
|
21
|
-
mouseWheelSpeedFactor: number;
|
|
22
|
-
pinchZoomFactor: number;
|
|
23
|
-
keyboardSpeedFactor: number;
|
|
24
|
-
pointerSpeedFactor: number;
|
|
25
|
-
inertia: number;
|
|
26
|
-
keepCameraFromGettingTooCloseFactor: number;
|
|
27
|
-
significantBoundingBoxSizeChangeShrinkFactor: number;
|
|
28
|
-
significantBoundingBoxSizeChangeGrowFactor: number;
|
|
29
|
-
};
|
|
30
|
-
declare abstract class WorkaroundCfgOrbitalCamera extends ArcRotateCamera {
|
|
31
|
-
abstract radius: number;
|
|
32
|
-
}
|
|
33
|
-
export declare class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
34
|
-
private _canvas;
|
|
35
|
-
constructor(scene: Scene, _canvas: HTMLElement, config?: Partial<CfgOrbitalCameraConfig>);
|
|
36
|
-
dispose(): void;
|
|
37
|
-
protected _config: CfgOrbitalCameraConfig;
|
|
38
|
-
private _currentBoundingBox;
|
|
39
|
-
private _latestSignificantChangeBoundingBox;
|
|
40
|
-
private _currentMinDistanceToKeepCameraOutOfModel;
|
|
41
|
-
private _currentMinDistanceToFitModelInView;
|
|
42
|
-
private _orbitalCameraControlObservable;
|
|
43
|
-
private _previousOrbitalCameraControlProps;
|
|
44
|
-
_disableSubFloorCam: boolean;
|
|
45
|
-
set disableSubFloorCam(v: boolean);
|
|
46
|
-
_lowestAllowedCameraHeight: number | undefined;
|
|
47
|
-
set lowestAllowedCameraHeight(v: number | undefined);
|
|
48
|
-
get lowestAllowedCameraHeight(): number | undefined;
|
|
49
|
-
disableAutomaticSizing: boolean;
|
|
50
|
-
disableZoom: boolean;
|
|
51
|
-
private _externalControlHasHappened;
|
|
52
|
-
forceRadius(r: number): void;
|
|
53
|
-
private _radius;
|
|
54
|
-
set radius(r: number);
|
|
55
|
-
get radius(): number;
|
|
56
|
-
private get _orbitalCameraControlProps();
|
|
57
|
-
private _boundNotifyCameraControlListeners;
|
|
58
|
-
frameRenderNeeded(): boolean;
|
|
59
|
-
private _notifyCameraControlListeners;
|
|
60
|
-
get cameraControlObservable(): Observable<CfgOrbitalCameraControlProps>;
|
|
61
|
-
setContentBoundingBox(newBoundingBox: CfgBoundingBox, force: boolean): void;
|
|
62
|
-
_applyAdaptToContentBoundingBox(force: boolean): void;
|
|
63
|
-
refreshCameraNearFar(): void;
|
|
64
|
-
private _applyNoSneakPeeking;
|
|
65
|
-
private _updateCameraLimits;
|
|
66
|
-
private _calculateNoPeekingLimit;
|
|
67
|
-
}
|
|
68
|
-
export {};
|
|
1
|
+
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera.js";
|
|
2
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
|
3
|
+
import { Observable } from "@configura/web-utilities";
|
|
4
|
+
import { CfgBoundingBox } from "../utilities/CfgBoundingBox.js";
|
|
5
|
+
import { CfgOrbitalCameraControlProps } from "./CfgOrbitalCameraControlProps.js";
|
|
6
|
+
export declare const MAX_UPPER_BETA_LIMIT: number;
|
|
7
|
+
export declare const MIN_LOWER_BETA_LIMIT = 0.1;
|
|
8
|
+
/**
|
|
9
|
+
* @param fov Field of view, in radians. Default value degToRad(30).
|
|
10
|
+
* @param mouseWheelSpeedFactor The higher the slower movement. Default value 200.
|
|
11
|
+
* @param pinchZoomFactor The higher the slower zoom (really dolly). Default value 100.
|
|
12
|
+
* @param keyboardSpeedFactor The higher the faster movement. Default value 0.002.
|
|
13
|
+
* @param pointerSpeedFactor The higher the slower movement. Default value 2000.
|
|
14
|
+
* @param inertia How fast does speed decline. Must be less than 1. Default value 0.93.
|
|
15
|
+
* @param keepCameraFromGettingTooCloseFactor How much further than closest corner is near limit. 1.5 means 50% further. Default value 1.5.
|
|
16
|
+
* @param significantBoundingBoxSizeChangeShrinkFactor How much shrink in size along any axis (X+, X-, Y+, Y-, Z+ or Z-) will make the the zoom reset. Default value 0.4 (40%).
|
|
17
|
+
* @param significantBoundingBoxSizeChangeGrowFactor How much growth in size along any axis (X+, X-, Y+, Y-, Z+ or Z-) will make the the zoom reset. Default value 0.1 (10%).
|
|
18
|
+
*/
|
|
19
|
+
export declare type CfgOrbitalCameraConfig = {
|
|
20
|
+
fov: number;
|
|
21
|
+
mouseWheelSpeedFactor: number;
|
|
22
|
+
pinchZoomFactor: number;
|
|
23
|
+
keyboardSpeedFactor: number;
|
|
24
|
+
pointerSpeedFactor: number;
|
|
25
|
+
inertia: number;
|
|
26
|
+
keepCameraFromGettingTooCloseFactor: number;
|
|
27
|
+
significantBoundingBoxSizeChangeShrinkFactor: number;
|
|
28
|
+
significantBoundingBoxSizeChangeGrowFactor: number;
|
|
29
|
+
};
|
|
30
|
+
declare abstract class WorkaroundCfgOrbitalCamera extends ArcRotateCamera {
|
|
31
|
+
abstract radius: number;
|
|
32
|
+
}
|
|
33
|
+
export declare class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
34
|
+
private _canvas;
|
|
35
|
+
constructor(scene: Scene, _canvas: HTMLElement, config?: Partial<CfgOrbitalCameraConfig>);
|
|
36
|
+
dispose(): void;
|
|
37
|
+
protected _config: CfgOrbitalCameraConfig;
|
|
38
|
+
private _currentBoundingBox;
|
|
39
|
+
private _latestSignificantChangeBoundingBox;
|
|
40
|
+
private _currentMinDistanceToKeepCameraOutOfModel;
|
|
41
|
+
private _currentMinDistanceToFitModelInView;
|
|
42
|
+
private _orbitalCameraControlObservable;
|
|
43
|
+
private _previousOrbitalCameraControlProps;
|
|
44
|
+
_disableSubFloorCam: boolean;
|
|
45
|
+
set disableSubFloorCam(v: boolean);
|
|
46
|
+
_lowestAllowedCameraHeight: number | undefined;
|
|
47
|
+
set lowestAllowedCameraHeight(v: number | undefined);
|
|
48
|
+
get lowestAllowedCameraHeight(): number | undefined;
|
|
49
|
+
disableAutomaticSizing: boolean;
|
|
50
|
+
disableZoom: boolean;
|
|
51
|
+
private _externalControlHasHappened;
|
|
52
|
+
forceRadius(r: number): void;
|
|
53
|
+
private _radius;
|
|
54
|
+
set radius(r: number);
|
|
55
|
+
get radius(): number;
|
|
56
|
+
private get _orbitalCameraControlProps();
|
|
57
|
+
private _boundNotifyCameraControlListeners;
|
|
58
|
+
frameRenderNeeded(): boolean;
|
|
59
|
+
private _notifyCameraControlListeners;
|
|
60
|
+
get cameraControlObservable(): Observable<CfgOrbitalCameraControlProps>;
|
|
61
|
+
setContentBoundingBox(newBoundingBox: CfgBoundingBox, force: boolean): void;
|
|
62
|
+
_applyAdaptToContentBoundingBox(force: boolean): void;
|
|
63
|
+
refreshCameraNearFar(): void;
|
|
64
|
+
private _applyNoSneakPeeking;
|
|
65
|
+
private _updateCameraLimits;
|
|
66
|
+
private _calculateNoPeekingLimit;
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
69
69
|
//# sourceMappingURL=CfgOrbitalCamera.d.ts.map
|
|
@@ -1,250 +1,250 @@
|
|
|
1
|
-
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera.js";
|
|
2
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
3
|
-
import { degToRad, Observable } from "@configura/web-utilities";
|
|
4
|
-
import { CfgBoundingBox } from "../utilities/CfgBoundingBox.js";
|
|
5
|
-
import { boundingBoxesAreSignificantlyDifferent, measureLongestDistanceToCorner, } from "../utilities/utilities3D.js";
|
|
6
|
-
import { CfgArcRotateCameraPointersInput } from "./CfgArcRotateCameraPointersInput.js";
|
|
7
|
-
import { orbitalCameraControlPropsEquals, } from "./CfgOrbitalCameraControlProps.js";
|
|
8
|
-
const NEAREST_ALLOWED_TO_BETA_LIMITS = 0.1;
|
|
9
|
-
export const MAX_UPPER_BETA_LIMIT = Math.PI - NEAREST_ALLOWED_TO_BETA_LIMITS;
|
|
10
|
-
export const MIN_LOWER_BETA_LIMIT = NEAREST_ALLOWED_TO_BETA_LIMITS;
|
|
11
|
-
const defaultOrbitalCameraConfig = {
|
|
12
|
-
fov: degToRad(30),
|
|
13
|
-
mouseWheelSpeedFactor: 200,
|
|
14
|
-
pinchZoomFactor: 100,
|
|
15
|
-
inertia: 0.93,
|
|
16
|
-
keyboardSpeedFactor: 0.002,
|
|
17
|
-
pointerSpeedFactor: 2000,
|
|
18
|
-
keepCameraFromGettingTooCloseFactor: 1.5,
|
|
19
|
-
significantBoundingBoxSizeChangeShrinkFactor: 0.4,
|
|
20
|
-
significantBoundingBoxSizeChangeGrowFactor: 0.1,
|
|
21
|
-
};
|
|
22
|
-
// This is a workaround as you are not allowed to override fields with accessors.
|
|
23
|
-
// By adding this abstract field this becomes possible. This is a hack.
|
|
24
|
-
class WorkaroundCfgOrbitalCamera extends ArcRotateCamera {
|
|
25
|
-
}
|
|
26
|
-
export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
27
|
-
constructor(scene, _canvas, config) {
|
|
28
|
-
super("CfgOrbitalCamera", 0, degToRad(90), 50, new Vector3(0, 0, 0), scene);
|
|
29
|
-
this._canvas = _canvas;
|
|
30
|
-
this._currentBoundingBox = new CfgBoundingBox();
|
|
31
|
-
this._latestSignificantChangeBoundingBox = new CfgBoundingBox();
|
|
32
|
-
this._disableSubFloorCam = false;
|
|
33
|
-
this._lowestAllowedCameraHeight = undefined;
|
|
34
|
-
this.disableAutomaticSizing = false;
|
|
35
|
-
this.disableZoom = false;
|
|
36
|
-
this._externalControlHasHappened = false;
|
|
37
|
-
this._radius = 0;
|
|
38
|
-
this._boundNotifyCameraControlListeners = () => {
|
|
39
|
-
this._notifyCameraControlListeners();
|
|
40
|
-
};
|
|
41
|
-
this.attachControl(_canvas, // This parameters is not actually used for anything. But still required.
|
|
42
|
-
false, // No panning with keyboard
|
|
43
|
-
false // No panning with mouse
|
|
44
|
-
);
|
|
45
|
-
// Workaround for touch issues on iOS, see comments in CfgArcRotateCameraPointersInput.ts
|
|
46
|
-
this.inputs.removeByType("ArcRotateCameraPointersInput");
|
|
47
|
-
this.inputs.add(new CfgArcRotateCameraPointersInput());
|
|
48
|
-
// Make sure to disable all forms of "panning", which for the ArcRotateCamera is defined
|
|
49
|
-
// as movement sideways without rotation to keep the camera centered on the target.
|
|
50
|
-
// The settings above for attachControl will not disable two-finger touch.
|
|
51
|
-
this.panningAxis = Vector3.Zero();
|
|
52
|
-
this.panningDistanceLimit = 0;
|
|
53
|
-
this.panningSensibility = 0;
|
|
54
|
-
this.panningInertia = 0;
|
|
55
|
-
this._config = Object.assign(Object.assign({}, defaultOrbitalCameraConfig), config);
|
|
56
|
-
const keyboardInput = this.inputs.attached["keyboard"];
|
|
57
|
-
keyboardInput.angularSpeed = this._config.keyboardSpeedFactor;
|
|
58
|
-
this.fov = this._config.fov;
|
|
59
|
-
this.inertia = this._config.inertia;
|
|
60
|
-
this.angularSensibilityX = this.angularSensibilityY = this._config.pointerSpeedFactor;
|
|
61
|
-
this.onViewMatrixChangedObservable.add(this._boundNotifyCameraControlListeners);
|
|
62
|
-
}
|
|
63
|
-
dispose() {
|
|
64
|
-
this.detachControl(this._canvas);
|
|
65
|
-
this.onViewMatrixChangedObservable.removeCallback(this._boundNotifyCameraControlListeners);
|
|
66
|
-
super.dispose();
|
|
67
|
-
}
|
|
68
|
-
set disableSubFloorCam(v) {
|
|
69
|
-
this._disableSubFloorCam = v;
|
|
70
|
-
}
|
|
71
|
-
set lowestAllowedCameraHeight(v) {
|
|
72
|
-
this._lowestAllowedCameraHeight = v;
|
|
73
|
-
}
|
|
74
|
-
get lowestAllowedCameraHeight() {
|
|
75
|
-
if (this._lowestAllowedCameraHeight !== undefined) {
|
|
76
|
-
if (this._disableSubFloorCam) {
|
|
77
|
-
return Math.max(0, this._lowestAllowedCameraHeight);
|
|
78
|
-
}
|
|
79
|
-
return this._lowestAllowedCameraHeight;
|
|
80
|
-
}
|
|
81
|
-
if (this._disableSubFloorCam) {
|
|
82
|
-
return 0;
|
|
83
|
-
}
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
forceRadius(r) {
|
|
87
|
-
this._radius = r;
|
|
88
|
-
}
|
|
89
|
-
set radius(r) {
|
|
90
|
-
if (this.disableZoom) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
this._radius = r;
|
|
94
|
-
}
|
|
95
|
-
get radius() {
|
|
96
|
-
return this._radius;
|
|
97
|
-
}
|
|
98
|
-
get _orbitalCameraControlProps() {
|
|
99
|
-
return {
|
|
100
|
-
distance: this.radius,
|
|
101
|
-
yaw: this.alpha,
|
|
102
|
-
pitch: this.beta,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
frameRenderNeeded() {
|
|
106
|
-
const externalControlHasHappened = this._externalControlHasHappened;
|
|
107
|
-
if (externalControlHasHappened) {
|
|
108
|
-
this._externalControlHasHappened = false;
|
|
109
|
-
}
|
|
110
|
-
return (this.useAutoRotationBehavior ||
|
|
111
|
-
externalControlHasHappened ||
|
|
112
|
-
this.inertialAlphaOffset !== 0 ||
|
|
113
|
-
this.inertialBetaOffset !== 0 ||
|
|
114
|
-
this.inertialPanningX !== 0 ||
|
|
115
|
-
this.inertialPanningY !== 0 ||
|
|
116
|
-
this.inertialRadiusOffset !== 0);
|
|
117
|
-
}
|
|
118
|
-
_notifyCameraControlListeners() {
|
|
119
|
-
if (this._orbitalCameraControlObservable === undefined) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const orbitalCameraControlProps = this._orbitalCameraControlProps;
|
|
123
|
-
if (this._previousOrbitalCameraControlProps !== undefined &&
|
|
124
|
-
orbitalCameraControlPropsEquals(this._previousOrbitalCameraControlProps, orbitalCameraControlProps)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
this._orbitalCameraControlObservable.notifyAll(orbitalCameraControlProps, this._orbitalCameraControlObservable);
|
|
128
|
-
this._previousOrbitalCameraControlProps = orbitalCameraControlProps;
|
|
129
|
-
}
|
|
130
|
-
get cameraControlObservable() {
|
|
131
|
-
if (this._orbitalCameraControlObservable === undefined) {
|
|
132
|
-
this._orbitalCameraControlObservable = new Observable();
|
|
133
|
-
this._orbitalCameraControlObservable.listen((c) => {
|
|
134
|
-
const { distance, yaw, pitch } = c;
|
|
135
|
-
let change = false;
|
|
136
|
-
if (distance !== undefined && distance !== this.radius) {
|
|
137
|
-
this.forceRadius(distance);
|
|
138
|
-
change = true;
|
|
139
|
-
}
|
|
140
|
-
if (yaw !== undefined && yaw !== this.alpha) {
|
|
141
|
-
this.alpha = yaw;
|
|
142
|
-
change = true;
|
|
143
|
-
}
|
|
144
|
-
if (pitch !== undefined && pitch !== this.beta) {
|
|
145
|
-
this.beta = pitch;
|
|
146
|
-
change = true;
|
|
147
|
-
}
|
|
148
|
-
if (change) {
|
|
149
|
-
this._externalControlHasHappened = true;
|
|
150
|
-
this._notifyCameraControlListeners();
|
|
151
|
-
}
|
|
152
|
-
}, this._orbitalCameraControlObservable);
|
|
153
|
-
}
|
|
154
|
-
return this._orbitalCameraControlObservable;
|
|
155
|
-
}
|
|
156
|
-
setContentBoundingBox(newBoundingBox, force) {
|
|
157
|
-
this._currentBoundingBox = newBoundingBox;
|
|
158
|
-
const significantChange = boundingBoxesAreSignificantlyDifferent(this._latestSignificantChangeBoundingBox, newBoundingBox, this._config.significantBoundingBoxSizeChangeShrinkFactor, this._config.significantBoundingBoxSizeChangeGrowFactor);
|
|
159
|
-
if (!significantChange && !force) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
this._latestSignificantChangeBoundingBox = newBoundingBox;
|
|
163
|
-
this._applyAdaptToContentBoundingBox(force);
|
|
164
|
-
this._applyNoSneakPeeking();
|
|
165
|
-
}
|
|
166
|
-
_applyAdaptToContentBoundingBox(force) {
|
|
167
|
-
const bb = this._currentBoundingBox;
|
|
168
|
-
if (bb.isEmpty) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
// Keeps the camera from recomputing angles
|
|
172
|
-
const pre = [this.alpha, this.beta];
|
|
173
|
-
this.target = bb.center;
|
|
174
|
-
if (this.disableAutomaticSizing) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
[this.alpha, this.beta] = pre;
|
|
178
|
-
this._updateCameraLimits();
|
|
179
|
-
const minDistanceToFitModelInView = this._currentMinDistanceToFitModelInView;
|
|
180
|
-
const minDistanceToKeepCameraOutOfModel = this._currentMinDistanceToKeepCameraOutOfModel;
|
|
181
|
-
if (minDistanceToFitModelInView !== undefined) {
|
|
182
|
-
if (force || this.radius < minDistanceToFitModelInView) {
|
|
183
|
-
this.forceRadius(minDistanceToFitModelInView);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if (minDistanceToKeepCameraOutOfModel !== undefined &&
|
|
187
|
-
minDistanceToFitModelInView !== undefined) {
|
|
188
|
-
this.lowerRadiusLimit =
|
|
189
|
-
minDistanceToKeepCameraOutOfModel *
|
|
190
|
-
this._config.keepCameraFromGettingTooCloseFactor;
|
|
191
|
-
this.upperRadiusLimit = minDistanceToFitModelInView * 2;
|
|
192
|
-
this.wheelPrecision =
|
|
193
|
-
this._config.mouseWheelSpeedFactor / minDistanceToKeepCameraOutOfModel;
|
|
194
|
-
this.pinchPrecision = this._config.pinchZoomFactor / minDistanceToKeepCameraOutOfModel;
|
|
195
|
-
this.speed = minDistanceToKeepCameraOutOfModel * 0.1;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
refreshCameraNearFar() {
|
|
199
|
-
const minDistanceToKeepCameraOutOfModel = this._currentMinDistanceToKeepCameraOutOfModel;
|
|
200
|
-
if (minDistanceToKeepCameraOutOfModel === undefined) {
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const cameraDistance = this.radius;
|
|
204
|
-
const extraSpaceFactor = 1.5; // Because when zooming fast it seems the limits do not keep up
|
|
205
|
-
const graceDistance = minDistanceToKeepCameraOutOfModel * extraSpaceFactor;
|
|
206
|
-
this.minZ = cameraDistance - graceDistance;
|
|
207
|
-
this.maxZ = cameraDistance + graceDistance;
|
|
208
|
-
}
|
|
209
|
-
_applyNoSneakPeeking() {
|
|
210
|
-
//It might be impolite to look at a Cfg models underside
|
|
211
|
-
const noPeekLimit = this._calculateNoPeekingLimit();
|
|
212
|
-
if (noPeekLimit === undefined || !isFinite(noPeekLimit)) {
|
|
213
|
-
this.upperBetaLimit = MAX_UPPER_BETA_LIMIT;
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
this.upperBetaLimit = Math.min(MAX_UPPER_BETA_LIMIT, Math.PI / 2 - noPeekLimit);
|
|
217
|
-
}
|
|
218
|
-
_updateCameraLimits() {
|
|
219
|
-
const bb = this._currentBoundingBox;
|
|
220
|
-
const fovVertical = this.fov;
|
|
221
|
-
const aspect = this.getEngine().getScreenAspectRatio();
|
|
222
|
-
const bbAdjustedForCameraPosition = bb.clone().translate(this.target.negate());
|
|
223
|
-
const longestDistanceToCornerInXYZSpace = measureLongestDistanceToCorner(bbAdjustedForCameraPosition, [0, 1, 2]);
|
|
224
|
-
const longestDistanceToCornerInXZPlane = measureLongestDistanceToCorner(bbAdjustedForCameraPosition, [0, 2]);
|
|
225
|
-
const fovHorizontalRad = 2 * Math.atan(Math.tan(fovVertical / 2) * aspect);
|
|
226
|
-
const maxAllowedHeight = longestDistanceToCornerInXYZSpace * 2;
|
|
227
|
-
const maxAllowedWidth = longestDistanceToCornerInXZPlane * 2; //Because the model can not be tilted, only spun
|
|
228
|
-
const minDistanceToFitInViewFromWidth = maxAllowedWidth / (2 * Math.tan(fovHorizontalRad / 2));
|
|
229
|
-
const minDistanceToFitInViewFromHeight = maxAllowedHeight / (2 * Math.tan(fovVertical / 2));
|
|
230
|
-
const minDistanceToFitModelInView = Math.max(minDistanceToFitInViewFromWidth, minDistanceToFitInViewFromHeight);
|
|
231
|
-
this._currentMinDistanceToKeepCameraOutOfModel = isFinite(longestDistanceToCornerInXYZSpace)
|
|
232
|
-
? longestDistanceToCornerInXYZSpace
|
|
233
|
-
: undefined;
|
|
234
|
-
this._currentMinDistanceToFitModelInView = isFinite(minDistanceToFitModelInView)
|
|
235
|
-
? minDistanceToFitModelInView
|
|
236
|
-
: undefined;
|
|
237
|
-
}
|
|
238
|
-
_calculateNoPeekingLimit() {
|
|
239
|
-
const bb = this._currentBoundingBox;
|
|
240
|
-
if (bb.isEmpty || this.lowestAllowedCameraHeight === undefined) {
|
|
241
|
-
return undefined;
|
|
242
|
-
}
|
|
243
|
-
const bottomDepth = bb.minimum.y -
|
|
244
|
-
this.target.y +
|
|
245
|
-
(bb.maximum.y - bb.minimum.y) * this.lowestAllowedCameraHeight;
|
|
246
|
-
const cameraDistance = this.radius;
|
|
247
|
-
const lowestAngleUnderHorizonRad = Math.asin(bottomDepth / cameraDistance);
|
|
248
|
-
return lowestAngleUnderHorizonRad;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
1
|
+
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera.js";
|
|
2
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
3
|
+
import { degToRad, Observable } from "@configura/web-utilities";
|
|
4
|
+
import { CfgBoundingBox } from "../utilities/CfgBoundingBox.js";
|
|
5
|
+
import { boundingBoxesAreSignificantlyDifferent, measureLongestDistanceToCorner, } from "../utilities/utilities3D.js";
|
|
6
|
+
import { CfgArcRotateCameraPointersInput } from "./CfgArcRotateCameraPointersInput.js";
|
|
7
|
+
import { orbitalCameraControlPropsEquals, } from "./CfgOrbitalCameraControlProps.js";
|
|
8
|
+
const NEAREST_ALLOWED_TO_BETA_LIMITS = 0.1;
|
|
9
|
+
export const MAX_UPPER_BETA_LIMIT = Math.PI - NEAREST_ALLOWED_TO_BETA_LIMITS;
|
|
10
|
+
export const MIN_LOWER_BETA_LIMIT = NEAREST_ALLOWED_TO_BETA_LIMITS;
|
|
11
|
+
const defaultOrbitalCameraConfig = {
|
|
12
|
+
fov: degToRad(30),
|
|
13
|
+
mouseWheelSpeedFactor: 200,
|
|
14
|
+
pinchZoomFactor: 100,
|
|
15
|
+
inertia: 0.93,
|
|
16
|
+
keyboardSpeedFactor: 0.002,
|
|
17
|
+
pointerSpeedFactor: 2000,
|
|
18
|
+
keepCameraFromGettingTooCloseFactor: 1.5,
|
|
19
|
+
significantBoundingBoxSizeChangeShrinkFactor: 0.4,
|
|
20
|
+
significantBoundingBoxSizeChangeGrowFactor: 0.1,
|
|
21
|
+
};
|
|
22
|
+
// This is a workaround as you are not allowed to override fields with accessors.
|
|
23
|
+
// By adding this abstract field this becomes possible. This is a hack.
|
|
24
|
+
class WorkaroundCfgOrbitalCamera extends ArcRotateCamera {
|
|
25
|
+
}
|
|
26
|
+
export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
|
|
27
|
+
constructor(scene, _canvas, config) {
|
|
28
|
+
super("CfgOrbitalCamera", 0, degToRad(90), 50, new Vector3(0, 0, 0), scene);
|
|
29
|
+
this._canvas = _canvas;
|
|
30
|
+
this._currentBoundingBox = new CfgBoundingBox();
|
|
31
|
+
this._latestSignificantChangeBoundingBox = new CfgBoundingBox();
|
|
32
|
+
this._disableSubFloorCam = false;
|
|
33
|
+
this._lowestAllowedCameraHeight = undefined;
|
|
34
|
+
this.disableAutomaticSizing = false;
|
|
35
|
+
this.disableZoom = false;
|
|
36
|
+
this._externalControlHasHappened = false;
|
|
37
|
+
this._radius = 0;
|
|
38
|
+
this._boundNotifyCameraControlListeners = () => {
|
|
39
|
+
this._notifyCameraControlListeners();
|
|
40
|
+
};
|
|
41
|
+
this.attachControl(_canvas, // This parameters is not actually used for anything. But still required.
|
|
42
|
+
false, // No panning with keyboard
|
|
43
|
+
false // No panning with mouse
|
|
44
|
+
);
|
|
45
|
+
// Workaround for touch issues on iOS, see comments in CfgArcRotateCameraPointersInput.ts
|
|
46
|
+
this.inputs.removeByType("ArcRotateCameraPointersInput");
|
|
47
|
+
this.inputs.add(new CfgArcRotateCameraPointersInput());
|
|
48
|
+
// Make sure to disable all forms of "panning", which for the ArcRotateCamera is defined
|
|
49
|
+
// as movement sideways without rotation to keep the camera centered on the target.
|
|
50
|
+
// The settings above for attachControl will not disable two-finger touch.
|
|
51
|
+
this.panningAxis = Vector3.Zero();
|
|
52
|
+
this.panningDistanceLimit = 0;
|
|
53
|
+
this.panningSensibility = 0;
|
|
54
|
+
this.panningInertia = 0;
|
|
55
|
+
this._config = Object.assign(Object.assign({}, defaultOrbitalCameraConfig), config);
|
|
56
|
+
const keyboardInput = this.inputs.attached["keyboard"];
|
|
57
|
+
keyboardInput.angularSpeed = this._config.keyboardSpeedFactor;
|
|
58
|
+
this.fov = this._config.fov;
|
|
59
|
+
this.inertia = this._config.inertia;
|
|
60
|
+
this.angularSensibilityX = this.angularSensibilityY = this._config.pointerSpeedFactor;
|
|
61
|
+
this.onViewMatrixChangedObservable.add(this._boundNotifyCameraControlListeners);
|
|
62
|
+
}
|
|
63
|
+
dispose() {
|
|
64
|
+
this.detachControl(this._canvas);
|
|
65
|
+
this.onViewMatrixChangedObservable.removeCallback(this._boundNotifyCameraControlListeners);
|
|
66
|
+
super.dispose();
|
|
67
|
+
}
|
|
68
|
+
set disableSubFloorCam(v) {
|
|
69
|
+
this._disableSubFloorCam = v;
|
|
70
|
+
}
|
|
71
|
+
set lowestAllowedCameraHeight(v) {
|
|
72
|
+
this._lowestAllowedCameraHeight = v;
|
|
73
|
+
}
|
|
74
|
+
get lowestAllowedCameraHeight() {
|
|
75
|
+
if (this._lowestAllowedCameraHeight !== undefined) {
|
|
76
|
+
if (this._disableSubFloorCam) {
|
|
77
|
+
return Math.max(0, this._lowestAllowedCameraHeight);
|
|
78
|
+
}
|
|
79
|
+
return this._lowestAllowedCameraHeight;
|
|
80
|
+
}
|
|
81
|
+
if (this._disableSubFloorCam) {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
forceRadius(r) {
|
|
87
|
+
this._radius = r;
|
|
88
|
+
}
|
|
89
|
+
set radius(r) {
|
|
90
|
+
if (this.disableZoom) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
this._radius = r;
|
|
94
|
+
}
|
|
95
|
+
get radius() {
|
|
96
|
+
return this._radius;
|
|
97
|
+
}
|
|
98
|
+
get _orbitalCameraControlProps() {
|
|
99
|
+
return {
|
|
100
|
+
distance: this.radius,
|
|
101
|
+
yaw: this.alpha,
|
|
102
|
+
pitch: this.beta,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
frameRenderNeeded() {
|
|
106
|
+
const externalControlHasHappened = this._externalControlHasHappened;
|
|
107
|
+
if (externalControlHasHappened) {
|
|
108
|
+
this._externalControlHasHappened = false;
|
|
109
|
+
}
|
|
110
|
+
return (this.useAutoRotationBehavior ||
|
|
111
|
+
externalControlHasHappened ||
|
|
112
|
+
this.inertialAlphaOffset !== 0 ||
|
|
113
|
+
this.inertialBetaOffset !== 0 ||
|
|
114
|
+
this.inertialPanningX !== 0 ||
|
|
115
|
+
this.inertialPanningY !== 0 ||
|
|
116
|
+
this.inertialRadiusOffset !== 0);
|
|
117
|
+
}
|
|
118
|
+
_notifyCameraControlListeners() {
|
|
119
|
+
if (this._orbitalCameraControlObservable === undefined) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const orbitalCameraControlProps = this._orbitalCameraControlProps;
|
|
123
|
+
if (this._previousOrbitalCameraControlProps !== undefined &&
|
|
124
|
+
orbitalCameraControlPropsEquals(this._previousOrbitalCameraControlProps, orbitalCameraControlProps)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
this._orbitalCameraControlObservable.notifyAll(orbitalCameraControlProps, this._orbitalCameraControlObservable);
|
|
128
|
+
this._previousOrbitalCameraControlProps = orbitalCameraControlProps;
|
|
129
|
+
}
|
|
130
|
+
get cameraControlObservable() {
|
|
131
|
+
if (this._orbitalCameraControlObservable === undefined) {
|
|
132
|
+
this._orbitalCameraControlObservable = new Observable();
|
|
133
|
+
this._orbitalCameraControlObservable.listen((c) => {
|
|
134
|
+
const { distance, yaw, pitch } = c;
|
|
135
|
+
let change = false;
|
|
136
|
+
if (distance !== undefined && distance !== this.radius) {
|
|
137
|
+
this.forceRadius(distance);
|
|
138
|
+
change = true;
|
|
139
|
+
}
|
|
140
|
+
if (yaw !== undefined && yaw !== this.alpha) {
|
|
141
|
+
this.alpha = yaw;
|
|
142
|
+
change = true;
|
|
143
|
+
}
|
|
144
|
+
if (pitch !== undefined && pitch !== this.beta) {
|
|
145
|
+
this.beta = pitch;
|
|
146
|
+
change = true;
|
|
147
|
+
}
|
|
148
|
+
if (change) {
|
|
149
|
+
this._externalControlHasHappened = true;
|
|
150
|
+
this._notifyCameraControlListeners();
|
|
151
|
+
}
|
|
152
|
+
}, this._orbitalCameraControlObservable);
|
|
153
|
+
}
|
|
154
|
+
return this._orbitalCameraControlObservable;
|
|
155
|
+
}
|
|
156
|
+
setContentBoundingBox(newBoundingBox, force) {
|
|
157
|
+
this._currentBoundingBox = newBoundingBox;
|
|
158
|
+
const significantChange = boundingBoxesAreSignificantlyDifferent(this._latestSignificantChangeBoundingBox, newBoundingBox, this._config.significantBoundingBoxSizeChangeShrinkFactor, this._config.significantBoundingBoxSizeChangeGrowFactor);
|
|
159
|
+
if (!significantChange && !force) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this._latestSignificantChangeBoundingBox = newBoundingBox;
|
|
163
|
+
this._applyAdaptToContentBoundingBox(force);
|
|
164
|
+
this._applyNoSneakPeeking();
|
|
165
|
+
}
|
|
166
|
+
_applyAdaptToContentBoundingBox(force) {
|
|
167
|
+
const bb = this._currentBoundingBox;
|
|
168
|
+
if (bb.isEmpty) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
// Keeps the camera from recomputing angles
|
|
172
|
+
const pre = [this.alpha, this.beta];
|
|
173
|
+
this.target = bb.center;
|
|
174
|
+
if (this.disableAutomaticSizing) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
[this.alpha, this.beta] = pre;
|
|
178
|
+
this._updateCameraLimits();
|
|
179
|
+
const minDistanceToFitModelInView = this._currentMinDistanceToFitModelInView;
|
|
180
|
+
const minDistanceToKeepCameraOutOfModel = this._currentMinDistanceToKeepCameraOutOfModel;
|
|
181
|
+
if (minDistanceToFitModelInView !== undefined) {
|
|
182
|
+
if (force || this.radius < minDistanceToFitModelInView) {
|
|
183
|
+
this.forceRadius(minDistanceToFitModelInView);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
if (minDistanceToKeepCameraOutOfModel !== undefined &&
|
|
187
|
+
minDistanceToFitModelInView !== undefined) {
|
|
188
|
+
this.lowerRadiusLimit =
|
|
189
|
+
minDistanceToKeepCameraOutOfModel *
|
|
190
|
+
this._config.keepCameraFromGettingTooCloseFactor;
|
|
191
|
+
this.upperRadiusLimit = minDistanceToFitModelInView * 2;
|
|
192
|
+
this.wheelPrecision =
|
|
193
|
+
this._config.mouseWheelSpeedFactor / minDistanceToKeepCameraOutOfModel;
|
|
194
|
+
this.pinchPrecision = this._config.pinchZoomFactor / minDistanceToKeepCameraOutOfModel;
|
|
195
|
+
this.speed = minDistanceToKeepCameraOutOfModel * 0.1;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
refreshCameraNearFar() {
|
|
199
|
+
const minDistanceToKeepCameraOutOfModel = this._currentMinDistanceToKeepCameraOutOfModel;
|
|
200
|
+
if (minDistanceToKeepCameraOutOfModel === undefined) {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const cameraDistance = this.radius;
|
|
204
|
+
const extraSpaceFactor = 1.5; // Because when zooming fast it seems the limits do not keep up
|
|
205
|
+
const graceDistance = minDistanceToKeepCameraOutOfModel * extraSpaceFactor;
|
|
206
|
+
this.minZ = cameraDistance - graceDistance;
|
|
207
|
+
this.maxZ = cameraDistance + graceDistance;
|
|
208
|
+
}
|
|
209
|
+
_applyNoSneakPeeking() {
|
|
210
|
+
//It might be impolite to look at a Cfg models underside
|
|
211
|
+
const noPeekLimit = this._calculateNoPeekingLimit();
|
|
212
|
+
if (noPeekLimit === undefined || !isFinite(noPeekLimit)) {
|
|
213
|
+
this.upperBetaLimit = MAX_UPPER_BETA_LIMIT;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.upperBetaLimit = Math.min(MAX_UPPER_BETA_LIMIT, Math.PI / 2 - noPeekLimit);
|
|
217
|
+
}
|
|
218
|
+
_updateCameraLimits() {
|
|
219
|
+
const bb = this._currentBoundingBox;
|
|
220
|
+
const fovVertical = this.fov;
|
|
221
|
+
const aspect = this.getEngine().getScreenAspectRatio();
|
|
222
|
+
const bbAdjustedForCameraPosition = bb.clone().translate(this.target.negate());
|
|
223
|
+
const longestDistanceToCornerInXYZSpace = measureLongestDistanceToCorner(bbAdjustedForCameraPosition, [0, 1, 2]);
|
|
224
|
+
const longestDistanceToCornerInXZPlane = measureLongestDistanceToCorner(bbAdjustedForCameraPosition, [0, 2]);
|
|
225
|
+
const fovHorizontalRad = 2 * Math.atan(Math.tan(fovVertical / 2) * aspect);
|
|
226
|
+
const maxAllowedHeight = longestDistanceToCornerInXYZSpace * 2;
|
|
227
|
+
const maxAllowedWidth = longestDistanceToCornerInXZPlane * 2; //Because the model can not be tilted, only spun
|
|
228
|
+
const minDistanceToFitInViewFromWidth = maxAllowedWidth / (2 * Math.tan(fovHorizontalRad / 2));
|
|
229
|
+
const minDistanceToFitInViewFromHeight = maxAllowedHeight / (2 * Math.tan(fovVertical / 2));
|
|
230
|
+
const minDistanceToFitModelInView = Math.max(minDistanceToFitInViewFromWidth, minDistanceToFitInViewFromHeight);
|
|
231
|
+
this._currentMinDistanceToKeepCameraOutOfModel = isFinite(longestDistanceToCornerInXYZSpace)
|
|
232
|
+
? longestDistanceToCornerInXYZSpace
|
|
233
|
+
: undefined;
|
|
234
|
+
this._currentMinDistanceToFitModelInView = isFinite(minDistanceToFitModelInView)
|
|
235
|
+
? minDistanceToFitModelInView
|
|
236
|
+
: undefined;
|
|
237
|
+
}
|
|
238
|
+
_calculateNoPeekingLimit() {
|
|
239
|
+
const bb = this._currentBoundingBox;
|
|
240
|
+
if (bb.isEmpty || this.lowestAllowedCameraHeight === undefined) {
|
|
241
|
+
return undefined;
|
|
242
|
+
}
|
|
243
|
+
const bottomDepth = bb.minimum.y -
|
|
244
|
+
this.target.y +
|
|
245
|
+
(bb.maximum.y - bb.minimum.y) * this.lowestAllowedCameraHeight;
|
|
246
|
+
const cameraDistance = this.radius;
|
|
247
|
+
const lowestAngleUnderHorizonRad = Math.asin(bottomDepth / cameraDistance);
|
|
248
|
+
return lowestAngleUnderHorizonRad;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export interface CfgOrbitalCameraControlProps {
|
|
2
|
-
distance?: number;
|
|
3
|
-
yaw?: number;
|
|
4
|
-
pitch?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function orbitalCameraControlPropsEquals(left: CfgOrbitalCameraControlProps, right: CfgOrbitalCameraControlProps): boolean;
|
|
1
|
+
export interface CfgOrbitalCameraControlProps {
|
|
2
|
+
distance?: number;
|
|
3
|
+
yaw?: number;
|
|
4
|
+
pitch?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function orbitalCameraControlPropsEquals(left: CfgOrbitalCameraControlProps, right: CfgOrbitalCameraControlProps): boolean;
|
|
7
7
|
//# sourceMappingURL=CfgOrbitalCameraControlProps.d.ts.map
|