@configura/babylon-view 1.6.1 → 2.0.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 +18 -18
- 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/CfgArcRotateCameraPointersInput.d.ts +26 -26
- package/dist/camera/CfgArcRotateCameraPointersInput.js +266 -266
- package/dist/camera/CfgOrbitalCamera.d.ts +73 -68
- package/dist/camera/CfgOrbitalCamera.js +260 -250
- package/dist/camera/CfgOrbitalCameraControlProps.d.ts +11 -6
- package/dist/camera/CfgOrbitalCameraControlProps.js +6 -3
- package/dist/camera/GradingApplier.d.ts +3 -3
- package/dist/camera/GradingApplier.js +48 -48
- package/dist/engine/EngineCreator.d.ts +3 -3
- package/dist/engine/EngineCreator.js +10 -10
- package/dist/geometry/CfgGeometry.d.ts +29 -29
- package/dist/geometry/CfgGeometry.js +146 -146
- package/dist/geometry/CfgMesh.d.ts +10 -10
- package/dist/geometry/CfgMesh.js +38 -38
- package/dist/geometry/geoSplitter.d.ts +8 -8
- package/dist/geometry/geoSplitter.js +192 -192
- package/dist/geometry/stretch/CfgMorphTarget.d.ts +15 -15
- package/dist/geometry/stretch/CfgMorphTarget.js +65 -65
- package/dist/geometry/stretch/CfgStretchData.d.ts +116 -116
- package/dist/geometry/stretch/CfgStretchData.js +350 -350
- package/dist/geometry/stretch/CfgStretchMorphGeometry.d.ts +16 -16
- package/dist/geometry/stretch/CfgStretchMorphGeometry.js +95 -95
- package/dist/index.d.ts +16 -13
- package/dist/index.js +16 -13
- package/dist/io/CfgHistoryToCameraConfConnector.d.ts +30 -0
- package/dist/io/CfgHistoryToCameraConfConnector.js +80 -0
- package/dist/io/CfgIOCameraConfConnector.d.ts +36 -0
- package/dist/io/CfgIOCameraConfConnector.js +82 -0
- package/dist/io/CfgObservableStateToCameraConfConnector.d.ts +11 -0
- package/dist/io/CfgObservableStateToCameraConfConnector.js +11 -0
- package/dist/io/CfgWindowMessageToCameraConfConnector.d.ts +11 -0
- package/dist/io/CfgWindowMessageToCameraConfConnector.js +11 -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 +19 -19
- package/dist/light/DefaultLightRig.js +77 -77
- package/dist/light/LightRigCreator.d.ts +9 -9
- package/dist/light/LightRigCreator.js +3 -3
- package/dist/material/CfgMaterial.d.ts +68 -68
- package/dist/material/CfgMaterial.js +482 -482
- package/dist/material/DummyMaterialCreator.d.ts +4 -4
- package/dist/material/DummyMaterialCreator.js +15 -15
- package/dist/material/material.d.ts +18 -18
- package/dist/material/material.js +128 -128
- package/dist/material/texture.d.ts +14 -14
- package/dist/material/texture.js +306 -306
- package/dist/nodes/CfgContentRootNode.d.ts +19 -19
- package/dist/nodes/CfgContentRootNode.js +75 -75
- package/dist/nodes/CfgDeferredMeshNode.d.ts +55 -55
- package/dist/nodes/CfgDeferredMeshNode.js +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 +229 -229
- 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 +265 -265
- 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 +78 -78
- package/dist/view/BaseView.js +303 -303
- package/dist/view/BaseViewConfiguration.d.ts +32 -32
- package/dist/view/BaseViewConfiguration.js +10 -10
- package/dist/view/RenderEnv.d.ts +43 -43
- package/dist/view/RenderEnv.js +7 -7
- package/dist/view/SingleProductDefaultCameraView.d.ts +37 -34
- package/dist/view/SingleProductDefaultCameraView.js +145 -141
- package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +42 -46
- package/dist/view/SingleProductDefaultCameraViewConfiguration.js +11 -11
- package/dist/view/SingleProductView.d.ts +44 -42
- package/dist/view/SingleProductView.js +212 -207
- package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
- package/dist/view/SingleProductViewConfiguration.js +19 -19
- package/package.json +5 -5
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import { ColorCurves } from "@babylonjs/core/Materials/colorCurves.js";
|
|
2
|
-
import { ImageProcessingConfiguration } from "@babylonjs/core/Materials/imageProcessingConfiguration.js";
|
|
3
|
-
import { DefaultRenderingPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js";
|
|
4
|
-
export const getDefaultGradingApplier = () => (camera) => {
|
|
5
|
-
const scene = camera.getScene();
|
|
6
|
-
// The second parameter below is HDR which is supposed to be enabled "as long as possible"
|
|
7
|
-
// according to the documentation. However, doing so causes problems with rendering against
|
|
8
|
-
// our transparent background:
|
|
9
|
-
// - Anti-aliasing breaks for very white colors (BanquetChair2 in ConfiguraKitchenAccessories)
|
|
10
|
-
// - Transparent objects gets rendered very differently against the transparent background
|
|
11
|
-
// compared to over a opaque surface (Electric Cart in ConfiguraIndustrialEquipment)
|
|
12
|
-
// - Transparent objects gets a very bright and color shifting results (ConfiguraHumans)
|
|
13
|
-
//
|
|
14
|
-
// The last point can be fixed by disabling premultipliedAlpha in the EngineConstructor,
|
|
15
|
-
// resulting in a bit better subjective colors compared to CET for "ConfiguraHumans".
|
|
16
|
-
//
|
|
17
|
-
// TODO Babylon: Figure out how we can enable the "hdr" flag again. Since we are using
|
|
18
|
-
// PBR we really should be using "hdr" to do things the right way, see this discussion:
|
|
19
|
-
// https://forum.babylonjs.com/t/enabling-hdr-in-defaultpipeline-disables-aa/14656/9
|
|
20
|
-
//
|
|
21
|
-
const pipeline = new DefaultRenderingPipeline("defaultPipeline", false, scene, [camera]);
|
|
22
|
-
// FXAA is not enabled since it causes excessive blur in detailed textures
|
|
23
|
-
// pipeline.fxaaEnabled = true;
|
|
24
|
-
// This affects anti-aliasing, more samples is better but also slower.
|
|
25
|
-
// Note that this does not seem to do anything unless HDR is enabled in the
|
|
26
|
-
// DefaultRenderingPipeline call.
|
|
27
|
-
pipeline.samples = 4;
|
|
28
|
-
pipeline.imageProcessingEnabled = true;
|
|
29
|
-
pipeline.imageProcessing.toneMappingEnabled = true;
|
|
30
|
-
pipeline.imageProcessing.toneMappingType = ImageProcessingConfiguration.TONEMAPPING_ACES;
|
|
31
|
-
// ACES tone mapping needs manual exposure adjustment in Babylon to look good on a normal
|
|
32
|
-
// monitor. More information can be found in the links below, note that "model-viewer" (in
|
|
33
|
-
// their "Fidelity" test) ended up using "1 / 0.6" rather than the value of 2.0 that was first
|
|
34
|
-
// decided upon in their pull request.
|
|
35
|
-
//
|
|
36
|
-
// https://github.com/google/model-viewer/pull/1340
|
|
37
|
-
// https://github.com/mrdoob/three.js/pull/19621
|
|
38
|
-
// https://modelviewer.dev/fidelity/
|
|
39
|
-
pipeline.imageProcessing.exposure = 1 / 0.6;
|
|
40
|
-
// We add a bit of extra contrast to make the image more appealing. This is highly subjective.
|
|
41
|
-
pipeline.imageProcessing.contrast = 1.2;
|
|
42
|
-
// The ACES color correction is quite desaturating, add back a bit of punch to the colors.
|
|
43
|
-
const curve = new ColorCurves();
|
|
44
|
-
curve.midtonesSaturation = 5;
|
|
45
|
-
curve.highlightsSaturation = 15;
|
|
46
|
-
pipeline.imageProcessing.colorCurves = curve;
|
|
47
|
-
pipeline.imageProcessing.colorCurvesEnabled = true;
|
|
48
|
-
};
|
|
1
|
+
import { ColorCurves } from "@babylonjs/core/Materials/colorCurves.js";
|
|
2
|
+
import { ImageProcessingConfiguration } from "@babylonjs/core/Materials/imageProcessingConfiguration.js";
|
|
3
|
+
import { DefaultRenderingPipeline } from "@babylonjs/core/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js";
|
|
4
|
+
export const getDefaultGradingApplier = () => (camera) => {
|
|
5
|
+
const scene = camera.getScene();
|
|
6
|
+
// The second parameter below is HDR which is supposed to be enabled "as long as possible"
|
|
7
|
+
// according to the documentation. However, doing so causes problems with rendering against
|
|
8
|
+
// our transparent background:
|
|
9
|
+
// - Anti-aliasing breaks for very white colors (BanquetChair2 in ConfiguraKitchenAccessories)
|
|
10
|
+
// - Transparent objects gets rendered very differently against the transparent background
|
|
11
|
+
// compared to over a opaque surface (Electric Cart in ConfiguraIndustrialEquipment)
|
|
12
|
+
// - Transparent objects gets a very bright and color shifting results (ConfiguraHumans)
|
|
13
|
+
//
|
|
14
|
+
// The last point can be fixed by disabling premultipliedAlpha in the EngineConstructor,
|
|
15
|
+
// resulting in a bit better subjective colors compared to CET for "ConfiguraHumans".
|
|
16
|
+
//
|
|
17
|
+
// TODO Babylon: Figure out how we can enable the "hdr" flag again. Since we are using
|
|
18
|
+
// PBR we really should be using "hdr" to do things the right way, see this discussion:
|
|
19
|
+
// https://forum.babylonjs.com/t/enabling-hdr-in-defaultpipeline-disables-aa/14656/9
|
|
20
|
+
//
|
|
21
|
+
const pipeline = new DefaultRenderingPipeline("defaultPipeline", false, scene, [camera]);
|
|
22
|
+
// FXAA is not enabled since it causes excessive blur in detailed textures
|
|
23
|
+
// pipeline.fxaaEnabled = true;
|
|
24
|
+
// This affects anti-aliasing, more samples is better but also slower.
|
|
25
|
+
// Note that this does not seem to do anything unless HDR is enabled in the
|
|
26
|
+
// DefaultRenderingPipeline call.
|
|
27
|
+
pipeline.samples = 4;
|
|
28
|
+
pipeline.imageProcessingEnabled = true;
|
|
29
|
+
pipeline.imageProcessing.toneMappingEnabled = true;
|
|
30
|
+
pipeline.imageProcessing.toneMappingType = ImageProcessingConfiguration.TONEMAPPING_ACES;
|
|
31
|
+
// ACES tone mapping needs manual exposure adjustment in Babylon to look good on a normal
|
|
32
|
+
// monitor. More information can be found in the links below, note that "model-viewer" (in
|
|
33
|
+
// their "Fidelity" test) ended up using "1 / 0.6" rather than the value of 2.0 that was first
|
|
34
|
+
// decided upon in their pull request.
|
|
35
|
+
//
|
|
36
|
+
// https://github.com/google/model-viewer/pull/1340
|
|
37
|
+
// https://github.com/mrdoob/three.js/pull/19621
|
|
38
|
+
// https://modelviewer.dev/fidelity/
|
|
39
|
+
pipeline.imageProcessing.exposure = 1 / 0.6;
|
|
40
|
+
// We add a bit of extra contrast to make the image more appealing. This is highly subjective.
|
|
41
|
+
pipeline.imageProcessing.contrast = 1.2;
|
|
42
|
+
// The ACES color correction is quite desaturating, add back a bit of punch to the colors.
|
|
43
|
+
const curve = new ColorCurves();
|
|
44
|
+
curve.midtonesSaturation = 5;
|
|
45
|
+
curve.highlightsSaturation = 15;
|
|
46
|
+
pipeline.imageProcessing.colorCurves = curve;
|
|
47
|
+
pipeline.imageProcessing.colorCurvesEnabled = true;
|
|
48
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
2
|
-
export declare type EngineCreator = (canvas: HTMLCanvasElement, width: number, height: number) => Engine;
|
|
3
|
-
export declare function getDefaultEngine(canvas: HTMLCanvasElement, width: number, height: number): Engine;
|
|
1
|
+
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
2
|
+
export declare type EngineCreator = (canvas: HTMLCanvasElement, width: number, height: number) => Engine;
|
|
3
|
+
export declare function getDefaultEngine(canvas: HTMLCanvasElement, width: number, height: number): Engine;
|
|
4
4
|
//# sourceMappingURL=EngineCreator.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
2
|
-
export function getDefaultEngine(canvas, width, height) {
|
|
3
|
-
// The xrCompatible flag below is used as a workaround for Babylon.js 4.2 crashing in Safari 15
|
|
4
|
-
// see WEB-8493 for additional details. It should be safe to apply to all browsers.
|
|
5
|
-
//
|
|
6
|
-
// TODO: Remove this workaround when upgrading to Babylon.js 5.0
|
|
7
|
-
const engine = new Engine(canvas, true, { xrCompatible: false, preserveDrawingBuffer: true }, true);
|
|
8
|
-
engine.setSize(Math.floor(width), Math.floor(height));
|
|
9
|
-
return engine;
|
|
10
|
-
}
|
|
1
|
+
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
2
|
+
export function getDefaultEngine(canvas, width, height) {
|
|
3
|
+
// The xrCompatible flag below is used as a workaround for Babylon.js 4.2 crashing in Safari 15
|
|
4
|
+
// see WEB-8493 for additional details. It should be safe to apply to all browsers.
|
|
5
|
+
//
|
|
6
|
+
// TODO: Remove this workaround when upgrading to Babylon.js 5.0
|
|
7
|
+
const engine = new Engine(canvas, true, { xrCompatible: false, preserveDrawingBuffer: true }, true);
|
|
8
|
+
engine.setSize(Math.floor(width), Math.floor(height));
|
|
9
|
+
return engine;
|
|
10
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
|
2
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
|
3
|
-
import { ATriMeshF } from "@configura/web-core/dist/cm/core3D/ATriMeshF.js";
|
|
4
|
-
import { UVMapper } from "@configura/web-core/dist/cm/core3D/uvmapper/UVMapper";
|
|
5
|
-
import { Logger, LogObservable, LogProducer } from "@configura/web-utilities";
|
|
6
|
-
import { CfgStretchData } from "./stretch/CfgStretchData.js";
|
|
7
|
-
import { CfgMorphTwiceStretchedGeometry } from "./stretch/CfgStretchMorphGeometry.js";
|
|
8
|
-
export declare function makeIndexMap(indices: Uint32Array | number[]): {
|
|
9
|
-
indexMap: Map<number, number>;
|
|
10
|
-
packedIndices: Uint32Array;
|
|
11
|
-
};
|
|
12
|
-
export declare class CfgGeometry extends Geometry implements LogProducer {
|
|
13
|
-
private readonly _ind;
|
|
14
|
-
private readonly _pos;
|
|
15
|
-
private readonly _uvs;
|
|
16
|
-
private readonly _nor;
|
|
17
|
-
private readonly _tan;
|
|
18
|
-
private readonly _col;
|
|
19
|
-
readonly morphGeometries: CfgMorphTwiceStretchedGeometry[];
|
|
20
|
-
logger: LogObservable;
|
|
21
|
-
static fromATriMeshF(logger: Logger, id: string, mesh: ATriMeshF, scene: Scene, stretchDatas: CfgStretchData[], uvMapper: UVMapper | undefined): CfgGeometry;
|
|
22
|
-
private constructor();
|
|
23
|
-
shallowClone(): CfgGeometry;
|
|
24
|
-
/**
|
|
25
|
-
* Returns a new CfgGeometry containing a subset of this CfgGeometry based on the given
|
|
26
|
-
* indices.
|
|
27
|
-
*/
|
|
28
|
-
cloneWithSubset(indices: Uint32Array | number[]): CfgGeometry;
|
|
29
|
-
}
|
|
1
|
+
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
|
2
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
|
3
|
+
import { ATriMeshF } from "@configura/web-core/dist/cm/core3D/ATriMeshF.js";
|
|
4
|
+
import { UVMapper } from "@configura/web-core/dist/cm/core3D/uvmapper/UVMapper";
|
|
5
|
+
import { Logger, LogObservable, LogProducer } from "@configura/web-utilities";
|
|
6
|
+
import { CfgStretchData } from "./stretch/CfgStretchData.js";
|
|
7
|
+
import { CfgMorphTwiceStretchedGeometry } from "./stretch/CfgStretchMorphGeometry.js";
|
|
8
|
+
export declare function makeIndexMap(indices: Uint32Array | number[]): {
|
|
9
|
+
indexMap: Map<number, number>;
|
|
10
|
+
packedIndices: Uint32Array;
|
|
11
|
+
};
|
|
12
|
+
export declare class CfgGeometry extends Geometry implements LogProducer {
|
|
13
|
+
private readonly _ind;
|
|
14
|
+
private readonly _pos;
|
|
15
|
+
private readonly _uvs;
|
|
16
|
+
private readonly _nor;
|
|
17
|
+
private readonly _tan;
|
|
18
|
+
private readonly _col;
|
|
19
|
+
readonly morphGeometries: CfgMorphTwiceStretchedGeometry[];
|
|
20
|
+
logger: LogObservable;
|
|
21
|
+
static fromATriMeshF(logger: Logger, id: string, mesh: ATriMeshF, scene: Scene, stretchDatas: CfgStretchData[], uvMapper: UVMapper | undefined): CfgGeometry;
|
|
22
|
+
private constructor();
|
|
23
|
+
shallowClone(): CfgGeometry;
|
|
24
|
+
/**
|
|
25
|
+
* Returns a new CfgGeometry containing a subset of this CfgGeometry based on the given
|
|
26
|
+
* indices.
|
|
27
|
+
*/
|
|
28
|
+
cloneWithSubset(indices: Uint32Array | number[]): CfgGeometry;
|
|
29
|
+
}
|
|
30
30
|
//# sourceMappingURL=CfgGeometry.d.ts.map
|
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
|
2
|
-
import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
|
|
3
|
-
import { LogObservable } from "@configura/web-utilities";
|
|
4
|
-
import { CfgMorphTwiceStretchedGeometry } from "./stretch/CfgStretchMorphGeometry.js";
|
|
5
|
-
export function makeIndexMap(indices) {
|
|
6
|
-
// Loop through all old index values, creating an index map between each unique old
|
|
7
|
-
// index value and their corresponding new index into the shorter arrays.
|
|
8
|
-
const indicesLength = indices.length;
|
|
9
|
-
const packedIndices = new Uint32Array(indicesLength);
|
|
10
|
-
const indexMap = new Map();
|
|
11
|
-
for (let i = 0; i < indicesLength; i++) {
|
|
12
|
-
const index = indices[i];
|
|
13
|
-
let newIndex = indexMap.get(index);
|
|
14
|
-
if (newIndex === undefined) {
|
|
15
|
-
newIndex = indexMap.size;
|
|
16
|
-
indexMap.set(index, newIndex);
|
|
17
|
-
}
|
|
18
|
-
packedIndices[i] = newIndex;
|
|
19
|
-
}
|
|
20
|
-
return { indexMap, packedIndices };
|
|
21
|
-
}
|
|
22
|
-
export class CfgGeometry extends Geometry {
|
|
23
|
-
constructor(id, scene, _ind, _pos, _uvs, _nor, _tan, _col, morphGeometries) {
|
|
24
|
-
super(id, scene);
|
|
25
|
-
this._ind = _ind;
|
|
26
|
-
this._pos = _pos;
|
|
27
|
-
this._uvs = _uvs;
|
|
28
|
-
this._nor = _nor;
|
|
29
|
-
this._tan = _tan;
|
|
30
|
-
this._col = _col;
|
|
31
|
-
this.morphGeometries = morphGeometries;
|
|
32
|
-
this.logger = new LogObservable();
|
|
33
|
-
const vertexData = new VertexData();
|
|
34
|
-
vertexData.indices = _ind;
|
|
35
|
-
vertexData.positions = _pos;
|
|
36
|
-
vertexData.uvs = _uvs;
|
|
37
|
-
vertexData.normals = _nor;
|
|
38
|
-
vertexData.tangents = _tan;
|
|
39
|
-
vertexData.colors = _col;
|
|
40
|
-
this.setAllVerticesData(vertexData, false);
|
|
41
|
-
}
|
|
42
|
-
static fromATriMeshF(logger, id, mesh, scene, stretchDatas, uvMapper) {
|
|
43
|
-
const positions = mesh.vertices;
|
|
44
|
-
const normals = 0 < mesh.normals.length ? mesh.normals : undefined;
|
|
45
|
-
const meshUvs = mesh.uvs;
|
|
46
|
-
let uvs;
|
|
47
|
-
if (meshUvs.length > 0) {
|
|
48
|
-
// Always use pre-baked UVs from CET if they exist.
|
|
49
|
-
// See comment on UVMapper.createUVCoordinates for more details.
|
|
50
|
-
uvs = meshUvs;
|
|
51
|
-
}
|
|
52
|
-
else if (uvMapper !== undefined && normals !== undefined) {
|
|
53
|
-
const min = [
|
|
54
|
-
Number.POSITIVE_INFINITY,
|
|
55
|
-
Number.POSITIVE_INFINITY,
|
|
56
|
-
Number.POSITIVE_INFINITY,
|
|
57
|
-
];
|
|
58
|
-
const max = [
|
|
59
|
-
Number.NEGATIVE_INFINITY,
|
|
60
|
-
Number.NEGATIVE_INFINITY,
|
|
61
|
-
Number.NEGATIVE_INFINITY,
|
|
62
|
-
];
|
|
63
|
-
// Calculate the bounds for each axis based on vertex positions
|
|
64
|
-
let p = 0;
|
|
65
|
-
let axis = 0;
|
|
66
|
-
for (let i = 0; i < positions.length; i++) {
|
|
67
|
-
p = positions[i];
|
|
68
|
-
axis = i % 3; // x, y, z
|
|
69
|
-
min[axis] = Math.min(min[axis], p);
|
|
70
|
-
max[axis] = Math.max(max[axis], p);
|
|
71
|
-
}
|
|
72
|
-
const size = max.map((m, axis) => m - min[axis]);
|
|
73
|
-
uvs = uvMapper.createUVCoordinates(logger, positions, {
|
|
74
|
-
min,
|
|
75
|
-
max,
|
|
76
|
-
size,
|
|
77
|
-
}, normals);
|
|
78
|
-
}
|
|
79
|
-
else if (uvMapper !== undefined) {
|
|
80
|
-
logger.warn("Mesh uses UV-mapper without mesh normals which is not supported");
|
|
81
|
-
}
|
|
82
|
-
return new this(id, scene, mesh.indices, positions, uvs !== undefined && uvs.length > 0 ? uvs : null, normals || null, mesh.tangents.length > 0 ? mesh.tangents : null, mesh.colors.length > 0 ? mesh.colors : null, stretchDatas.map((stretchData) => CfgMorphTwiceStretchedGeometry.make(logger, uvMapper, stretchData, positions, normals, uvs)));
|
|
83
|
-
}
|
|
84
|
-
shallowClone() {
|
|
85
|
-
return new CfgGeometry(this.id, this.getScene(), this._ind, this._pos, this._uvs, this._nor, this._tan, this._col, this.morphGeometries);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns a new CfgGeometry containing a subset of this CfgGeometry based on the given
|
|
89
|
-
* indices.
|
|
90
|
-
*/
|
|
91
|
-
cloneWithSubset(indices) {
|
|
92
|
-
const thisInd = this._ind;
|
|
93
|
-
const thisPos = this._pos;
|
|
94
|
-
const thisUvs = this._uvs;
|
|
95
|
-
const thisNor = this._nor;
|
|
96
|
-
const thisCol = this._col;
|
|
97
|
-
const thisTan = this._tan;
|
|
98
|
-
const indicesLength = indices.length;
|
|
99
|
-
// Babylon will use all vertex positions in the Geometry (not only the ones referenced
|
|
100
|
-
// by the indices) to determine the bounding box. As such, we need to go through the
|
|
101
|
-
// the new subset of indices and only keep the references values in each attribute.
|
|
102
|
-
const { indexMap, packedIndices: ind } = makeIndexMap(indices);
|
|
103
|
-
// The length of the indexMap tells us how many unique index value we found.
|
|
104
|
-
const count = indexMap.size;
|
|
105
|
-
console.log(`Creating CfgGeometry subset (${indicesLength / 3}/${thisInd.length / 3} triangles, ${count} unique indices)`);
|
|
106
|
-
const pos = new Float32Array(count * 3);
|
|
107
|
-
const uvs = thisUvs && new Float32Array(count * 2);
|
|
108
|
-
const nor = thisNor && new Float32Array(count * 3);
|
|
109
|
-
const tan = thisTan && new Float32Array(count * 4);
|
|
110
|
-
const col = thisCol && new Float32Array(count * 4);
|
|
111
|
-
// Use the index map to move only the referenced used values from all the attributes
|
|
112
|
-
// over to new smaller arrays.
|
|
113
|
-
//
|
|
114
|
-
// A note about the code: The code below is "unrolled" by design since it can be a lot
|
|
115
|
-
// of indexes to process. A more compact version with an inner loop of 0..3 with some
|
|
116
|
-
// additional if checks turned out to be up to 30 times slower in Chrome (1.5ms vs
|
|
117
|
-
// 40ms) for the "repack" call when loading and splitting the forklift model.
|
|
118
|
-
for (const [oldIndex, newIndex] of indexMap) {
|
|
119
|
-
pos[newIndex * 3] = thisPos[oldIndex * 3];
|
|
120
|
-
pos[newIndex * 3 + 1] = thisPos[oldIndex * 3 + 1];
|
|
121
|
-
pos[newIndex * 3 + 2] = thisPos[oldIndex * 3 + 2];
|
|
122
|
-
if (uvs !== null && thisUvs !== null) {
|
|
123
|
-
uvs[newIndex * 2] = thisUvs[oldIndex * 2];
|
|
124
|
-
uvs[newIndex * 2 + 1] = thisUvs[oldIndex * 2 + 1];
|
|
125
|
-
}
|
|
126
|
-
if (nor !== null && thisNor !== null) {
|
|
127
|
-
nor[newIndex * 3] = thisNor[oldIndex * 3];
|
|
128
|
-
nor[newIndex * 3 + 1] = thisNor[oldIndex * 3 + 1];
|
|
129
|
-
nor[newIndex * 3 + 2] = thisNor[oldIndex * 3 + 2];
|
|
130
|
-
}
|
|
131
|
-
if (tan !== null && thisTan !== null) {
|
|
132
|
-
tan[newIndex * 4] = thisTan[oldIndex * 4];
|
|
133
|
-
tan[newIndex * 4 + 1] = thisTan[oldIndex * 4 + 1];
|
|
134
|
-
tan[newIndex * 4 + 2] = thisTan[oldIndex * 4 + 2];
|
|
135
|
-
tan[newIndex * 4 + 3] = thisTan[oldIndex * 4 + 3];
|
|
136
|
-
}
|
|
137
|
-
if (col !== null && thisCol !== null) {
|
|
138
|
-
col[newIndex * 4] = thisCol[oldIndex * 4];
|
|
139
|
-
col[newIndex * 4 + 1] = thisCol[oldIndex * 4 + 1];
|
|
140
|
-
col[newIndex * 4 + 2] = thisCol[oldIndex * 4 + 2];
|
|
141
|
-
col[newIndex * 4 + 3] = thisCol[oldIndex * 4 + 3];
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return new CfgGeometry(this.id + ` (subset ${indices.length})`, this.getScene(), ind, pos, uvs, nor, tan, col, this.morphGeometries.map((morphTarget) => morphTarget.cloneWithSubset(indices)));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
1
|
+
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
|
2
|
+
import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
|
|
3
|
+
import { LogObservable } from "@configura/web-utilities";
|
|
4
|
+
import { CfgMorphTwiceStretchedGeometry } from "./stretch/CfgStretchMorphGeometry.js";
|
|
5
|
+
export function makeIndexMap(indices) {
|
|
6
|
+
// Loop through all old index values, creating an index map between each unique old
|
|
7
|
+
// index value and their corresponding new index into the shorter arrays.
|
|
8
|
+
const indicesLength = indices.length;
|
|
9
|
+
const packedIndices = new Uint32Array(indicesLength);
|
|
10
|
+
const indexMap = new Map();
|
|
11
|
+
for (let i = 0; i < indicesLength; i++) {
|
|
12
|
+
const index = indices[i];
|
|
13
|
+
let newIndex = indexMap.get(index);
|
|
14
|
+
if (newIndex === undefined) {
|
|
15
|
+
newIndex = indexMap.size;
|
|
16
|
+
indexMap.set(index, newIndex);
|
|
17
|
+
}
|
|
18
|
+
packedIndices[i] = newIndex;
|
|
19
|
+
}
|
|
20
|
+
return { indexMap, packedIndices };
|
|
21
|
+
}
|
|
22
|
+
export class CfgGeometry extends Geometry {
|
|
23
|
+
constructor(id, scene, _ind, _pos, _uvs, _nor, _tan, _col, morphGeometries) {
|
|
24
|
+
super(id, scene);
|
|
25
|
+
this._ind = _ind;
|
|
26
|
+
this._pos = _pos;
|
|
27
|
+
this._uvs = _uvs;
|
|
28
|
+
this._nor = _nor;
|
|
29
|
+
this._tan = _tan;
|
|
30
|
+
this._col = _col;
|
|
31
|
+
this.morphGeometries = morphGeometries;
|
|
32
|
+
this.logger = new LogObservable();
|
|
33
|
+
const vertexData = new VertexData();
|
|
34
|
+
vertexData.indices = _ind;
|
|
35
|
+
vertexData.positions = _pos;
|
|
36
|
+
vertexData.uvs = _uvs;
|
|
37
|
+
vertexData.normals = _nor;
|
|
38
|
+
vertexData.tangents = _tan;
|
|
39
|
+
vertexData.colors = _col;
|
|
40
|
+
this.setAllVerticesData(vertexData, false);
|
|
41
|
+
}
|
|
42
|
+
static fromATriMeshF(logger, id, mesh, scene, stretchDatas, uvMapper) {
|
|
43
|
+
const positions = mesh.vertices;
|
|
44
|
+
const normals = 0 < mesh.normals.length ? mesh.normals : undefined;
|
|
45
|
+
const meshUvs = mesh.uvs;
|
|
46
|
+
let uvs;
|
|
47
|
+
if (meshUvs.length > 0) {
|
|
48
|
+
// Always use pre-baked UVs from CET if they exist.
|
|
49
|
+
// See comment on UVMapper.createUVCoordinates for more details.
|
|
50
|
+
uvs = meshUvs;
|
|
51
|
+
}
|
|
52
|
+
else if (uvMapper !== undefined && normals !== undefined) {
|
|
53
|
+
const min = [
|
|
54
|
+
Number.POSITIVE_INFINITY,
|
|
55
|
+
Number.POSITIVE_INFINITY,
|
|
56
|
+
Number.POSITIVE_INFINITY,
|
|
57
|
+
];
|
|
58
|
+
const max = [
|
|
59
|
+
Number.NEGATIVE_INFINITY,
|
|
60
|
+
Number.NEGATIVE_INFINITY,
|
|
61
|
+
Number.NEGATIVE_INFINITY,
|
|
62
|
+
];
|
|
63
|
+
// Calculate the bounds for each axis based on vertex positions
|
|
64
|
+
let p = 0;
|
|
65
|
+
let axis = 0;
|
|
66
|
+
for (let i = 0; i < positions.length; i++) {
|
|
67
|
+
p = positions[i];
|
|
68
|
+
axis = i % 3; // x, y, z
|
|
69
|
+
min[axis] = Math.min(min[axis], p);
|
|
70
|
+
max[axis] = Math.max(max[axis], p);
|
|
71
|
+
}
|
|
72
|
+
const size = max.map((m, axis) => m - min[axis]);
|
|
73
|
+
uvs = uvMapper.createUVCoordinates(logger, positions, {
|
|
74
|
+
min,
|
|
75
|
+
max,
|
|
76
|
+
size,
|
|
77
|
+
}, normals);
|
|
78
|
+
}
|
|
79
|
+
else if (uvMapper !== undefined) {
|
|
80
|
+
logger.warn("Mesh uses UV-mapper without mesh normals which is not supported");
|
|
81
|
+
}
|
|
82
|
+
return new this(id, scene, mesh.indices, positions, uvs !== undefined && uvs.length > 0 ? uvs : null, normals || null, mesh.tangents.length > 0 ? mesh.tangents : null, mesh.colors.length > 0 ? mesh.colors : null, stretchDatas.map((stretchData) => CfgMorphTwiceStretchedGeometry.make(logger, uvMapper, stretchData, positions, normals, uvs)));
|
|
83
|
+
}
|
|
84
|
+
shallowClone() {
|
|
85
|
+
return new CfgGeometry(this.id, this.getScene(), this._ind, this._pos, this._uvs, this._nor, this._tan, this._col, this.morphGeometries);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns a new CfgGeometry containing a subset of this CfgGeometry based on the given
|
|
89
|
+
* indices.
|
|
90
|
+
*/
|
|
91
|
+
cloneWithSubset(indices) {
|
|
92
|
+
const thisInd = this._ind;
|
|
93
|
+
const thisPos = this._pos;
|
|
94
|
+
const thisUvs = this._uvs;
|
|
95
|
+
const thisNor = this._nor;
|
|
96
|
+
const thisCol = this._col;
|
|
97
|
+
const thisTan = this._tan;
|
|
98
|
+
const indicesLength = indices.length;
|
|
99
|
+
// Babylon will use all vertex positions in the Geometry (not only the ones referenced
|
|
100
|
+
// by the indices) to determine the bounding box. As such, we need to go through the
|
|
101
|
+
// the new subset of indices and only keep the references values in each attribute.
|
|
102
|
+
const { indexMap, packedIndices: ind } = makeIndexMap(indices);
|
|
103
|
+
// The length of the indexMap tells us how many unique index value we found.
|
|
104
|
+
const count = indexMap.size;
|
|
105
|
+
console.log(`Creating CfgGeometry subset (${indicesLength / 3}/${thisInd.length / 3} triangles, ${count} unique indices)`);
|
|
106
|
+
const pos = new Float32Array(count * 3);
|
|
107
|
+
const uvs = thisUvs && new Float32Array(count * 2);
|
|
108
|
+
const nor = thisNor && new Float32Array(count * 3);
|
|
109
|
+
const tan = thisTan && new Float32Array(count * 4);
|
|
110
|
+
const col = thisCol && new Float32Array(count * 4);
|
|
111
|
+
// Use the index map to move only the referenced used values from all the attributes
|
|
112
|
+
// over to new smaller arrays.
|
|
113
|
+
//
|
|
114
|
+
// A note about the code: The code below is "unrolled" by design since it can be a lot
|
|
115
|
+
// of indexes to process. A more compact version with an inner loop of 0..3 with some
|
|
116
|
+
// additional if checks turned out to be up to 30 times slower in Chrome (1.5ms vs
|
|
117
|
+
// 40ms) for the "repack" call when loading and splitting the forklift model.
|
|
118
|
+
for (const [oldIndex, newIndex] of indexMap) {
|
|
119
|
+
pos[newIndex * 3] = thisPos[oldIndex * 3];
|
|
120
|
+
pos[newIndex * 3 + 1] = thisPos[oldIndex * 3 + 1];
|
|
121
|
+
pos[newIndex * 3 + 2] = thisPos[oldIndex * 3 + 2];
|
|
122
|
+
if (uvs !== null && thisUvs !== null) {
|
|
123
|
+
uvs[newIndex * 2] = thisUvs[oldIndex * 2];
|
|
124
|
+
uvs[newIndex * 2 + 1] = thisUvs[oldIndex * 2 + 1];
|
|
125
|
+
}
|
|
126
|
+
if (nor !== null && thisNor !== null) {
|
|
127
|
+
nor[newIndex * 3] = thisNor[oldIndex * 3];
|
|
128
|
+
nor[newIndex * 3 + 1] = thisNor[oldIndex * 3 + 1];
|
|
129
|
+
nor[newIndex * 3 + 2] = thisNor[oldIndex * 3 + 2];
|
|
130
|
+
}
|
|
131
|
+
if (tan !== null && thisTan !== null) {
|
|
132
|
+
tan[newIndex * 4] = thisTan[oldIndex * 4];
|
|
133
|
+
tan[newIndex * 4 + 1] = thisTan[oldIndex * 4 + 1];
|
|
134
|
+
tan[newIndex * 4 + 2] = thisTan[oldIndex * 4 + 2];
|
|
135
|
+
tan[newIndex * 4 + 3] = thisTan[oldIndex * 4 + 3];
|
|
136
|
+
}
|
|
137
|
+
if (col !== null && thisCol !== null) {
|
|
138
|
+
col[newIndex * 4] = thisCol[oldIndex * 4];
|
|
139
|
+
col[newIndex * 4 + 1] = thisCol[oldIndex * 4 + 1];
|
|
140
|
+
col[newIndex * 4 + 2] = thisCol[oldIndex * 4 + 2];
|
|
141
|
+
col[newIndex * 4 + 3] = thisCol[oldIndex * 4 + 3];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return new CfgGeometry(this.id + ` (subset ${indices.length})`, this.getScene(), ind, pos, uvs, nor, tan, col, this.morphGeometries.map((morphTarget) => morphTarget.cloneWithSubset(indices)));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
|
2
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
3
|
-
import { CfgProductNode } from "../nodes/CfgProductNode.js";
|
|
4
|
-
import { RenderEnv } from "../view/RenderEnv.js";
|
|
5
|
-
import { CfgGeometry } from "./CfgGeometry.js";
|
|
6
|
-
export declare class CfgMesh extends Mesh {
|
|
7
|
-
private readonly _morphTargets;
|
|
8
|
-
constructor(name: string, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, geometry: CfgGeometry, material: PBRMaterial);
|
|
9
|
-
refreshStretch(): void;
|
|
10
|
-
}
|
|
1
|
+
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
|
2
|
+
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
3
|
+
import { CfgProductNode } from "../nodes/CfgProductNode.js";
|
|
4
|
+
import { RenderEnv } from "../view/RenderEnv.js";
|
|
5
|
+
import { CfgGeometry } from "./CfgGeometry.js";
|
|
6
|
+
export declare class CfgMesh extends Mesh {
|
|
7
|
+
private readonly _morphTargets;
|
|
8
|
+
constructor(name: string, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, geometry: CfgGeometry, material: PBRMaterial);
|
|
9
|
+
refreshStretch(): void;
|
|
10
|
+
}
|
|
11
11
|
//# sourceMappingURL=CfgMesh.d.ts.map
|
package/dist/geometry/CfgMesh.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
2
|
-
import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager.js";
|
|
3
|
-
import { CfgMorphTarget } from "./stretch/CfgMorphTarget.js";
|
|
4
|
-
export class CfgMesh extends Mesh {
|
|
5
|
-
constructor(name, renderEnvironment, cfgProductNodeParent, geometry, material) {
|
|
6
|
-
super(name, renderEnvironment.scene);
|
|
7
|
-
this._morphTargets = [];
|
|
8
|
-
// Cloning is a hack to handle two things: the Geometry subclass getting automatically
|
|
9
|
-
// disposed when the last associated mesh is disposed, for example when changing options
|
|
10
|
-
// back and forth. This way every CfgMesh has it's own instance so we do not need to worry
|
|
11
|
-
// about it being disposed.
|
|
12
|
-
// The other issue being handled is the a short circuit in Babylon between CfgMeshes when
|
|
13
|
-
// using stretch. Meshes using the same CfgGeometry are affected when one of them is unloaded.
|
|
14
|
-
// IIRC we are using a geometry cache which is probably holding on firmly to this instance
|
|
15
|
-
// and reusing it for the next time we need the same mesh. If that cache is ever cleared,
|
|
16
|
-
// it should also dispose the geometry inside it.
|
|
17
|
-
const cloneGeometry = geometry.shallowClone();
|
|
18
|
-
cloneGeometry.applyToMesh(this);
|
|
19
|
-
this.material = material;
|
|
20
|
-
const morphGeometries = cloneGeometry.morphGeometries;
|
|
21
|
-
if (morphGeometries.length !== 0) {
|
|
22
|
-
const manager = new MorphTargetManager();
|
|
23
|
-
manager.enableNormalMorphing = false;
|
|
24
|
-
manager.enableTangentMorphing = false;
|
|
25
|
-
this.morphTargetManager = manager;
|
|
26
|
-
for (const morphGeometry of morphGeometries) {
|
|
27
|
-
const morphTarget = new CfgMorphTarget(morphGeometry, cfgProductNodeParent);
|
|
28
|
-
this._morphTargets.push(morphTarget);
|
|
29
|
-
manager.addTarget(morphTarget);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
refreshStretch() {
|
|
34
|
-
for (const morphTarget of this._morphTargets) {
|
|
35
|
-
morphTarget.refreshStretch();
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
|
2
|
+
import { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager.js";
|
|
3
|
+
import { CfgMorphTarget } from "./stretch/CfgMorphTarget.js";
|
|
4
|
+
export class CfgMesh extends Mesh {
|
|
5
|
+
constructor(name, renderEnvironment, cfgProductNodeParent, geometry, material) {
|
|
6
|
+
super(name, renderEnvironment.scene);
|
|
7
|
+
this._morphTargets = [];
|
|
8
|
+
// Cloning is a hack to handle two things: the Geometry subclass getting automatically
|
|
9
|
+
// disposed when the last associated mesh is disposed, for example when changing options
|
|
10
|
+
// back and forth. This way every CfgMesh has it's own instance so we do not need to worry
|
|
11
|
+
// about it being disposed.
|
|
12
|
+
// The other issue being handled is the a short circuit in Babylon between CfgMeshes when
|
|
13
|
+
// using stretch. Meshes using the same CfgGeometry are affected when one of them is unloaded.
|
|
14
|
+
// IIRC we are using a geometry cache which is probably holding on firmly to this instance
|
|
15
|
+
// and reusing it for the next time we need the same mesh. If that cache is ever cleared,
|
|
16
|
+
// it should also dispose the geometry inside it.
|
|
17
|
+
const cloneGeometry = geometry.shallowClone();
|
|
18
|
+
cloneGeometry.applyToMesh(this);
|
|
19
|
+
this.material = material;
|
|
20
|
+
const morphGeometries = cloneGeometry.morphGeometries;
|
|
21
|
+
if (morphGeometries.length !== 0) {
|
|
22
|
+
const manager = new MorphTargetManager();
|
|
23
|
+
manager.enableNormalMorphing = false;
|
|
24
|
+
manager.enableTangentMorphing = false;
|
|
25
|
+
this.morphTargetManager = manager;
|
|
26
|
+
for (const morphGeometry of morphGeometries) {
|
|
27
|
+
const morphTarget = new CfgMorphTarget(morphGeometry, cfgProductNodeParent);
|
|
28
|
+
this._morphTargets.push(morphTarget);
|
|
29
|
+
manager.addTarget(morphTarget);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
refreshStretch() {
|
|
34
|
+
for (const morphTarget of this._morphTargets) {
|
|
35
|
+
morphTarget.refreshStretch();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Logger } from "@configura/web-utilities";
|
|
2
|
-
import { CfgGeometry } from "./CfgGeometry.js";
|
|
3
|
-
export declare function splitIndexQuick(logger: Logger, geo: CfgGeometry): number[][] | undefined;
|
|
4
|
-
export declare function splitIndexComplete(logger: Logger, geo: CfgGeometry, conf: {
|
|
5
|
-
maxFinalGroups: number;
|
|
6
|
-
maxProgressGroups: number;
|
|
7
|
-
acceptCoordinateMatch?: boolean;
|
|
8
|
-
}): number[][] | undefined;
|
|
1
|
+
import { Logger } from "@configura/web-utilities";
|
|
2
|
+
import { CfgGeometry } from "./CfgGeometry.js";
|
|
3
|
+
export declare function splitIndexQuick(logger: Logger, geo: CfgGeometry): number[][] | undefined;
|
|
4
|
+
export declare function splitIndexComplete(logger: Logger, geo: CfgGeometry, conf: {
|
|
5
|
+
maxFinalGroups: number;
|
|
6
|
+
maxProgressGroups: number;
|
|
7
|
+
acceptCoordinateMatch?: boolean;
|
|
8
|
+
}): number[][] | undefined;
|
|
9
9
|
//# sourceMappingURL=geoSplitter.d.ts.map
|