@configura/babylon-view 2.2.0-alpha.1 → 2.2.0-alpha.3
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/animation/index.d.ts +5 -0
- package/dist/animation/index.js +4 -0
- 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/camera/index.d.ts +6 -0
- package/dist/camera/index.js +5 -0
- package/dist/engine/EngineCreator.d.ts +3 -3
- package/dist/engine/EngineCreator.js +10 -10
- package/dist/engine/index.d.ts +2 -0
- package/dist/engine/index.js +1 -0
- 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 +8 -16
- package/dist/index.js +8 -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/io/index.d.ts +4 -0
- package/dist/io/index.js +3 -0
- 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 +23 -19
- package/dist/light/DefaultLightRig.js +82 -77
- package/dist/light/LightRigCreator.d.ts +9 -9
- package/dist/light/LightRigCreator.js +3 -3
- package/dist/light/index.d.ts +6 -0
- package/dist/light/index.js +5 -0
- 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/scene/index.d.ts +2 -0
- package/dist/scene/index.js +1 -0
- 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/index.d.ts +4 -0
- package/dist/utilities/index.js +3 -0
- 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/dist/view/index.d.ts +8 -0
- package/dist/view/index.js +7 -0
- package/package.json +5 -5
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
2
|
-
import { Color } from "@configura/web-core/dist/cm/basic/Color.js";
|
|
3
|
-
import { ColorF } from "@configura/web-core/dist/cm/basic/ColorF.js";
|
|
4
|
-
/**
|
|
5
|
-
* Converts a number of different color formats into Color3 for use with Babylon.js
|
|
6
|
-
* Returns White if object is undefined.
|
|
7
|
-
*/
|
|
8
|
-
export function toColor3(object) {
|
|
9
|
-
if (object === undefined) {
|
|
10
|
-
return Color3.White();
|
|
11
|
-
}
|
|
12
|
-
if (typeof object === "number") {
|
|
13
|
-
// Assume object is a 24 bit integer
|
|
14
|
-
return Color3.FromInts((object >>> 16) & 0xff, (object >>> 8) & 0xff, object & 0xff);
|
|
15
|
-
}
|
|
16
|
-
if (typeof object === "string") {
|
|
17
|
-
// Assume object is a hex-string
|
|
18
|
-
return Color3.FromHexString(object);
|
|
19
|
-
}
|
|
20
|
-
if (object instanceof ColorF) {
|
|
21
|
-
// Object is a DEX ColorF (floats, 0-1)
|
|
22
|
-
return new Color3(object.r, object.g, object.b);
|
|
23
|
-
}
|
|
24
|
-
if (object instanceof Color) {
|
|
25
|
-
// Object is a DEX Color (integers 0-255)
|
|
26
|
-
return Color3.FromInts(object.r, object.g, object.b);
|
|
27
|
-
}
|
|
28
|
-
// Must be Color3 already
|
|
29
|
-
return object;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* in: r,g,b in [0,1], out: h in [0,360) and s,l in [0,1]
|
|
33
|
-
* Original source: https://stackoverflow.com/a/54071699/1488048
|
|
34
|
-
*/
|
|
35
|
-
export function rgb2hsl(r, g, b) {
|
|
36
|
-
const a = Math.max(r, g, b);
|
|
37
|
-
const n = a - Math.min(r, g, b);
|
|
38
|
-
const f = 1 - Math.abs(a + a - n - 1);
|
|
39
|
-
const h = n && (a === r ? (g - b) / n : a === g ? 2 + (b - r) / n : 4 + (r - g) / n);
|
|
40
|
-
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* input: h in [0,360] and s,v in [0,1] - output: r,g,b in [0,1]
|
|
44
|
-
* Original source: https://stackoverflow.com/a/54014428/1488048
|
|
45
|
-
*/
|
|
46
|
-
export function hsl2rgb(h, s, l) {
|
|
47
|
-
const a = s * Math.min(l, 1 - l);
|
|
48
|
-
const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
49
|
-
return [f(0), f(8), f(4)];
|
|
50
|
-
}
|
|
1
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
|
2
|
+
import { Color } from "@configura/web-core/dist/cm/basic/Color.js";
|
|
3
|
+
import { ColorF } from "@configura/web-core/dist/cm/basic/ColorF.js";
|
|
4
|
+
/**
|
|
5
|
+
* Converts a number of different color formats into Color3 for use with Babylon.js
|
|
6
|
+
* Returns White if object is undefined.
|
|
7
|
+
*/
|
|
8
|
+
export function toColor3(object) {
|
|
9
|
+
if (object === undefined) {
|
|
10
|
+
return Color3.White();
|
|
11
|
+
}
|
|
12
|
+
if (typeof object === "number") {
|
|
13
|
+
// Assume object is a 24 bit integer
|
|
14
|
+
return Color3.FromInts((object >>> 16) & 0xff, (object >>> 8) & 0xff, object & 0xff);
|
|
15
|
+
}
|
|
16
|
+
if (typeof object === "string") {
|
|
17
|
+
// Assume object is a hex-string
|
|
18
|
+
return Color3.FromHexString(object);
|
|
19
|
+
}
|
|
20
|
+
if (object instanceof ColorF) {
|
|
21
|
+
// Object is a DEX ColorF (floats, 0-1)
|
|
22
|
+
return new Color3(object.r, object.g, object.b);
|
|
23
|
+
}
|
|
24
|
+
if (object instanceof Color) {
|
|
25
|
+
// Object is a DEX Color (integers 0-255)
|
|
26
|
+
return Color3.FromInts(object.r, object.g, object.b);
|
|
27
|
+
}
|
|
28
|
+
// Must be Color3 already
|
|
29
|
+
return object;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* in: r,g,b in [0,1], out: h in [0,360) and s,l in [0,1]
|
|
33
|
+
* Original source: https://stackoverflow.com/a/54071699/1488048
|
|
34
|
+
*/
|
|
35
|
+
export function rgb2hsl(r, g, b) {
|
|
36
|
+
const a = Math.max(r, g, b);
|
|
37
|
+
const n = a - Math.min(r, g, b);
|
|
38
|
+
const f = 1 - Math.abs(a + a - n - 1);
|
|
39
|
+
const h = n && (a === r ? (g - b) / n : a === g ? 2 + (b - r) / n : 4 + (r - g) / n);
|
|
40
|
+
return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* input: h in [0,360] and s,v in [0,1] - output: r,g,b in [0,1]
|
|
44
|
+
* Original source: https://stackoverflow.com/a/54014428/1488048
|
|
45
|
+
*/
|
|
46
|
+
export function hsl2rgb(h, s, l) {
|
|
47
|
+
const a = s * Math.min(l, 1 - l);
|
|
48
|
+
const f = (n, k = (n + h / 30) % 12) => l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
|
|
49
|
+
return [f(0), f(8), f(4)];
|
|
50
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Color } from "@configura/web-core/dist/cm/basic/Color.js";
|
|
2
|
-
export declare function aggregateImage<T>(image: HTMLImageElement, aggregator: (imgData: ImageData) => T): T | undefined;
|
|
3
|
-
export declare function calculateLightnessFromImage(image: HTMLImageElement): number | undefined;
|
|
4
|
-
export declare function allPixelsAreColor(image: HTMLImageElement): false | Color;
|
|
5
|
-
export declare function isLikelyBumpMap(image: HTMLImageElement, acceptableDeviationFromGray?: number): boolean;
|
|
6
|
-
export declare function isLikelyNormalMap(image: HTMLImageElement): boolean;
|
|
1
|
+
import { Color } from "@configura/web-core/dist/cm/basic/Color.js";
|
|
2
|
+
export declare function aggregateImage<T>(image: HTMLImageElement, aggregator: (imgData: ImageData) => T): T | undefined;
|
|
3
|
+
export declare function calculateLightnessFromImage(image: HTMLImageElement): number | undefined;
|
|
4
|
+
export declare function allPixelsAreColor(image: HTMLImageElement): false | Color;
|
|
5
|
+
export declare function isLikelyBumpMap(image: HTMLImageElement, acceptableDeviationFromGray?: number): boolean;
|
|
6
|
+
export declare function isLikelyNormalMap(image: HTMLImageElement): boolean;
|
|
7
7
|
//# sourceMappingURL=utilitiesImage.d.ts.map
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import { Color, ColorType } from "@configura/web-core/dist/cm/basic/Color.js";
|
|
2
|
-
export function aggregateImage(image, aggregator) {
|
|
3
|
-
const canvas = document.createElement("canvas");
|
|
4
|
-
canvas.width = image.width;
|
|
5
|
-
canvas.height = image.height;
|
|
6
|
-
const context = canvas.getContext("2d");
|
|
7
|
-
if (context !== null) {
|
|
8
|
-
context.drawImage(image, 0, 0);
|
|
9
|
-
const imgData = context.getImageData(0, 0, image.width, image.height);
|
|
10
|
-
return aggregator(imgData);
|
|
11
|
-
}
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
const CC = 4; // All imageData will be 4 channel (RGBA)
|
|
15
|
-
export function calculateLightnessFromImage(image) {
|
|
16
|
-
return aggregateImage(image, (imgData) => {
|
|
17
|
-
let t = 0;
|
|
18
|
-
const data = imgData.data;
|
|
19
|
-
const size = data.length;
|
|
20
|
-
for (let i = 0; i < size; i += CC) {
|
|
21
|
-
const r = data[i];
|
|
22
|
-
const g = data[i + 1];
|
|
23
|
-
const b = data[i + 2];
|
|
24
|
-
t += Math.max(r, g, b) + Math.min(r, g, b);
|
|
25
|
-
}
|
|
26
|
-
const average = (2 * t) / (size * 255);
|
|
27
|
-
return average;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
export function allPixelsAreColor(image) {
|
|
31
|
-
return (aggregateImage(image, (imgData) => {
|
|
32
|
-
const data = imgData.data;
|
|
33
|
-
const size = data.length;
|
|
34
|
-
if (size === 0) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
for (let i = 0; i < size; i++) {
|
|
38
|
-
if (i < CC) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (data[i] !== data[i % CC]) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return new Color(ColorType.rgbaColor, data[0], data[1], data[2], data[3]);
|
|
46
|
-
}) || false);
|
|
47
|
-
}
|
|
48
|
-
export function isLikelyBumpMap(image, acceptableDeviationFromGray = 0) {
|
|
49
|
-
const isAcceptableDeviation = (c1, c2) => {
|
|
50
|
-
const pxAcceptableDeviation = acceptableDeviationFromGray * 255;
|
|
51
|
-
return Math.abs(c1 - c2) < pxAcceptableDeviation;
|
|
52
|
-
};
|
|
53
|
-
return (aggregateImage(image, (imgData) => {
|
|
54
|
-
const data = imgData.data;
|
|
55
|
-
const size = data.length;
|
|
56
|
-
const variationsInChannels = [false, false, false];
|
|
57
|
-
for (let i = 0; i < size; i += CC) {
|
|
58
|
-
const r = data[i];
|
|
59
|
-
const g = data[i + 1];
|
|
60
|
-
const b = data[i + 2];
|
|
61
|
-
if (isAcceptableDeviation(r, g) &&
|
|
62
|
-
isAcceptableDeviation(g, b) &&
|
|
63
|
-
isAcceptableDeviation(b, r)) {
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
if (i === 0) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
let variedChannelsCount = 0;
|
|
70
|
-
for (let j = 0; j < CC - 1; j++) {
|
|
71
|
-
if (data[i + j] !== data[j]) {
|
|
72
|
-
variationsInChannels[j] = true;
|
|
73
|
-
}
|
|
74
|
-
if (variationsInChannels[j]) {
|
|
75
|
-
variedChannelsCount++;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (1 < variedChannelsCount) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return true;
|
|
83
|
-
}) || false);
|
|
84
|
-
}
|
|
85
|
-
export function isLikelyNormalMap(image) {
|
|
86
|
-
// A normal map represents the local surface inclination (direction, slope) relative
|
|
87
|
-
// to the texture. In every pixel the values RGB represent the three base vectors XYZ.
|
|
88
|
-
// A complete flat surface will have all normals pointing straight out of the texture,
|
|
89
|
-
// in the Z-direction. This is the blue component. Therefore a normal map will normally
|
|
90
|
-
// look blueish. We here test that we have a certain amount more of blue than the other
|
|
91
|
-
// components to see if the is likely a normal-map.
|
|
92
|
-
const blueMoreThanRedAndGreenThreshold = 1.2;
|
|
93
|
-
return (aggregateImage(image, (imgData) => {
|
|
94
|
-
const data = imgData.data;
|
|
95
|
-
const size = data.length;
|
|
96
|
-
const channelSum = [0, 0, 0];
|
|
97
|
-
for (let i = 0; i < size; i++) {
|
|
98
|
-
const comp = i % CC;
|
|
99
|
-
if (comp === 3) {
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
channelSum[comp] += data[i];
|
|
103
|
-
}
|
|
104
|
-
const [r, g, b] = channelSum;
|
|
105
|
-
return (blueMoreThanRedAndGreenThreshold < b / r && blueMoreThanRedAndGreenThreshold < b / g);
|
|
106
|
-
}) || false);
|
|
107
|
-
}
|
|
1
|
+
import { Color, ColorType } from "@configura/web-core/dist/cm/basic/Color.js";
|
|
2
|
+
export function aggregateImage(image, aggregator) {
|
|
3
|
+
const canvas = document.createElement("canvas");
|
|
4
|
+
canvas.width = image.width;
|
|
5
|
+
canvas.height = image.height;
|
|
6
|
+
const context = canvas.getContext("2d");
|
|
7
|
+
if (context !== null) {
|
|
8
|
+
context.drawImage(image, 0, 0);
|
|
9
|
+
const imgData = context.getImageData(0, 0, image.width, image.height);
|
|
10
|
+
return aggregator(imgData);
|
|
11
|
+
}
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const CC = 4; // All imageData will be 4 channel (RGBA)
|
|
15
|
+
export function calculateLightnessFromImage(image) {
|
|
16
|
+
return aggregateImage(image, (imgData) => {
|
|
17
|
+
let t = 0;
|
|
18
|
+
const data = imgData.data;
|
|
19
|
+
const size = data.length;
|
|
20
|
+
for (let i = 0; i < size; i += CC) {
|
|
21
|
+
const r = data[i];
|
|
22
|
+
const g = data[i + 1];
|
|
23
|
+
const b = data[i + 2];
|
|
24
|
+
t += Math.max(r, g, b) + Math.min(r, g, b);
|
|
25
|
+
}
|
|
26
|
+
const average = (2 * t) / (size * 255);
|
|
27
|
+
return average;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
export function allPixelsAreColor(image) {
|
|
31
|
+
return (aggregateImage(image, (imgData) => {
|
|
32
|
+
const data = imgData.data;
|
|
33
|
+
const size = data.length;
|
|
34
|
+
if (size === 0) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
for (let i = 0; i < size; i++) {
|
|
38
|
+
if (i < CC) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (data[i] !== data[i % CC]) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return new Color(ColorType.rgbaColor, data[0], data[1], data[2], data[3]);
|
|
46
|
+
}) || false);
|
|
47
|
+
}
|
|
48
|
+
export function isLikelyBumpMap(image, acceptableDeviationFromGray = 0) {
|
|
49
|
+
const isAcceptableDeviation = (c1, c2) => {
|
|
50
|
+
const pxAcceptableDeviation = acceptableDeviationFromGray * 255;
|
|
51
|
+
return Math.abs(c1 - c2) < pxAcceptableDeviation;
|
|
52
|
+
};
|
|
53
|
+
return (aggregateImage(image, (imgData) => {
|
|
54
|
+
const data = imgData.data;
|
|
55
|
+
const size = data.length;
|
|
56
|
+
const variationsInChannels = [false, false, false];
|
|
57
|
+
for (let i = 0; i < size; i += CC) {
|
|
58
|
+
const r = data[i];
|
|
59
|
+
const g = data[i + 1];
|
|
60
|
+
const b = data[i + 2];
|
|
61
|
+
if (isAcceptableDeviation(r, g) &&
|
|
62
|
+
isAcceptableDeviation(g, b) &&
|
|
63
|
+
isAcceptableDeviation(b, r)) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
if (i === 0) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
let variedChannelsCount = 0;
|
|
70
|
+
for (let j = 0; j < CC - 1; j++) {
|
|
71
|
+
if (data[i + j] !== data[j]) {
|
|
72
|
+
variationsInChannels[j] = true;
|
|
73
|
+
}
|
|
74
|
+
if (variationsInChannels[j]) {
|
|
75
|
+
variedChannelsCount++;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (1 < variedChannelsCount) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}) || false);
|
|
84
|
+
}
|
|
85
|
+
export function isLikelyNormalMap(image) {
|
|
86
|
+
// A normal map represents the local surface inclination (direction, slope) relative
|
|
87
|
+
// to the texture. In every pixel the values RGB represent the three base vectors XYZ.
|
|
88
|
+
// A complete flat surface will have all normals pointing straight out of the texture,
|
|
89
|
+
// in the Z-direction. This is the blue component. Therefore a normal map will normally
|
|
90
|
+
// look blueish. We here test that we have a certain amount more of blue than the other
|
|
91
|
+
// components to see if the is likely a normal-map.
|
|
92
|
+
const blueMoreThanRedAndGreenThreshold = 1.2;
|
|
93
|
+
return (aggregateImage(image, (imgData) => {
|
|
94
|
+
const data = imgData.data;
|
|
95
|
+
const size = data.length;
|
|
96
|
+
const channelSum = [0, 0, 0];
|
|
97
|
+
for (let i = 0; i < size; i++) {
|
|
98
|
+
const comp = i % CC;
|
|
99
|
+
if (comp === 3) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
channelSum[comp] += data[i];
|
|
103
|
+
}
|
|
104
|
+
const [r, g, b] = channelSum;
|
|
105
|
+
return (blueMoreThanRedAndGreenThreshold < b / r && blueMoreThanRedAndGreenThreshold < b / g);
|
|
106
|
+
}) || false);
|
|
107
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { DtoTransform as ModelTransform, RootNodeSource } from "@configura/web-api";
|
|
2
|
-
import { CfgAnchorRef } from "./anchor/anchor.js";
|
|
3
|
-
export declare function makeIdentifier(type: "uri" | "file", v: string): string;
|
|
4
|
-
export declare function identifierIsUri(identifier: string): boolean;
|
|
5
|
-
export declare function makeIdentifierFromRootNodeSource(source: RootNodeSource): string;
|
|
6
|
-
export declare function isSameIdentifierTransformAndAnchor(identifier1: string, transform1: ModelTransform | undefined, anchor1: CfgAnchorRef | undefined, identifier2: string, transform2: ModelTransform | undefined, anchor2: CfgAnchorRef | undefined): boolean;
|
|
7
|
-
export declare function isSameRootNodeSource(source1: RootNodeSource, source2: RootNodeSource): boolean;
|
|
1
|
+
import { DtoTransform as ModelTransform, RootNodeSource } from "@configura/web-api";
|
|
2
|
+
import { CfgAnchorRef } from "./anchor/anchor.js";
|
|
3
|
+
export declare function makeIdentifier(type: "uri" | "file", v: string): string;
|
|
4
|
+
export declare function identifierIsUri(identifier: string): boolean;
|
|
5
|
+
export declare function makeIdentifierFromRootNodeSource(source: RootNodeSource): string;
|
|
6
|
+
export declare function isSameIdentifierTransformAndAnchor(identifier1: string, transform1: ModelTransform | undefined, anchor1: CfgAnchorRef | undefined, identifier2: string, transform2: ModelTransform | undefined, anchor2: CfgAnchorRef | undefined): boolean;
|
|
7
|
+
export declare function isSameRootNodeSource(source1: RootNodeSource, source2: RootNodeSource): boolean;
|
|
8
8
|
//# sourceMappingURL=utilitiesSymRootIdentifier.d.ts.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { isModel } from "@configura/web-api";
|
|
2
|
-
import { CfgAnchorRef } from "./anchor/anchor.js";
|
|
3
|
-
import { modelTransformsEqual } from "./utilities3D.js";
|
|
4
|
-
export function makeIdentifier(type, v) {
|
|
5
|
-
return `${type}:${v}`;
|
|
6
|
-
}
|
|
7
|
-
export function identifierIsUri(identifier) {
|
|
8
|
-
return identifier.startsWith("uri:");
|
|
9
|
-
}
|
|
10
|
-
export function makeIdentifierFromRootNodeSource(source) {
|
|
11
|
-
return isModel(source)
|
|
12
|
-
? makeIdentifier("uri", source.uri)
|
|
13
|
-
: makeIdentifier("file", source.name);
|
|
14
|
-
}
|
|
15
|
-
export function isSameIdentifierTransformAndAnchor(identifier1, transform1, anchor1, identifier2, transform2, anchor2) {
|
|
16
|
-
return (identifier1 === identifier2 &&
|
|
17
|
-
((transform1 === undefined && transform2 === undefined) ||
|
|
18
|
-
(transform1 !== undefined &&
|
|
19
|
-
transform2 !== undefined &&
|
|
20
|
-
modelTransformsEqual(transform1, transform2))) &&
|
|
21
|
-
((anchor1 === undefined && anchor2 === undefined) ||
|
|
22
|
-
(anchor1 !== undefined && anchor2 !== undefined && anchor1.equal(anchor2))));
|
|
23
|
-
}
|
|
24
|
-
export function isSameRootNodeSource(source1, source2) {
|
|
25
|
-
return isSameIdentifierTransformAndAnchor(makeIdentifierFromRootNodeSource(source1), isModel(source1) ? source1.t : undefined, isModel(source1) ? CfgAnchorRef.make(source1.anchor) : undefined, makeIdentifierFromRootNodeSource(source2), isModel(source2) ? source2.t : undefined, isModel(source2) ? CfgAnchorRef.make(source2.anchor) : undefined);
|
|
26
|
-
}
|
|
1
|
+
import { isModel } from "@configura/web-api";
|
|
2
|
+
import { CfgAnchorRef } from "./anchor/anchor.js";
|
|
3
|
+
import { modelTransformsEqual } from "./utilities3D.js";
|
|
4
|
+
export function makeIdentifier(type, v) {
|
|
5
|
+
return `${type}:${v}`;
|
|
6
|
+
}
|
|
7
|
+
export function identifierIsUri(identifier) {
|
|
8
|
+
return identifier.startsWith("uri:");
|
|
9
|
+
}
|
|
10
|
+
export function makeIdentifierFromRootNodeSource(source) {
|
|
11
|
+
return isModel(source)
|
|
12
|
+
? makeIdentifier("uri", source.uri)
|
|
13
|
+
: makeIdentifier("file", source.name);
|
|
14
|
+
}
|
|
15
|
+
export function isSameIdentifierTransformAndAnchor(identifier1, transform1, anchor1, identifier2, transform2, anchor2) {
|
|
16
|
+
return (identifier1 === identifier2 &&
|
|
17
|
+
((transform1 === undefined && transform2 === undefined) ||
|
|
18
|
+
(transform1 !== undefined &&
|
|
19
|
+
transform2 !== undefined &&
|
|
20
|
+
modelTransformsEqual(transform1, transform2))) &&
|
|
21
|
+
((anchor1 === undefined && anchor2 === undefined) ||
|
|
22
|
+
(anchor1 !== undefined && anchor2 !== undefined && anchor1.equal(anchor2))));
|
|
23
|
+
}
|
|
24
|
+
export function isSameRootNodeSource(source1, source2) {
|
|
25
|
+
return isSameIdentifierTransformAndAnchor(makeIdentifierFromRootNodeSource(source1), isModel(source1) ? source1.t : undefined, isModel(source1) ? CfgAnchorRef.make(source1.anchor) : undefined, makeIdentifierFromRootNodeSource(source2), isModel(source2) ? source2.t : undefined, isModel(source2) ? CfgAnchorRef.make(source2.anchor) : undefined);
|
|
26
|
+
}
|
package/dist/view/BaseView.d.ts
CHANGED
|
@@ -1,79 +1,81 @@
|
|
|
1
|
-
import { Camera } from "@babylonjs/core/Cameras/camera.js";
|
|
2
|
-
import "@babylonjs/core/Debug/debugLayer.js";
|
|
3
|
-
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
4
|
-
import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
5
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
|
6
|
-
import { AggregatedLoadingObservable, EventListener, Observable } from "@configura/web-utilities";
|
|
7
|
-
import { CameraCreator } from "../camera/CameraCreator.js";
|
|
8
|
-
import { GradingApplier } from "../camera/GradingApplier.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
export declare const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
export declare
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
protected
|
|
39
|
-
protected
|
|
40
|
-
protected
|
|
41
|
-
protected
|
|
42
|
-
protected
|
|
43
|
-
protected
|
|
44
|
-
protected
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
private
|
|
50
|
-
private
|
|
51
|
-
|
|
52
|
-
protected
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
protected
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
protected
|
|
73
|
-
protected
|
|
74
|
-
|
|
75
|
-
protected
|
|
76
|
-
|
|
77
|
-
protected
|
|
78
|
-
|
|
1
|
+
import { Camera } from "@babylonjs/core/Cameras/camera.js";
|
|
2
|
+
import "@babylonjs/core/Debug/debugLayer.js";
|
|
3
|
+
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
4
|
+
import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
5
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
|
6
|
+
import { AggregatedLoadingObservable, EventListener, Observable } from "@configura/web-utilities";
|
|
7
|
+
import { CameraCreator } from "../camera/CameraCreator.js";
|
|
8
|
+
import { GradingApplier } from "../camera/GradingApplier.js";
|
|
9
|
+
import { SSAO2PipelineConfiguration } from "../camera/SSAO2PipelineCreator.js";
|
|
10
|
+
import { EngineCreator } from "../engine/EngineCreator.js";
|
|
11
|
+
import { LightRig, LightRigCreator } from "../light/LightRigCreator.js";
|
|
12
|
+
import { DummyMaterialCreator } from "../material/DummyMaterialCreator.js";
|
|
13
|
+
import { CfgContentRootNode } from "../nodes/CfgContentRootNode.js";
|
|
14
|
+
import { SceneCreator } from "../scene/SceneCreator.js";
|
|
15
|
+
import { BaseViewConfiguration, BaseViewEventMap, CameraConfigurationProps, DetailLevel, ImageDumpCallback } from "./BaseViewConfiguration.js";
|
|
16
|
+
import { RenderEnv } from "./RenderEnv";
|
|
17
|
+
export declare const CET_TO_BABYLON_MATRIX: Matrix;
|
|
18
|
+
export declare const BABYLON_TO_CET_MATRIX: Matrix;
|
|
19
|
+
/**
|
|
20
|
+
* Load the highest quality meshes by default.
|
|
21
|
+
*
|
|
22
|
+
* @remarks We only use "base" as a last fallback. The reason is that even though this LOD level
|
|
23
|
+
* could theoretically include a better version than "super" it is not normally included in CmSym
|
|
24
|
+
* files and never used by CET, which makes it unpredictable. See WRD-387 for a case where it
|
|
25
|
+
* caused problems when it was the first choice.
|
|
26
|
+
*/
|
|
27
|
+
export declare const DEFAULT_DETAIL_LEVELS: DetailLevel[];
|
|
28
|
+
export declare type BaseViewConstructorOptions<C extends Camera> = {
|
|
29
|
+
canvas: HTMLCanvasElement;
|
|
30
|
+
cameraCreator: CameraCreator<C>;
|
|
31
|
+
engineCreator?: EngineCreator;
|
|
32
|
+
lightRigCreator?: LightRigCreator;
|
|
33
|
+
sceneCreator?: SceneCreator;
|
|
34
|
+
gradingApplier?: GradingApplier;
|
|
35
|
+
dummyMaterialCreator?: DummyMaterialCreator;
|
|
36
|
+
};
|
|
37
|
+
export declare abstract class BaseView<C extends Camera, T extends BaseViewEventMap = BaseViewEventMap> {
|
|
38
|
+
protected _destroyed: boolean;
|
|
39
|
+
protected _viewportSize: [number, number] | undefined;
|
|
40
|
+
protected _canvas: HTMLCanvasElement;
|
|
41
|
+
protected _scene: Scene;
|
|
42
|
+
protected _engine: Engine;
|
|
43
|
+
protected _camera: C;
|
|
44
|
+
protected _lightRig: LightRig;
|
|
45
|
+
protected _inspectorActive: boolean;
|
|
46
|
+
private _cameraConfigurationObservable;
|
|
47
|
+
private _previousCameraConf;
|
|
48
|
+
protected _contentRoot: CfgContentRootNode;
|
|
49
|
+
private _needsRenderFrame;
|
|
50
|
+
private _dumpNextFrameToImage;
|
|
51
|
+
private _enginePauseSemaphore;
|
|
52
|
+
protected _errorObservable: Observable<Error>;
|
|
53
|
+
protected _loadingObservable: AggregatedLoadingObservable;
|
|
54
|
+
private _renderEnvironmentObservable;
|
|
55
|
+
protected _renderEnvironment: RenderEnv;
|
|
56
|
+
private _dummyMaterialCreator;
|
|
57
|
+
constructor(options: BaseViewConstructorOptions<C>);
|
|
58
|
+
destroy(): void;
|
|
59
|
+
pauseRendering(): void;
|
|
60
|
+
resumeRendering(): void;
|
|
61
|
+
private _hideInspector;
|
|
62
|
+
showInspector(target: HTMLElement | undefined): void;
|
|
63
|
+
enablePipeline(enabled: boolean | undefined, config: SSAO2PipelineConfiguration): void;
|
|
64
|
+
setConfiguration(configuration: BaseViewConfiguration): void;
|
|
65
|
+
get cameraConfiguration(): CameraConfigurationProps;
|
|
66
|
+
protected get contentCenter(): Vector3;
|
|
67
|
+
private _boundNotifyCameraListeners;
|
|
68
|
+
protected notifyCameraListeners(): void;
|
|
69
|
+
addEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
70
|
+
removeEventListener<K extends keyof T>(event: K, listener: EventListener<T, K>): void;
|
|
71
|
+
scheduleRerender(dumpNextFrameToImage?: ImageDumpCallback): void;
|
|
72
|
+
protected isContinuousRender(): boolean;
|
|
73
|
+
protected getNeededFrameRender(time: number): boolean;
|
|
74
|
+
protected browserTick(time: number): void;
|
|
75
|
+
protected renderFrame(time: number): void;
|
|
76
|
+
resizeViewport(width: number, height: number): void;
|
|
77
|
+
protected handleSizing(_force: boolean): void;
|
|
78
|
+
protected refreshCameraNearFar(): void;
|
|
79
|
+
protected notifyError: (e: unknown) => void;
|
|
80
|
+
}
|
|
79
81
|
//# sourceMappingURL=BaseView.d.ts.map
|