@combeenation/3d-viewer 5.0.0-ar2 → 5.0.0
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 -7
- package/dist/lib-cjs/api/classes/element.js.map +1 -1
- package/dist/lib-cjs/api/classes/placementAnimation.js +4 -1
- package/dist/lib-cjs/api/classes/placementAnimation.js.map +1 -1
- package/dist/lib-cjs/api/classes/viewer.d.ts +1 -1
- package/dist/lib-cjs/api/classes/viewer.js +9 -6
- package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
- package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +15 -16
- package/dist/lib-cjs/api/manager/gltfExportManager.js +47 -46
- package/dist/lib-cjs/api/manager/gltfExportManager.js.map +1 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +3 -1
- package/dist/lib-cjs/api/manager/variantInstanceManager.js +23 -12
- package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +1 -1
- package/dist/lib-cjs/api/util/globalTypes.d.ts +6 -0
- 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 +20 -8
- package/src/api/classes/placementAnimation.ts +4 -1
- package/src/api/classes/viewer.ts +14 -7
- package/src/api/manager/gltfExportManager.ts +61 -46
- package/src/api/manager/variantInstanceManager.ts +22 -4
- package/src/api/util/globalTypes.ts +7 -0
- package/src/api/util/structureHelper.ts +43 -0
- package/src/pagesconfig.json +4 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltfExportManager.js","sourceRoot":"","sources":["../../../../src/api/manager/gltfExportManager.ts"],"names":[],"mappings":";;;;AAAA,yEAAwE;AACxE,+DAA0D;AAC1D,oEAAmE;AAEnE,sDAAqE;AACrE,uCAAkC;AAElC;IACE;;OAEG;IACH,2BAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAElD;;OAEG;IACiB,wBAAM,GAA1B,UAA2B,MAAc;;;gBACvC,sBAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAC;;;KACtC;IAED
|
|
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,2DAAwE;AACxE,uCAAkC;AAElC;IACE;;OAEG;IACH,2BAAgC,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;IAElD;;OAEG;IACiB,wBAAM,GAA1B,UAA2B,MAAc;;;gBACvC,sBAAO,IAAI,iBAAiB,CAAC,MAAM,CAAC,EAAC;;;KACtC;IAED;;;;;OAKG;IACU,qCAAS,GAAtB,UACE,QAA2B,EAC3B,aAAkC,EAClC,QAA2B;QAF3B,yBAAA,EAAA,2BAA2B;QAC3B,8BAAA,EAAA,kBAAkC;;;;;;wBAGlC,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBACR,qBAAM,yBAAW,CAAC,QAAQ,CACxC,IAAI,CAAC,MAAM,CAAC,KAAK,EACjB,OAAO,EACP,IAAI,CAAC,iBAAiB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAChD,EAAA;;wBAJK,OAAO,GAAG,SAIf;wBACD,IAAI,CAAC,iBAAiB,EAAE,CAAC;wBACnB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;wBAE/C,iFAAiF;wBACjF,IAAI,OAAO,YAAY,IAAI,EAAE;4BAC3B,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gCAC9B,QAAQ,IAAI,MAAM,CAAC;6BACpB;4BACD,sBAAO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QAAQ,GAAE,CAAC,CAAC,6KAA6K;QACtP,cAAc,CAAC,iBAAiB,GAAG,IAAI,CAAC;QACxC,cAAc,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC,kDAAkD;QACpG,cAAc,CAAC,KAAK,GAAG,GAAG,CAAC;QAC3B,cAAc,CAAC,WAAW,GAAG,IAAI,mBAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvD,cAAc,CAAC,gBAAgB,GAAG,yBAAW,CAAC,sBAAsB,CAAC;QACrE,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC/B,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC;QAEhC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED;;;OAGG;IACO,qDAAyB,GAAnC,UAAoC,GAAgB;QAClD,OAAO,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC;IACjC,CAAC;IACH,wBAAC;AAAD,CAAC,AAtLD,IAsLC;AAtLY,8CAAiB"}
|
|
@@ -7,6 +7,7 @@ import { VariantInstance } from '../classes/variantInstance';
|
|
|
7
7
|
*/
|
|
8
8
|
export declare class VariantInstanceManager extends EventBroadcaster {
|
|
9
9
|
protected rootVariant: Variant;
|
|
10
|
+
protected variantInstancePromises: Map<string, Promise<VariantInstance>>;
|
|
10
11
|
protected variantInstances: Map<string, VariantInstance>;
|
|
11
12
|
protected variantInstanceDefinitions: Map<string, VariantInstanceDefinition>;
|
|
12
13
|
protected parameters: ParameterBag;
|
|
@@ -36,7 +37,8 @@ export declare class VariantInstanceManager extends EventBroadcaster {
|
|
|
36
37
|
/**
|
|
37
38
|
* Retrieves a {@link VariantInstance}.
|
|
38
39
|
* If the instance has been created, the created instance will be returned.
|
|
39
|
-
* If the instance is registered, the instance will be created.
|
|
40
|
+
* If the instance is registered, the instance will be created and returned.
|
|
41
|
+
* if the instance has already been requested and is currently pending, the dedicated promise will be returned.
|
|
40
42
|
* If none of these apply, an Error is thrown.
|
|
41
43
|
*
|
|
42
44
|
* @emits {@link Event.VARIANT_INSTANCE_CREATED}
|
|
@@ -20,6 +20,7 @@ var VariantInstanceManager = /** @class */ (function (_super) {
|
|
|
20
20
|
function VariantInstanceManager(rootVariant) {
|
|
21
21
|
var _this = _super.call(this) || this;
|
|
22
22
|
_this.rootVariant = rootVariant;
|
|
23
|
+
_this.variantInstancePromises = new Map();
|
|
23
24
|
_this.variantInstances = new Map();
|
|
24
25
|
_this.variantInstanceDefinitions = new Map();
|
|
25
26
|
_this.parameters = {};
|
|
@@ -69,26 +70,36 @@ var VariantInstanceManager = /** @class */ (function (_super) {
|
|
|
69
70
|
/**
|
|
70
71
|
* Retrieves a {@link VariantInstance}.
|
|
71
72
|
* If the instance has been created, the created instance will be returned.
|
|
72
|
-
* If the instance is registered, the instance will be created.
|
|
73
|
+
* If the instance is registered, the instance will be created and returned.
|
|
74
|
+
* if the instance has already been requested and is currently pending, the dedicated promise will be returned.
|
|
73
75
|
* If none of these apply, an Error is thrown.
|
|
74
76
|
*
|
|
75
77
|
* @emits {@link Event.VARIANT_INSTANCE_CREATED}
|
|
76
78
|
*/
|
|
77
79
|
VariantInstanceManager.prototype.get = function (name) {
|
|
78
80
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
79
|
-
var definition;
|
|
81
|
+
var definition, vip;
|
|
82
|
+
var _this = this;
|
|
80
83
|
return tslib_1.__generator(this, function (_a) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
// 1) see if we have an instance of that name already and return it if found
|
|
85
|
+
if (this.variantInstances.has(name)) {
|
|
86
|
+
return [2 /*return*/, this.variantInstances.get(name)]; // cannot be null, hence the exclamation mark
|
|
87
|
+
}
|
|
88
|
+
// 2) try to get promise from list of requested instances and return it if found
|
|
89
|
+
if (this.variantInstancePromises.has(name)) {
|
|
90
|
+
return [2 /*return*/, this.variantInstancePromises.get(name)];
|
|
91
|
+
}
|
|
92
|
+
// 3) see if there's a definition of that name, create an instance from it and store the related promise
|
|
93
|
+
if (this.variantInstanceDefinitions.has(name)) {
|
|
94
|
+
definition = this.variantInstanceDefinitions.get(name);
|
|
95
|
+
vip = this.createFromDefinition(definition);
|
|
96
|
+
this.variantInstancePromises.set(name, vip);
|
|
97
|
+
// remove promise after it has been finished
|
|
98
|
+
vip.then(function () { return _this.variantInstancePromises.delete(name); });
|
|
99
|
+
return [2 /*return*/, vip];
|
|
91
100
|
}
|
|
101
|
+
//* if we are here, no instance definition of that name exists. throw error.
|
|
102
|
+
throw Error("VariantInstance with name \"" + name + "\" neither created nor configured.");
|
|
92
103
|
});
|
|
93
104
|
});
|
|
94
105
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variantInstanceManager.js","sourceRoot":"","sources":["../../../../src/api/manager/variantInstanceManager.ts"],"names":[],"mappings":";;;;AAAA,uCAAkC;AAClC,oDAAmD;AACnD,0CAAyC;AACzC,gEAA+D;AAC/D,kDAAiD;AAEjD,8DAA6D;AAE7D;;;GAGG;AACH;IAA4C,kDAAgB;
|
|
1
|
+
{"version":3,"file":"variantInstanceManager.js","sourceRoot":"","sources":["../../../../src/api/manager/variantInstanceManager.ts"],"names":[],"mappings":";;;;AAAA,uCAAkC;AAClC,oDAAmD;AACnD,0CAAyC;AACzC,gEAA+D;AAC/D,kDAAiD;AAEjD,8DAA6D;AAE7D;;;GAGG;AACH;IAA4C,kDAAgB;IAW1D;;OAEG;IACH,gCAAgC,WAAoB;QAApD,YACE,iBAAO,SACR;QAF+B,iBAAW,GAAX,WAAW,CAAS;QAb1C,6BAAuB,GAA0C,IAAI,GAAG,EAAE,CAAC;QAE3E,sBAAgB,GAAiC,IAAI,GAAG,EAAE,CAAC;QAE3D,gCAA0B,GAA2C,IAAI,GAAG,EAAE,CAAC;QAE/E,gBAAU,GAAiB,EAAE,CAAC;QAE9B,YAAM,GAAmD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wBACzD,qBAAM,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,EAAA;;wBAA1D,MAAM,GAAG,SAAiD;wBAC1D,eAAe,GAAG,IAAI,iCAAe,CAAC,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;wBACrE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;wBAC5D,IAAI,CAAC,cAAc,CAAC,aAAK,CAAC,wBAAwB,EAAE,eAAe,CAAC,CAAC;wBACrE,sBAAO,eAAe,EAAC;;;;KACxB;IAED;;;OAGG;IACO,iDAAgB,GAA1B,UAA2B,IAAY;QACrC,IAAI,YAAY,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;YAC7B,YAAY,GAAM,IAAI,SAAI,CAAG,CAAC;YAC9B,CAAC,EAAE,CAAC;SACL;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IACH,6BAAC;AAAD,CAAC,AA5PD,CAA4C,mCAAgB,GA4P3D;AA5PY,wDAAsB"}
|
|
@@ -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,WAA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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": "5.
|
|
47
|
-
"@babylonjs/inspector": "5.
|
|
48
|
-
"@babylonjs/loaders": "5.
|
|
49
|
-
"@babylonjs/materials": "5.
|
|
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"
|
|
@@ -37,6 +37,7 @@ import { DottedPath } from './dottedPath';
|
|
|
37
37
|
import { Parameter } from './parameter';
|
|
38
38
|
import { Variant } from './variant';
|
|
39
39
|
import { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';
|
|
40
|
+
import { Node } from '@babylonjs/core';
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* An {@link Element} of a {@link Variant}. Acts as a container for diverse definitions. Lives only in the context of a
|
|
@@ -134,6 +135,25 @@ export class Element extends VariantParameterizable {
|
|
|
134
135
|
return merge({}, this.variant.inheritedParameters, this.parameters);
|
|
135
136
|
}
|
|
136
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
|
+
|
|
137
157
|
/**
|
|
138
158
|
* @protected
|
|
139
159
|
*/
|
|
@@ -313,14 +333,6 @@ export class Element extends VariantParameterizable {
|
|
|
313
333
|
// finally apply the texture on the desired node material
|
|
314
334
|
setMaterialTexture(node, texture, false);
|
|
315
335
|
|
|
316
|
-
// WORK IN PROGRESS
|
|
317
|
-
const theMaterial: Material = node.material;
|
|
318
|
-
const theMaterialTextures = theMaterial.getActiveTextures();
|
|
319
|
-
const texturesOnScene: BaseTexture[] = node.getScene().textures;
|
|
320
|
-
// node.getScene().textures.push(texture);
|
|
321
|
-
// debugger;
|
|
322
|
-
// WORK IN PROGRESS
|
|
323
|
-
|
|
324
336
|
return this;
|
|
325
337
|
}
|
|
326
338
|
|
|
@@ -50,8 +50,11 @@ export class PlacementAnimation implements AnimationInterface {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
this.prepareAnimationDefinition();
|
|
53
|
+
// create (shallow) copy for GSAP which doesn't contain `shortestWay`,
|
|
54
|
+
// because that's not part of the original `TweenVars` input typing and therefore leads to warnings
|
|
55
|
+
const { shortestWay, ...gsapTweenVars } = this._animationDefinition;
|
|
53
56
|
this._timeline = gsap.timeline({
|
|
54
|
-
defaults:
|
|
57
|
+
defaults: gsapTweenVars,
|
|
55
58
|
paused: true,
|
|
56
59
|
});
|
|
57
60
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPointerEvent } from '@babylonjs/core';
|
|
1
|
+
import { AbstractMesh, IPointerEvent } from '@babylonjs/core';
|
|
2
2
|
import { ArcRotateCamera } from '@babylonjs/core/Cameras/arcRotateCamera';
|
|
3
3
|
import { PickingInfo } from '@babylonjs/core/Collisions/pickingInfo';
|
|
4
4
|
import { BoundingInfo } from '@babylonjs/core/Culling/boundingInfo';
|
|
@@ -12,6 +12,7 @@ import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
|
12
12
|
import { ScreenshotTools } from '@babylonjs/core/Misc/screenshotTools';
|
|
13
13
|
import { Scene } from '@babylonjs/core/scene';
|
|
14
14
|
import { WebXRSessionManager } from '@babylonjs/core/XR/webXRSessionManager';
|
|
15
|
+
import { isMeshIncludedInExclusionList } from '../util/structureHelper';
|
|
15
16
|
import { isString } from 'lodash-es';
|
|
16
17
|
import { version } from '../../buildinfo.json';
|
|
17
18
|
import { sceneSetup } from '../internal/sceneSetup';
|
|
@@ -321,7 +322,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
321
322
|
/**
|
|
322
323
|
* Calculates the bounding box from all visible meshes on the scene.
|
|
323
324
|
*/
|
|
324
|
-
public async calculateBoundingBox(): Promise<Mesh> {
|
|
325
|
+
public async calculateBoundingBox(excludeGeometry?: ExcludedGeometry): Promise<Mesh> {
|
|
325
326
|
if (this.scene.meshes.length === 0) {
|
|
326
327
|
throw new Error('There are currently no meshes on the scene.');
|
|
327
328
|
}
|
|
@@ -335,7 +336,9 @@ export class Viewer extends EventBroadcaster {
|
|
|
335
336
|
const isNotBBoxMesh = bbName !== mesh.id;
|
|
336
337
|
// ignore meshes with invalid bounding infos
|
|
337
338
|
const hasValidBBoxInfo = mesh.getBoundingInfo().boundingSphere.radius > 0;
|
|
338
|
-
|
|
339
|
+
// ignore excluded meshes
|
|
340
|
+
const isExcluded = excludeGeometry ? isMeshIncludedInExclusionList(mesh as Mesh, excludeGeometry) : false;
|
|
341
|
+
return isEnabled && isNotBBoxMesh && hasValidBBoxInfo && !isExcluded;
|
|
339
342
|
})
|
|
340
343
|
.reduce(
|
|
341
344
|
(accBBoxMinMax, curMesh, idx) => {
|
|
@@ -371,7 +374,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
371
374
|
}
|
|
372
375
|
|
|
373
376
|
// get bounding box of all visible meshes, this is the base for the autofocus algorithm
|
|
374
|
-
const boundingBox = await this.calculateBoundingBox();
|
|
377
|
+
const boundingBox = await this.calculateBoundingBox(settings?.exclude);
|
|
375
378
|
|
|
376
379
|
// focus the helper camera and set the calculated camera data to the real camera
|
|
377
380
|
const helperCamera = this.getFocusedHelperCamera(boundingBox, settings);
|
|
@@ -421,6 +424,7 @@ export class Viewer extends EventBroadcaster {
|
|
|
421
424
|
plane.material.diffuseTexture = dynamicTexture;
|
|
422
425
|
return plane;
|
|
423
426
|
};
|
|
427
|
+
|
|
424
428
|
const axisX = Mesh.CreateLines(
|
|
425
429
|
'axisX',
|
|
426
430
|
[
|
|
@@ -430,7 +434,8 @@ export class Viewer extends EventBroadcaster {
|
|
|
430
434
|
new Vector3(dimension, 0, 0),
|
|
431
435
|
new Vector3(dimension * 0.95, -0.05 * dimension, 0),
|
|
432
436
|
],
|
|
433
|
-
scene
|
|
437
|
+
scene,
|
|
438
|
+
false
|
|
434
439
|
);
|
|
435
440
|
axisX.color = new Color3(1, 0, 0);
|
|
436
441
|
const xChar = makeTextPlane('X', 'red', dimension / 10);
|
|
@@ -444,7 +449,8 @@ export class Viewer extends EventBroadcaster {
|
|
|
444
449
|
new Vector3(0, dimension, 0),
|
|
445
450
|
new Vector3(0.05 * dimension, dimension * 0.95, 0),
|
|
446
451
|
],
|
|
447
|
-
scene
|
|
452
|
+
scene,
|
|
453
|
+
false
|
|
448
454
|
);
|
|
449
455
|
axisY.color = new Color3(0, 1, 0);
|
|
450
456
|
const yChar = makeTextPlane('Y', 'green', dimension / 10);
|
|
@@ -458,7 +464,8 @@ export class Viewer extends EventBroadcaster {
|
|
|
458
464
|
new Vector3(0, 0, dimension),
|
|
459
465
|
new Vector3(0, 0.05 * dimension, dimension * 0.95),
|
|
460
466
|
],
|
|
461
|
-
scene
|
|
467
|
+
scene,
|
|
468
|
+
false
|
|
462
469
|
);
|
|
463
470
|
axisZ.color = new Color3(0, 0, 1);
|
|
464
471
|
const zChar = makeTextPlane('Z', 'blue', dimension / 10);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { Mesh } from '@babylonjs/core';
|
|
1
2
|
import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
|
|
2
3
|
import { Color3 } from '@babylonjs/core/Maths/math.color';
|
|
3
4
|
import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
4
5
|
import { Scene } from '@babylonjs/core/scene';
|
|
5
6
|
import { GLTF2Export, IExportOptions } from '@babylonjs/serializers';
|
|
7
|
+
import { isMeshIncludedInExclusionList } from '../util/structureHelper';
|
|
6
8
|
import { merge } from 'lodash-es';
|
|
7
9
|
|
|
8
10
|
export class GltfExportManager {
|
|
@@ -22,10 +24,19 @@ export class GltfExportManager {
|
|
|
22
24
|
* Exports selected nodes to a file.
|
|
23
25
|
* @param filename optional name of the exported .GLB file.
|
|
24
26
|
* @param exportOptions export options to be merged with default options. See {@link gltfExportOptions}.
|
|
27
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export.
|
|
25
28
|
*/
|
|
26
|
-
public async exportGlb(
|
|
29
|
+
public async exportGlb(
|
|
30
|
+
filename = 'glb-export.glb',
|
|
31
|
+
exportOptions: IExportOptions = {},
|
|
32
|
+
excluded?: ExcludedGeometry
|
|
33
|
+
): Promise<File | undefined> {
|
|
27
34
|
this.exportPreProcess();
|
|
28
|
-
const glbData = await GLTF2Export.GLBAsync(
|
|
35
|
+
const glbData = await GLTF2Export.GLBAsync(
|
|
36
|
+
this.viewer.scene,
|
|
37
|
+
'dummy',
|
|
38
|
+
this.gltfExportOptions(exportOptions, excluded)
|
|
39
|
+
);
|
|
29
40
|
this.exportPostProcess();
|
|
30
41
|
const resBlob = glbData.glTFFiles['dummy.glb']; // should be only one file for glb
|
|
31
42
|
|
|
@@ -45,12 +56,15 @@ export class GltfExportManager {
|
|
|
45
56
|
* Exports selected nodes to GLTF. This may result in more than one file, since textures are exported separately.
|
|
46
57
|
* @param filename name of the main (text-based) .GLTF file referring to separate texture files.
|
|
47
58
|
* @param exportOptions export options to be merged with default options. See {@link gltfExportOptions}.
|
|
59
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export.
|
|
48
60
|
*/
|
|
49
|
-
public async exportGltfToFile(filename: string, exportOptions: IExportOptions = {}) {
|
|
61
|
+
public async exportGltfToFile(filename: string, exportOptions: IExportOptions = {}, excluded?: ExcludedGeometry) {
|
|
50
62
|
this.exportPreProcess();
|
|
51
|
-
await GLTF2Export.GLTFAsync(this.viewer.scene, filename, this.gltfExportOptions(exportOptions)).then(
|
|
52
|
-
glb
|
|
53
|
-
|
|
63
|
+
await GLTF2Export.GLTFAsync(this.viewer.scene, filename, this.gltfExportOptions(exportOptions, excluded)).then(
|
|
64
|
+
glb => {
|
|
65
|
+
glb.downloadFiles();
|
|
66
|
+
}
|
|
67
|
+
);
|
|
54
68
|
this.exportPostProcess();
|
|
55
69
|
}
|
|
56
70
|
|
|
@@ -58,20 +72,22 @@ export class GltfExportManager {
|
|
|
58
72
|
* Exports selected nodes to GLB. This results in one binary file.
|
|
59
73
|
* @param filename name of the .GLB file.
|
|
60
74
|
* @param exportOptions export options to be merged with default options. See {@link gltfExportOptions}.
|
|
75
|
+
* @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
|
|
61
76
|
*/
|
|
62
|
-
public async exportGlbToFile(filename: string, exportOptions: IExportOptions = {}) {
|
|
77
|
+
public async exportGlbToFile(filename: string, exportOptions: IExportOptions = {}, excluded?: ExcludedGeometry) {
|
|
63
78
|
this.exportPreProcess();
|
|
64
|
-
await GLTF2Export.GLBAsync(this.viewer.scene, filename, this.gltfExportOptions(exportOptions)).then(
|
|
65
|
-
glb
|
|
66
|
-
|
|
79
|
+
await GLTF2Export.GLBAsync(this.viewer.scene, filename, this.gltfExportOptions(exportOptions, excluded)).then(
|
|
80
|
+
glb => {
|
|
81
|
+
glb.downloadFiles();
|
|
82
|
+
}
|
|
83
|
+
);
|
|
67
84
|
this.exportPostProcess();
|
|
68
85
|
}
|
|
69
86
|
|
|
70
87
|
/**
|
|
71
88
|
* Gets predefined {@link IExportOptions } merged with given ones.
|
|
72
|
-
* @protected
|
|
73
89
|
*/
|
|
74
|
-
protected gltfExportOptions(mergeWithOptions: IExportOptions = {}): IExportOptions {
|
|
90
|
+
protected gltfExportOptions(mergeWithOptions: IExportOptions = {}, excluded?: ExcludedGeometry): IExportOptions {
|
|
75
91
|
const defaultOptions = {
|
|
76
92
|
// includeCoordinateSystemConversionNodes: true,
|
|
77
93
|
shouldExportNode: function (node: any) {
|
|
@@ -84,6 +100,9 @@ export class GltfExportManager {
|
|
|
84
100
|
if (node.name === '__bounding_box__') {
|
|
85
101
|
return false;
|
|
86
102
|
}
|
|
103
|
+
if (excluded && node instanceof Mesh && isMeshIncludedInExclusionList(node, excluded)) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
87
106
|
return true;
|
|
88
107
|
},
|
|
89
108
|
};
|
|
@@ -92,78 +111,66 @@ export class GltfExportManager {
|
|
|
92
111
|
|
|
93
112
|
/**
|
|
94
113
|
* Stuff to be done before exporting to GLTF
|
|
95
|
-
* @protected
|
|
96
114
|
*/
|
|
97
115
|
protected exportPreProcess() {
|
|
98
116
|
this.viewer.pauseRendering();
|
|
99
|
-
this.exchangeRefractionMaterials(
|
|
117
|
+
this.exchangeRefractionMaterials();
|
|
100
118
|
}
|
|
101
119
|
|
|
102
120
|
/**
|
|
103
121
|
* Stuff to be done after the GLTF export
|
|
104
|
-
* @protected
|
|
105
122
|
*/
|
|
106
123
|
protected exportPostProcess() {
|
|
107
|
-
this.restoreRefractionMaterials(
|
|
124
|
+
this.restoreRefractionMaterials();
|
|
108
125
|
this.viewer.resumeRendering();
|
|
109
126
|
}
|
|
110
127
|
|
|
111
128
|
/**
|
|
112
129
|
* Materials with refraction set are not exported properly.
|
|
113
130
|
* Exchange all such (relevant) materials with a more export-friendly version
|
|
114
|
-
* @param suffix String to be added to the replacement material's name
|
|
115
|
-
* @protected
|
|
116
131
|
*/
|
|
117
|
-
protected exchangeRefractionMaterials(
|
|
132
|
+
protected exchangeRefractionMaterials() {
|
|
118
133
|
for (const n of this.viewer.scene.getNodes()) {
|
|
119
134
|
if (!(n instanceof AbstractMesh)) continue;
|
|
120
135
|
if (!(n.material instanceof PBRMaterial)) continue;
|
|
121
|
-
if ((n.material as PBRMaterial).subSurface.isRefractionEnabled
|
|
136
|
+
if (!(n.material as PBRMaterial).subSurface.isRefractionEnabled) continue;
|
|
122
137
|
if ((n.material as PBRMaterial).transparencyMode !== PBRMaterial.PBRMATERIAL_OPAQUE) continue;
|
|
123
138
|
// if we're here, we have a node holding a material with set refraction whose transparencyMode is set to PBRMATERIAL_OPAQUE
|
|
124
|
-
n.material = this.createRefractionMaterialReplacement(n.material
|
|
139
|
+
n.material = this.createRefractionMaterialReplacement(n.material);
|
|
125
140
|
}
|
|
126
141
|
}
|
|
127
142
|
|
|
128
143
|
/**
|
|
129
144
|
* Restore original materials with set refraction.
|
|
130
|
-
* @param suffix String added to the replacement material's name
|
|
131
|
-
* @protected
|
|
132
145
|
*/
|
|
133
|
-
protected restoreRefractionMaterials(
|
|
146
|
+
protected restoreRefractionMaterials() {
|
|
134
147
|
for (const n of this.viewer.scene.getNodes()) {
|
|
135
|
-
if (n instanceof AbstractMesh
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
148
|
+
if (!(n instanceof AbstractMesh)) continue;
|
|
149
|
+
if (!(n.material instanceof PBRMaterial)) continue;
|
|
150
|
+
if (!this.isMaterialClonedForExport(n.material)) continue;
|
|
151
|
+
// at this point we have a pbrmaterial tagged as cloned in its metadata that's set on a mesh
|
|
152
|
+
|
|
153
|
+
// restore and dispose
|
|
154
|
+
const currMaterial = n.material;
|
|
155
|
+
const prevMaterial = this.viewer.scene.getMaterialByUniqueID(n.material.metadata.clonedFrom);
|
|
156
|
+
if (prevMaterial) {
|
|
157
|
+
n.material = prevMaterial; // restore previous material
|
|
158
|
+
currMaterial.dispose(false, true); // dispose of clone
|
|
141
159
|
}
|
|
142
160
|
}
|
|
143
|
-
// dispose of all clones.
|
|
144
|
-
let allClonedMaterials = [];
|
|
145
|
-
for (const mat of this.viewer.scene.materials) {
|
|
146
|
-
if (mat.name.endsWith(suffix)) allClonedMaterials.push(mat.name);
|
|
147
|
-
}
|
|
148
|
-
allClonedMaterials.forEach(mat => {
|
|
149
|
-
this.viewer.scene.getMaterialByName(mat)?.dispose(false, true);
|
|
150
|
-
});
|
|
151
161
|
}
|
|
152
162
|
|
|
153
163
|
/**
|
|
154
164
|
* Create an export-friendly replacement material for a material using refraction.
|
|
155
165
|
* @param mat Material to be replaced
|
|
156
|
-
* @param suffix String to be added to the replacement material's name
|
|
157
|
-
* @protected
|
|
158
166
|
*/
|
|
159
|
-
protected createRefractionMaterialReplacement(mat: PBRMaterial
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (this.viewer.scene.getMaterialByName(newMatName))
|
|
163
|
-
return this.viewer.scene.getMaterialByName(newMatName) as PBRMaterial;
|
|
167
|
+
protected createRefractionMaterialReplacement(mat: PBRMaterial): PBRMaterial {
|
|
168
|
+
// if we're dealing with a clone already, return it instead of cloning
|
|
169
|
+
if (this.isMaterialClonedForExport(mat)) return mat;
|
|
164
170
|
|
|
165
171
|
// change material according to https://www.notion.so/combeenation/Glas-materials-don-t-look-glasy-after-export-d5fda2c6515e4420a8772744d3e6b460
|
|
166
|
-
let clonedMaterial = mat.clone(mat.name
|
|
172
|
+
let clonedMaterial = mat.clone(mat.name); // clone material. clone uses same name
|
|
173
|
+
clonedMaterial.metadata = { ...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
|
|
167
174
|
clonedMaterial.refractionTexture = null;
|
|
168
175
|
clonedMaterial.metallicReflectanceTexture = null; // is this the correct one for metallic roughness?
|
|
169
176
|
clonedMaterial.alpha = 0.7;
|
|
@@ -174,4 +181,12 @@ export class GltfExportManager {
|
|
|
174
181
|
|
|
175
182
|
return clonedMaterial;
|
|
176
183
|
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Inspect if a material was temporarily cloned for GLB export
|
|
187
|
+
* @param mat Material to be inspected
|
|
188
|
+
*/
|
|
189
|
+
protected isMaterialClonedForExport(mat: PBRMaterial): boolean {
|
|
190
|
+
return mat.metadata.clonedFrom;
|
|
191
|
+
}
|
|
177
192
|
}
|