@combeenation/3d-viewer 11.0.0-beta1 → 12.0.0-alpha1

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.
@@ -1,102 +1,26 @@
1
+ import { Node as BjsNode, PBRMaterial } from '../../index';
1
2
  import { Viewer } from '../classes/viewer';
2
- import { PBRMaterial } from '@babylonjs/core/Materials/PBR/pbrMaterial';
3
- import { Scene } from '@babylonjs/core/scene';
4
- import { IExportOptions } from '@babylonjs/serializers/glTF/2.0';
5
- declare type MetadataMap = {
6
- [key: string]: any;
7
- };
3
+ import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
8
4
  export declare class GltfExportManager {
9
5
  protected viewer: Viewer;
10
- protected static readonly _CLONED_FROM_MAT_METADATA_PROPERTY = "clonedFrom";
11
- static readonly NAME_BEFORE_EXPORT_METADATA_PROPERTY = "nameBeforeExport";
12
- /**
13
- * Constructor.
14
- */
6
+ protected static readonly _METADATA_PROPS: {
7
+ exportNode: string;
8
+ deleteAfterExport: string;
9
+ exchangeMaterialWith: string;
10
+ };
15
11
  protected constructor(viewer: Viewer);
16
- /**
17
- * Creates an {@link GltfExportManager}.
18
- */
19
12
  static create(viewer: Viewer): Promise<GltfExportManager>;
20
- /**
21
- * Exports selected nodes to a file.
22
- * @param filename optional name of the exported .GLB file.
23
- * @param exportOptions export options to be merged with default options.\
24
- * `exportOptions.exchangeRefractionMaterials` and `exportOptions.limitTextureSize`
25
- * default to `true` if not given.
26
- * @param optimizeForAR adjusts the exported GLB so that known AR issues get fixed automatically
27
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
28
- */
29
- exportGlb(filename?: string, { exchangeRefractionMaterials, limitTextureSize, ...exportOptions }?: IExportOptionsExtended, optimizeForAR?: boolean, excluded?: ExcludedGeometryList): Promise<File | undefined>;
30
- /**
31
- * Exports selected nodes to GLTF. This may result in more than one file, since textures are exported separately.
32
- * @param filename name of the main (text-based) .GLTF file referring to separate texture files.
33
- * @param exportOptions export options to be merged with default options.\
34
- * `exportOptions.exchangeRefractionMaterials` and `exportOptions.limitTextureSize`
35
- * default to `true` if not given.
36
- * @param optimizeForAR adjusts the exported GLB so that known AR issues get fixed automatically
37
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
38
- */
39
- exportGltfToFile(filename: string, { exchangeRefractionMaterials, limitTextureSize, ...exportOptions }?: IExportOptionsExtended, optimizeForAR?: boolean, excluded?: ExcludedGeometryList): Promise<void>;
40
- /**
41
- * Exports selected nodes to GLB. This results in one binary file.
42
- * @param filename name of the .GLB file.
43
- * @param exportOptions export options to be merged with default options.\
44
- * `exportOptions.exchangeRefractionMaterials` and `exportOptions.limitTextureSize`
45
- * default to `true` if not given.
46
- * @param optimizeForAR adjusts the exported GLB so that known AR issues get fixed automatically
47
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
48
- */
49
- exportGlbToFile(filename: string, { exchangeRefractionMaterials, limitTextureSize, ...exportOptions }?: IExportOptionsExtended, optimizeForAR?: boolean, excluded?: ExcludedGeometryList): Promise<void>;
50
- /**
51
- * Gets predefined {@link IExportOptions } merged with given ones.
52
- */
53
- protected gltfExportOptions(mergeWithOptions?: IExportOptions, excluded?: ExcludedGeometryList): IExportOptions;
54
- /**
55
- * Stuff to be done before exporting to GLTF
56
- *
57
- * @returns Either the original scene if no adjustments have been made or a copied scene (which can be disposed after
58
- * the export) if adjustments have been made
59
- */
60
- protected exportPreProcess(exchangeRefractionMaterials: boolean, limitTextureSize: boolean, optimizeForAR: boolean): Promise<{
61
- scene: Scene;
62
- sceneCopied: boolean;
63
- }>;
64
- /**
65
- * Create a copy of the viewer scene, which can be further processed and optimized for the GLB export.
66
- * There is no "scene.clone" function, therefore the scene is serialized and loaded again to achieve this result.
67
- */
68
- protected copyViewerScene(limitTextureSize: boolean): Promise<Scene>;
69
- /**
70
- * Stuff to be done after the GLTF export
71
- */
72
- protected exportPostProcess(scene: Scene, disposeScene: boolean): void;
73
- /**
74
- * Remove all node metadata and return them in a map
75
- */
76
- protected extractMetadataOfAllNodes(): MetadataMap;
77
- /**
78
- * Restore node metadata from previously cropped metadata map
79
- */
80
- protected restoreMetadataOfAllNodes(metadataMap: MetadataMap): void;
81
- /**
82
- * Materials with refraction set are not exported properly.
83
- * Exchange all such (relevant) materials with a more export-friendly version
84
- */
85
- protected exchangeRefractionMaterials(scene: Scene): void;
13
+ exportGlb(filename?: string, excluded?: ExcludedGeometryList): Promise<File | undefined>;
14
+ exportGltfToFile(filename: string, excluded?: ExcludedGeometryList): Promise<void>;
15
+ exportGlbToFile(filename: string, excluded?: ExcludedGeometryList): Promise<void>;
16
+ protected _exportPreProcess(excluded?: ExcludedGeometryList): Promise<void>;
17
+ protected _exportPostProcess(): Promise<void>;
18
+ protected _gltfExportOptions(): IExportOptions;
19
+ protected _prepareNodeForExport(node: TransformNode, clonedParent: Nullable<TransformNode>, excluded?: ExcludedGeometryList): void;
20
+ protected _shouldExportNode(node: BjsNode, excluded?: ExcludedGeometryList): boolean;
21
+ protected _shouldReplaceMaterial(material: Material): boolean;
86
22
  /**
87
23
  * Create an export-friendly replacement material for a material using refraction.
88
- * @param mat Material to be replaced
89
- */
90
- protected createRefractionMaterialReplacement(mat: PBRMaterial): PBRMaterial;
91
- /**
92
- * Inspect if a material was temporarily cloned for GLB export
93
- * @param mat Material to be inspected
94
- */
95
- protected isMaterialClonedForExport(mat: PBRMaterial): boolean;
96
- /**
97
- * Set unique mesh names for GLB export.
98
- * Duplicate names lead to problems in AR on iOS devices.
99
24
  */
100
- protected setUniqueMeshNames(scene: Scene): void;
25
+ protected _createRefractionMaterialReplacement(material: PBRMaterial): PBRMaterial;
101
26
  }
102
- export {};
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,65 +8,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
9
  });
33
10
  };
34
- var __rest = (this && this.__rest) || function (s, e) {
35
- var t = {};
36
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
37
- t[p] = s[p];
38
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
39
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
40
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
41
- t[p[i]] = s[p[i]];
42
- }
43
- return t;
44
- };
45
11
  Object.defineProperty(exports, "__esModule", { value: true });
46
12
  exports.GltfExportManager = void 0;
47
- const geometryHelper_1 = require("..//util/geometryHelper");
13
+ const index_1 = require("../../index");
48
14
  const viewer_1 = require("../classes/viewer");
49
15
  const babylonHelper_1 = require("../util/babylonHelper");
16
+ const geometryHelper_1 = require("../util/geometryHelper");
50
17
  const structureHelper_1 = require("../util/structureHelper");
51
- const engine_1 = require("@babylonjs/core/Engines/engine");
52
- const engineStore_1 = require("@babylonjs/core/Engines/engineStore");
53
- const sceneLoader_1 = require("@babylonjs/core/Loading/sceneLoader");
54
- const pbrMaterial_1 = require("@babylonjs/core/Materials/PBR/pbrMaterial");
55
- const math_color_1 = require("@babylonjs/core/Maths/math.color");
56
- const abstractMesh_1 = require("@babylonjs/core/Meshes/abstractMesh");
18
+ const mesh_1 = require("@babylonjs/core/Meshes/mesh");
57
19
  const transformNode_1 = require("@babylonjs/core/Meshes/transformNode");
58
- const sceneSerializer_1 = require("@babylonjs/core/Misc/sceneSerializer");
59
- const scene_1 = require("@babylonjs/core/scene");
60
- const _2_0_1 = require("@babylonjs/serializers/glTF/2.0");
61
- const lodash_es_1 = require("lodash-es");
20
+ const glTFSerializer_1 = require("@babylonjs/serializers/glTF/2.0/glTFSerializer");
62
21
  class GltfExportManager {
63
- /**
64
- * Constructor.
65
- */
66
22
  constructor(viewer) {
67
23
  this.viewer = viewer;
68
24
  }
69
- /**
70
- * Creates an {@link GltfExportManager}.
71
- */
72
25
  static create(viewer) {
73
26
  return __awaiter(this, void 0, void 0, function* () {
74
27
  return new GltfExportManager(viewer);
75
28
  });
76
29
  }
77
- /**
78
- * Exports selected nodes to a file.
79
- * @param filename optional name of the exported .GLB file.
80
- * @param exportOptions export options to be merged with default options.\
81
- * `exportOptions.exchangeRefractionMaterials` and `exportOptions.limitTextureSize`
82
- * default to `true` if not given.
83
- * @param optimizeForAR adjusts the exported GLB so that known AR issues get fixed automatically
84
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
85
- */
86
- exportGlb(filename = 'glb-export.glb', _a = {}, optimizeForAR, excluded) {
87
- var { exchangeRefractionMaterials = true, limitTextureSize = true } = _a, exportOptions = __rest(_a, ["exchangeRefractionMaterials", "limitTextureSize"]);
88
- if (optimizeForAR === void 0) { optimizeForAR = false; }
30
+ exportGlb(filename = 'glb-export.glb', excluded) {
89
31
  return __awaiter(this, void 0, void 0, function* () {
90
- const { scene, sceneCopied } = yield this.exportPreProcess(exchangeRefractionMaterials, limitTextureSize, optimizeForAR);
91
- const glbData = yield _2_0_1.GLTF2Export.GLBAsync(scene, 'dummy', this.gltfExportOptions(exportOptions, excluded));
92
- this.exportPostProcess(scene, sceneCopied);
32
+ yield this._exportPreProcess(excluded);
33
+ const glbData = yield glTFSerializer_1.GLTF2Export.GLBAsync(this.viewer.scene, 'dummy', this._gltfExportOptions());
34
+ yield this._exportPostProcess();
93
35
  const resBlob = glbData.glTFFiles['dummy.glb'];
94
36
  // check if result is valid, according to the typings this could also be a string
95
37
  if (resBlob instanceof Blob) {
@@ -104,220 +46,139 @@ class GltfExportManager {
104
46
  }
105
47
  });
106
48
  }
107
- /**
108
- * Exports selected nodes to GLTF. This may result in more than one file, since textures are exported separately.
109
- * @param filename name of the main (text-based) .GLTF file referring to separate texture files.
110
- * @param exportOptions export options to be merged with default options.\
111
- * `exportOptions.exchangeRefractionMaterials` and `exportOptions.limitTextureSize`
112
- * default to `true` if not given.
113
- * @param optimizeForAR adjusts the exported GLB so that known AR issues get fixed automatically
114
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
115
- */
116
- exportGltfToFile(filename, _a = {}, optimizeForAR, excluded) {
117
- var { exchangeRefractionMaterials = true, limitTextureSize = true } = _a, exportOptions = __rest(_a, ["exchangeRefractionMaterials", "limitTextureSize"]);
118
- if (optimizeForAR === void 0) { optimizeForAR = false; }
49
+ exportGltfToFile(filename, excluded) {
119
50
  return __awaiter(this, void 0, void 0, function* () {
120
- const { scene, sceneCopied } = yield this.exportPreProcess(exchangeRefractionMaterials, limitTextureSize, optimizeForAR);
121
- const gltf = yield _2_0_1.GLTF2Export.GLTFAsync(scene, filename, this.gltfExportOptions(exportOptions, excluded));
51
+ yield this._exportPreProcess(excluded);
52
+ const gltf = yield glTFSerializer_1.GLTF2Export.GLTFAsync(this.viewer.scene, filename, this._gltfExportOptions());
122
53
  gltf.downloadFiles();
123
- this.exportPostProcess(scene, sceneCopied);
54
+ this._exportPostProcess();
124
55
  });
125
56
  }
126
- /**
127
- * Exports selected nodes to GLB. This results in one binary file.
128
- * @param filename name of the .GLB file.
129
- * @param exportOptions export options to be merged with default options.\
130
- * `exportOptions.exchangeRefractionMaterials` and `exportOptions.limitTextureSize`
131
- * default to `true` if not given.
132
- * @param optimizeForAR adjusts the exported GLB so that known AR issues get fixed automatically
133
- * @param excluded optional list of geometry (meshes, elements, variants, variantInstances) to be excluded from export
134
- */
135
- exportGlbToFile(filename, _a = {}, optimizeForAR, excluded) {
136
- var { exchangeRefractionMaterials = true, limitTextureSize = true } = _a, exportOptions = __rest(_a, ["exchangeRefractionMaterials", "limitTextureSize"]);
137
- if (optimizeForAR === void 0) { optimizeForAR = false; }
57
+ exportGlbToFile(filename, excluded) {
138
58
  return __awaiter(this, void 0, void 0, function* () {
139
- const { scene, sceneCopied } = yield this.exportPreProcess(exchangeRefractionMaterials, limitTextureSize, optimizeForAR);
140
- const glb = yield _2_0_1.GLTF2Export.GLBAsync(scene, filename, this.gltfExportOptions(exportOptions, excluded));
59
+ yield this._exportPreProcess(excluded);
60
+ const glb = yield glTFSerializer_1.GLTF2Export.GLBAsync(this.viewer.scene, filename, this._gltfExportOptions());
141
61
  glb.downloadFiles();
142
- this.exportPostProcess(scene, sceneCopied);
62
+ yield this._exportPostProcess();
143
63
  });
144
64
  }
145
- /**
146
- * Gets predefined {@link IExportOptions } merged with given ones.
147
- */
148
- gltfExportOptions(mergeWithOptions = {}, excluded) {
149
- const defaultOptions = {
150
- shouldExportNode: function (node) {
151
- if (!node.isEnabled()) {
152
- return false;
153
- }
154
- if (node.name.startsWith(viewer_1.Viewer.BOUNDING_BOX_NAME)) {
155
- return false;
156
- }
157
- if (excluded && node instanceof transformNode_1.TransformNode && (0, structureHelper_1.isNodeIncludedInExclusionList)(node, excluded)) {
158
- return false;
159
- }
160
- return true;
161
- },
162
- };
163
- return (0, lodash_es_1.merge)({}, defaultOptions, mergeWithOptions);
164
- }
165
- /**
166
- * Stuff to be done before exporting to GLTF
167
- *
168
- * @returns Either the original scene if no adjustments have been made or a copied scene (which can be disposed after
169
- * the export) if adjustments have been made
170
- */
171
- exportPreProcess(exchangeRefractionMaterials, limitTextureSize, optimizeForAR) {
65
+ _exportPreProcess(excluded) {
172
66
  return __awaiter(this, void 0, void 0, function* () {
173
- if (!exchangeRefractionMaterials && !optimizeForAR && !limitTextureSize) {
174
- // no need to copy the scene if no adjustments have to be made
175
- return { scene: this.viewer.scene, sceneCopied: false };
176
- }
177
- // copy the scene for the GLB export improvements, so that the original viewer scene remains untouched
178
- const copiedScene = yield this.copyViewerScene(limitTextureSize);
179
- if (exchangeRefractionMaterials) {
180
- this.exchangeRefractionMaterials(copiedScene);
181
- }
182
- if (optimizeForAR) {
183
- this.setUniqueMeshNames(copiedScene);
184
- // get rid of negative scalings and morph targets, since iOS can't handle it in the QuickLook app
185
- (0, geometryHelper_1.bakeGeometryOfAllMeshes)(copiedScene);
186
- // certain devices can't load models with skeletons, just remove them since animations are not supported in the AR
187
- // scene anyway
188
- while (copiedScene.skeletons.length) {
189
- const skeleton = copiedScene.skeletons.pop();
190
- skeleton.dispose();
191
- }
192
- }
193
- return { scene: copiedScene, sceneCopied: true };
67
+ // handle materials
68
+ this.viewer.scene.materials
69
+ .filter(material => this._shouldReplaceMaterial(material))
70
+ .forEach(material => this._createRefractionMaterialReplacement(material));
71
+ // handle nodes
72
+ this.viewer.scene.rootNodes.forEach(rootNode => this._prepareNodeForExport(rootNode, null, excluded));
73
+ // reset transformation of all "TransformNodes", which couldn't be handled by the geometry baking algorithm
74
+ // it's important that this is done AFTER all geometries have been baked
75
+ this.viewer.scene
76
+ .getNodes()
77
+ .filter(node => { var _a; return !!((_a = node.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.exportNode]); })
78
+ .forEach(node => (0, geometryHelper_1.resetTransformation)(node));
194
79
  });
195
80
  }
196
- /**
197
- * Create a copy of the viewer scene, which can be further processed and optimized for the GLB export.
198
- * There is no "scene.clone" function, therefore the scene is serialized and loaded again to achieve this result.
199
- */
200
- copyViewerScene(limitTextureSize) {
81
+ _exportPostProcess() {
201
82
  return __awaiter(this, void 0, void 0, function* () {
202
- // required by the scene serializer
203
- yield Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "physicsenginecomponent" */ '@babylonjs/core/Physics/physicsEngineComponent')));
204
- // copy scene function uses scene serializer, which can't handle "complex" data like classes, function or recursive
205
- // data structures in metadata
206
- // it basically does a `JSON.stringify` on the metadata
207
- // therefore the metadata has to be removed from the nodes before the copy process
208
- const metadataArr = this.extractMetadataOfAllNodes();
209
- // serialize the scene
210
- const serializedScene = yield sceneSerializer_1.SceneSerializer.SerializeAsync(this.viewer.scene);
211
- // set the cropped metadata back to the viewer scene nodes
212
- this.restoreMetadataOfAllNodes(metadataArr);
213
- // load the scene into an invisible "dummy" canvas
214
- const dummyCanvas = document.createElement('canvas');
215
- const engine = new engine_1.Engine(dummyCanvas);
216
- if (limitTextureSize) {
217
- // according to some tests iOS devices break when exporting a scene with textures above 1024
218
- // this only affects the scene clone for the export
219
- engine.getCaps().maxTextureSize = 1024;
220
- }
221
- // overwritting _LastCreatedScene to fix issue: https://combeenation.youtrack.cloud/issue/CB-8972
222
- // In short: dummy scene erroneously interacts with original viewer scene
223
- // setting viewer scene as fallback again (`_LastCreatedScene`) resolves that issue
224
- const curLastScene = engineStore_1.EngineStore._LastCreatedScene;
225
- const newScene = new scene_1.Scene(engine);
226
- engineStore_1.EngineStore._LastCreatedScene = curLastScene;
227
- sceneLoader_1.SceneLoader.ShowLoadingScreen = false;
228
- yield sceneLoader_1.SceneLoader.AppendAsync('', 'data:' + JSON.stringify(serializedScene), newScene, undefined, '.babylon');
229
- return newScene;
83
+ // dispose all nodes and material that have only been created for the export
84
+ this.viewer.scene.rootNodes
85
+ .filter(rootNode => { var _a; return (_a = rootNode.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.deleteAfterExport]; })
86
+ .forEach(rootNode => rootNode.dispose());
87
+ this.viewer.scene.materials
88
+ .filter(mat => { var _a; return !!((_a = mat.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.deleteAfterExport]); })
89
+ .forEach(material => material.dispose(false, false));
230
90
  });
231
91
  }
232
- /**
233
- * Stuff to be done after the GLTF export
234
- */
235
- exportPostProcess(scene, disposeScene) {
236
- if (disposeScene) {
237
- // copied scene for GLB export is not needed anymore, therefore it can be removed
238
- scene.getEngine().dispose();
239
- }
240
- }
241
- /**
242
- * Remove all node metadata and return them in a map
243
- */
244
- extractMetadataOfAllNodes() {
245
- return this.viewer.scene.getNodes().reduce((accMetadataObj, curNode) => {
246
- const metadata = curNode.metadata;
247
- delete curNode.metadata;
248
- return Object.assign(Object.assign({}, accMetadataObj), { [curNode.uniqueId.toString()]: metadata });
249
- }, {});
92
+ _gltfExportOptions() {
93
+ return {
94
+ shouldExportNode: function (node) {
95
+ var _a;
96
+ return !!((_a = node.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.exportNode]);
97
+ },
98
+ // keep root node(s)
99
+ // this seems to be important due to the geometry baking and transformation resetting stuff
100
+ // => root node has no transformation anymore, which seems to be problematic for the import
101
+ removeNoopRootNodes: false,
102
+ };
250
103
  }
251
- /**
252
- * Restore node metadata from previously cropped metadata map
253
- */
254
- restoreMetadataOfAllNodes(metadataMap) {
255
- this.viewer.scene.getNodes().forEach(node => {
256
- const metadata = metadataMap[node.uniqueId.toString()];
257
- if (metadata) {
258
- node.metadata = metadata;
104
+ _prepareNodeForExport(node, clonedParent, excluded) {
105
+ var _a, _b;
106
+ if (!this._shouldExportNode(node, excluded)) {
107
+ return;
108
+ }
109
+ // clone original node and create unique name (via uniqueId)
110
+ const newNodeName = `${node.name}_${node.uniqueId}`;
111
+ const clonedNode = node instanceof index_1.InstancedMesh
112
+ ? (0, geometryHelper_1.createMeshFromInstancedMesh)(node, newNodeName)
113
+ : node.clone(newNodeName, clonedParent, true);
114
+ // bake transformation, so that we won't get negative values anymore
115
+ // also exchange material
116
+ if (clonedNode instanceof mesh_1.Mesh) {
117
+ (0, geometryHelper_1.bakeGeometryOfMesh)(clonedNode);
118
+ const exchangeWithMaterial = (_b = (_a = clonedNode.material) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b[GltfExportManager._METADATA_PROPS.exchangeMaterialWith];
119
+ if (exchangeWithMaterial) {
120
+ clonedNode.material = this.viewer.scene.getMaterialByName(exchangeWithMaterial);
259
121
  }
122
+ }
123
+ // signalize that this is a cloned node
124
+ (0, babylonHelper_1.injectMetadata)(clonedNode, {
125
+ [GltfExportManager._METADATA_PROPS.exportNode]: true,
126
+ [GltfExportManager._METADATA_PROPS.deleteAfterExport]: true,
260
127
  });
128
+ // recourse into children
129
+ const childs = node.getChildTransformNodes(true);
130
+ childs.forEach(child => this._prepareNodeForExport(child, clonedNode, excluded));
261
131
  }
262
- /**
263
- * Materials with refraction set are not exported properly.
264
- * Exchange all such (relevant) materials with a more export-friendly version
265
- */
266
- exchangeRefractionMaterials(scene) {
267
- for (const n of scene.getNodes()) {
268
- if (!(n instanceof abstractMesh_1.AbstractMesh))
269
- continue;
270
- if (!(n.material instanceof pbrMaterial_1.PBRMaterial))
271
- continue;
272
- if (!n.material.subSurface.isRefractionEnabled)
273
- continue;
274
- if (n.material.transparencyMode !== pbrMaterial_1.PBRMaterial.PBRMATERIAL_OPAQUE)
275
- continue;
276
- // if we're here, we have a node holding a material with set refraction whose transparencyMode is set to
277
- // PBRMATERIAL_OPAQUE
278
- n.material = this.createRefractionMaterialReplacement(n.material);
132
+ _shouldExportNode(node, excluded) {
133
+ if (!(node instanceof transformNode_1.TransformNode)) {
134
+ return false;
279
135
  }
136
+ if (node.name === viewer_1.Viewer.BOUNDING_BOX_NAME) {
137
+ return false;
138
+ }
139
+ if (!node.isEnabled()) {
140
+ return false;
141
+ }
142
+ if (excluded && (0, structureHelper_1.isNodeIncludedInExclusionList)(node, excluded)) {
143
+ return false;
144
+ }
145
+ return true;
146
+ }
147
+ _shouldReplaceMaterial(material) {
148
+ if (!(material instanceof index_1.PBRMaterial)) {
149
+ return false;
150
+ }
151
+ if (!material.subSurface.isRefractionEnabled) {
152
+ return false;
153
+ }
154
+ if (material.transparencyMode !== index_1.PBRMaterial.PBRMATERIAL_OPAQUE) {
155
+ return false;
156
+ }
157
+ return true;
280
158
  }
281
159
  /**
282
160
  * Create an export-friendly replacement material for a material using refraction.
283
- * @param mat Material to be replaced
284
161
  */
285
- createRefractionMaterialReplacement(mat) {
286
- // if we're dealing with a clone already, return it instead of cloning
287
- if (this.isMaterialClonedForExport(mat))
288
- return mat;
162
+ _createRefractionMaterialReplacement(material) {
163
+ const newName = `${material.name}_clone`;
289
164
  // change material according to https://www.notion.so/combeenation/Glas-materials-don-t-look-glasy-after-export-d5fda2c6515e4420a8772744d3e6b460
290
- const clonedMaterial = mat.clone(mat.name); // clone material. clone uses same name
291
- clonedMaterial.metadata = Object.assign(Object.assign({}, mat.metadata), { [GltfExportManager._CLONED_FROM_MAT_METADATA_PROPERTY]: 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
165
+ const clonedMaterial = material.clone(newName); // clone material
292
166
  clonedMaterial.refractionTexture = null;
293
167
  clonedMaterial.metallicReflectanceTexture = null; // is this the correct one for metallic roughness?
294
168
  clonedMaterial.alpha = 0.7;
295
- clonedMaterial.albedoColor = new math_color_1.Color3(0.3, 0.3, 0.3);
296
- clonedMaterial.transparencyMode = pbrMaterial_1.PBRMaterial.PBRMATERIAL_ALPHABLEND;
169
+ clonedMaterial.albedoColor = new index_1.Color3(0.3, 0.3, 0.3);
170
+ clonedMaterial.transparencyMode = index_1.PBRMaterial.PBRMATERIAL_ALPHABLEND;
297
171
  clonedMaterial.metallic = 0.65;
298
172
  clonedMaterial.roughness = 0.15;
173
+ (0, babylonHelper_1.injectMetadata)(material, { [GltfExportManager._METADATA_PROPS.exchangeMaterialWith]: newName });
174
+ (0, babylonHelper_1.injectMetadata)(clonedMaterial, { [GltfExportManager._METADATA_PROPS.deleteAfterExport]: true });
299
175
  return clonedMaterial;
300
176
  }
301
- /**
302
- * Inspect if a material was temporarily cloned for GLB export
303
- * @param mat Material to be inspected
304
- */
305
- isMaterialClonedForExport(mat) {
306
- return (0, lodash_es_1.has)(mat.metadata, GltfExportManager._CLONED_FROM_MAT_METADATA_PROPERTY);
307
- }
308
- /**
309
- * Set unique mesh names for GLB export.
310
- * Duplicate names lead to problems in AR on iOS devices.
311
- */
312
- setUniqueMeshNames(scene) {
313
- const allNodes = scene.getNodes().filter(node => node instanceof transformNode_1.TransformNode);
314
- allNodes.forEach(currMesh => {
315
- (0, babylonHelper_1.injectMetadata)(currMesh, { [GltfExportManager.NAME_BEFORE_EXPORT_METADATA_PROPERTY]: currMesh.name }, false);
316
- currMesh.name = `${currMesh.name}_${currMesh.uniqueId}`;
317
- });
318
- }
319
177
  }
320
178
  exports.GltfExportManager = GltfExportManager;
321
- GltfExportManager._CLONED_FROM_MAT_METADATA_PROPERTY = 'clonedFrom';
322
- GltfExportManager.NAME_BEFORE_EXPORT_METADATA_PROPERTY = 'nameBeforeExport';
179
+ GltfExportManager._METADATA_PROPS = {
180
+ exportNode: 'exportNode',
181
+ deleteAfterExport: 'deleteAfterExport',
182
+ exchangeMaterialWith: 'exchangeMaterialWith',
183
+ };
323
184
  //# sourceMappingURL=gltfExportManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"gltfExportManager.js","sourceRoot":"","sources":["../../../../src/api/manager/gltfExportManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAkE;AAClE,8CAA2C;AAC3C,yDAA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oCAAoC,CAAC,QAAqB;QAClE,MAAM,OAAO,GAAG,GAAG,QAAQ,CAAC,IAAI,QAAQ,CAAC;QACzC,gJAAgJ;QAChJ,MAAM,cAAc,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB;QACjE,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,cAAM,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QACvD,cAAc,CAAC,gBAAgB,GAAG,mBAAW,CAAC,sBAAsB,CAAC;QACrE,cAAc,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC/B,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC;QAEhC,IAAA,8BAAc,EAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,oBAAoB,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;QAChG,IAAA,8BAAc,EAAC,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhG,OAAO,cAAc,CAAC;IACxB,CAAC;;AArLH,8CAsLC;AArL2B,iCAAe,GAAG;IAC1C,UAAU,EAAE,YAAY;IACxB,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;CAC7C,CAAC"}
@@ -1,7 +1,7 @@
1
- /**
2
- * Removes morph targets and sets transformation values back to their default values.
3
- * The effects from morph targets and tranformation values will be "baked" in the geometry, so that the final appearance
4
- * of the meshes stay the same.
5
- */
6
- declare const bakeGeometryOfAllMeshes: (scene: Scene) => void;
7
- export { bakeGeometryOfAllMeshes };
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
+ declare const createMeshFromInstancedMesh: (instancedMesh: InstancedMesh, newName: string) => Mesh;
5
+ declare const bakeGeometryOfMesh: (mesh: Mesh) => void;
6
+ declare const resetTransformation: (node: TransformNode) => void;
7
+ export { createMeshFromInstancedMesh, bakeGeometryOfMesh, resetTransformation };