@configura/babylon-view 1.2.1-alpha.0 → 1.3.0-alpha.2

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.
@@ -41,7 +41,11 @@ export declare class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
41
41
  private _currentMinDistanceToFitModelInView;
42
42
  private _orbitalCameraControlObservable;
43
43
  private _previousOrbitalCameraControlProps;
44
- disableSubFloorCam: boolean;
44
+ _disableSubFloorCam: boolean;
45
+ set disableSubFloorCam(v: boolean);
46
+ _lowestAllowedCameraHeight: number | undefined;
47
+ set lowestAllowedCameraHeight(v: number | undefined);
48
+ get lowestAllowedCameraHeight(): number | undefined;
45
49
  disableAutomaticSizing: boolean;
46
50
  disableZoom: boolean;
47
51
  private _externalControlHasHappened;
@@ -29,7 +29,8 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
29
29
  this._canvas = _canvas;
30
30
  this._currentBoundingBox = new CfgBoundingBox();
31
31
  this._latestSignificantChangeBoundingBox = new CfgBoundingBox();
32
- this.disableSubFloorCam = false;
32
+ this._disableSubFloorCam = false;
33
+ this._lowestAllowedCameraHeight = undefined;
33
34
  this.disableAutomaticSizing = false;
34
35
  this.disableZoom = false;
35
36
  this._externalControlHasHappened = false;
@@ -64,6 +65,24 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
64
65
  this.onViewMatrixChangedObservable.removeCallback(this._boundNotifyCameraControlListeners);
65
66
  super.dispose();
66
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
+ }
67
86
  forceRadius(r) {
68
87
  this._radius = r;
69
88
  }
@@ -188,10 +207,6 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
188
207
  this.maxZ = cameraDistance + graceDistance;
189
208
  }
190
209
  _applyNoSneakPeeking() {
191
- if (!this.disableSubFloorCam) {
192
- this.upperBetaLimit = MAX_UPPER_BETA_LIMIT;
193
- return;
194
- }
195
210
  //It might be impolite to look at a Cfg models underside
196
211
  const noPeekLimit = this._calculateNoPeekingLimit();
197
212
  if (noPeekLimit === undefined || !isFinite(noPeekLimit)) {
@@ -222,10 +237,12 @@ export class CfgOrbitalCamera extends WorkaroundCfgOrbitalCamera {
222
237
  }
223
238
  _calculateNoPeekingLimit() {
224
239
  const bb = this._currentBoundingBox;
225
- if (bb.isEmpty) {
240
+ if (bb.isEmpty || this.lowestAllowedCameraHeight === undefined) {
226
241
  return undefined;
227
242
  }
228
- const bottomDepth = bb.minimum.y - this.target.y;
243
+ const bottomDepth = bb.minimum.y -
244
+ this.target.y +
245
+ (bb.maximum.y - bb.minimum.y) * this.lowestAllowedCameraHeight;
229
246
  const cameraDistance = this.radius;
230
247
  const lowestAngleUnderHorizonRad = Math.asin(bottomDepth / cameraDistance);
231
248
  return lowestAngleUnderHorizonRad;
@@ -4,7 +4,7 @@ export function getDefaultEngine(canvas, width, height) {
4
4
  // see WEB-8493 for additional details. It should be safe to apply to all browsers.
5
5
  //
6
6
  // TODO: Remove this workaround when upgrading to Babylon.js 5.0
7
- const engine = new Engine(canvas, true, { xrCompatible: false }, true);
7
+ const engine = new Engine(canvas, true, { xrCompatible: false, preserveDrawingBuffer: true }, true);
8
8
  engine.setSize(Math.floor(width), Math.floor(height));
9
9
  return engine;
10
10
  }
@@ -40,6 +40,7 @@ export class SingleProductDefaultCameraView extends SingleProductView {
40
40
  this._camera.disableAutomaticSizing = cameraConf.disableAutomaticSizing === true;
41
41
  this._camera.disableZoom = cameraConf.disableZoom === true;
42
42
  this._camera.disableSubFloorCam = cameraConf.disableSubFloorCam === true;
43
+ this._camera.lowestAllowedCameraHeight = cameraConf.lowestAllowedCameraHeight;
43
44
  this._cameraConf = cameraConf;
44
45
  this.resetCamera();
45
46
  const { autoRotate } = cameraConf;
@@ -5,6 +5,7 @@ import { SingleProductViewConfiguration, SingleProductViewEventMap } from "./Sin
5
5
  * @param disableZoom Don't let the camera dolly in and out. Zoom is stricly speaking not correct, we only dolly the camera.
6
6
  * @param disableAutomaticSizing Turn off automatic adaption of camera distance and light rig size.
7
7
  * @param disableSubFloorCam It is common that catalogue models are designed to never be shown from below. This limits camera polar angle.
8
+ * @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.
8
9
  * @param distance Only works if disableAutomaticSizing is set
9
10
  * @param yaw Horisontal angle for the camera. Range -π/2 to π/2 radians.
10
11
  * @param pitch Vertical angle for the camera. Range 0 to π/2 radians, measured from the north pole.
@@ -20,6 +21,7 @@ export interface SingleProductDefaultCameraViewConfiguration extends SingleProdu
20
21
  disableZoom?: boolean;
21
22
  disableAutomaticSizing?: boolean;
22
23
  disableSubFloorCam?: boolean;
24
+ lowestAllowedCameraHeight?: number;
23
25
  autoRotate?: {
24
26
  idleRotationSpeed?: number;
25
27
  idleRotationSpinupTime?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@configura/babylon-view",
3
- "version": "1.2.1-alpha.0",
3
+ "version": "1.3.0-alpha.2",
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": "^1.2.1-alpha.0",
20
- "@configura/web-utilities": "^1.2.1-alpha.0"
19
+ "@configura/web-core": "^1.3.0-alpha.2",
20
+ "@configura/web-utilities": "^1.3.0-alpha.2"
21
21
  },
22
22
  "devDependencies": {
23
- "@configura/web-api": "^1.2.1-alpha.0",
23
+ "@configura/web-api": "^1.3.0-alpha.2",
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": "7bdeec1bf6ce76bb1efb6e57138810fa430bd733"
30
+ "gitHead": "ecc00b624310c03a59c0ac5933e06df92326436d"
31
31
  }