@configura/babylon-view 1.4.0 → 1.6.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.
Files changed (125) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +1 -1
  3. package/dist/animation/AnimatableObject.d.ts +8 -8
  4. package/dist/animation/AnimatableObject.js +3 -3
  5. package/dist/animation/animator/Animator.d.ts +33 -33
  6. package/dist/animation/animator/Animator.js +58 -58
  7. package/dist/animation/animator/AnimatorEasing.d.ts +16 -16
  8. package/dist/animation/animator/AnimatorEasing.js +31 -31
  9. package/dist/animation/animator/AnimatorEasingMatrix.d.ts +14 -14
  10. package/dist/animation/animator/AnimatorEasingMatrix.js +16 -16
  11. package/dist/animation/animator/AnimatorHighlight.d.ts +16 -16
  12. package/dist/animation/animator/AnimatorHighlight.js +32 -32
  13. package/dist/animation/animator/AnimatorPointToPoint.d.ts +8 -8
  14. package/dist/animation/animator/AnimatorPointToPoint.js +14 -14
  15. package/dist/animation/animator/AnimatorQueue.d.ts +13 -13
  16. package/dist/animation/animator/AnimatorQueue.js +57 -57
  17. package/dist/animation/animator/AnimatorScale.d.ts +8 -8
  18. package/dist/animation/animator/AnimatorScale.js +13 -13
  19. package/dist/animation/animator/AnimatorSpin.d.ts +10 -10
  20. package/dist/animation/animator/AnimatorSpin.js +13 -13
  21. package/dist/animation/animator/EasingFunctions.d.ts +35 -35
  22. package/dist/animation/animator/EasingFunctions.js +137 -137
  23. package/dist/animation/coordinator/Coordinator.d.ts +28 -28
  24. package/dist/animation/coordinator/Coordinator.js +47 -47
  25. package/dist/animation/coordinator/CoordinatorDropAndSpin.d.ts +22 -22
  26. package/dist/animation/coordinator/CoordinatorDropAndSpin.js +133 -133
  27. package/dist/animation/coordinator/CoordinatorIdentity.d.ts +11 -11
  28. package/dist/animation/coordinator/CoordinatorIdentity.js +12 -12
  29. package/dist/animation/coordinator/CoordinatorNodeQueues.d.ts +18 -18
  30. package/dist/animation/coordinator/CoordinatorNodeQueues.js +50 -50
  31. package/dist/animation/coordinator/CoordinatorPulse.d.ts +21 -21
  32. package/dist/animation/coordinator/CoordinatorPulse.js +47 -47
  33. package/dist/animation/coordinator/CoordinatorPulseBounce.d.ts +14 -14
  34. package/dist/animation/coordinator/CoordinatorPulseBounce.js +40 -40
  35. package/dist/animation/coordinator/CoordinatorPulseHighlight.d.ts +13 -13
  36. package/dist/animation/coordinator/CoordinatorPulseHighlight.js +34 -34
  37. package/dist/animation/coordinator/CoordinatorPulseInflate.d.ts +14 -14
  38. package/dist/animation/coordinator/CoordinatorPulseInflate.js +30 -30
  39. package/dist/camera/CameraCreator.d.ts +5 -5
  40. package/dist/camera/CameraCreator.js +4 -4
  41. package/dist/camera/CfgArcRotateCameraPointersInput.d.ts +26 -26
  42. package/dist/camera/CfgArcRotateCameraPointersInput.js +264 -264
  43. package/dist/camera/CfgOrbitalCamera.d.ts +68 -68
  44. package/dist/camera/CfgOrbitalCamera.js +250 -250
  45. package/dist/camera/CfgOrbitalCameraControlProps.d.ts +6 -6
  46. package/dist/camera/CfgOrbitalCameraControlProps.js +3 -3
  47. package/dist/camera/GradingApplier.d.ts +3 -3
  48. package/dist/camera/GradingApplier.js +48 -48
  49. package/dist/engine/EngineCreator.d.ts +3 -3
  50. package/dist/engine/EngineCreator.js +10 -10
  51. package/dist/geometry/CfgGeometry.d.ts +29 -29
  52. package/dist/geometry/CfgGeometry.js +146 -146
  53. package/dist/geometry/CfgMesh.d.ts +10 -10
  54. package/dist/geometry/CfgMesh.js +38 -38
  55. package/dist/geometry/geoSplitter.d.ts +8 -8
  56. package/dist/geometry/geoSplitter.js +192 -192
  57. package/dist/geometry/stretch/CfgMorphTarget.d.ts +15 -15
  58. package/dist/geometry/stretch/CfgMorphTarget.js +65 -65
  59. package/dist/geometry/stretch/CfgStretchData.d.ts +116 -114
  60. package/dist/geometry/stretch/CfgStretchData.js +346 -340
  61. package/dist/geometry/stretch/CfgStretchMorphGeometry.d.ts +16 -16
  62. package/dist/geometry/stretch/CfgStretchMorphGeometry.js +95 -95
  63. package/dist/index.d.ts +13 -13
  64. package/dist/index.js +13 -13
  65. package/dist/light/CfgDirectionalLight.d.ts +8 -8
  66. package/dist/light/CfgDirectionalLight.js +18 -18
  67. package/dist/light/CfgHemisphericLight.d.ts +7 -7
  68. package/dist/light/CfgHemisphericLight.js +17 -17
  69. package/dist/light/CfgPointLight.d.ts +8 -8
  70. package/dist/light/CfgPointLight.js +18 -18
  71. package/dist/light/DefaultLightRig.d.ts +19 -19
  72. package/dist/light/DefaultLightRig.js +77 -77
  73. package/dist/light/LightRigCreator.d.ts +9 -9
  74. package/dist/light/LightRigCreator.js +3 -3
  75. package/dist/material/CfgMaterial.d.ts +68 -68
  76. package/dist/material/CfgMaterial.js +482 -482
  77. package/dist/material/DummyMaterialCreator.d.ts +4 -4
  78. package/dist/material/DummyMaterialCreator.js +15 -15
  79. package/dist/material/material.d.ts +18 -18
  80. package/dist/material/material.js +128 -128
  81. package/dist/material/texture.d.ts +14 -14
  82. package/dist/material/texture.js +306 -306
  83. package/dist/nodes/CfgContentRootNode.d.ts +19 -19
  84. package/dist/nodes/CfgContentRootNode.js +75 -75
  85. package/dist/nodes/CfgDeferredMeshNode.d.ts +55 -55
  86. package/dist/nodes/CfgDeferredMeshNode.js +377 -377
  87. package/dist/nodes/CfgProductNode.d.ts +126 -126
  88. package/dist/nodes/CfgProductNode.js +579 -578
  89. package/dist/nodes/CfgSymNode.d.ts +50 -50
  90. package/dist/nodes/CfgSymNode.js +249 -249
  91. package/dist/nodes/CfgSymRootNode.d.ts +45 -45
  92. package/dist/nodes/CfgSymRootNode.js +220 -220
  93. package/dist/nodes/CfgTransformNode.d.ts +33 -33
  94. package/dist/nodes/CfgTransformNode.js +83 -83
  95. package/dist/scene/SceneCreator.d.ts +6 -6
  96. package/dist/scene/SceneCreator.js +22 -22
  97. package/dist/utilities/CfgBoundingBox.d.ts +21 -21
  98. package/dist/utilities/CfgBoundingBox.js +81 -81
  99. package/dist/utilities/anchor/anchor.d.ts +55 -51
  100. package/dist/utilities/anchor/anchor.js +140 -136
  101. package/dist/utilities/anchor/anchorMap.d.ts +20 -20
  102. package/dist/utilities/anchor/anchorMap.js +111 -111
  103. package/dist/utilities/utilities3D.d.ts +70 -70
  104. package/dist/utilities/utilities3D.js +265 -265
  105. package/dist/utilities/utilitiesColor.d.ts +18 -18
  106. package/dist/utilities/utilitiesColor.js +48 -48
  107. package/dist/utilities/utilitiesImage.d.ts +6 -6
  108. package/dist/utilities/utilitiesImage.js +107 -107
  109. package/dist/utilities/utilitiesSymRootIdentifier.d.ts +7 -7
  110. package/dist/utilities/utilitiesSymRootIdentifier.js +26 -26
  111. package/dist/view/BaseView.d.ts +78 -78
  112. package/dist/view/BaseView.js +297 -297
  113. package/dist/view/BaseViewConfiguration.d.ts +32 -32
  114. package/dist/view/BaseViewConfiguration.js +10 -8
  115. package/dist/view/RenderEnv.d.ts +43 -43
  116. package/dist/view/RenderEnv.js +7 -7
  117. package/dist/view/SingleProductDefaultCameraView.d.ts +33 -33
  118. package/dist/view/SingleProductDefaultCameraView.js +141 -141
  119. package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +46 -46
  120. package/dist/view/SingleProductDefaultCameraViewConfiguration.js +11 -11
  121. package/dist/view/SingleProductView.d.ts +42 -42
  122. package/dist/view/SingleProductView.js +206 -206
  123. package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
  124. package/dist/view/SingleProductViewConfiguration.js +19 -19
  125. package/package.json +5 -5
@@ -1,8 +1,10 @@
1
- import { vector3Equals } from "../utilities/utilities3D.js";
2
- export { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
3
- export function cameraConfigurationPropsEquals(left, right) {
4
- return (left.nearClipping === right.nearClipping &&
5
- left.farClipping === right.farClipping &&
6
- vector3Equals(left.position, right.position) &&
7
- left.fov === right.fov);
8
- }
1
+ import { vector3Equals } from "../utilities/utilities3D.js";
2
+ export { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
3
+ export function cameraConfigurationPropsEquals(left, right) {
4
+ return (left.nearClipping === right.nearClipping &&
5
+ left.farClipping === right.farClipping &&
6
+ vector3Equals(left.position, right.position) &&
7
+ vector3Equals(left.contentPosition, right.contentPosition) &&
8
+ left.fov === right.fov &&
9
+ left.aspect === right.aspect);
10
+ }
@@ -1,44 +1,44 @@
1
- import { AssetsManager } from "@babylonjs/core/Misc/assetsManager.js";
2
- import { Scene } from "@babylonjs/core/scene.js";
3
- import { GMaterial3D } from "@configura/web-core/dist/cm/core3D/GMaterial3D.js";
4
- import { SymComponent } from "@configura/web-core/dist/cm/format/cmsym/components/SymComponent.js";
5
- import { SymGetMeshEnv } from "@configura/web-core/dist/cm/format/cmsym/components/SymGetMeshEnv.js";
6
- import { SymNode } from "@configura/web-core/dist/cm/format/cmsym/SymNode.js";
7
- import { DexManager } from "@configura/web-core/dist/cm/format/dex/DexManager.js";
8
- import { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
9
- import { PromiseCache } from "@configura/web-utilities";
10
- import { CfgGeometry } from "../geometry/CfgGeometry.js";
11
- import { LightRig } from "../light/LightRigCreator.js";
12
- import { CfgMaterial } from "../material/CfgMaterial.js";
13
- import { MaterialWithMetaData } from "../material/material.js";
14
- import { TextureImageWithMetaData } from "../material/texture.js";
15
- import { ScheduleRerender } from "./BaseViewConfiguration.js";
16
- export declare type GeometryCacheIdentifierObject = {
17
- component: SymComponent;
18
- stretchDatasHash: number;
19
- uvMapperHash: number | undefined;
20
- };
21
- export interface RenderEnv {
22
- scene: Scene;
23
- assetsManager: AssetsManager;
24
- dummyMaterial: CfgMaterial;
25
- geometryCache: PromiseCache<GeometryCacheIdentifierObject, GeometryCacheEntry | undefined>;
26
- symNodeCache: PromiseCache<string, SymNode>;
27
- materialCache: PromiseCache<string | GMaterial3D, MaterialWithMetaData>;
28
- textureImageCache: PromiseCache<string, TextureImageWithMetaData>;
29
- derivedNormalMapCache: PromiseCache<string, HTMLImageElement | undefined>;
30
- lightRig: LightRig;
31
- scheduleRerender: ScheduleRerender;
32
- notifyError: (e: any) => void;
33
- symMeshEnv: SymGetMeshEnv;
34
- dexManager: DexManager;
35
- cullEmptyNodes: boolean;
36
- allowedDetailLevels: DetailLevel | DetailLevel[];
37
- }
38
- export declare class GeometryCacheEntry {
39
- readonly geometry: CfgGeometry;
40
- readonly doubleSided: boolean | undefined;
41
- readonly lowerLeftTextureOrigin: boolean | undefined;
42
- constructor(geometry: CfgGeometry, doubleSided: boolean | undefined, lowerLeftTextureOrigin: boolean | undefined);
43
- }
1
+ import { AssetsManager } from "@babylonjs/core/Misc/assetsManager.js";
2
+ import { Scene } from "@babylonjs/core/scene.js";
3
+ import { GMaterial3D } from "@configura/web-core/dist/cm/core3D/GMaterial3D.js";
4
+ import { SymComponent } from "@configura/web-core/dist/cm/format/cmsym/components/SymComponent.js";
5
+ import { SymGetMeshEnv } from "@configura/web-core/dist/cm/format/cmsym/components/SymGetMeshEnv.js";
6
+ import { SymNode } from "@configura/web-core/dist/cm/format/cmsym/SymNode.js";
7
+ import { DexManager } from "@configura/web-core/dist/cm/format/dex/DexManager.js";
8
+ import { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
9
+ import { PromiseCache } from "@configura/web-utilities";
10
+ import { CfgGeometry } from "../geometry/CfgGeometry.js";
11
+ import { LightRig } from "../light/LightRigCreator.js";
12
+ import { CfgMaterial } from "../material/CfgMaterial.js";
13
+ import { MaterialWithMetaData } from "../material/material.js";
14
+ import { TextureImageWithMetaData } from "../material/texture.js";
15
+ import { ScheduleRerender } from "./BaseViewConfiguration.js";
16
+ export declare type GeometryCacheIdentifierObject = {
17
+ component: SymComponent;
18
+ stretchDatasHash: number;
19
+ uvMapperHash: number | undefined;
20
+ };
21
+ export interface RenderEnv {
22
+ scene: Scene;
23
+ assetsManager: AssetsManager;
24
+ dummyMaterial: CfgMaterial;
25
+ geometryCache: PromiseCache<GeometryCacheIdentifierObject, GeometryCacheEntry | undefined>;
26
+ symNodeCache: PromiseCache<string, SymNode>;
27
+ materialCache: PromiseCache<string | GMaterial3D, MaterialWithMetaData>;
28
+ textureImageCache: PromiseCache<string, TextureImageWithMetaData>;
29
+ derivedNormalMapCache: PromiseCache<string, HTMLImageElement | undefined>;
30
+ lightRig: LightRig;
31
+ scheduleRerender: ScheduleRerender;
32
+ notifyError: (e: unknown) => void;
33
+ symMeshEnv: SymGetMeshEnv;
34
+ dexManager: DexManager;
35
+ cullEmptyNodes: boolean;
36
+ allowedDetailLevels: DetailLevel | DetailLevel[];
37
+ }
38
+ export declare class GeometryCacheEntry {
39
+ readonly geometry: CfgGeometry;
40
+ readonly doubleSided: boolean | undefined;
41
+ readonly lowerLeftTextureOrigin: boolean | undefined;
42
+ constructor(geometry: CfgGeometry, doubleSided: boolean | undefined, lowerLeftTextureOrigin: boolean | undefined);
43
+ }
44
44
  //# sourceMappingURL=RenderEnv.d.ts.map
@@ -1,7 +1,7 @@
1
- export class GeometryCacheEntry {
2
- constructor(geometry, doubleSided, lowerLeftTextureOrigin) {
3
- this.geometry = geometry;
4
- this.doubleSided = doubleSided;
5
- this.lowerLeftTextureOrigin = lowerLeftTextureOrigin;
6
- }
7
- }
1
+ export class GeometryCacheEntry {
2
+ constructor(geometry, doubleSided, lowerLeftTextureOrigin) {
3
+ this.geometry = geometry;
4
+ this.doubleSided = doubleSided;
5
+ this.lowerLeftTextureOrigin = lowerLeftTextureOrigin;
6
+ }
7
+ }
@@ -1,34 +1,34 @@
1
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
- import { EventListener, Observable } from "@configura/web-utilities";
3
- import { CfgOrbitalCamera } from "../camera/CfgOrbitalCamera.js";
4
- import { EngineCreator } from "../engine/EngineCreator.js";
5
- import { LightRigCreator } from "../light/LightRigCreator.js";
6
- import { DummyMaterialCreator } from "../material/DummyMaterialCreator.js";
7
- import { SceneCreator } from "../scene/SceneCreator.js";
8
- import { OrbitalCameraConfigurationProps, SingleProductDefaultCameraViewConfiguration, SingleProductDefaultCameraViewEventMap } from "./SingleProductDefaultCameraViewConfiguration.js";
9
- import { SingleProductView } from "./SingleProductView.js";
10
- export declare type SingleProductDefaultCameraViewConstructorOptions = {
11
- canvas: HTMLCanvasElement;
12
- engineCreator?: EngineCreator;
13
- lightRigCreator?: LightRigCreator;
14
- sceneCreator?: SceneCreator;
15
- dummyMaterialCreator?: DummyMaterialCreator;
16
- };
17
- export declare class SingleProductDefaultCameraView<T extends SingleProductDefaultCameraViewEventMap = SingleProductDefaultCameraViewEventMap> extends SingleProductView<CfgOrbitalCamera, T> {
18
- private _orbitalCameraConfigurationObservable;
19
- private _previousOrbitalCameraConf;
20
- constructor(options: SingleProductDefaultCameraViewConstructorOptions);
21
- private _cameraConf;
22
- resetCamera(): void;
23
- setConfiguration(configuration: SingleProductDefaultCameraViewConfiguration): void;
24
- addEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
25
- removeEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
26
- get orbitalCameraConfiguration(): OrbitalCameraConfigurationProps;
27
- protected notifyCameraListeners(): void;
28
- get cameraControlObservable(): Observable<import("../index.js").CfgOrbitalCameraControlProps>;
29
- protected get contentCenter(): Vector3;
30
- protected handleSizing(force: boolean): false | undefined;
31
- protected refreshCameraNearFar(): void;
32
- protected getNeededFrameRender(time: number): boolean;
33
- }
1
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
+ import { EventListener, Observable } from "@configura/web-utilities";
3
+ import { CfgOrbitalCamera } from "../camera/CfgOrbitalCamera.js";
4
+ import { EngineCreator } from "../engine/EngineCreator.js";
5
+ import { LightRigCreator } from "../light/LightRigCreator.js";
6
+ import { DummyMaterialCreator } from "../material/DummyMaterialCreator.js";
7
+ import { SceneCreator } from "../scene/SceneCreator.js";
8
+ import { OrbitalCameraConfigurationProps, SingleProductDefaultCameraViewConfiguration, SingleProductDefaultCameraViewEventMap } from "./SingleProductDefaultCameraViewConfiguration.js";
9
+ import { SingleProductView } from "./SingleProductView.js";
10
+ export declare type SingleProductDefaultCameraViewConstructorOptions = {
11
+ canvas: HTMLCanvasElement;
12
+ engineCreator?: EngineCreator;
13
+ lightRigCreator?: LightRigCreator;
14
+ sceneCreator?: SceneCreator;
15
+ dummyMaterialCreator?: DummyMaterialCreator;
16
+ };
17
+ export declare class SingleProductDefaultCameraView<T extends SingleProductDefaultCameraViewEventMap = SingleProductDefaultCameraViewEventMap> extends SingleProductView<CfgOrbitalCamera, T> {
18
+ private _orbitalCameraConfigurationObservable;
19
+ private _previousOrbitalCameraConf;
20
+ constructor(options: SingleProductDefaultCameraViewConstructorOptions);
21
+ private _cameraConf;
22
+ resetCamera(): void;
23
+ setConfiguration(configuration: SingleProductDefaultCameraViewConfiguration): void;
24
+ addEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
25
+ removeEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
26
+ get orbitalCameraConfiguration(): OrbitalCameraConfigurationProps;
27
+ protected notifyCameraListeners(): void;
28
+ get cameraControlObservable(): Observable<import("../index.js").CfgOrbitalCameraControlProps>;
29
+ protected get contentCenter(): Vector3;
30
+ protected handleSizing(force: boolean): false | undefined;
31
+ protected refreshCameraNearFar(): void;
32
+ protected getNeededFrameRender(time: number): boolean;
33
+ }
34
34
  //# sourceMappingURL=SingleProductDefaultCameraView.d.ts.map
@@ -1,141 +1,141 @@
1
- import { Observable } from "@configura/web-utilities";
2
- import { getDefaultCamera } from "../camera/CameraCreator.js";
3
- import { MAX_UPPER_BETA_LIMIT, MIN_LOWER_BETA_LIMIT, } from "../camera/CfgOrbitalCamera.js";
4
- import { CfgBoundingBox } from "../utilities/CfgBoundingBox.js";
5
- import { measureLongestDistanceToCorner } from "../utilities/utilities3D.js";
6
- import { CET_TO_BABYLON_MATRIX } from "./BaseView.js";
7
- import { orbitalCameraConfigurationPropsEquals, } from "./SingleProductDefaultCameraViewConfiguration.js";
8
- import { SingleProductView } from "./SingleProductView.js";
9
- const CONTENT_TO_LIGHT_RIG_SCALE_FACTOR = 1;
10
- export class SingleProductDefaultCameraView extends SingleProductView {
11
- constructor(options) {
12
- super(Object.assign(Object.assign({}, options), { cameraCreator: getDefaultCamera }));
13
- this._cameraConf = {};
14
- }
15
- resetCamera() {
16
- this.handleSizing(true);
17
- const { distance, pitch, yaw } = this._cameraConf;
18
- let change = false;
19
- if (distance !== undefined) {
20
- this._camera.forceRadius(distance);
21
- change = true;
22
- }
23
- if (pitch !== undefined) {
24
- this._camera.beta = pitch;
25
- change = true;
26
- }
27
- if (yaw !== undefined) {
28
- this._camera.alpha = yaw;
29
- change = true;
30
- }
31
- if (change) {
32
- // Force a recompute of the view matrix as if a target-change happens in
33
- // the same frame render alpha/beta will be reset.
34
- this._camera.getViewMatrix();
35
- }
36
- }
37
- setConfiguration(configuration) {
38
- super.setConfiguration(configuration);
39
- const cameraConf = configuration.camera || {};
40
- this._camera.disableAutomaticSizing = cameraConf.disableAutomaticSizing === true;
41
- this._camera.disableZoom = cameraConf.disableZoom === true;
42
- this._camera.disableSubFloorCam = cameraConf.disableSubFloorCam === true;
43
- this._camera.lowestAllowedCameraHeight = cameraConf.lowestAllowedCameraHeight;
44
- this._cameraConf = cameraConf;
45
- this.resetCamera();
46
- const { autoRotate } = cameraConf;
47
- if (autoRotate !== undefined) {
48
- this._camera.useAutoRotationBehavior = true;
49
- const behavior = this._camera.autoRotationBehavior;
50
- if (behavior !== null) {
51
- if (autoRotate.idleRotationSpeed !== undefined) {
52
- behavior.idleRotationSpeed = autoRotate.idleRotationSpeed;
53
- }
54
- if (autoRotate.idleRotationSpinupTime !== undefined) {
55
- behavior.idleRotationSpinupTime = autoRotate.idleRotationSpinupTime;
56
- }
57
- if (autoRotate.idleRotationWaitTime !== undefined) {
58
- behavior.idleRotationWaitTime = autoRotate.idleRotationWaitTime;
59
- }
60
- if (autoRotate.zoomStopsAnimation !== undefined) {
61
- behavior.zoomStopsAnimation = autoRotate.zoomStopsAnimation;
62
- }
63
- }
64
- }
65
- else {
66
- this._camera.useAutoRotationBehavior = false;
67
- }
68
- }
69
- addEventListener(event, listener) {
70
- switch (event) {
71
- case "orbitalCameraConfiguration":
72
- if (this._orbitalCameraConfigurationObservable === undefined) {
73
- this._orbitalCameraConfigurationObservable =
74
- new Observable();
75
- }
76
- this._orbitalCameraConfigurationObservable.listen(listener);
77
- break;
78
- default:
79
- super.addEventListener(event, listener);
80
- }
81
- }
82
- removeEventListener(event, listener) {
83
- switch (event) {
84
- case "orbitalCameraConfiguration":
85
- if (this._orbitalCameraConfigurationObservable === undefined) {
86
- return;
87
- }
88
- this._orbitalCameraConfigurationObservable.stopListen(listener);
89
- break;
90
- default:
91
- super.removeEventListener(event, listener);
92
- }
93
- }
94
- get orbitalCameraConfiguration() {
95
- const camera = this._camera;
96
- return Object.assign({ disableZoom: camera.disableZoom, minDistance: camera.lowerRadiusLimit || 0, maxDistance: camera.upperRadiusLimit || Infinity, minYaw: camera.lowerAlphaLimit || -Math.PI, maxYaw: camera.upperAlphaLimit || Math.PI, minPitch: Math.max(camera.lowerBetaLimit || MIN_LOWER_BETA_LIMIT, MIN_LOWER_BETA_LIMIT), maxPitch: Math.min(camera.upperBetaLimit || MAX_UPPER_BETA_LIMIT, MAX_UPPER_BETA_LIMIT) }, this.cameraConfiguration);
97
- }
98
- notifyCameraListeners() {
99
- super.notifyCameraListeners();
100
- if (this._orbitalCameraConfigurationObservable === undefined) {
101
- return;
102
- }
103
- const cameraConf = this.orbitalCameraConfiguration;
104
- if (this._previousOrbitalCameraConf !== undefined &&
105
- orbitalCameraConfigurationPropsEquals(this._previousOrbitalCameraConf, cameraConf)) {
106
- return;
107
- }
108
- this._orbitalCameraConfigurationObservable.notifyAll(cameraConf, this._orbitalCameraConfigurationObservable);
109
- this._previousOrbitalCameraConf = cameraConf;
110
- }
111
- get cameraControlObservable() {
112
- return this._camera.cameraControlObservable;
113
- }
114
- get contentCenter() {
115
- return this._camera.target;
116
- }
117
- handleSizing(force) {
118
- super.handleSizing(force);
119
- if (this._viewportSize === undefined) {
120
- return false;
121
- }
122
- const currentProductNode = this.currentProductNode;
123
- const boundingBox = currentProductNode === undefined
124
- ? new CfgBoundingBox()
125
- : currentProductNode.boundingBox;
126
- boundingBox.applyMatrix(CET_TO_BABYLON_MATRIX);
127
- this._camera.setContentBoundingBox(boundingBox, force);
128
- if (!boundingBox.isEmpty) {
129
- this._lightRig.scale =
130
- measureLongestDistanceToCorner(boundingBox, [0, 1, 2]) *
131
- CONTENT_TO_LIGHT_RIG_SCALE_FACTOR;
132
- }
133
- }
134
- refreshCameraNearFar() {
135
- super.refreshCameraNearFar();
136
- this._camera.refreshCameraNearFar();
137
- }
138
- getNeededFrameRender(time) {
139
- return super.getNeededFrameRender(time) || this._camera.frameRenderNeeded();
140
- }
141
- }
1
+ import { Observable } from "@configura/web-utilities";
2
+ import { getDefaultCamera } from "../camera/CameraCreator.js";
3
+ import { MAX_UPPER_BETA_LIMIT, MIN_LOWER_BETA_LIMIT, } from "../camera/CfgOrbitalCamera.js";
4
+ import { CfgBoundingBox } from "../utilities/CfgBoundingBox.js";
5
+ import { measureLongestDistanceToCorner } from "../utilities/utilities3D.js";
6
+ import { CET_TO_BABYLON_MATRIX } from "./BaseView.js";
7
+ import { orbitalCameraConfigurationPropsEquals, } from "./SingleProductDefaultCameraViewConfiguration.js";
8
+ import { SingleProductView } from "./SingleProductView.js";
9
+ const CONTENT_TO_LIGHT_RIG_SCALE_FACTOR = 1;
10
+ export class SingleProductDefaultCameraView extends SingleProductView {
11
+ constructor(options) {
12
+ super(Object.assign(Object.assign({}, options), { cameraCreator: getDefaultCamera }));
13
+ this._cameraConf = {};
14
+ }
15
+ resetCamera() {
16
+ this.handleSizing(true);
17
+ const { distance, pitch, yaw } = this._cameraConf;
18
+ let change = false;
19
+ if (distance !== undefined) {
20
+ this._camera.forceRadius(distance);
21
+ change = true;
22
+ }
23
+ if (pitch !== undefined) {
24
+ this._camera.beta = pitch;
25
+ change = true;
26
+ }
27
+ if (yaw !== undefined) {
28
+ this._camera.alpha = yaw;
29
+ change = true;
30
+ }
31
+ if (change) {
32
+ // Force a recompute of the view matrix as if a target-change happens in
33
+ // the same frame render alpha/beta will be reset.
34
+ this._camera.getViewMatrix();
35
+ }
36
+ }
37
+ setConfiguration(configuration) {
38
+ super.setConfiguration(configuration);
39
+ const cameraConf = configuration.camera || {};
40
+ this._camera.disableAutomaticSizing = cameraConf.disableAutomaticSizing === true;
41
+ this._camera.disableZoom = cameraConf.disableZoom === true;
42
+ this._camera.disableSubFloorCam = cameraConf.disableSubFloorCam === true;
43
+ this._camera.lowestAllowedCameraHeight = cameraConf.lowestAllowedCameraHeight;
44
+ this._cameraConf = cameraConf;
45
+ this.resetCamera();
46
+ const { autoRotate } = cameraConf;
47
+ if (autoRotate !== undefined) {
48
+ this._camera.useAutoRotationBehavior = true;
49
+ const behavior = this._camera.autoRotationBehavior;
50
+ if (behavior !== null) {
51
+ if (autoRotate.idleRotationSpeed !== undefined) {
52
+ behavior.idleRotationSpeed = autoRotate.idleRotationSpeed;
53
+ }
54
+ if (autoRotate.idleRotationSpinupTime !== undefined) {
55
+ behavior.idleRotationSpinupTime = autoRotate.idleRotationSpinupTime;
56
+ }
57
+ if (autoRotate.idleRotationWaitTime !== undefined) {
58
+ behavior.idleRotationWaitTime = autoRotate.idleRotationWaitTime;
59
+ }
60
+ if (autoRotate.zoomStopsAnimation !== undefined) {
61
+ behavior.zoomStopsAnimation = autoRotate.zoomStopsAnimation;
62
+ }
63
+ }
64
+ }
65
+ else {
66
+ this._camera.useAutoRotationBehavior = false;
67
+ }
68
+ }
69
+ addEventListener(event, listener) {
70
+ switch (event) {
71
+ case "orbitalCameraConfiguration":
72
+ if (this._orbitalCameraConfigurationObservable === undefined) {
73
+ this._orbitalCameraConfigurationObservable =
74
+ new Observable();
75
+ }
76
+ this._orbitalCameraConfigurationObservable.listen(listener);
77
+ break;
78
+ default:
79
+ super.addEventListener(event, listener);
80
+ }
81
+ }
82
+ removeEventListener(event, listener) {
83
+ switch (event) {
84
+ case "orbitalCameraConfiguration":
85
+ if (this._orbitalCameraConfigurationObservable === undefined) {
86
+ return;
87
+ }
88
+ this._orbitalCameraConfigurationObservable.stopListen(listener);
89
+ break;
90
+ default:
91
+ super.removeEventListener(event, listener);
92
+ }
93
+ }
94
+ get orbitalCameraConfiguration() {
95
+ const camera = this._camera;
96
+ return Object.assign({ disableZoom: camera.disableZoom, minDistance: camera.lowerRadiusLimit || 0, maxDistance: camera.upperRadiusLimit || Infinity, minYaw: camera.lowerAlphaLimit || -Math.PI, maxYaw: camera.upperAlphaLimit || Math.PI, minPitch: Math.max(camera.lowerBetaLimit || MIN_LOWER_BETA_LIMIT, MIN_LOWER_BETA_LIMIT), maxPitch: Math.min(camera.upperBetaLimit || MAX_UPPER_BETA_LIMIT, MAX_UPPER_BETA_LIMIT) }, this.cameraConfiguration);
97
+ }
98
+ notifyCameraListeners() {
99
+ super.notifyCameraListeners();
100
+ if (this._orbitalCameraConfigurationObservable === undefined) {
101
+ return;
102
+ }
103
+ const cameraConf = this.orbitalCameraConfiguration;
104
+ if (this._previousOrbitalCameraConf !== undefined &&
105
+ orbitalCameraConfigurationPropsEquals(this._previousOrbitalCameraConf, cameraConf)) {
106
+ return;
107
+ }
108
+ this._orbitalCameraConfigurationObservable.notifyAll(cameraConf, this._orbitalCameraConfigurationObservable);
109
+ this._previousOrbitalCameraConf = cameraConf;
110
+ }
111
+ get cameraControlObservable() {
112
+ return this._camera.cameraControlObservable;
113
+ }
114
+ get contentCenter() {
115
+ return this._camera.target;
116
+ }
117
+ handleSizing(force) {
118
+ super.handleSizing(force);
119
+ if (this._viewportSize === undefined) {
120
+ return false;
121
+ }
122
+ const currentProductNode = this.currentProductNode;
123
+ const boundingBox = currentProductNode === undefined
124
+ ? new CfgBoundingBox()
125
+ : currentProductNode.boundingBox;
126
+ boundingBox.applyMatrix(CET_TO_BABYLON_MATRIX);
127
+ this._camera.setContentBoundingBox(boundingBox, force);
128
+ if (!boundingBox.isEmpty) {
129
+ this._lightRig.scale =
130
+ measureLongestDistanceToCorner(boundingBox, [0, 1, 2]) *
131
+ CONTENT_TO_LIGHT_RIG_SCALE_FACTOR;
132
+ }
133
+ }
134
+ refreshCameraNearFar() {
135
+ super.refreshCameraNearFar();
136
+ this._camera.refreshCameraNearFar();
137
+ }
138
+ getNeededFrameRender(time) {
139
+ return super.getNeededFrameRender(time) || this._camera.frameRenderNeeded();
140
+ }
141
+ }
@@ -1,47 +1,47 @@
1
- import { EventListener } from "@configura/web-utilities";
2
- import { CameraConfigurationProps } from "./BaseViewConfiguration.js";
3
- import { SingleProductViewConfiguration, SingleProductViewEventMap } from "./SingleProductViewConfiguration.js";
4
- /**
5
- * @param disableZoom Don't let the camera dolly in and out. Zoom is stricly speaking not correct, we only dolly the camera.
6
- * @param disableAutomaticSizing Turn off automatic adaption of camera distance and light rig size.
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.
9
- * @param distance Only works if disableAutomaticSizing is set
10
- * @param yaw Horisontal angle for the camera. Range -π/2 to π/2 radians.
11
- * @param pitch Vertical angle for the camera. Range 0 to π/2 radians, measured from the north pole.
12
- * @param autoRotate See babylon-documentation for parameter-documentation
13
- */
14
- export declare type SingleProductDefaultCameraDirection = {
15
- distance?: number;
16
- yaw?: number;
17
- pitch?: number;
18
- };
19
- export interface SingleProductDefaultCameraViewConfiguration extends SingleProductViewConfiguration {
20
- camera?: SingleProductDefaultCameraDirection & {
21
- disableZoom?: boolean;
22
- disableAutomaticSizing?: boolean;
23
- disableSubFloorCam?: boolean;
24
- lowestAllowedCameraHeight?: number;
25
- autoRotate?: {
26
- idleRotationSpeed?: number;
27
- idleRotationSpinupTime?: number;
28
- idleRotationWaitTime?: number;
29
- zoomStopsAnimation?: boolean;
30
- };
31
- };
32
- }
33
- export interface SingleProductDefaultCameraViewEventMap extends SingleProductViewEventMap {
34
- orbitalCameraConfiguration: OrbitalCameraConfigurationProps;
35
- }
36
- export declare type SingleProductDefaultCameraViewEventListener<K extends keyof SingleProductDefaultCameraViewEventMap> = EventListener<SingleProductDefaultCameraViewEventMap, K>;
37
- export interface OrbitalCameraConfigurationProps extends CameraConfigurationProps {
38
- disableZoom: boolean;
39
- minDistance: number;
40
- maxDistance: number;
41
- minYaw: number;
42
- maxYaw: number;
43
- minPitch: number;
44
- maxPitch: number;
45
- }
46
- export declare function orbitalCameraConfigurationPropsEquals(left: OrbitalCameraConfigurationProps, right: OrbitalCameraConfigurationProps): boolean;
1
+ import { EventListener } from "@configura/web-utilities";
2
+ import { CameraConfigurationProps } from "./BaseViewConfiguration.js";
3
+ import { SingleProductViewConfiguration, SingleProductViewEventMap } from "./SingleProductViewConfiguration.js";
4
+ /**
5
+ * @param disableZoom Don't let the camera dolly in and out. Zoom is stricly speaking not correct, we only dolly the camera.
6
+ * @param disableAutomaticSizing Turn off automatic adaption of camera distance and light rig size.
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.
9
+ * @param distance Only works if disableAutomaticSizing is set
10
+ * @param yaw Horisontal angle for the camera. Range -π/2 to π/2 radians.
11
+ * @param pitch Vertical angle for the camera. Range 0 to π/2 radians, measured from the north pole.
12
+ * @param autoRotate See babylon-documentation for parameter-documentation
13
+ */
14
+ export declare type SingleProductDefaultCameraDirection = {
15
+ distance?: number;
16
+ yaw?: number;
17
+ pitch?: number;
18
+ };
19
+ export interface SingleProductDefaultCameraViewConfiguration extends SingleProductViewConfiguration {
20
+ camera?: SingleProductDefaultCameraDirection & {
21
+ disableZoom?: boolean;
22
+ disableAutomaticSizing?: boolean;
23
+ disableSubFloorCam?: boolean;
24
+ lowestAllowedCameraHeight?: number;
25
+ autoRotate?: {
26
+ idleRotationSpeed?: number;
27
+ idleRotationSpinupTime?: number;
28
+ idleRotationWaitTime?: number;
29
+ zoomStopsAnimation?: boolean;
30
+ };
31
+ };
32
+ }
33
+ export interface SingleProductDefaultCameraViewEventMap extends SingleProductViewEventMap {
34
+ orbitalCameraConfiguration: OrbitalCameraConfigurationProps;
35
+ }
36
+ export declare type SingleProductDefaultCameraViewEventListener<K extends keyof SingleProductDefaultCameraViewEventMap> = EventListener<SingleProductDefaultCameraViewEventMap, K>;
37
+ export interface OrbitalCameraConfigurationProps extends CameraConfigurationProps {
38
+ disableZoom: boolean;
39
+ minDistance: number;
40
+ maxDistance: number;
41
+ minYaw: number;
42
+ maxYaw: number;
43
+ minPitch: number;
44
+ maxPitch: number;
45
+ }
46
+ export declare function orbitalCameraConfigurationPropsEquals(left: OrbitalCameraConfigurationProps, right: OrbitalCameraConfigurationProps): boolean;
47
47
  //# sourceMappingURL=SingleProductDefaultCameraViewConfiguration.d.ts.map
@@ -1,11 +1,11 @@
1
- import { cameraConfigurationPropsEquals, } from "./BaseViewConfiguration.js";
2
- export function orbitalCameraConfigurationPropsEquals(left, right) {
3
- return (left.disableZoom === right.disableZoom &&
4
- left.minDistance === right.minDistance &&
5
- left.maxDistance === right.maxDistance &&
6
- left.minYaw === right.minYaw &&
7
- left.maxYaw === right.maxYaw &&
8
- left.minPitch === right.minPitch &&
9
- left.maxPitch === right.maxPitch &&
10
- cameraConfigurationPropsEquals(left, right));
11
- }
1
+ import { cameraConfigurationPropsEquals, } from "./BaseViewConfiguration.js";
2
+ export function orbitalCameraConfigurationPropsEquals(left, right) {
3
+ return (left.disableZoom === right.disableZoom &&
4
+ left.minDistance === right.minDistance &&
5
+ left.maxDistance === right.maxDistance &&
6
+ left.minYaw === right.minYaw &&
7
+ left.maxYaw === right.maxYaw &&
8
+ left.minPitch === right.minPitch &&
9
+ left.maxPitch === right.maxPitch &&
10
+ cameraConfigurationPropsEquals(left, right));
11
+ }