@combeenation/3d-viewer 4.3.0 → 5.0.0-beta4
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/dist/lib-cjs/api/classes/element.d.ts +9 -0
- package/dist/lib-cjs/api/classes/element.js +25 -0
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +30 -1
- package/dist/lib-cjs/api/classes/viewer.js +86 -24
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +40 -10
- package/dist/lib-cjs/api/manager/gltfExportManager.js +134 -19
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +7 -1
- package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -0
- package/dist/lib-cjs/api/util/structureHelper.js +45 -0
- package/dist/lib-cjs/api/util/structureHelper.js.map +1 -0
- package/package.json +5 -5
- package/src/api/classes/element.ts +21 -0
- package/src/api/classes/viewer.ts +67 -10
- package/src/api/manager/gltfExportManager.ts +192 -0
- package/src/api/util/globalTypes.ts +8 -1
- package/src/api/util/structureHelper.ts +43 -0
|
@@ -2,39 +2,62 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GltfExportManager = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
+
var core_1 = require("@babylonjs/core");
|
|
6
|
+
var pbrMaterial_1 = require("@babylonjs/core/Materials/PBR/pbrMaterial");
|
|
7
|
+
var math_color_1 = require("@babylonjs/core/Maths/math.color");
|
|
8
|
+
var abstractMesh_1 = require("@babylonjs/core/Meshes/abstractMesh");
|
|
5
9
|
var serializers_1 = require("@babylonjs/serializers");
|
|
10
|
+
var structureHelper_1 = require("api/util/structureHelper");
|
|
6
11
|
var lodash_es_1 = require("lodash-es");
|
|
7
12
|
var GltfExportManager = /** @class */ (function () {
|
|
8
13
|
/**
|
|
9
14
|
* Constructor.
|
|
10
15
|
*/
|
|
11
|
-
function GltfExportManager(
|
|
12
|
-
this.
|
|
16
|
+
function GltfExportManager(viewer) {
|
|
17
|
+
this.viewer = viewer;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* Creates an {@link GltfExportManager}.
|
|
16
21
|
*/
|
|
17
|
-
GltfExportManager.create = function (
|
|
22
|
+
GltfExportManager.create = function (viewer) {
|
|
18
23
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
19
24
|
return tslib_1.__generator(this, function (_a) {
|
|
20
|
-
return [2 /*return*/, new GltfExportManager(
|
|
25
|
+
return [2 /*return*/, new GltfExportManager(viewer)];
|
|
21
26
|
});
|
|
22
27
|
});
|
|
23
28
|
};
|
|
24
29
|
/**
|
|
25
|
-
* Exports selected nodes to a
|
|
30
|
+
* Exports selected nodes to a file.
|
|
31
|
+
* @param filename optional name of the exported .GLB file.
|
|
26
32
|
* @param exportOptions export options to be merged with default options. See {@link gltfExportOptions}.
|
|
33
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export.
|
|
27
34
|
*/
|
|
28
|
-
GltfExportManager.prototype.exportGlb = function (exportOptions) {
|
|
35
|
+
GltfExportManager.prototype.exportGlb = function (filename, exportOptions, excluded) {
|
|
36
|
+
if (filename === void 0) { filename = 'glb-export.glb'; }
|
|
29
37
|
if (exportOptions === void 0) { exportOptions = {}; }
|
|
30
38
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
31
|
-
var glbData;
|
|
39
|
+
var glbData, resBlob;
|
|
32
40
|
return tslib_1.__generator(this, function (_a) {
|
|
33
41
|
switch (_a.label) {
|
|
34
|
-
case 0:
|
|
42
|
+
case 0:
|
|
43
|
+
this.exportPreProcess();
|
|
44
|
+
return [4 /*yield*/, serializers_1.GLTF2Export.GLBAsync(this.viewer.scene, 'dummy', this.gltfExportOptions(exportOptions, excluded))];
|
|
35
45
|
case 1:
|
|
36
46
|
glbData = _a.sent();
|
|
37
|
-
|
|
47
|
+
this.exportPostProcess();
|
|
48
|
+
resBlob = glbData.glTFFiles['dummy.glb'];
|
|
49
|
+
// check if result is valid, according to the typings this could also be a string
|
|
50
|
+
if (resBlob instanceof Blob) {
|
|
51
|
+
if (!filename.endsWith('.glb')) {
|
|
52
|
+
filename += '.glb';
|
|
53
|
+
}
|
|
54
|
+
return [2 /*return*/, new File([resBlob], filename)];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
// result was not a valid blob
|
|
58
|
+
return [2 /*return*/, undefined];
|
|
59
|
+
}
|
|
60
|
+
return [2 /*return*/];
|
|
38
61
|
}
|
|
39
62
|
});
|
|
40
63
|
});
|
|
@@ -43,17 +66,21 @@ var GltfExportManager = /** @class */ (function () {
|
|
|
43
66
|
* Exports selected nodes to GLTF. This may result in more than one file, since textures are exported separately.
|
|
44
67
|
* @param filename name of the main (text-based) .GLTF file referring to separate texture files.
|
|
45
68
|
* @param exportOptions export options to be merged with default options. See {@link gltfExportOptions}.
|
|
69
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export.
|
|
46
70
|
*/
|
|
47
|
-
GltfExportManager.prototype.exportGltfToFile = function (filename, exportOptions) {
|
|
71
|
+
GltfExportManager.prototype.exportGltfToFile = function (filename, exportOptions, excluded) {
|
|
48
72
|
if (exportOptions === void 0) { exportOptions = {}; }
|
|
49
73
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
50
74
|
return tslib_1.__generator(this, function (_a) {
|
|
51
75
|
switch (_a.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
case 0:
|
|
77
|
+
this.exportPreProcess();
|
|
78
|
+
return [4 /*yield*/, serializers_1.GLTF2Export.GLTFAsync(this.viewer.scene, filename, this.gltfExportOptions(exportOptions, excluded)).then(function (glb) {
|
|
79
|
+
glb.downloadFiles();
|
|
80
|
+
})];
|
|
55
81
|
case 1:
|
|
56
82
|
_a.sent();
|
|
83
|
+
this.exportPostProcess();
|
|
57
84
|
return [2 /*return*/];
|
|
58
85
|
}
|
|
59
86
|
});
|
|
@@ -63,17 +90,21 @@ var GltfExportManager = /** @class */ (function () {
|
|
|
63
90
|
* Exports selected nodes to GLB. This results in one binary file.
|
|
64
91
|
* @param filename name of the .GLB file.
|
|
65
92
|
* @param exportOptions export options to be merged with default options. See {@link gltfExportOptions}.
|
|
93
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
|
|
66
94
|
*/
|
|
67
|
-
GltfExportManager.prototype.exportGlbToFile = function (filename, exportOptions) {
|
|
95
|
+
GltfExportManager.prototype.exportGlbToFile = function (filename, exportOptions, excluded) {
|
|
68
96
|
if (exportOptions === void 0) { exportOptions = {}; }
|
|
69
97
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
70
98
|
return tslib_1.__generator(this, function (_a) {
|
|
71
99
|
switch (_a.label) {
|
|
72
|
-
case 0:
|
|
73
|
-
|
|
74
|
-
|
|
100
|
+
case 0:
|
|
101
|
+
this.exportPreProcess();
|
|
102
|
+
return [4 /*yield*/, serializers_1.GLTF2Export.GLBAsync(this.viewer.scene, filename, this.gltfExportOptions(exportOptions, excluded)).then(function (glb) {
|
|
103
|
+
glb.downloadFiles();
|
|
104
|
+
})];
|
|
75
105
|
case 1:
|
|
76
106
|
_a.sent();
|
|
107
|
+
this.exportPostProcess();
|
|
77
108
|
return [2 /*return*/];
|
|
78
109
|
}
|
|
79
110
|
});
|
|
@@ -81,9 +112,8 @@ var GltfExportManager = /** @class */ (function () {
|
|
|
81
112
|
};
|
|
82
113
|
/**
|
|
83
114
|
* Gets predefined {@link IExportOptions } merged with given ones.
|
|
84
|
-
* @protected
|
|
85
115
|
*/
|
|
86
|
-
GltfExportManager.prototype.gltfExportOptions = function (mergeWithOptions) {
|
|
116
|
+
GltfExportManager.prototype.gltfExportOptions = function (mergeWithOptions, excluded) {
|
|
87
117
|
if (mergeWithOptions === void 0) { mergeWithOptions = {}; }
|
|
88
118
|
var defaultOptions = {
|
|
89
119
|
// includeCoordinateSystemConversionNodes: true,
|
|
@@ -97,11 +127,96 @@ var GltfExportManager = /** @class */ (function () {
|
|
|
97
127
|
if (node.name === '__bounding_box__') {
|
|
98
128
|
return false;
|
|
99
129
|
}
|
|
130
|
+
if (excluded && node instanceof core_1.Mesh && structureHelper_1.isMeshIncludedInExclusionList(node, excluded)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
100
133
|
return true;
|
|
101
134
|
},
|
|
102
135
|
};
|
|
103
136
|
return lodash_es_1.merge({}, defaultOptions, mergeWithOptions);
|
|
104
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Stuff to be done before exporting to GLTF
|
|
140
|
+
*/
|
|
141
|
+
GltfExportManager.prototype.exportPreProcess = function () {
|
|
142
|
+
this.viewer.pauseRendering();
|
|
143
|
+
this.exchangeRefractionMaterials();
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Stuff to be done after the GLTF export
|
|
147
|
+
*/
|
|
148
|
+
GltfExportManager.prototype.exportPostProcess = function () {
|
|
149
|
+
this.restoreRefractionMaterials();
|
|
150
|
+
this.viewer.resumeRendering();
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Materials with refraction set are not exported properly.
|
|
154
|
+
* Exchange all such (relevant) materials with a more export-friendly version
|
|
155
|
+
*/
|
|
156
|
+
GltfExportManager.prototype.exchangeRefractionMaterials = function () {
|
|
157
|
+
for (var _i = 0, _a = this.viewer.scene.getNodes(); _i < _a.length; _i++) {
|
|
158
|
+
var n = _a[_i];
|
|
159
|
+
if (!(n instanceof abstractMesh_1.AbstractMesh))
|
|
160
|
+
continue;
|
|
161
|
+
if (!(n.material instanceof pbrMaterial_1.PBRMaterial))
|
|
162
|
+
continue;
|
|
163
|
+
if (!n.material.subSurface.isRefractionEnabled)
|
|
164
|
+
continue;
|
|
165
|
+
if (n.material.transparencyMode !== pbrMaterial_1.PBRMaterial.PBRMATERIAL_OPAQUE)
|
|
166
|
+
continue;
|
|
167
|
+
// if we're here, we have a node holding a material with set refraction whose transparencyMode is set to PBRMATERIAL_OPAQUE
|
|
168
|
+
n.material = this.createRefractionMaterialReplacement(n.material);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Restore original materials with set refraction.
|
|
173
|
+
*/
|
|
174
|
+
GltfExportManager.prototype.restoreRefractionMaterials = function () {
|
|
175
|
+
for (var _i = 0, _a = this.viewer.scene.getNodes(); _i < _a.length; _i++) {
|
|
176
|
+
var n = _a[_i];
|
|
177
|
+
if (!(n instanceof abstractMesh_1.AbstractMesh))
|
|
178
|
+
continue;
|
|
179
|
+
if (!(n.material instanceof pbrMaterial_1.PBRMaterial))
|
|
180
|
+
continue;
|
|
181
|
+
if (!this.isMaterialClonedForExport(n.material))
|
|
182
|
+
continue;
|
|
183
|
+
// at this point we have a pbrmaterial tagged as cloned in its metadata that's set on a mesh
|
|
184
|
+
// restore and dispose
|
|
185
|
+
var currMaterial = n.material;
|
|
186
|
+
var prevMaterial = this.viewer.scene.getMaterialByUniqueID(n.material.metadata.clonedFrom);
|
|
187
|
+
if (prevMaterial) {
|
|
188
|
+
n.material = prevMaterial; // restore previous material
|
|
189
|
+
currMaterial.dispose(false, true); // dispose of clone
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* Create an export-friendly replacement material for a material using refraction.
|
|
195
|
+
* @param mat Material to be replaced
|
|
196
|
+
*/
|
|
197
|
+
GltfExportManager.prototype.createRefractionMaterialReplacement = function (mat) {
|
|
198
|
+
// if we're dealing with a clone already, return it instead of cloning
|
|
199
|
+
if (this.isMaterialClonedForExport(mat))
|
|
200
|
+
return mat;
|
|
201
|
+
// change material according to https://www.notion.so/combeenation/Glas-materials-don-t-look-glasy-after-export-d5fda2c6515e4420a8772744d3e6b460
|
|
202
|
+
var clonedMaterial = mat.clone(mat.name); // clone material. clone uses same name
|
|
203
|
+
clonedMaterial.metadata = tslib_1.__assign(tslib_1.__assign({}, mat.metadata), { clonedFrom: mat.uniqueId }); // create shallow copy of metadata on clone. see https://forum.babylonjs.com/t/the-metadata-of-the-mesh-cloned-by-the-instantiatemodelstoscene-method-is-a-shallow-copy/21563
|
|
204
|
+
clonedMaterial.refractionTexture = null;
|
|
205
|
+
clonedMaterial.metallicReflectanceTexture = null; // is this the correct one for metallic roughness?
|
|
206
|
+
clonedMaterial.alpha = 0.7;
|
|
207
|
+
clonedMaterial.albedoColor = new math_color_1.Color3(0.3, 0.3, 0.3);
|
|
208
|
+
clonedMaterial.transparencyMode = pbrMaterial_1.PBRMaterial.PBRMATERIAL_ALPHABLEND;
|
|
209
|
+
clonedMaterial.metallic = 0.65;
|
|
210
|
+
clonedMaterial.roughness = 0.15;
|
|
211
|
+
return clonedMaterial;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Inspect if a material was temporarily cloned for GLB export
|
|
215
|
+
* @param mat Material to be inspected
|
|
216
|
+
*/
|
|
217
|
+
GltfExportManager.prototype.isMaterialClonedForExport = function (mat) {
|
|
218
|
+
return mat.metadata.clonedFrom;
|
|
219
|
+
};
|
|
105
220
|
return GltfExportManager;
|
|
106
221
|
}());
|
|
107
222
|
exports.GltfExportManager = GltfExportManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltfExportManager.js","sourceRoot":"","sources":["../../../../src/api/manager/gltfExportManager.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"gltfExportManager.js","sourceRoot":"","sources":["../../../../src/api/manager/gltfExportManager.ts"],"names":[],"mappings":";;;;AAAA,wCAAuC;AACvC,yEAAwE;AACxE,+DAA0D;AAC1D,oEAAmE;AAEnE,sDAAqE;AACrE,4DAAyE;AACzE,uCAAkC;AAElC;IACE;;OAEG;IACH,2BAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IA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AAnC,UAAoC,GAAgB;QAClD,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;IACjC,CAAC;IACH,wBAAC;AAAD,CAAC,AAtLD,IAsLC;AAtLY,8CAAiB"}
|
|
@@ -27,7 +27,7 @@ declare type ArcRotateCamera = import('@babylonjs/core/Cameras/arcRotateCamera')
|
|
|
27
27
|
declare type IScreenshotSize = import('@babylonjs/core/Misc/interfaces/screenshotSize').IScreenshotSize;
|
|
28
28
|
declare type BabylonAnimation = import('@babylonjs/core/Animations/animation').Animation;
|
|
29
29
|
declare type CubeTexture = import('@babylonjs/core/Materials/Textures/cubeTexture').CubeTexture;
|
|
30
|
-
declare type MeshBuilder = import('@babylonjs/core/Meshes/meshBuilder').MeshBuilder;
|
|
30
|
+
declare type MeshBuilder = typeof import('@babylonjs/core/Meshes/meshBuilder').MeshBuilder;
|
|
31
31
|
declare type Texture = import('@babylonjs/core/Materials/Textures/texture').Texture;
|
|
32
32
|
declare type HemisphericLight = import('@babylonjs/core/Lights/hemisphericLight').HemisphericLight;
|
|
33
33
|
declare type DirectionalLight = import('@babylonjs/core/Lights/directionalLight').DirectionalLight;
|
|
@@ -209,6 +209,10 @@ declare type ScreenshotSettings = {
|
|
|
209
209
|
/** Default `false` */
|
|
210
210
|
renderSprites?: boolean;
|
|
211
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Use this to define geometry to be excluded from autofocus, GLB export, etc.
|
|
214
|
+
*/
|
|
215
|
+
declare type ExcludedGeometry = (Mesh | VariantInstance | Variant | VariantElement)[];
|
|
212
216
|
declare type AutofocusSettings = {
|
|
213
217
|
/**
|
|
214
218
|
* Can be used to customize the margins shown around the 3d model when calling {@link autofocusActiveCamera}.\
|
|
@@ -224,6 +228,8 @@ declare type AutofocusSettings = {
|
|
|
224
228
|
beta?: number;
|
|
225
229
|
/** Optional animation for the focusing camera movement */
|
|
226
230
|
animation?: string | AnimationDefinition;
|
|
231
|
+
/** Optional list of geometry to be excluded from consideration */
|
|
232
|
+
exclude?: ExcludedGeometry;
|
|
227
233
|
};
|
|
228
234
|
declare type LightDefinitions = {
|
|
229
235
|
[name: string]: LightDefinition | string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
2
|
+
/**
|
|
3
|
+
* Find out if a mesh is part of a list of excluded geometry
|
|
4
|
+
* @param mesh BJS mesh
|
|
5
|
+
* @param list list of excluded geometry
|
|
6
|
+
* @returns boolean based on whether mesh was found in list
|
|
7
|
+
*/
|
|
8
|
+
declare const isMeshIncludedInExclusionList: (mesh: Mesh, list: ExcludedGeometry) => boolean;
|
|
9
|
+
export { isMeshIncludedInExclusionList };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMeshIncludedInExclusionList = void 0;
|
|
4
|
+
var mesh_1 = require("@babylonjs/core/Meshes/mesh");
|
|
5
|
+
var variant_1 = require("../classes/variant");
|
|
6
|
+
var variantInstance_1 = require("../classes/variantInstance");
|
|
7
|
+
var element_1 = require("../classes/element");
|
|
8
|
+
/**
|
|
9
|
+
* Find out if a mesh is part of a list of excluded geometry
|
|
10
|
+
* @param mesh BJS mesh
|
|
11
|
+
* @param list list of excluded geometry
|
|
12
|
+
* @returns boolean based on whether mesh was found in list
|
|
13
|
+
*/
|
|
14
|
+
var isMeshIncludedInExclusionList = function (mesh, list) {
|
|
15
|
+
var checkMesh = function (inputMesh, meshToCheck) {
|
|
16
|
+
return inputMesh.uniqueId === meshToCheck.uniqueId;
|
|
17
|
+
};
|
|
18
|
+
var checkElement = function (inputEl, meshToCheck) {
|
|
19
|
+
return inputEl.meshesFlat.some(function (m) { return checkMesh(m, meshToCheck); });
|
|
20
|
+
};
|
|
21
|
+
var checkVariant = function (inputVariant, meshToCheck) {
|
|
22
|
+
return inputVariant.elements.some(function (el) { return checkElement(el, meshToCheck); });
|
|
23
|
+
};
|
|
24
|
+
var checkVariantInstance = function (inputVarInst, meshToCheck) {
|
|
25
|
+
return inputVarInst.variant.elements.some(function (el) { return checkElement(el, meshToCheck); });
|
|
26
|
+
};
|
|
27
|
+
var isExcluded = list.some(function (geometryToExclude) {
|
|
28
|
+
if (geometryToExclude instanceof variantInstance_1.VariantInstance) {
|
|
29
|
+
return checkVariantInstance(geometryToExclude, mesh);
|
|
30
|
+
}
|
|
31
|
+
if (geometryToExclude instanceof variant_1.Variant) {
|
|
32
|
+
return checkVariant(geometryToExclude, mesh);
|
|
33
|
+
}
|
|
34
|
+
if (geometryToExclude instanceof element_1.Element) {
|
|
35
|
+
return checkElement(geometryToExclude, mesh);
|
|
36
|
+
}
|
|
37
|
+
if (geometryToExclude instanceof mesh_1.Mesh) {
|
|
38
|
+
return checkMesh(geometryToExclude, mesh);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
});
|
|
42
|
+
return isExcluded;
|
|
43
|
+
};
|
|
44
|
+
exports.isMeshIncludedInExclusionList = isMeshIncludedInExclusionList;
|
|
45
|
+
//# sourceMappingURL=structureHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structureHelper.js","sourceRoot":"","sources":["../../../../src/api/util/structureHelper.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,8CAA6C;AAC7C,8DAA6D;AAC7D,8CAA6C;AAE7C;;;;;GAKG;AACH,IAAM,6BAA6B,GAAG,UAAU,IAAU,EAAE,IAAsB;IAChF,IAAM,SAAS,GAAG,UAAC,SAAe,EAAE,WAAiB;QACnD,OAAO,SAAS,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,CAAC;IACrD,CAAC,CAAC;IACF,IAAM,YAAY,GAAG,UAAC,OAAgB,EAAE,WAAiB;QACvD,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,UAAA,CAAC,IAAI,OAAA,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,EAAzB,CAAyB,CAAC,CAAC;IACjE,CAAC,CAAC;IACF,IAAM,YAAY,GAAG,UAAC,YAAqB,EAAE,WAAiB;QAC5D,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,EAAE,IAAI,OAAA,YAAY,CAAC,EAAE,EAAE,WAAW,CAAC,EAA7B,CAA6B,CAAC,CAAC;IACzE,CAAC,CAAC;IACF,IAAM,oBAAoB,GAAG,UAAC,YAA6B,EAAE,WAAiB;QAC5E,OAAO,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAA,EAAE,IAAI,OAAA,YAAY,CAAC,EAAE,EAAE,WAAW,CAAC,EAA7B,CAA6B,CAAC,CAAC;IACjF,CAAC,CAAC;IACF,IAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAA,iBAAiB;QAC5C,IAAI,iBAAiB,YAAY,iCAAe,EAAE;YAChD,OAAO,oBAAoB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;SACtD;QACD,IAAI,iBAAiB,YAAY,iBAAO,EAAE;YACxC,OAAO,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;SAC9C;QACD,IAAI,iBAAiB,YAAY,iBAAO,EAAE;YACxC,OAAO,YAAY,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;SAC9C;QACD,IAAI,iBAAiB,YAAY,WAAI,EAAE;YACrC,OAAO,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;SAC3C;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEO,sEAA6B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@combeenation/3d-viewer",
|
|
3
3
|
"description": "Combeenation 3D Viewer",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-beta4",
|
|
5
5
|
"homepage": "https://github.com/Combeenation/3d-viewer#readme",
|
|
6
6
|
"keywords": [],
|
|
7
7
|
"author": "",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
"format": "prettier --write ."
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@babylonjs/core": "
|
|
47
|
-
"@babylonjs/inspector": "
|
|
48
|
-
"@babylonjs/loaders": "
|
|
49
|
-
"@babylonjs/materials": "
|
|
46
|
+
"@babylonjs/core": "^5.6.0",
|
|
47
|
+
"@babylonjs/inspector": "5.6.0",
|
|
48
|
+
"@babylonjs/loaders": "5.6.0",
|
|
49
|
+
"@babylonjs/materials": "5.6.0",
|
|
50
50
|
"eventemitter3": "^4.0.0",
|
|
51
51
|
"gsap": "^3.5.1",
|
|
52
52
|
"lodash-es": "^4.17.15"
|
|
@@ -36,6 +36,8 @@ import { VariantParameterizable } from './../classes/variantParameterizable';
|
|
|
36
36
|
import { DottedPath } from './dottedPath';
|
|
37
37
|
import { Parameter } from './parameter';
|
|
38
38
|
import { Variant } from './variant';
|
|
39
|
+
import { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';
|
|
40
|
+
import { Node } from '@babylonjs/core';
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
|
|
@@ -133,6 +135,25 @@ export class Element extends VariantParameterizable {
|
|
|
133
135
|
return merge({}, this.variant.inheritedParameters, this.parameters);
|
|
134
136
|
}
|
|
135
137
|
|
|
138
|
+
/**
|
|
139
|
+
* The actual {@link Mesh}es that make up this {@link Element}.
|
|
140
|
+
* Handy for e.g. creating a bounding box around an entire element.
|
|
141
|
+
*/
|
|
142
|
+
get meshesFlat(): Mesh[] {
|
|
143
|
+
const flatMeshes = this.nodes.reduce((accFlatMeshes, curNode) => {
|
|
144
|
+
const currMeshes = curNode.getChildMeshes(false, n => n instanceof Mesh) as Mesh[];
|
|
145
|
+
return [...accFlatMeshes, ...currMeshes];
|
|
146
|
+
}, [] as Mesh[]);
|
|
147
|
+
return flatMeshes;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The meshes of this {@link Element}.
|
|
152
|
+
*/
|
|
153
|
+
get meshes(): Mesh[] {
|
|
154
|
+
return this.nodes.filter(node => node instanceof Mesh) as Mesh[];
|
|
155
|
+
}
|
|
156
|
+
|
|
136
157
|
/**
|
|
137
158
|
* @protected
|
|
138
159
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AbstractMesh, IPointerEvent } from '@babylonjs/core';
|
|
1
2
|
import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
|
|
2
3
|
import { PickingInfo } from '@babylonjs/core/Collisions/pickingInfo';
|
|
3
4
|
import { BoundingInfo } from '@babylonjs/core/Culling/boundingInfo';
|
|
@@ -10,14 +11,17 @@ import { Vector3 } from '@babylonjs/core/Maths/math.vector';
|
|
|
10
11
|
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
11
12
|
import { ScreenshotTools } from '@babylonjs/core/Misc/screenshotTools';
|
|
12
13
|
import { Scene } from '@babylonjs/core/scene';
|
|
14
|
+
import { WebXRSessionManager } from '@babylonjs/core/XR/webXRSessionManager';
|
|
15
|
+
import { isMeshIncludedInExclusionList } from 'api/util/structureHelper';
|
|
13
16
|
import { isString } from 'lodash-es';
|
|
14
17
|
import { version } from '../../buildinfo.json';
|
|
15
18
|
import { sceneSetup } from '../internal/sceneSetup';
|
|
16
19
|
import { AnimationManager } from '../manager/animationManager';
|
|
20
|
+
import { GltfExportManager } from '../manager/gltfExportManager';
|
|
17
21
|
import { SceneManager } from '../manager/sceneManager';
|
|
18
22
|
import { VariantInstanceManager } from '../manager/variantInstanceManager';
|
|
19
23
|
import { SpecStorage } from '../store/specStorage';
|
|
20
|
-
import { debounce, loadJson
|
|
24
|
+
import { debounce, loadJson } from '../util/resourceHelper';
|
|
21
25
|
import { Event } from './event';
|
|
22
26
|
import { EventBroadcaster } from './eventBroadcaster';
|
|
23
27
|
import { Parameter } from './parameter';
|
|
@@ -40,12 +44,16 @@ export class Viewer extends EventBroadcaster {
|
|
|
40
44
|
|
|
41
45
|
protected _sceneManager: SceneManager | null = null;
|
|
42
46
|
|
|
47
|
+
protected _gltfExportManager: GltfExportManager | null = null;
|
|
48
|
+
|
|
43
49
|
protected _variantInstances: VariantInstanceManager | null = null;
|
|
44
50
|
|
|
45
51
|
// default value is `true` ATM for compatibility reasons
|
|
46
52
|
// in the future material cloning should be the edge case
|
|
47
53
|
protected _cloneMaterialsOnMutation: boolean = true;
|
|
48
54
|
|
|
55
|
+
protected _isRenderLoopPaused: boolean = false;
|
|
56
|
+
|
|
49
57
|
static version = version;
|
|
50
58
|
|
|
51
59
|
/**
|
|
@@ -67,13 +75,30 @@ export class Viewer extends EventBroadcaster {
|
|
|
67
75
|
return this._scene;
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Gets the {@link SceneManager} attached to the viewer.
|
|
80
|
+
*
|
|
81
|
+
* @throws Error if the {@link SceneManager} has not been initialized.
|
|
82
|
+
*/
|
|
70
83
|
get sceneManager(): SceneManager {
|
|
71
84
|
if (!this._sceneManager) {
|
|
72
|
-
throw new Error(`
|
|
85
|
+
throw new Error(`SceneManager has not been initialized.`);
|
|
73
86
|
}
|
|
74
87
|
return this._sceneManager;
|
|
75
88
|
}
|
|
76
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Gets the {@link GltfExportManager} attached to the viewer.
|
|
92
|
+
*
|
|
93
|
+
* @throws Error if the {@link GltfExportManager} has not been initialized.
|
|
94
|
+
*/
|
|
95
|
+
get gltfExportManager(): GltfExportManager {
|
|
96
|
+
if (!this._gltfExportManager) {
|
|
97
|
+
throw new Error(`GltfExportManager has not been initialized.`);
|
|
98
|
+
}
|
|
99
|
+
return this._gltfExportManager;
|
|
100
|
+
}
|
|
101
|
+
|
|
77
102
|
/**
|
|
78
103
|
* Gets the BabylonJS Engine that is attached to the viewer.
|
|
79
104
|
*/
|
|
@@ -154,6 +179,8 @@ export class Viewer extends EventBroadcaster {
|
|
|
154
179
|
}
|
|
155
180
|
await this.createVariantInstances();
|
|
156
181
|
}
|
|
182
|
+
// create gltf export manager
|
|
183
|
+
this._gltfExportManager = await GltfExportManager.create(this);
|
|
157
184
|
// resize handler
|
|
158
185
|
window.addEventListener('resize', debounce(this.resize.bind(this), 100));
|
|
159
186
|
// wait until scene is completely ready
|
|
@@ -162,7 +189,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
162
189
|
this.broadcastEvent(Event.BOOTSTRAP_END, this);
|
|
163
190
|
// render loop
|
|
164
191
|
this.engine.runRenderLoop(() => {
|
|
165
|
-
this.scene.render();
|
|
192
|
+
if (!this._isRenderLoopPaused) this.scene.render();
|
|
166
193
|
});
|
|
167
194
|
return this;
|
|
168
195
|
}
|
|
@@ -285,10 +312,17 @@ export class Viewer extends EventBroadcaster {
|
|
|
285
312
|
});
|
|
286
313
|
}
|
|
287
314
|
|
|
315
|
+
/**
|
|
316
|
+
* Checks whether the browser is capable of handling XR.
|
|
317
|
+
*/
|
|
318
|
+
public async isBrowserARCapable(): Promise<boolean> {
|
|
319
|
+
return await WebXRSessionManager.IsSessionSupportedAsync('immersive-ar');
|
|
320
|
+
}
|
|
321
|
+
|
|
288
322
|
/**
|
|
289
323
|
* Calculates the bounding box from all visible meshes on the scene.
|
|
290
324
|
*/
|
|
291
|
-
public async calculateBoundingBox(): Promise<Mesh> {
|
|
325
|
+
public async calculateBoundingBox(excludeGeometry?: ExcludedGeometry): Promise<Mesh> {
|
|
292
326
|
if (this.scene.meshes.length === 0) {
|
|
293
327
|
throw new Error('There are currently no meshes on the scene.');
|
|
294
328
|
}
|
|
@@ -302,7 +336,9 @@ export class Viewer extends EventBroadcaster {
|
|
|
302
336
|
const isNotBBoxMesh = bbName !== mesh.id;
|
|
303
337
|
// ignore meshes with invalid bounding infos
|
|
304
338
|
const hasValidBBoxInfo = mesh.getBoundingInfo().boundingSphere.radius > 0;
|
|
305
|
-
|
|
339
|
+
// ignore excluded meshes
|
|
340
|
+
const isExcluded = excludeGeometry ? isMeshIncludedInExclusionList(mesh as Mesh, excludeGeometry) : false;
|
|
341
|
+
return isEnabled && isNotBBoxMesh && hasValidBBoxInfo && !isExcluded;
|
|
306
342
|
})
|
|
307
343
|
.reduce(
|
|
308
344
|
(accBBoxMinMax, curMesh, idx) => {
|
|
@@ -323,6 +359,9 @@ export class Viewer extends EventBroadcaster {
|
|
|
323
359
|
return boundingBox;
|
|
324
360
|
}
|
|
325
361
|
|
|
362
|
+
/**
|
|
363
|
+
* Focuses the camera to see every visible mesh in scene and tries to optimize wheel precision and panning
|
|
364
|
+
*/
|
|
326
365
|
public async autofocusActiveCamera(settings?: AutofocusSettings) {
|
|
327
366
|
// first check some preconditions
|
|
328
367
|
const activeCamera = this.scene.activeCamera;
|
|
@@ -335,7 +374,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
335
374
|
}
|
|
336
375
|
|
|
337
376
|
// get bounding box of all visible meshes, this is the base for the autofocus algorithm
|
|
338
|
-
const boundingBox = await this.calculateBoundingBox();
|
|
377
|
+
const boundingBox = await this.calculateBoundingBox(settings?.exclude);
|
|
339
378
|
|
|
340
379
|
// focus the helper camera and set the calculated camera data to the real camera
|
|
341
380
|
const helperCamera = this.getFocusedHelperCamera(boundingBox, settings);
|
|
@@ -385,6 +424,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
385
424
|
plane.material.diffuseTexture = dynamicTexture;
|
|
386
425
|
return plane;
|
|
387
426
|
};
|
|
427
|
+
|
|
388
428
|
const axisX = Mesh.CreateLines(
|
|
389
429
|
'axisX',
|
|
390
430
|
[
|
|
@@ -394,7 +434,8 @@ export class Viewer extends EventBroadcaster {
|
|
|
394
434
|
new Vector3(dimension, 0, 0),
|
|
395
435
|
new Vector3(dimension * 0.95, -0.05 * dimension, 0),
|
|
396
436
|
],
|
|
397
|
-
scene
|
|
437
|
+
scene,
|
|
438
|
+
false
|
|
398
439
|
);
|
|
399
440
|
axisX.color = new Color3(1, 0, 0);
|
|
400
441
|
const xChar = makeTextPlane('X', 'red', dimension / 10);
|
|
@@ -408,7 +449,8 @@ export class Viewer extends EventBroadcaster {
|
|
|
408
449
|
new Vector3(0, dimension, 0),
|
|
409
450
|
new Vector3(0.05 * dimension, dimension * 0.95, 0),
|
|
410
451
|
],
|
|
411
|
-
scene
|
|
452
|
+
scene,
|
|
453
|
+
false
|
|
412
454
|
);
|
|
413
455
|
axisY.color = new Color3(0, 1, 0);
|
|
414
456
|
const yChar = makeTextPlane('Y', 'green', dimension / 10);
|
|
@@ -422,13 +464,28 @@ export class Viewer extends EventBroadcaster {
|
|
|
422
464
|
new Vector3(0, 0, dimension),
|
|
423
465
|
new Vector3(0, 0.05 * dimension, dimension * 0.95),
|
|
424
466
|
],
|
|
425
|
-
scene
|
|
467
|
+
scene,
|
|
468
|
+
false
|
|
426
469
|
);
|
|
427
470
|
axisZ.color = new Color3(0, 0, 1);
|
|
428
471
|
const zChar = makeTextPlane('Z', 'blue', dimension / 10);
|
|
429
472
|
zChar.position = new Vector3(0, 0.05 * dimension, 0.9 * dimension);
|
|
430
473
|
}
|
|
431
474
|
|
|
475
|
+
/**
|
|
476
|
+
* Pause render loop.
|
|
477
|
+
*/
|
|
478
|
+
public pauseRendering() {
|
|
479
|
+
this._isRenderLoopPaused = true;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Resume render loop when paused.
|
|
484
|
+
*/
|
|
485
|
+
public resumeRendering() {
|
|
486
|
+
this._isRenderLoopPaused = false;
|
|
487
|
+
}
|
|
488
|
+
|
|
432
489
|
/**
|
|
433
490
|
* @emits {@link Event.SCENE_PROCESSING_START}
|
|
434
491
|
* @emits {@link Event.SCENE_PROCESSING_END}
|
|
@@ -444,7 +501,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
444
501
|
const scene = await sceneSetup(engine, sceneJson);
|
|
445
502
|
if (sceneJson.meshPicking) {
|
|
446
503
|
new HighlightLayer('default', scene);
|
|
447
|
-
scene.onPointerPick = (pointerEvent:
|
|
504
|
+
scene.onPointerPick = (pointerEvent: IPointerEvent, pickInfo: PickingInfo) => {
|
|
448
505
|
if (!pickInfo.hit) {
|
|
449
506
|
return;
|
|
450
507
|
}
|