@configura/babylon-view 2.2.0-alpha.0 → 2.2.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.
- package/.eslintrc.json +5 -5
- 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 +53 -53
- package/dist/animation/coordinator/CoordinatorDropAndSpin.d.ts +22 -22
- package/dist/animation/coordinator/CoordinatorDropAndSpin.js +138 -138
- package/dist/animation/coordinator/CoordinatorIdentity.d.ts +11 -11
- package/dist/animation/coordinator/CoordinatorIdentity.js +14 -14
- 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 +35 -35
- package/dist/animation/coordinator/CoordinatorPulseHighlight.d.ts +13 -13
- package/dist/animation/coordinator/CoordinatorPulseHighlight.js +29 -29
- package/dist/animation/coordinator/CoordinatorPulseInflate.d.ts +14 -14
- package/dist/animation/coordinator/CoordinatorPulseInflate.js +23 -23
- package/dist/camera/CameraCreator.d.ts +5 -5
- package/dist/camera/CameraCreator.js +4 -4
- package/dist/camera/CfgOrbitalCamera.d.ts +76 -76
- package/dist/camera/CfgOrbitalCamera.js +277 -277
- package/dist/camera/CfgOrbitalCameraControlProps.d.ts +14 -14
- package/dist/camera/CfgOrbitalCameraControlProps.js +7 -7
- package/dist/camera/GradingApplier.d.ts +3 -3
- package/dist/camera/GradingApplier.js +48 -48
- package/dist/camera/SSAO2PipelineCreator.d.ts +28 -0
- package/dist/camera/SSAO2PipelineCreator.js +23 -0
- 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 +116 -116
- package/dist/geometry/stretch/CfgStretchData.js +347 -347
- package/dist/geometry/stretch/CfgStretchMorphGeometry.d.ts +16 -16
- package/dist/geometry/stretch/CfgStretchMorphGeometry.js +95 -95
- package/dist/index.d.ts +17 -16
- package/dist/index.js +17 -16
- package/dist/io/CfgHistoryToCameraConfConnector.d.ts +31 -31
- package/dist/io/CfgHistoryToCameraConfConnector.js +90 -90
- package/dist/io/CfgIOCameraConfConnector.d.ts +35 -35
- package/dist/io/CfgIOCameraConfConnector.js +81 -81
- package/dist/io/CfgObservableStateToCameraConfConnector.d.ts +10 -10
- package/dist/io/CfgObservableStateToCameraConfConnector.js +11 -11
- package/dist/io/CfgWindowMessageToCameraConfConnector.d.ts +10 -10
- package/dist/io/CfgWindowMessageToCameraConfConnector.js +11 -11
- 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 +497 -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 +316 -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 +378 -378
- package/dist/nodes/CfgProductNode.d.ts +127 -127
- package/dist/nodes/CfgProductNode.js +598 -598
- 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 +240 -240
- 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 +50 -50
- package/dist/utilities/anchor/anchor.js +133 -133
- 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 +259 -259
- package/dist/utilities/utilitiesColor.d.ts +18 -18
- package/dist/utilities/utilitiesColor.js +50 -50
- 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 +80 -78
- package/dist/view/BaseView.js +321 -303
- package/dist/view/BaseViewConfiguration.d.ts +38 -32
- package/dist/view/BaseViewConfiguration.js +10 -10
- package/dist/view/RenderEnv.d.ts +45 -43
- package/dist/view/RenderEnv.js +7 -7
- package/dist/view/SingleProductDefaultCameraView.d.ts +38 -38
- package/dist/view/SingleProductDefaultCameraView.js +149 -149
- package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +44 -44
- package/dist/view/SingleProductDefaultCameraViewConfiguration.js +11 -11
- package/dist/view/SingleProductView.d.ts +44 -44
- package/dist/view/SingleProductView.js +212 -212
- package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
- package/dist/view/SingleProductViewConfiguration.js +19 -19
- package/package.json +9 -5
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export interface
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
2
|
+
import { MIPS_TEXTURE_LEVEL } from "@configura/web-core/dist/cm/core3D/GMaterialPBR.js";
|
|
3
|
+
import { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
|
|
4
|
+
import { EventListener } from "@configura/web-utilities";
|
|
5
|
+
import { RenderEnv } from "./RenderEnv.js";
|
|
6
|
+
export { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
|
|
7
|
+
/**
|
|
8
|
+
* @param allowedDetailLevels Optionally controls the detail level (LOD, level of detail) allowed
|
|
9
|
+
* when loading the 3D models. Provide a single DetailLevel or an array of them if you want to
|
|
10
|
+
* override the default selection and/or order. The order of the array defines the priority since
|
|
11
|
+
* models are not guaranteed to have all DetailLevels available.
|
|
12
|
+
*
|
|
13
|
+
* @param orderIndependentTransparency This controls the rendering technique for transparent
|
|
14
|
+
* materials. Note: Enabling this causes conflicts with post processing render pipelines.
|
|
15
|
+
*/
|
|
16
|
+
export interface BaseViewConfiguration {
|
|
17
|
+
allowedDetailLevels?: DetailLevel | DetailLevel[];
|
|
18
|
+
textureResolutionLevel?: MIPS_TEXTURE_LEVEL;
|
|
19
|
+
orderIndependentTransparency?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare type BaseViewEventListener<K extends keyof BaseViewEventMap> = EventListener<BaseViewEventMap, K>;
|
|
22
|
+
export declare type ScheduleRerender = (dumpNextFrameToImage?: ImageDumpCallback) => void;
|
|
23
|
+
export declare type ImageDumpCallback = (imageDataUrl: string) => void;
|
|
24
|
+
export interface BaseViewEventMap {
|
|
25
|
+
renderEnv: RenderEnv;
|
|
26
|
+
error: Error;
|
|
27
|
+
loading: boolean;
|
|
28
|
+
cameraConfiguration: CameraConfigurationProps;
|
|
29
|
+
}
|
|
30
|
+
export interface CameraConfigurationProps {
|
|
31
|
+
nearClipping: number;
|
|
32
|
+
farClipping: number;
|
|
33
|
+
position: Vector3;
|
|
34
|
+
contentPosition: Vector3;
|
|
35
|
+
fov: number;
|
|
36
|
+
aspect: number;
|
|
37
|
+
}
|
|
38
|
+
export declare function cameraConfigurationPropsEquals(left: CameraConfigurationProps, right: CameraConfigurationProps): boolean;
|
|
33
39
|
//# sourceMappingURL=BaseViewConfiguration.d.ts.map
|
|
@@ -1,10 +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
|
-
vector3Equals(left.contentPosition, right.contentPosition) &&
|
|
8
|
-
left.fov === right.fov &&
|
|
9
|
-
left.aspect === right.aspect);
|
|
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
|
+
vector3Equals(left.contentPosition, right.contentPosition) &&
|
|
8
|
+
left.fov === right.fov &&
|
|
9
|
+
left.aspect === right.aspect);
|
|
10
|
+
}
|
package/dist/view/RenderEnv.d.ts
CHANGED
|
@@ -1,44 +1,46 @@
|
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
readonly
|
|
42
|
-
|
|
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 { MIPS_TEXTURE_LEVEL } from "@configura/web-core/dist/cm/core3D/GMaterialPBR.js";
|
|
5
|
+
import { SymComponent } from "@configura/web-core/dist/cm/format/cmsym/components/SymComponent.js";
|
|
6
|
+
import { SymGetMeshEnv } from "@configura/web-core/dist/cm/format/cmsym/components/SymGetMeshEnv.js";
|
|
7
|
+
import { SymNode } from "@configura/web-core/dist/cm/format/cmsym/SymNode.js";
|
|
8
|
+
import { DexManager } from "@configura/web-core/dist/cm/format/dex/DexManager.js";
|
|
9
|
+
import { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
|
|
10
|
+
import { PromiseCache } from "@configura/web-utilities";
|
|
11
|
+
import { CfgGeometry } from "../geometry/CfgGeometry.js";
|
|
12
|
+
import { LightRig } from "../light/LightRigCreator.js";
|
|
13
|
+
import { CfgMaterial } from "../material/CfgMaterial.js";
|
|
14
|
+
import { MaterialWithMetaData } from "../material/material.js";
|
|
15
|
+
import { TextureImageWithMetaData } from "../material/texture.js";
|
|
16
|
+
import { ScheduleRerender } from "./BaseViewConfiguration.js";
|
|
17
|
+
export declare type GeometryCacheIdentifierObject = {
|
|
18
|
+
component: SymComponent;
|
|
19
|
+
stretchDatasHash: number;
|
|
20
|
+
uvMapperHash: number | undefined;
|
|
21
|
+
};
|
|
22
|
+
export interface RenderEnv {
|
|
23
|
+
scene: Scene;
|
|
24
|
+
assetsManager: AssetsManager;
|
|
25
|
+
dummyMaterial: CfgMaterial;
|
|
26
|
+
geometryCache: PromiseCache<GeometryCacheIdentifierObject, GeometryCacheEntry | undefined>;
|
|
27
|
+
symNodeCache: PromiseCache<string, SymNode>;
|
|
28
|
+
materialCache: PromiseCache<string | GMaterial3D, MaterialWithMetaData>;
|
|
29
|
+
textureImageCache: PromiseCache<string, TextureImageWithMetaData>;
|
|
30
|
+
derivedNormalMapCache: PromiseCache<string, HTMLImageElement | undefined>;
|
|
31
|
+
lightRig: LightRig;
|
|
32
|
+
scheduleRerender: ScheduleRerender;
|
|
33
|
+
notifyError: (e: unknown) => void;
|
|
34
|
+
symMeshEnv: SymGetMeshEnv;
|
|
35
|
+
dexManager: DexManager;
|
|
36
|
+
cullEmptyNodes: boolean;
|
|
37
|
+
allowedDetailLevels: DetailLevel | DetailLevel[];
|
|
38
|
+
textureResolutionLevel: MIPS_TEXTURE_LEVEL;
|
|
39
|
+
}
|
|
40
|
+
export declare class GeometryCacheEntry {
|
|
41
|
+
readonly geometry: CfgGeometry;
|
|
42
|
+
readonly doubleSided: boolean | undefined;
|
|
43
|
+
readonly lowerLeftTextureOrigin: boolean | undefined;
|
|
44
|
+
constructor(geometry: CfgGeometry, doubleSided: boolean | undefined, lowerLeftTextureOrigin: boolean | undefined);
|
|
45
|
+
}
|
|
44
46
|
//# sourceMappingURL=RenderEnv.d.ts.map
|
package/dist/view/RenderEnv.js
CHANGED
|
@@ -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,39 +1,39 @@
|
|
|
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 { CfgOrbitalCameraControlProps } from "../camera/CfgOrbitalCameraControlProps.js";
|
|
5
|
-
import { EngineCreator } from "../engine/EngineCreator.js";
|
|
6
|
-
import { LightRigCreator } from "../light/LightRigCreator.js";
|
|
7
|
-
import { DummyMaterialCreator } from "../material/DummyMaterialCreator.js";
|
|
8
|
-
import { SceneCreator } from "../scene/SceneCreator.js";
|
|
9
|
-
import { OrbitalCameraConfigurationProps, SingleProductDefaultCameraViewConfiguration, SingleProductDefaultCameraViewEventMap } from "./SingleProductDefaultCameraViewConfiguration.js";
|
|
10
|
-
import { SingleProductView } from "./SingleProductView.js";
|
|
11
|
-
export declare type SingleProductDefaultCameraViewConstructorOptions = {
|
|
12
|
-
canvas: HTMLCanvasElement;
|
|
13
|
-
engineCreator?: EngineCreator;
|
|
14
|
-
lightRigCreator?: LightRigCreator;
|
|
15
|
-
sceneCreator?: SceneCreator;
|
|
16
|
-
dummyMaterialCreator?: DummyMaterialCreator;
|
|
17
|
-
};
|
|
18
|
-
export declare class SingleProductDefaultCameraView<T extends SingleProductDefaultCameraViewEventMap = SingleProductDefaultCameraViewEventMap> extends SingleProductView<CfgOrbitalCamera, T> {
|
|
19
|
-
private _orbitalCameraConfigurationObservable;
|
|
20
|
-
private _previousOrbitalCameraConf;
|
|
21
|
-
constructor(options: SingleProductDefaultCameraViewConstructorOptions);
|
|
22
|
-
private _cameraDefaults;
|
|
23
|
-
private initOrResetCamera;
|
|
24
|
-
resetCamera(): void;
|
|
25
|
-
setConfiguration(configuration: SingleProductDefaultCameraViewConfiguration): void;
|
|
26
|
-
addEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
27
|
-
removeEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
28
|
-
get orbitalCameraConfiguration(): OrbitalCameraConfigurationProps;
|
|
29
|
-
protected notifyCameraListeners(): void;
|
|
30
|
-
get cameraControlObservable(): Observable<CfgOrbitalCameraControlProps>;
|
|
31
|
-
protected get contentCenter(): Vector3;
|
|
32
|
-
/**
|
|
33
|
-
* @param force true means force apply camera distance and camera bounds. false means force do not apply.
|
|
34
|
-
*/
|
|
35
|
-
protected handleSizing(force: boolean): void;
|
|
36
|
-
protected refreshCameraNearFar(): void;
|
|
37
|
-
protected getNeededFrameRender(time: number): boolean;
|
|
38
|
-
}
|
|
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 { CfgOrbitalCameraControlProps } from "../camera/CfgOrbitalCameraControlProps.js";
|
|
5
|
+
import { EngineCreator } from "../engine/EngineCreator.js";
|
|
6
|
+
import { LightRigCreator } from "../light/LightRigCreator.js";
|
|
7
|
+
import { DummyMaterialCreator } from "../material/DummyMaterialCreator.js";
|
|
8
|
+
import { SceneCreator } from "../scene/SceneCreator.js";
|
|
9
|
+
import { OrbitalCameraConfigurationProps, SingleProductDefaultCameraViewConfiguration, SingleProductDefaultCameraViewEventMap } from "./SingleProductDefaultCameraViewConfiguration.js";
|
|
10
|
+
import { SingleProductView } from "./SingleProductView.js";
|
|
11
|
+
export declare type SingleProductDefaultCameraViewConstructorOptions = {
|
|
12
|
+
canvas: HTMLCanvasElement;
|
|
13
|
+
engineCreator?: EngineCreator;
|
|
14
|
+
lightRigCreator?: LightRigCreator;
|
|
15
|
+
sceneCreator?: SceneCreator;
|
|
16
|
+
dummyMaterialCreator?: DummyMaterialCreator;
|
|
17
|
+
};
|
|
18
|
+
export declare class SingleProductDefaultCameraView<T extends SingleProductDefaultCameraViewEventMap = SingleProductDefaultCameraViewEventMap> extends SingleProductView<CfgOrbitalCamera, T> {
|
|
19
|
+
private _orbitalCameraConfigurationObservable;
|
|
20
|
+
private _previousOrbitalCameraConf;
|
|
21
|
+
constructor(options: SingleProductDefaultCameraViewConstructorOptions);
|
|
22
|
+
private _cameraDefaults;
|
|
23
|
+
private initOrResetCamera;
|
|
24
|
+
resetCamera(): void;
|
|
25
|
+
setConfiguration(configuration: SingleProductDefaultCameraViewConfiguration): void;
|
|
26
|
+
addEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
27
|
+
removeEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
28
|
+
get orbitalCameraConfiguration(): OrbitalCameraConfigurationProps;
|
|
29
|
+
protected notifyCameraListeners(): void;
|
|
30
|
+
get cameraControlObservable(): Observable<CfgOrbitalCameraControlProps>;
|
|
31
|
+
protected get contentCenter(): Vector3;
|
|
32
|
+
/**
|
|
33
|
+
* @param force true means force apply camera distance and camera bounds. false means force do not apply.
|
|
34
|
+
*/
|
|
35
|
+
protected handleSizing(force: boolean): void;
|
|
36
|
+
protected refreshCameraNearFar(): void;
|
|
37
|
+
protected getNeededFrameRender(time: number): boolean;
|
|
38
|
+
}
|
|
39
39
|
//# sourceMappingURL=SingleProductDefaultCameraView.d.ts.map
|
|
@@ -1,149 +1,149 @@
|
|
|
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._cameraDefaults = {};
|
|
14
|
-
}
|
|
15
|
-
initOrResetCamera(props) {
|
|
16
|
-
this.handleSizing(true);
|
|
17
|
-
const { distance, pitch, yaw } = props;
|
|
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
|
-
resetCamera() {
|
|
38
|
-
this.initOrResetCamera(this._cameraDefaults);
|
|
39
|
-
}
|
|
40
|
-
setConfiguration(configuration) {
|
|
41
|
-
var _a;
|
|
42
|
-
super.setConfiguration(configuration);
|
|
43
|
-
const cameraConf = configuration.camera || {};
|
|
44
|
-
this._camera.disableAutomaticSizing = cameraConf.disableAutomaticSizing === true;
|
|
45
|
-
this._camera.disableZoom = cameraConf.disableZoom === true;
|
|
46
|
-
this._camera.disableSubFloorCam = cameraConf.disableSubFloorCam === true;
|
|
47
|
-
this._camera.lowestAllowedCameraHeight = cameraConf.lowestAllowedCameraHeight;
|
|
48
|
-
this._cameraDefaults = cameraConf;
|
|
49
|
-
this.initOrResetCamera((_a = cameraConf.initial) !== null && _a !== void 0 ? _a : cameraConf);
|
|
50
|
-
const { autoRotate } = cameraConf;
|
|
51
|
-
if (autoRotate !== undefined) {
|
|
52
|
-
this._camera.useAutoRotationBehavior = true;
|
|
53
|
-
const behavior = this._camera.autoRotationBehavior;
|
|
54
|
-
if (behavior !== null) {
|
|
55
|
-
if (autoRotate.idleRotationSpeed !== undefined) {
|
|
56
|
-
behavior.idleRotationSpeed = autoRotate.idleRotationSpeed;
|
|
57
|
-
}
|
|
58
|
-
if (autoRotate.idleRotationSpinupTime !== undefined) {
|
|
59
|
-
behavior.idleRotationSpinupTime = autoRotate.idleRotationSpinupTime;
|
|
60
|
-
}
|
|
61
|
-
if (autoRotate.idleRotationWaitTime !== undefined) {
|
|
62
|
-
behavior.idleRotationWaitTime = autoRotate.idleRotationWaitTime;
|
|
63
|
-
}
|
|
64
|
-
if (autoRotate.zoomStopsAnimation !== undefined) {
|
|
65
|
-
behavior.zoomStopsAnimation = autoRotate.zoomStopsAnimation;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this._camera.useAutoRotationBehavior = false;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
addEventListener(event, listener) {
|
|
74
|
-
switch (event) {
|
|
75
|
-
case "orbitalCameraConfiguration":
|
|
76
|
-
if (this._orbitalCameraConfigurationObservable === undefined) {
|
|
77
|
-
this._orbitalCameraConfigurationObservable =
|
|
78
|
-
new Observable();
|
|
79
|
-
}
|
|
80
|
-
this._orbitalCameraConfigurationObservable.listen(listener);
|
|
81
|
-
break;
|
|
82
|
-
default:
|
|
83
|
-
super.addEventListener(event, listener);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
removeEventListener(event, listener) {
|
|
87
|
-
switch (event) {
|
|
88
|
-
case "orbitalCameraConfiguration":
|
|
89
|
-
if (this._orbitalCameraConfigurationObservable === undefined) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
this._orbitalCameraConfigurationObservable.stopListen(listener);
|
|
93
|
-
break;
|
|
94
|
-
default:
|
|
95
|
-
super.removeEventListener(event, listener);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
get orbitalCameraConfiguration() {
|
|
99
|
-
const camera = this._camera;
|
|
100
|
-
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);
|
|
101
|
-
}
|
|
102
|
-
notifyCameraListeners() {
|
|
103
|
-
super.notifyCameraListeners();
|
|
104
|
-
if (this._orbitalCameraConfigurationObservable === undefined) {
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
const cameraConf = this.orbitalCameraConfiguration;
|
|
108
|
-
if (this._previousOrbitalCameraConf !== undefined &&
|
|
109
|
-
orbitalCameraConfigurationPropsEquals(this._previousOrbitalCameraConf, cameraConf)) {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
this._orbitalCameraConfigurationObservable.notifyAll(cameraConf, this._orbitalCameraConfigurationObservable);
|
|
113
|
-
this._previousOrbitalCameraConf = cameraConf;
|
|
114
|
-
}
|
|
115
|
-
get cameraControlObservable() {
|
|
116
|
-
return this._camera.cameraControlObservable;
|
|
117
|
-
}
|
|
118
|
-
get contentCenter() {
|
|
119
|
-
return this._camera.target;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* @param force true means force apply camera distance and camera bounds. false means force do not apply.
|
|
123
|
-
*/
|
|
124
|
-
handleSizing(force) {
|
|
125
|
-
super.handleSizing(force);
|
|
126
|
-
if (this._viewportSize === undefined) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const currentProductNode = this.currentProductNode;
|
|
130
|
-
const boundingBox = currentProductNode === undefined
|
|
131
|
-
? new CfgBoundingBox()
|
|
132
|
-
: currentProductNode.boundingBox;
|
|
133
|
-
boundingBox.applyMatrix(CET_TO_BABYLON_MATRIX);
|
|
134
|
-
const initialCameraDistanceSetPreventsInitialAutoSizingSet = this.isFirstLoad && this._cameraDefaults.distance !== undefined;
|
|
135
|
-
this._camera.setContentBoundingBox(boundingBox, initialCameraDistanceSetPreventsInitialAutoSizingSet ? false : force ? true : undefined);
|
|
136
|
-
if (!boundingBox.isEmpty) {
|
|
137
|
-
this._lightRig.scale =
|
|
138
|
-
measureLongestDistanceToCorner(boundingBox, [0, 1, 2]) *
|
|
139
|
-
CONTENT_TO_LIGHT_RIG_SCALE_FACTOR;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
refreshCameraNearFar() {
|
|
143
|
-
super.refreshCameraNearFar();
|
|
144
|
-
this._camera.refreshCameraNearFar();
|
|
145
|
-
}
|
|
146
|
-
getNeededFrameRender(time) {
|
|
147
|
-
return super.getNeededFrameRender(time) || this._camera.frameRenderNeeded();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
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._cameraDefaults = {};
|
|
14
|
+
}
|
|
15
|
+
initOrResetCamera(props) {
|
|
16
|
+
this.handleSizing(true);
|
|
17
|
+
const { distance, pitch, yaw } = props;
|
|
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
|
+
resetCamera() {
|
|
38
|
+
this.initOrResetCamera(this._cameraDefaults);
|
|
39
|
+
}
|
|
40
|
+
setConfiguration(configuration) {
|
|
41
|
+
var _a;
|
|
42
|
+
super.setConfiguration(configuration);
|
|
43
|
+
const cameraConf = configuration.camera || {};
|
|
44
|
+
this._camera.disableAutomaticSizing = cameraConf.disableAutomaticSizing === true;
|
|
45
|
+
this._camera.disableZoom = cameraConf.disableZoom === true;
|
|
46
|
+
this._camera.disableSubFloorCam = cameraConf.disableSubFloorCam === true;
|
|
47
|
+
this._camera.lowestAllowedCameraHeight = cameraConf.lowestAllowedCameraHeight;
|
|
48
|
+
this._cameraDefaults = cameraConf;
|
|
49
|
+
this.initOrResetCamera((_a = cameraConf.initial) !== null && _a !== void 0 ? _a : cameraConf);
|
|
50
|
+
const { autoRotate } = cameraConf;
|
|
51
|
+
if (autoRotate !== undefined) {
|
|
52
|
+
this._camera.useAutoRotationBehavior = true;
|
|
53
|
+
const behavior = this._camera.autoRotationBehavior;
|
|
54
|
+
if (behavior !== null) {
|
|
55
|
+
if (autoRotate.idleRotationSpeed !== undefined) {
|
|
56
|
+
behavior.idleRotationSpeed = autoRotate.idleRotationSpeed;
|
|
57
|
+
}
|
|
58
|
+
if (autoRotate.idleRotationSpinupTime !== undefined) {
|
|
59
|
+
behavior.idleRotationSpinupTime = autoRotate.idleRotationSpinupTime;
|
|
60
|
+
}
|
|
61
|
+
if (autoRotate.idleRotationWaitTime !== undefined) {
|
|
62
|
+
behavior.idleRotationWaitTime = autoRotate.idleRotationWaitTime;
|
|
63
|
+
}
|
|
64
|
+
if (autoRotate.zoomStopsAnimation !== undefined) {
|
|
65
|
+
behavior.zoomStopsAnimation = autoRotate.zoomStopsAnimation;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
this._camera.useAutoRotationBehavior = false;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
addEventListener(event, listener) {
|
|
74
|
+
switch (event) {
|
|
75
|
+
case "orbitalCameraConfiguration":
|
|
76
|
+
if (this._orbitalCameraConfigurationObservable === undefined) {
|
|
77
|
+
this._orbitalCameraConfigurationObservable =
|
|
78
|
+
new Observable();
|
|
79
|
+
}
|
|
80
|
+
this._orbitalCameraConfigurationObservable.listen(listener);
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
super.addEventListener(event, listener);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
removeEventListener(event, listener) {
|
|
87
|
+
switch (event) {
|
|
88
|
+
case "orbitalCameraConfiguration":
|
|
89
|
+
if (this._orbitalCameraConfigurationObservable === undefined) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this._orbitalCameraConfigurationObservable.stopListen(listener);
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
super.removeEventListener(event, listener);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
get orbitalCameraConfiguration() {
|
|
99
|
+
const camera = this._camera;
|
|
100
|
+
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);
|
|
101
|
+
}
|
|
102
|
+
notifyCameraListeners() {
|
|
103
|
+
super.notifyCameraListeners();
|
|
104
|
+
if (this._orbitalCameraConfigurationObservable === undefined) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const cameraConf = this.orbitalCameraConfiguration;
|
|
108
|
+
if (this._previousOrbitalCameraConf !== undefined &&
|
|
109
|
+
orbitalCameraConfigurationPropsEquals(this._previousOrbitalCameraConf, cameraConf)) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this._orbitalCameraConfigurationObservable.notifyAll(cameraConf, this._orbitalCameraConfigurationObservable);
|
|
113
|
+
this._previousOrbitalCameraConf = cameraConf;
|
|
114
|
+
}
|
|
115
|
+
get cameraControlObservable() {
|
|
116
|
+
return this._camera.cameraControlObservable;
|
|
117
|
+
}
|
|
118
|
+
get contentCenter() {
|
|
119
|
+
return this._camera.target;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* @param force true means force apply camera distance and camera bounds. false means force do not apply.
|
|
123
|
+
*/
|
|
124
|
+
handleSizing(force) {
|
|
125
|
+
super.handleSizing(force);
|
|
126
|
+
if (this._viewportSize === undefined) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const currentProductNode = this.currentProductNode;
|
|
130
|
+
const boundingBox = currentProductNode === undefined
|
|
131
|
+
? new CfgBoundingBox()
|
|
132
|
+
: currentProductNode.boundingBox;
|
|
133
|
+
boundingBox.applyMatrix(CET_TO_BABYLON_MATRIX);
|
|
134
|
+
const initialCameraDistanceSetPreventsInitialAutoSizingSet = this.isFirstLoad && this._cameraDefaults.distance !== undefined;
|
|
135
|
+
this._camera.setContentBoundingBox(boundingBox, initialCameraDistanceSetPreventsInitialAutoSizingSet ? false : force ? true : undefined);
|
|
136
|
+
if (!boundingBox.isEmpty) {
|
|
137
|
+
this._lightRig.scale =
|
|
138
|
+
measureLongestDistanceToCorner(boundingBox, [0, 1, 2]) *
|
|
139
|
+
CONTENT_TO_LIGHT_RIG_SCALE_FACTOR;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
refreshCameraNearFar() {
|
|
143
|
+
super.refreshCameraNearFar();
|
|
144
|
+
this._camera.refreshCameraNearFar();
|
|
145
|
+
}
|
|
146
|
+
getNeededFrameRender(time) {
|
|
147
|
+
return super.getNeededFrameRender(time) || this._camera.frameRenderNeeded();
|
|
148
|
+
}
|
|
149
|
+
}
|