@combeenation/3d-viewer 12.4.1 → 12.4.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/README.md +9 -9
- package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
- package/dist/lib-cjs/api/classes/animationInterface.js +2 -2
- package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
- package/dist/lib-cjs/api/classes/dottedPath.js +166 -166
- package/dist/lib-cjs/api/classes/element.d.ts +153 -153
- package/dist/lib-cjs/api/classes/element.js +702 -702
- package/dist/lib-cjs/api/classes/event.d.ts +401 -401
- package/dist/lib-cjs/api/classes/event.js +424 -424
- package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
- package/dist/lib-cjs/api/classes/eventBroadcaster.js +49 -49
- package/dist/lib-cjs/api/classes/fuzzyMap.d.ts +7 -7
- package/dist/lib-cjs/api/classes/fuzzyMap.js +21 -21
- package/dist/lib-cjs/api/classes/parameter.d.ts +410 -410
- package/dist/lib-cjs/api/classes/parameter.js +642 -642
- package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
- package/dist/lib-cjs/api/classes/parameterObservable.js +72 -72
- package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
- package/dist/lib-cjs/api/classes/parameterizable.js +102 -102
- package/dist/lib-cjs/api/classes/placementAnimation.d.ts +45 -45
- package/dist/lib-cjs/api/classes/placementAnimation.js +176 -176
- package/dist/lib-cjs/api/classes/variant.d.ts +261 -261
- package/dist/lib-cjs/api/classes/variant.js +872 -872
- package/dist/lib-cjs/api/classes/variantInstance.d.ts +53 -53
- package/dist/lib-cjs/api/classes/variantInstance.js +125 -125
- package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
- package/dist/lib-cjs/api/classes/variantParameterizable.js +86 -86
- package/dist/lib-cjs/api/classes/viewer.d.ts +215 -215
- package/dist/lib-cjs/api/classes/viewer.js +708 -708
- package/dist/lib-cjs/api/classes/viewerError.d.ts +43 -43
- package/dist/lib-cjs/api/classes/viewerError.js +55 -55
- package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
- package/dist/lib-cjs/api/classes/viewerLight.js +344 -344
- package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
- package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
- package/dist/lib-cjs/api/internal/sceneSetup.d.ts +13 -13
- package/dist/lib-cjs/api/internal/sceneSetup.js +227 -227
- package/dist/lib-cjs/api/manager/animationManager.d.ts +30 -30
- package/dist/lib-cjs/api/manager/animationManager.js +126 -126
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +80 -80
- package/dist/lib-cjs/api/manager/gltfExportManager.js +300 -299
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/sceneManager.d.ts +33 -33
- package/dist/lib-cjs/api/manager/sceneManager.js +128 -128
- package/dist/lib-cjs/api/manager/tagManager.d.ts +118 -118
- package/dist/lib-cjs/api/manager/tagManager.js +530 -530
- package/dist/lib-cjs/api/manager/textureLoadManager.d.ts +22 -22
- package/dist/lib-cjs/api/manager/textureLoadManager.js +107 -107
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +106 -106
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +290 -290
- package/dist/lib-cjs/api/store/specStorage.d.ts +32 -32
- package/dist/lib-cjs/api/store/specStorage.js +65 -65
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +238 -238
- package/dist/lib-cjs/api/util/babylonHelper.js +825 -825
- package/dist/lib-cjs/api/util/debugHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/debugHelper.js +93 -93
- package/dist/lib-cjs/api/util/deviceHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/deviceHelper.js +28 -28
- package/dist/lib-cjs/api/util/geometryHelper.d.ts +17 -17
- package/dist/lib-cjs/api/util/geometryHelper.js +112 -112
- package/dist/lib-cjs/api/util/globalTypes.d.ts +490 -490
- package/dist/lib-cjs/api/util/globalTypes.js +1 -1
- package/dist/lib-cjs/api/util/resourceHelper.d.ts +58 -58
- package/dist/lib-cjs/api/util/resourceHelper.js +214 -214
- package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +58 -58
- package/dist/lib-cjs/api/util/sceneLoaderHelper.js +228 -228
- package/dist/lib-cjs/api/util/stringHelper.d.ts +13 -13
- package/dist/lib-cjs/api/util/stringHelper.js +32 -32
- package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -9
- package/dist/lib-cjs/api/util/structureHelper.js +57 -57
- package/dist/lib-cjs/buildinfo.json +3 -3
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/dist/lib-cjs/index.d.ts +63 -63
- package/dist/lib-cjs/index.js +128 -128
- package/package.json +93 -92
- package/src/api/classes/animationInterface.ts +10 -10
- package/src/api/classes/dottedPath.ts +181 -181
- package/src/api/classes/element.ts +766 -766
- package/src/api/classes/event.ts +457 -457
- package/src/api/classes/eventBroadcaster.ts +52 -52
- package/src/api/classes/fuzzyMap.ts +21 -21
- package/src/api/classes/parameter.ts +686 -686
- package/src/api/classes/parameterObservable.ts +73 -73
- package/src/api/classes/parameterizable.ts +87 -87
- package/src/api/classes/placementAnimation.ts +162 -162
- package/src/api/classes/variant.ts +965 -965
- package/src/api/classes/variantInstance.ts +123 -123
- package/src/api/classes/variantParameterizable.ts +83 -83
- package/src/api/classes/viewer.ts +751 -751
- package/src/api/classes/viewerError.ts +63 -63
- package/src/api/classes/viewerLight.ts +335 -335
- package/src/api/internal/debugViewer.ts +90 -90
- package/src/api/internal/lensRendering.ts +9 -9
- package/src/api/internal/sceneSetup.ts +208 -208
- package/src/api/manager/animationManager.ts +143 -143
- package/src/api/manager/gltfExportManager.ts +337 -334
- package/src/api/manager/sceneManager.ts +134 -134
- package/src/api/manager/tagManager.ts +572 -572
- package/src/api/manager/textureLoadManager.ts +107 -107
- package/src/api/manager/variantInstanceManager.ts +306 -306
- package/src/api/store/specStorage.ts +68 -68
- package/src/api/util/babylonHelper.ts +915 -915
- package/src/api/util/debugHelper.ts +121 -121
- package/src/api/util/deviceHelper.ts +31 -31
- package/src/api/util/geometryHelper.ts +142 -142
- package/src/api/util/globalTypes.ts +566 -566
- package/src/api/util/resourceHelper.ts +201 -201
- package/src/api/util/sceneLoaderHelper.ts +247 -247
- package/src/api/util/stringHelper.ts +30 -30
- package/src/api/util/structureHelper.ts +62 -62
- package/src/buildinfo.json +3 -3
- package/src/dev.ts +70 -70
- package/src/index.ts +116 -116
- package/src/types.d.ts +49 -49
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create debug coordinate system located in world origin.
|
|
3
|
-
* This function is based on Babylon.js `AxesViewer`, axis texts are added manually.
|
|
4
|
-
*/
|
|
5
|
-
export declare function showWorldCoordinates(dimension: number): void;
|
|
6
|
-
/**
|
|
7
|
-
* Remove meshes and materials that are associated with the debug world coordinates system
|
|
8
|
-
*/
|
|
9
|
-
export declare function hideWorldCoordinates(): void;
|
|
1
|
+
/**
|
|
2
|
+
* Create debug coordinate system located in world origin.
|
|
3
|
+
* This function is based on Babylon.js `AxesViewer`, axis texts are added manually.
|
|
4
|
+
*/
|
|
5
|
+
export declare function showWorldCoordinates(dimension: number): void;
|
|
6
|
+
/**
|
|
7
|
+
* Remove meshes and materials that are associated with the debug world coordinates system
|
|
8
|
+
*/
|
|
9
|
+
export declare function hideWorldCoordinates(): void;
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hideWorldCoordinates = exports.showWorldCoordinates = void 0;
|
|
4
|
-
const axesViewer_1 = require("@babylonjs/core/Debug/axesViewer");
|
|
5
|
-
const dynamicTexture_1 = require("@babylonjs/core/Materials/Textures/dynamicTexture");
|
|
6
|
-
const standardMaterial_1 = require("@babylonjs/core/Materials/standardMaterial");
|
|
7
|
-
const math_color_1 = require("@babylonjs/core/Maths/math.color");
|
|
8
|
-
const math_vector_1 = require("@babylonjs/core/Maths/math.vector");
|
|
9
|
-
const meshBuilder_1 = require("@babylonjs/core/Meshes/meshBuilder");
|
|
10
|
-
const transformNode_1 = require("@babylonjs/core/Meshes/transformNode");
|
|
11
|
-
const utilityLayerRenderer_1 = require("@babylonjs/core/Rendering/utilityLayerRenderer");
|
|
12
|
-
const _DEBUG_AXIS_MAP = {
|
|
13
|
-
X: { color: math_color_1.Color3.Red().scale(0.5), position: new math_vector_1.Vector3(1, 0, 0) },
|
|
14
|
-
Y: { color: math_color_1.Color3.Green().scale(0.5), position: new math_vector_1.Vector3(0, 1, 0) },
|
|
15
|
-
Z: { color: math_color_1.Color3.Blue().scale(0.5), position: new math_vector_1.Vector3(0, 0, 1) },
|
|
16
|
-
};
|
|
17
|
-
const _WORLD_COORD_ROOT_KEY = '__world_coordinates__';
|
|
18
|
-
let _AXES_VIEWER;
|
|
19
|
-
/**
|
|
20
|
-
* Create debug coordinate system located in world origin.
|
|
21
|
-
* This function is based on Babylon.js `AxesViewer`, axis texts are added manually.
|
|
22
|
-
*/
|
|
23
|
-
function showWorldCoordinates(dimension) {
|
|
24
|
-
// make sure to remove already existing debug coordinate systems
|
|
25
|
-
hideWorldCoordinates();
|
|
26
|
-
// draw in utility layer, so that there is no interaction with the actually scene content (eg: glb export, autofocus)
|
|
27
|
-
const utilityLayerScene = utilityLayerRenderer_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
28
|
-
const worldCoordRoot = new transformNode_1.TransformNode('__world_coordinates__', utilityLayerScene);
|
|
29
|
-
// axes viewer coordinate system is a bit too large
|
|
30
|
-
// multiply with unify factor to create arrows which exactly match the length of the input dimension
|
|
31
|
-
const factor = _getWorldCoordinatesAxesUnifyFactor();
|
|
32
|
-
_AXES_VIEWER = new axesViewer_1.AxesViewer(utilityLayerScene, dimension * factor);
|
|
33
|
-
_prepareWorldCoordinateAxis('X', _AXES_VIEWER.xAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
34
|
-
_prepareWorldCoordinateAxis('Y', _AXES_VIEWER.yAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
35
|
-
_prepareWorldCoordinateAxis('Z', _AXES_VIEWER.zAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
36
|
-
}
|
|
37
|
-
exports.showWorldCoordinates = showWorldCoordinates;
|
|
38
|
-
/**
|
|
39
|
-
* Remove meshes and materials that are associated with the debug world coordinates system
|
|
40
|
-
*/
|
|
41
|
-
function hideWorldCoordinates() {
|
|
42
|
-
const utilityLayerScene = utilityLayerRenderer_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
43
|
-
_AXES_VIEWER === null || _AXES_VIEWER === void 0 ? void 0 : _AXES_VIEWER.dispose();
|
|
44
|
-
const worldCoordRoot = utilityLayerScene.getTransformNodeByName(_WORLD_COORD_ROOT_KEY);
|
|
45
|
-
if (worldCoordRoot) {
|
|
46
|
-
worldCoordRoot.dispose(false, true);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.hideWorldCoordinates = hideWorldCoordinates;
|
|
50
|
-
/**
|
|
51
|
-
* Adjust and enhance coordinate axes to fulfill our needs.
|
|
52
|
-
* - moves nodes into common root
|
|
53
|
-
* - adds text node
|
|
54
|
-
*/
|
|
55
|
-
function _prepareWorldCoordinateAxis(text, axis, root, dimension, utilityLayerScene) {
|
|
56
|
-
// create unique names
|
|
57
|
-
axis.name = `${_WORLD_COORD_ROOT_KEY}.${text}`;
|
|
58
|
-
axis.parent = root;
|
|
59
|
-
// create text mesh via dynamic texture
|
|
60
|
-
const dynamicTexture = new dynamicTexture_1.DynamicTexture(`${_WORLD_COORD_ROOT_KEY}.${text}`, 50, utilityLayerScene, true);
|
|
61
|
-
dynamicTexture.hasAlpha = true;
|
|
62
|
-
// 42.5 is a magic offset, so that the text is vertically centered for font size 50px
|
|
63
|
-
// horizontal centering works well with the standard behaviour of Babylon.js (setting "null" as "width")
|
|
64
|
-
dynamicTexture.drawText(text, null, 42.5, 'bold 50px Arial', 'white', 'transparent', true);
|
|
65
|
-
const material = new standardMaterial_1.StandardMaterial(`${_WORLD_COORD_ROOT_KEY}.${text}`, utilityLayerScene);
|
|
66
|
-
material.disableLighting = true;
|
|
67
|
-
material.emissiveColor = _DEBUG_AXIS_MAP[text].color;
|
|
68
|
-
material.diffuseTexture = dynamicTexture;
|
|
69
|
-
const plane = meshBuilder_1.MeshBuilder.CreatePlane(`${_WORLD_COORD_ROOT_KEY}.${text}.TextPlane`, { size: dimension / 10 }, utilityLayerScene);
|
|
70
|
-
// make sure that text is located outside of arrow
|
|
71
|
-
plane.position = _DEBUG_AXIS_MAP[text].position.multiplyByFloats(dimension * 1.05, dimension * 1.05, dimension * 1.05);
|
|
72
|
-
plane.parent = root;
|
|
73
|
-
plane.material = material;
|
|
74
|
-
// will be rendered on top of "default" meshes => taken from Babylon.js repo "AxesViewer" implementation
|
|
75
|
-
plane.renderingGroupId = 2;
|
|
76
|
-
// setting billboard mode ensures, that the text is always readable
|
|
77
|
-
plane.billboardMode = transformNode_1.TransformNode.BILLBOARDMODE_ALL;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Calculate factor for creating world coordinate axes with exactly one unit in length
|
|
81
|
-
*/
|
|
82
|
-
function _getWorldCoordinatesAxesUnifyFactor() {
|
|
83
|
-
// These constants are taken from the Babylon.js repository
|
|
84
|
-
const coneZPosOffset = 0.3;
|
|
85
|
-
const coneHeight = 0.075;
|
|
86
|
-
const baseScaling = 4;
|
|
87
|
-
// cone is moved 0.3 units away from the center
|
|
88
|
-
// the origin of the cone will be located on 1.2, if combined with the base scaling of 4
|
|
89
|
-
// invert that offset to get the origin to 1
|
|
90
|
-
// also consider the cone height to move the tip of the cone to 1 instead the center
|
|
91
|
-
const factor = 1 / ((coneZPosOffset + coneHeight / 2) * baseScaling);
|
|
92
|
-
return factor;
|
|
93
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hideWorldCoordinates = exports.showWorldCoordinates = void 0;
|
|
4
|
+
const axesViewer_1 = require("@babylonjs/core/Debug/axesViewer");
|
|
5
|
+
const dynamicTexture_1 = require("@babylonjs/core/Materials/Textures/dynamicTexture");
|
|
6
|
+
const standardMaterial_1 = require("@babylonjs/core/Materials/standardMaterial");
|
|
7
|
+
const math_color_1 = require("@babylonjs/core/Maths/math.color");
|
|
8
|
+
const math_vector_1 = require("@babylonjs/core/Maths/math.vector");
|
|
9
|
+
const meshBuilder_1 = require("@babylonjs/core/Meshes/meshBuilder");
|
|
10
|
+
const transformNode_1 = require("@babylonjs/core/Meshes/transformNode");
|
|
11
|
+
const utilityLayerRenderer_1 = require("@babylonjs/core/Rendering/utilityLayerRenderer");
|
|
12
|
+
const _DEBUG_AXIS_MAP = {
|
|
13
|
+
X: { color: math_color_1.Color3.Red().scale(0.5), position: new math_vector_1.Vector3(1, 0, 0) },
|
|
14
|
+
Y: { color: math_color_1.Color3.Green().scale(0.5), position: new math_vector_1.Vector3(0, 1, 0) },
|
|
15
|
+
Z: { color: math_color_1.Color3.Blue().scale(0.5), position: new math_vector_1.Vector3(0, 0, 1) },
|
|
16
|
+
};
|
|
17
|
+
const _WORLD_COORD_ROOT_KEY = '__world_coordinates__';
|
|
18
|
+
let _AXES_VIEWER;
|
|
19
|
+
/**
|
|
20
|
+
* Create debug coordinate system located in world origin.
|
|
21
|
+
* This function is based on Babylon.js `AxesViewer`, axis texts are added manually.
|
|
22
|
+
*/
|
|
23
|
+
function showWorldCoordinates(dimension) {
|
|
24
|
+
// make sure to remove already existing debug coordinate systems
|
|
25
|
+
hideWorldCoordinates();
|
|
26
|
+
// draw in utility layer, so that there is no interaction with the actually scene content (eg: glb export, autofocus)
|
|
27
|
+
const utilityLayerScene = utilityLayerRenderer_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
28
|
+
const worldCoordRoot = new transformNode_1.TransformNode('__world_coordinates__', utilityLayerScene);
|
|
29
|
+
// axes viewer coordinate system is a bit too large
|
|
30
|
+
// multiply with unify factor to create arrows which exactly match the length of the input dimension
|
|
31
|
+
const factor = _getWorldCoordinatesAxesUnifyFactor();
|
|
32
|
+
_AXES_VIEWER = new axesViewer_1.AxesViewer(utilityLayerScene, dimension * factor);
|
|
33
|
+
_prepareWorldCoordinateAxis('X', _AXES_VIEWER.xAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
34
|
+
_prepareWorldCoordinateAxis('Y', _AXES_VIEWER.yAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
35
|
+
_prepareWorldCoordinateAxis('Z', _AXES_VIEWER.zAxis, worldCoordRoot, dimension, utilityLayerScene);
|
|
36
|
+
}
|
|
37
|
+
exports.showWorldCoordinates = showWorldCoordinates;
|
|
38
|
+
/**
|
|
39
|
+
* Remove meshes and materials that are associated with the debug world coordinates system
|
|
40
|
+
*/
|
|
41
|
+
function hideWorldCoordinates() {
|
|
42
|
+
const utilityLayerScene = utilityLayerRenderer_1.UtilityLayerRenderer.DefaultUtilityLayer.utilityLayerScene;
|
|
43
|
+
_AXES_VIEWER === null || _AXES_VIEWER === void 0 ? void 0 : _AXES_VIEWER.dispose();
|
|
44
|
+
const worldCoordRoot = utilityLayerScene.getTransformNodeByName(_WORLD_COORD_ROOT_KEY);
|
|
45
|
+
if (worldCoordRoot) {
|
|
46
|
+
worldCoordRoot.dispose(false, true);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.hideWorldCoordinates = hideWorldCoordinates;
|
|
50
|
+
/**
|
|
51
|
+
* Adjust and enhance coordinate axes to fulfill our needs.
|
|
52
|
+
* - moves nodes into common root
|
|
53
|
+
* - adds text node
|
|
54
|
+
*/
|
|
55
|
+
function _prepareWorldCoordinateAxis(text, axis, root, dimension, utilityLayerScene) {
|
|
56
|
+
// create unique names
|
|
57
|
+
axis.name = `${_WORLD_COORD_ROOT_KEY}.${text}`;
|
|
58
|
+
axis.parent = root;
|
|
59
|
+
// create text mesh via dynamic texture
|
|
60
|
+
const dynamicTexture = new dynamicTexture_1.DynamicTexture(`${_WORLD_COORD_ROOT_KEY}.${text}`, 50, utilityLayerScene, true);
|
|
61
|
+
dynamicTexture.hasAlpha = true;
|
|
62
|
+
// 42.5 is a magic offset, so that the text is vertically centered for font size 50px
|
|
63
|
+
// horizontal centering works well with the standard behaviour of Babylon.js (setting "null" as "width")
|
|
64
|
+
dynamicTexture.drawText(text, null, 42.5, 'bold 50px Arial', 'white', 'transparent', true);
|
|
65
|
+
const material = new standardMaterial_1.StandardMaterial(`${_WORLD_COORD_ROOT_KEY}.${text}`, utilityLayerScene);
|
|
66
|
+
material.disableLighting = true;
|
|
67
|
+
material.emissiveColor = _DEBUG_AXIS_MAP[text].color;
|
|
68
|
+
material.diffuseTexture = dynamicTexture;
|
|
69
|
+
const plane = meshBuilder_1.MeshBuilder.CreatePlane(`${_WORLD_COORD_ROOT_KEY}.${text}.TextPlane`, { size: dimension / 10 }, utilityLayerScene);
|
|
70
|
+
// make sure that text is located outside of arrow
|
|
71
|
+
plane.position = _DEBUG_AXIS_MAP[text].position.multiplyByFloats(dimension * 1.05, dimension * 1.05, dimension * 1.05);
|
|
72
|
+
plane.parent = root;
|
|
73
|
+
plane.material = material;
|
|
74
|
+
// will be rendered on top of "default" meshes => taken from Babylon.js repo "AxesViewer" implementation
|
|
75
|
+
plane.renderingGroupId = 2;
|
|
76
|
+
// setting billboard mode ensures, that the text is always readable
|
|
77
|
+
plane.billboardMode = transformNode_1.TransformNode.BILLBOARDMODE_ALL;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Calculate factor for creating world coordinate axes with exactly one unit in length
|
|
81
|
+
*/
|
|
82
|
+
function _getWorldCoordinatesAxesUnifyFactor() {
|
|
83
|
+
// These constants are taken from the Babylon.js repository
|
|
84
|
+
const coneZPosOffset = 0.3;
|
|
85
|
+
const coneHeight = 0.075;
|
|
86
|
+
const baseScaling = 4;
|
|
87
|
+
// cone is moved 0.3 units away from the center
|
|
88
|
+
// the origin of the cone will be located on 1.2, if combined with the base scaling of 4
|
|
89
|
+
// invert that offset to get the origin to 1
|
|
90
|
+
// also consider the cone height to move the tip of the cone to 1 instead the center
|
|
91
|
+
const factor = 1 / ((coneZPosOffset + coneHeight / 2) * baseScaling);
|
|
92
|
+
return factor;
|
|
93
|
+
}
|
|
94
94
|
//# sourceMappingURL=debugHelper.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the current device is an iPhone
|
|
3
|
-
*/
|
|
4
|
-
declare const getIsIPhone: () => boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Checks if the current device is "scaled down", as defined in the Spec
|
|
7
|
-
*/
|
|
8
|
-
declare const getIsScaledDownDevice: () => boolean;
|
|
9
|
-
export { getIsIPhone, getIsScaledDownDevice };
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current device is an iPhone
|
|
3
|
+
*/
|
|
4
|
+
declare const getIsIPhone: () => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the current device is "scaled down", as defined in the Spec
|
|
7
|
+
*/
|
|
8
|
+
declare const getIsScaledDownDevice: () => boolean;
|
|
9
|
+
export { getIsIPhone, getIsScaledDownDevice };
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIsScaledDownDevice = exports.getIsIPhone = void 0;
|
|
4
|
-
const specStorage_1 = require("../store/specStorage");
|
|
5
|
-
/**
|
|
6
|
-
* Checks if the current device is an iPhone
|
|
7
|
-
*/
|
|
8
|
-
const getIsIPhone = () => {
|
|
9
|
-
const isIPhone = /iPhone/.test(navigator.userAgent);
|
|
10
|
-
return isIPhone;
|
|
11
|
-
};
|
|
12
|
-
exports.getIsIPhone = getIsIPhone;
|
|
13
|
-
/**
|
|
14
|
-
* Checks if the current device is "scaled down", as defined in the Spec
|
|
15
|
-
*/
|
|
16
|
-
const getIsScaledDownDevice = () => {
|
|
17
|
-
var _a;
|
|
18
|
-
const sceneJson = specStorage_1.SpecStorage.get('scene');
|
|
19
|
-
if (!((_a = sceneJson.engine) === null || _a === void 0 ? void 0 : _a.limitTextureSize)) {
|
|
20
|
-
// no down scaling defined
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
// check device
|
|
24
|
-
const deviceFits = sceneJson.engine.limitTextureSize.devices === 'all' ||
|
|
25
|
-
(sceneJson.engine.limitTextureSize.devices === 'iPhone' && getIsIPhone());
|
|
26
|
-
return deviceFits;
|
|
27
|
-
};
|
|
28
|
-
exports.getIsScaledDownDevice = getIsScaledDownDevice;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getIsScaledDownDevice = exports.getIsIPhone = void 0;
|
|
4
|
+
const specStorage_1 = require("../store/specStorage");
|
|
5
|
+
/**
|
|
6
|
+
* Checks if the current device is an iPhone
|
|
7
|
+
*/
|
|
8
|
+
const getIsIPhone = () => {
|
|
9
|
+
const isIPhone = /iPhone/.test(navigator.userAgent);
|
|
10
|
+
return isIPhone;
|
|
11
|
+
};
|
|
12
|
+
exports.getIsIPhone = getIsIPhone;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the current device is "scaled down", as defined in the Spec
|
|
15
|
+
*/
|
|
16
|
+
const getIsScaledDownDevice = () => {
|
|
17
|
+
var _a;
|
|
18
|
+
const sceneJson = specStorage_1.SpecStorage.get('scene');
|
|
19
|
+
if (!((_a = sceneJson.engine) === null || _a === void 0 ? void 0 : _a.limitTextureSize)) {
|
|
20
|
+
// no down scaling defined
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
// check device
|
|
24
|
+
const deviceFits = sceneJson.engine.limitTextureSize.devices === 'all' ||
|
|
25
|
+
(sceneJson.engine.limitTextureSize.devices === 'iPhone' && getIsIPhone());
|
|
26
|
+
return deviceFits;
|
|
27
|
+
};
|
|
28
|
+
exports.getIsScaledDownDevice = getIsScaledDownDevice;
|
|
29
29
|
//# sourceMappingURL=deviceHelper.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
|
|
2
|
-
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
3
|
-
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a "standard" mesh from an instanced mesh, by cloning the source mesh and applying transformation data
|
|
6
|
-
*/
|
|
7
|
-
declare const createMeshFromInstancedMesh: (instancedMesh: InstancedMesh, newName: string, clonedParent: Nullable<TransformNode>) => Mesh;
|
|
8
|
-
/**
|
|
9
|
-
* Removes transformation data from the mesh and stores it in the geometry, which is called "baking".
|
|
10
|
-
* Also considers the geometry change from morph targets.
|
|
11
|
-
*/
|
|
12
|
-
declare const bakeGeometryOfMesh: (mesh: Mesh) => void;
|
|
13
|
-
/**
|
|
14
|
-
* Resets transformation to initial state
|
|
15
|
-
*/
|
|
16
|
-
declare const resetTransformation: (node: TransformNode) => void;
|
|
17
|
-
export { createMeshFromInstancedMesh, bakeGeometryOfMesh, resetTransformation };
|
|
1
|
+
import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
|
|
2
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
3
|
+
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a "standard" mesh from an instanced mesh, by cloning the source mesh and applying transformation data
|
|
6
|
+
*/
|
|
7
|
+
declare const createMeshFromInstancedMesh: (instancedMesh: InstancedMesh, newName: string, clonedParent: Nullable<TransformNode>) => Mesh;
|
|
8
|
+
/**
|
|
9
|
+
* Removes transformation data from the mesh and stores it in the geometry, which is called "baking".
|
|
10
|
+
* Also considers the geometry change from morph targets.
|
|
11
|
+
*/
|
|
12
|
+
declare const bakeGeometryOfMesh: (mesh: Mesh) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Resets transformation to initial state
|
|
15
|
+
*/
|
|
16
|
+
declare const resetTransformation: (node: TransformNode) => void;
|
|
17
|
+
export { createMeshFromInstancedMesh, bakeGeometryOfMesh, resetTransformation };
|
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resetTransformation = exports.bakeGeometryOfMesh = exports.createMeshFromInstancedMesh = void 0;
|
|
4
|
-
const buffer_1 = require("@babylonjs/core/Buffers/buffer");
|
|
5
|
-
const math_vector_1 = require("@babylonjs/core/Maths/math.vector");
|
|
6
|
-
/**
|
|
7
|
-
* Creates a "standard" mesh from an instanced mesh, by cloning the source mesh and applying transformation data
|
|
8
|
-
*/
|
|
9
|
-
const createMeshFromInstancedMesh = function (instancedMesh, newName, clonedParent) {
|
|
10
|
-
// first create a clone of the source mesh
|
|
11
|
-
const newMesh = instancedMesh.sourceMesh.clone(newName, clonedParent, true);
|
|
12
|
-
// apply the transformation data, it's important to create clones of the transformations to not touch the original
|
|
13
|
-
// transformation when applying changes (eg: geometry baking)
|
|
14
|
-
newMesh.position = instancedMesh.position.clone();
|
|
15
|
-
newMesh.rotation = instancedMesh.rotation.clone();
|
|
16
|
-
newMesh.scaling = instancedMesh.scaling.clone();
|
|
17
|
-
// rotation quaternion is optional
|
|
18
|
-
if (instancedMesh.rotationQuaternion) {
|
|
19
|
-
newMesh.rotationQuaternion = instancedMesh.rotationQuaternion.clone();
|
|
20
|
-
}
|
|
21
|
-
// also sync the enabled state from the original instanced mesh
|
|
22
|
-
newMesh.setEnabled(instancedMesh.isEnabled(false));
|
|
23
|
-
return newMesh;
|
|
24
|
-
};
|
|
25
|
-
exports.createMeshFromInstancedMesh = createMeshFromInstancedMesh;
|
|
26
|
-
/**
|
|
27
|
-
* Removes transformation data from the mesh and stores it in the geometry, which is called "baking".
|
|
28
|
-
* Also considers the geometry change from morph targets.
|
|
29
|
-
*/
|
|
30
|
-
const bakeGeometryOfMesh = function (mesh) {
|
|
31
|
-
if (!mesh.geometry) {
|
|
32
|
-
// no geometry available, nothing to do
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
// geometries can be shared across multiple meshes, first make them unique to avoid side-effects
|
|
36
|
-
mesh.makeGeometryUnique();
|
|
37
|
-
// Babylon.js already provides a function for baking the current skeleton changes into the geometry
|
|
38
|
-
if (mesh.skeleton) {
|
|
39
|
-
mesh.applySkeleton(mesh.skeleton);
|
|
40
|
-
mesh.skeleton = null;
|
|
41
|
-
}
|
|
42
|
-
// NOTE: in difference to skeletons and transformations there is no baking function for morph targets (yet)
|
|
43
|
-
// however another approach could be to re-apply the position and normals data, as there are nice functions for it
|
|
44
|
-
// - `getPositionData(applySkeleton: boolean = false, applyMorph: boolean = false)`
|
|
45
|
-
// - `getNormalsData(applySkeleton: boolean = false, applyMorph: boolean = false)`
|
|
46
|
-
// you can decide if skeletons and morph targets can be added, which is exactly what we want
|
|
47
|
-
// I'm still hesitant to use it because "tangent" and "UV" kinds are not supported, whereas I'm not sure if it's
|
|
48
|
-
// required
|
|
49
|
-
// => try it out when there is enough time for detailed regression tests!
|
|
50
|
-
const morphTargetManager = mesh.morphTargetManager;
|
|
51
|
-
const geometry = mesh.geometry;
|
|
52
|
-
if (morphTargetManager === null || morphTargetManager === void 0 ? void 0 : morphTargetManager.numTargets) {
|
|
53
|
-
// apply morph target vertices data to mesh geometry
|
|
54
|
-
// mostly only the "PositionKind" is implemented
|
|
55
|
-
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.PositionKind, morphTargetManager, geometry);
|
|
56
|
-
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.NormalKind, morphTargetManager, geometry);
|
|
57
|
-
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.TangentKind, morphTargetManager, geometry);
|
|
58
|
-
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.UVKind, morphTargetManager, geometry);
|
|
59
|
-
// remove morph target manager with all it's morph targets
|
|
60
|
-
mesh.morphTargetManager = null;
|
|
61
|
-
}
|
|
62
|
-
// bake the transformation data in the mesh geometry, fortunately there is already a help function from Babylon.js
|
|
63
|
-
mesh.bakeCurrentTransformIntoVertices();
|
|
64
|
-
};
|
|
65
|
-
exports.bakeGeometryOfMesh = bakeGeometryOfMesh;
|
|
66
|
-
/**
|
|
67
|
-
* Resets transformation to initial state
|
|
68
|
-
*/
|
|
69
|
-
const resetTransformation = function (node) {
|
|
70
|
-
node.position = new math_vector_1.Vector3(0, 0, 0);
|
|
71
|
-
node.rotation = new math_vector_1.Vector3(0, 0, 0);
|
|
72
|
-
node.rotationQuaternion = null;
|
|
73
|
-
node.scaling = new math_vector_1.Vector3(1, 1, 1);
|
|
74
|
-
};
|
|
75
|
-
exports.resetTransformation = resetTransformation;
|
|
76
|
-
/**
|
|
77
|
-
* @param kind morph targets can affect various vertices kinds, whereas "position" is the most common one
|
|
78
|
-
* still other kinds (like normals or tangents) can be affected as well and can be provided on this input
|
|
79
|
-
*/
|
|
80
|
-
const _bakeMorphTargetManagerIntoVertices = function (kind, morphTargetManager, geometry) {
|
|
81
|
-
const origVerticesData = geometry.getVerticesData(kind);
|
|
82
|
-
if (!origVerticesData) {
|
|
83
|
-
// no vertices data for this kind availabe on the mesh geometry
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
let verticesData = [...origVerticesData];
|
|
87
|
-
for (let i = 0; i < morphTargetManager.numTargets; i++) {
|
|
88
|
-
const target = morphTargetManager.getTarget(i);
|
|
89
|
-
const targetVerticesData = _getVerticesDataFromMorphTarget(kind, target);
|
|
90
|
-
if (targetVerticesData) {
|
|
91
|
-
// vertices data of this kind are implemented on the morph target
|
|
92
|
-
// add the influence of this morph target to the vertices data
|
|
93
|
-
// formula is taken from: https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets#basics
|
|
94
|
-
verticesData = verticesData.map((oldVal, idx) => oldVal + (targetVerticesData[idx] - origVerticesData[idx]) * target.influence);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
// apply the updated vertices data
|
|
98
|
-
geometry.setVerticesData(kind, verticesData);
|
|
99
|
-
};
|
|
100
|
-
const _getVerticesDataFromMorphTarget = function (kind, morphTarget) {
|
|
101
|
-
switch (kind) {
|
|
102
|
-
case buffer_1.VertexBuffer.PositionKind:
|
|
103
|
-
return morphTarget.getPositions();
|
|
104
|
-
case buffer_1.VertexBuffer.NormalKind:
|
|
105
|
-
return morphTarget.getNormals();
|
|
106
|
-
case buffer_1.VertexBuffer.TangentKind:
|
|
107
|
-
return morphTarget.getTangents();
|
|
108
|
-
case buffer_1.VertexBuffer.UVKind:
|
|
109
|
-
return morphTarget.getUVs();
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetTransformation = exports.bakeGeometryOfMesh = exports.createMeshFromInstancedMesh = void 0;
|
|
4
|
+
const buffer_1 = require("@babylonjs/core/Buffers/buffer");
|
|
5
|
+
const math_vector_1 = require("@babylonjs/core/Maths/math.vector");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a "standard" mesh from an instanced mesh, by cloning the source mesh and applying transformation data
|
|
8
|
+
*/
|
|
9
|
+
const createMeshFromInstancedMesh = function (instancedMesh, newName, clonedParent) {
|
|
10
|
+
// first create a clone of the source mesh
|
|
11
|
+
const newMesh = instancedMesh.sourceMesh.clone(newName, clonedParent, true);
|
|
12
|
+
// apply the transformation data, it's important to create clones of the transformations to not touch the original
|
|
13
|
+
// transformation when applying changes (eg: geometry baking)
|
|
14
|
+
newMesh.position = instancedMesh.position.clone();
|
|
15
|
+
newMesh.rotation = instancedMesh.rotation.clone();
|
|
16
|
+
newMesh.scaling = instancedMesh.scaling.clone();
|
|
17
|
+
// rotation quaternion is optional
|
|
18
|
+
if (instancedMesh.rotationQuaternion) {
|
|
19
|
+
newMesh.rotationQuaternion = instancedMesh.rotationQuaternion.clone();
|
|
20
|
+
}
|
|
21
|
+
// also sync the enabled state from the original instanced mesh
|
|
22
|
+
newMesh.setEnabled(instancedMesh.isEnabled(false));
|
|
23
|
+
return newMesh;
|
|
24
|
+
};
|
|
25
|
+
exports.createMeshFromInstancedMesh = createMeshFromInstancedMesh;
|
|
26
|
+
/**
|
|
27
|
+
* Removes transformation data from the mesh and stores it in the geometry, which is called "baking".
|
|
28
|
+
* Also considers the geometry change from morph targets.
|
|
29
|
+
*/
|
|
30
|
+
const bakeGeometryOfMesh = function (mesh) {
|
|
31
|
+
if (!mesh.geometry) {
|
|
32
|
+
// no geometry available, nothing to do
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// geometries can be shared across multiple meshes, first make them unique to avoid side-effects
|
|
36
|
+
mesh.makeGeometryUnique();
|
|
37
|
+
// Babylon.js already provides a function for baking the current skeleton changes into the geometry
|
|
38
|
+
if (mesh.skeleton) {
|
|
39
|
+
mesh.applySkeleton(mesh.skeleton);
|
|
40
|
+
mesh.skeleton = null;
|
|
41
|
+
}
|
|
42
|
+
// NOTE: in difference to skeletons and transformations there is no baking function for morph targets (yet)
|
|
43
|
+
// however another approach could be to re-apply the position and normals data, as there are nice functions for it
|
|
44
|
+
// - `getPositionData(applySkeleton: boolean = false, applyMorph: boolean = false)`
|
|
45
|
+
// - `getNormalsData(applySkeleton: boolean = false, applyMorph: boolean = false)`
|
|
46
|
+
// you can decide if skeletons and morph targets can be added, which is exactly what we want
|
|
47
|
+
// I'm still hesitant to use it because "tangent" and "UV" kinds are not supported, whereas I'm not sure if it's
|
|
48
|
+
// required
|
|
49
|
+
// => try it out when there is enough time for detailed regression tests!
|
|
50
|
+
const morphTargetManager = mesh.morphTargetManager;
|
|
51
|
+
const geometry = mesh.geometry;
|
|
52
|
+
if (morphTargetManager === null || morphTargetManager === void 0 ? void 0 : morphTargetManager.numTargets) {
|
|
53
|
+
// apply morph target vertices data to mesh geometry
|
|
54
|
+
// mostly only the "PositionKind" is implemented
|
|
55
|
+
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.PositionKind, morphTargetManager, geometry);
|
|
56
|
+
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.NormalKind, morphTargetManager, geometry);
|
|
57
|
+
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.TangentKind, morphTargetManager, geometry);
|
|
58
|
+
_bakeMorphTargetManagerIntoVertices(buffer_1.VertexBuffer.UVKind, morphTargetManager, geometry);
|
|
59
|
+
// remove morph target manager with all it's morph targets
|
|
60
|
+
mesh.morphTargetManager = null;
|
|
61
|
+
}
|
|
62
|
+
// bake the transformation data in the mesh geometry, fortunately there is already a help function from Babylon.js
|
|
63
|
+
mesh.bakeCurrentTransformIntoVertices();
|
|
64
|
+
};
|
|
65
|
+
exports.bakeGeometryOfMesh = bakeGeometryOfMesh;
|
|
66
|
+
/**
|
|
67
|
+
* Resets transformation to initial state
|
|
68
|
+
*/
|
|
69
|
+
const resetTransformation = function (node) {
|
|
70
|
+
node.position = new math_vector_1.Vector3(0, 0, 0);
|
|
71
|
+
node.rotation = new math_vector_1.Vector3(0, 0, 0);
|
|
72
|
+
node.rotationQuaternion = null;
|
|
73
|
+
node.scaling = new math_vector_1.Vector3(1, 1, 1);
|
|
74
|
+
};
|
|
75
|
+
exports.resetTransformation = resetTransformation;
|
|
76
|
+
/**
|
|
77
|
+
* @param kind morph targets can affect various vertices kinds, whereas "position" is the most common one
|
|
78
|
+
* still other kinds (like normals or tangents) can be affected as well and can be provided on this input
|
|
79
|
+
*/
|
|
80
|
+
const _bakeMorphTargetManagerIntoVertices = function (kind, morphTargetManager, geometry) {
|
|
81
|
+
const origVerticesData = geometry.getVerticesData(kind);
|
|
82
|
+
if (!origVerticesData) {
|
|
83
|
+
// no vertices data for this kind availabe on the mesh geometry
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
let verticesData = [...origVerticesData];
|
|
87
|
+
for (let i = 0; i < morphTargetManager.numTargets; i++) {
|
|
88
|
+
const target = morphTargetManager.getTarget(i);
|
|
89
|
+
const targetVerticesData = _getVerticesDataFromMorphTarget(kind, target);
|
|
90
|
+
if (targetVerticesData) {
|
|
91
|
+
// vertices data of this kind are implemented on the morph target
|
|
92
|
+
// add the influence of this morph target to the vertices data
|
|
93
|
+
// formula is taken from: https://doc.babylonjs.com/features/featuresDeepDive/mesh/morphTargets#basics
|
|
94
|
+
verticesData = verticesData.map((oldVal, idx) => oldVal + (targetVerticesData[idx] - origVerticesData[idx]) * target.influence);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// apply the updated vertices data
|
|
98
|
+
geometry.setVerticesData(kind, verticesData);
|
|
99
|
+
};
|
|
100
|
+
const _getVerticesDataFromMorphTarget = function (kind, morphTarget) {
|
|
101
|
+
switch (kind) {
|
|
102
|
+
case buffer_1.VertexBuffer.PositionKind:
|
|
103
|
+
return morphTarget.getPositions();
|
|
104
|
+
case buffer_1.VertexBuffer.NormalKind:
|
|
105
|
+
return morphTarget.getNormals();
|
|
106
|
+
case buffer_1.VertexBuffer.TangentKind:
|
|
107
|
+
return morphTarget.getTangents();
|
|
108
|
+
case buffer_1.VertexBuffer.UVKind:
|
|
109
|
+
return morphTarget.getUVs();
|
|
110
|
+
}
|
|
111
|
+
return null;
|
|
112
|
+
};
|
|
113
113
|
//# sourceMappingURL=geometryHelper.js.map
|