@combeenation/3d-viewer 12.4.1 → 13.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.
Files changed (213) hide show
  1. package/dist/lib-cjs/buildinfo.json +1 -1
  2. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
  3. package/dist/lib-cjs/index.d.ts +63 -63
  4. package/dist/lib-cjs/index.js +81 -114
  5. package/dist/lib-cjs/index.js.map +1 -1
  6. package/dist/lib-cjs/internal/cbnCustomBabylonLoaderPlugin.d.ts +10 -0
  7. package/dist/lib-cjs/internal/cbnCustomBabylonLoaderPlugin.js +124 -0
  8. package/dist/lib-cjs/internal/cbnCustomBabylonLoaderPlugin.js.map +1 -0
  9. package/dist/lib-cjs/internal/cloningHelper.d.ts +19 -0
  10. package/dist/lib-cjs/internal/cloningHelper.js +165 -0
  11. package/dist/lib-cjs/internal/cloningHelper.js.map +1 -0
  12. package/dist/lib-cjs/internal/deviceHelper.d.ts +9 -0
  13. package/dist/lib-cjs/{api/util → internal}/deviceHelper.js +6 -10
  14. package/dist/lib-cjs/internal/deviceHelper.js.map +1 -0
  15. package/dist/lib-cjs/internal/geometryHelper.d.ts +21 -0
  16. package/dist/lib-cjs/{api/util → internal}/geometryHelper.js +57 -24
  17. package/dist/lib-cjs/internal/geometryHelper.js.map +1 -0
  18. package/dist/lib-cjs/internal/metadataHelper.d.ts +26 -0
  19. package/dist/lib-cjs/internal/metadataHelper.js +51 -0
  20. package/dist/lib-cjs/internal/metadataHelper.js.map +1 -0
  21. package/dist/lib-cjs/internal/paintableHelper.d.ts +40 -0
  22. package/dist/lib-cjs/internal/paintableHelper.js +287 -0
  23. package/dist/lib-cjs/internal/paintableHelper.js.map +1 -0
  24. package/dist/lib-cjs/internal/tagsHelper.d.ts +12 -0
  25. package/dist/lib-cjs/internal/tagsHelper.js +38 -0
  26. package/dist/lib-cjs/internal/tagsHelper.js.map +1 -0
  27. package/dist/lib-cjs/manager/cameraManager.d.ts +51 -0
  28. package/dist/lib-cjs/manager/cameraManager.js +154 -0
  29. package/dist/lib-cjs/manager/cameraManager.js.map +1 -0
  30. package/dist/lib-cjs/manager/debugManager.d.ts +60 -0
  31. package/dist/lib-cjs/manager/debugManager.js +218 -0
  32. package/dist/lib-cjs/manager/debugManager.js.map +1 -0
  33. package/dist/lib-cjs/manager/eventManager.d.ts +52 -0
  34. package/dist/lib-cjs/manager/eventManager.js +72 -0
  35. package/dist/lib-cjs/manager/eventManager.js.map +1 -0
  36. package/dist/lib-cjs/{api/manager → manager}/gltfExportManager.d.ts +29 -34
  37. package/dist/lib-cjs/{api/manager → manager}/gltfExportManager.js +99 -120
  38. package/dist/lib-cjs/manager/gltfExportManager.js.map +1 -0
  39. package/dist/lib-cjs/manager/materialManager.d.ts +35 -0
  40. package/dist/lib-cjs/manager/materialManager.js +126 -0
  41. package/dist/lib-cjs/manager/materialManager.js.map +1 -0
  42. package/dist/lib-cjs/manager/modelManager.d.ts +145 -0
  43. package/dist/lib-cjs/manager/modelManager.js +381 -0
  44. package/dist/lib-cjs/manager/modelManager.js.map +1 -0
  45. package/dist/lib-cjs/manager/parameterManager.d.ts +210 -0
  46. package/dist/lib-cjs/manager/parameterManager.js +515 -0
  47. package/dist/lib-cjs/manager/parameterManager.js.map +1 -0
  48. package/dist/lib-cjs/manager/sceneManager.d.ts +45 -0
  49. package/dist/lib-cjs/manager/sceneManager.js +65 -0
  50. package/dist/lib-cjs/manager/sceneManager.js.map +1 -0
  51. package/dist/lib-cjs/manager/screenshotManager.d.ts +36 -0
  52. package/dist/lib-cjs/manager/screenshotManager.js +40 -0
  53. package/dist/lib-cjs/manager/screenshotManager.js.map +1 -0
  54. package/dist/lib-cjs/manager/textureManager.d.ts +12 -0
  55. package/dist/lib-cjs/manager/textureManager.js +44 -0
  56. package/dist/lib-cjs/manager/textureManager.js.map +1 -0
  57. package/dist/lib-cjs/viewer.d.ts +117 -0
  58. package/dist/lib-cjs/viewer.js +222 -0
  59. package/dist/lib-cjs/viewer.js.map +1 -0
  60. package/dist/lib-cjs/{api/classes/viewerError.d.ts → viewerError.d.ts} +6 -1
  61. package/dist/lib-cjs/{api/classes/viewerError.js → viewerError.js} +6 -1
  62. package/dist/lib-cjs/viewerError.js.map +1 -0
  63. package/package.json +10 -11
  64. package/src/dev.ts +14 -37
  65. package/src/{types.d.ts → globalTypes.d.ts} +8 -18
  66. package/src/index.ts +79 -113
  67. package/src/internal/cbnCustomBabylonLoaderPlugin.ts +149 -0
  68. package/src/internal/cloningHelper.ts +225 -0
  69. package/src/internal/deviceHelper.ts +25 -0
  70. package/src/{api/util → internal}/geometryHelper.ts +63 -24
  71. package/src/internal/metadataHelper.ts +63 -0
  72. package/src/internal/paintableHelper.ts +310 -0
  73. package/src/internal/tagsHelper.ts +41 -0
  74. package/src/manager/cameraManager.ts +236 -0
  75. package/src/manager/debugManager.ts +245 -0
  76. package/src/manager/eventManager.ts +72 -0
  77. package/src/{api/manager → manager}/gltfExportManager.ts +132 -125
  78. package/src/manager/materialManager.ts +135 -0
  79. package/src/manager/modelManager.ts +456 -0
  80. package/src/manager/parameterManager.ts +652 -0
  81. package/src/manager/sceneManager.ts +101 -0
  82. package/src/manager/screenshotManager.ts +59 -0
  83. package/src/manager/textureManager.ts +32 -0
  84. package/src/viewer.ts +296 -0
  85. package/src/{api/classes/viewerError.ts → viewerError.ts} +6 -1
  86. package/dist/lib-cjs/api/classes/animationInterface.d.ts +0 -8
  87. package/dist/lib-cjs/api/classes/animationInterface.js +0 -3
  88. package/dist/lib-cjs/api/classes/animationInterface.js.map +0 -1
  89. package/dist/lib-cjs/api/classes/dottedPath.d.ts +0 -79
  90. package/dist/lib-cjs/api/classes/dottedPath.js +0 -167
  91. package/dist/lib-cjs/api/classes/dottedPath.js.map +0 -1
  92. package/dist/lib-cjs/api/classes/element.d.ts +0 -153
  93. package/dist/lib-cjs/api/classes/element.js +0 -703
  94. package/dist/lib-cjs/api/classes/element.js.map +0 -1
  95. package/dist/lib-cjs/api/classes/event.d.ts +0 -401
  96. package/dist/lib-cjs/api/classes/event.js +0 -425
  97. package/dist/lib-cjs/api/classes/event.js.map +0 -1
  98. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +0 -26
  99. package/dist/lib-cjs/api/classes/eventBroadcaster.js +0 -50
  100. package/dist/lib-cjs/api/classes/eventBroadcaster.js.map +0 -1
  101. package/dist/lib-cjs/api/classes/fuzzyMap.d.ts +0 -7
  102. package/dist/lib-cjs/api/classes/fuzzyMap.js +0 -22
  103. package/dist/lib-cjs/api/classes/fuzzyMap.js.map +0 -1
  104. package/dist/lib-cjs/api/classes/parameter.d.ts +0 -410
  105. package/dist/lib-cjs/api/classes/parameter.js +0 -643
  106. package/dist/lib-cjs/api/classes/parameter.js.map +0 -1
  107. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +0 -36
  108. package/dist/lib-cjs/api/classes/parameterObservable.js +0 -73
  109. package/dist/lib-cjs/api/classes/parameterObservable.js.map +0 -1
  110. package/dist/lib-cjs/api/classes/parameterizable.d.ts +0 -15
  111. package/dist/lib-cjs/api/classes/parameterizable.js +0 -103
  112. package/dist/lib-cjs/api/classes/parameterizable.js.map +0 -1
  113. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +0 -45
  114. package/dist/lib-cjs/api/classes/placementAnimation.js +0 -177
  115. package/dist/lib-cjs/api/classes/placementAnimation.js.map +0 -1
  116. package/dist/lib-cjs/api/classes/variant.d.ts +0 -261
  117. package/dist/lib-cjs/api/classes/variant.js +0 -873
  118. package/dist/lib-cjs/api/classes/variant.js.map +0 -1
  119. package/dist/lib-cjs/api/classes/variantInstance.d.ts +0 -53
  120. package/dist/lib-cjs/api/classes/variantInstance.js +0 -126
  121. package/dist/lib-cjs/api/classes/variantInstance.js.map +0 -1
  122. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +0 -17
  123. package/dist/lib-cjs/api/classes/variantParameterizable.js +0 -87
  124. package/dist/lib-cjs/api/classes/variantParameterizable.js.map +0 -1
  125. package/dist/lib-cjs/api/classes/viewer.d.ts +0 -215
  126. package/dist/lib-cjs/api/classes/viewer.js +0 -709
  127. package/dist/lib-cjs/api/classes/viewer.js.map +0 -1
  128. package/dist/lib-cjs/api/classes/viewerError.js.map +0 -1
  129. package/dist/lib-cjs/api/classes/viewerLight.d.ts +0 -66
  130. package/dist/lib-cjs/api/classes/viewerLight.js +0 -345
  131. package/dist/lib-cjs/api/classes/viewerLight.js.map +0 -1
  132. package/dist/lib-cjs/api/internal/lensRendering.d.ts +0 -8
  133. package/dist/lib-cjs/api/internal/lensRendering.js +0 -12
  134. package/dist/lib-cjs/api/internal/lensRendering.js.map +0 -1
  135. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +0 -13
  136. package/dist/lib-cjs/api/internal/sceneSetup.js +0 -228
  137. package/dist/lib-cjs/api/internal/sceneSetup.js.map +0 -1
  138. package/dist/lib-cjs/api/manager/animationManager.d.ts +0 -30
  139. package/dist/lib-cjs/api/manager/animationManager.js +0 -127
  140. package/dist/lib-cjs/api/manager/animationManager.js.map +0 -1
  141. package/dist/lib-cjs/api/manager/gltfExportManager.js.map +0 -1
  142. package/dist/lib-cjs/api/manager/sceneManager.d.ts +0 -33
  143. package/dist/lib-cjs/api/manager/sceneManager.js +0 -129
  144. package/dist/lib-cjs/api/manager/sceneManager.js.map +0 -1
  145. package/dist/lib-cjs/api/manager/tagManager.d.ts +0 -118
  146. package/dist/lib-cjs/api/manager/tagManager.js +0 -531
  147. package/dist/lib-cjs/api/manager/tagManager.js.map +0 -1
  148. package/dist/lib-cjs/api/manager/textureLoadManager.d.ts +0 -22
  149. package/dist/lib-cjs/api/manager/textureLoadManager.js +0 -108
  150. package/dist/lib-cjs/api/manager/textureLoadManager.js.map +0 -1
  151. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +0 -106
  152. package/dist/lib-cjs/api/manager/variantInstanceManager.js +0 -291
  153. package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +0 -1
  154. package/dist/lib-cjs/api/store/specStorage.d.ts +0 -32
  155. package/dist/lib-cjs/api/store/specStorage.js +0 -66
  156. package/dist/lib-cjs/api/store/specStorage.js.map +0 -1
  157. package/dist/lib-cjs/api/util/babylonHelper.d.ts +0 -238
  158. package/dist/lib-cjs/api/util/babylonHelper.js +0 -826
  159. package/dist/lib-cjs/api/util/babylonHelper.js.map +0 -1
  160. package/dist/lib-cjs/api/util/debugHelper.d.ts +0 -9
  161. package/dist/lib-cjs/api/util/debugHelper.js +0 -94
  162. package/dist/lib-cjs/api/util/debugHelper.js.map +0 -1
  163. package/dist/lib-cjs/api/util/deviceHelper.d.ts +0 -9
  164. package/dist/lib-cjs/api/util/deviceHelper.js.map +0 -1
  165. package/dist/lib-cjs/api/util/geometryHelper.d.ts +0 -17
  166. package/dist/lib-cjs/api/util/geometryHelper.js.map +0 -1
  167. package/dist/lib-cjs/api/util/globalTypes.d.ts +0 -490
  168. package/dist/lib-cjs/api/util/globalTypes.js +0 -2
  169. package/dist/lib-cjs/api/util/globalTypes.js.map +0 -1
  170. package/dist/lib-cjs/api/util/resourceHelper.d.ts +0 -58
  171. package/dist/lib-cjs/api/util/resourceHelper.js +0 -215
  172. package/dist/lib-cjs/api/util/resourceHelper.js.map +0 -1
  173. package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +0 -58
  174. package/dist/lib-cjs/api/util/sceneLoaderHelper.js +0 -229
  175. package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +0 -1
  176. package/dist/lib-cjs/api/util/stringHelper.d.ts +0 -13
  177. package/dist/lib-cjs/api/util/stringHelper.js +0 -33
  178. package/dist/lib-cjs/api/util/stringHelper.js.map +0 -1
  179. package/dist/lib-cjs/api/util/structureHelper.d.ts +0 -9
  180. package/dist/lib-cjs/api/util/structureHelper.js +0 -58
  181. package/dist/lib-cjs/api/util/structureHelper.js.map +0 -1
  182. package/src/api/classes/animationInterface.ts +0 -10
  183. package/src/api/classes/dottedPath.ts +0 -181
  184. package/src/api/classes/element.ts +0 -766
  185. package/src/api/classes/event.ts +0 -457
  186. package/src/api/classes/eventBroadcaster.ts +0 -52
  187. package/src/api/classes/fuzzyMap.ts +0 -21
  188. package/src/api/classes/parameter.ts +0 -686
  189. package/src/api/classes/parameterObservable.ts +0 -73
  190. package/src/api/classes/parameterizable.ts +0 -87
  191. package/src/api/classes/placementAnimation.ts +0 -162
  192. package/src/api/classes/variant.ts +0 -965
  193. package/src/api/classes/variantInstance.ts +0 -123
  194. package/src/api/classes/variantParameterizable.ts +0 -83
  195. package/src/api/classes/viewer.ts +0 -751
  196. package/src/api/classes/viewerLight.ts +0 -335
  197. package/src/api/internal/debugViewer.ts +0 -90
  198. package/src/api/internal/lensRendering.ts +0 -9
  199. package/src/api/internal/sceneSetup.ts +0 -208
  200. package/src/api/manager/animationManager.ts +0 -143
  201. package/src/api/manager/sceneManager.ts +0 -134
  202. package/src/api/manager/tagManager.ts +0 -572
  203. package/src/api/manager/textureLoadManager.ts +0 -107
  204. package/src/api/manager/variantInstanceManager.ts +0 -306
  205. package/src/api/store/specStorage.ts +0 -68
  206. package/src/api/util/babylonHelper.ts +0 -915
  207. package/src/api/util/debugHelper.ts +0 -121
  208. package/src/api/util/deviceHelper.ts +0 -31
  209. package/src/api/util/globalTypes.ts +0 -566
  210. package/src/api/util/resourceHelper.ts +0 -201
  211. package/src/api/util/sceneLoaderHelper.ts +0 -247
  212. package/src/api/util/stringHelper.ts +0 -30
  213. package/src/api/util/structureHelper.ts +0 -62
@@ -10,29 +10,89 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.GltfExportManager = void 0;
13
- const babylonHelper_1 = require("../util/babylonHelper");
14
- const deviceHelper_1 = require("../util/deviceHelper");
15
- const geometryHelper_1 = require("../util/geometryHelper");
16
- const structureHelper_1 = require("../util/structureHelper");
17
- const pbrMaterial_1 = require("@babylonjs/core/Materials/PBR/pbrMaterial");
18
- const dynamicTexture_1 = require("@babylonjs/core/Materials/Textures/dynamicTexture");
19
- const renderTargetTexture_1 = require("@babylonjs/core/Materials/Textures/renderTargetTexture");
20
- const math_vector_1 = require("@babylonjs/core/Maths/math.vector");
21
- const instancedMesh_1 = require("@babylonjs/core/Meshes/instancedMesh");
22
- const mesh_1 = require("@babylonjs/core/Meshes/mesh");
23
- const transformNode_1 = require("@babylonjs/core/Meshes/transformNode");
24
- require("@babylonjs/serializers/glTF/2.0/Extensions/KHR_texture_transform");
25
- const glTFSerializer_1 = require("@babylonjs/serializers/glTF/2.0/glTFSerializer");
13
+ const index_1 = require("../index");
14
+ const deviceHelper_1 = require("../internal/deviceHelper");
15
+ const geometryHelper_1 = require("../internal/geometryHelper");
16
+ const geometryHelper_2 = require("../internal/geometryHelper");
17
+ const metadataHelper_1 = require("../internal/metadataHelper");
18
+ /**
19
+ * Manager for gltf export and augmented reality features
20
+ */
26
21
  class GltfExportManager {
22
+ /** @internal */
27
23
  constructor(viewer) {
28
24
  this.viewer = viewer;
29
25
  // store initial max texture size, so that we can restore it in the post processing
30
26
  this._maxTextureSize = viewer.engine.getCaps().maxTextureSize;
31
27
  }
32
- static create(viewer) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return new GltfExportManager(viewer);
35
- });
28
+ /**
29
+ * Defines options for the export.
30
+ * We don't allow the user to overwrite certain settings, since we rely on properties like `removeNoopRootNodes` to
31
+ * stay `true` in order to make the AR export work.
32
+ * We could theoretically allow it if AR optimization is not desired, but this may confuse the user.
33
+ */
34
+ static _gltfExportOptions(optimizeForAR, excluded) {
35
+ return {
36
+ shouldExportNode: function (node) {
37
+ if (optimizeForAR) {
38
+ // we explicitely marked nodes, that should be exported in AR mode
39
+ return (0, metadataHelper_1.getInternalMetadataValue)(node, 'exportNode');
40
+ }
41
+ else {
42
+ // use the default export node check (enabled state, exclusion list, etc...)
43
+ return GltfExportManager._shouldExportNode(node, excluded);
44
+ }
45
+ },
46
+ };
47
+ }
48
+ /**
49
+ * Checks if a node should be available in the export
50
+ */
51
+ static _shouldExportNode(node, excluded) {
52
+ if (!(node instanceof index_1.TransformNode)) {
53
+ return false;
54
+ }
55
+ // TODO WTT: think of adding "BackgroundHelper" and nodes with "infiniteDistance" here as well, at least in AR mode
56
+ if (!node.isEnabled()) {
57
+ return false;
58
+ }
59
+ if (excluded && (0, geometryHelper_2.isNodeExcluded)(node, excluded)) {
60
+ return false;
61
+ }
62
+ return true;
63
+ }
64
+ /**
65
+ * Creates a clone of the material which should be used for the export.
66
+ * This is mostly required for recreating textures with lower sizes.
67
+ * CAUTION: Material exchanging is not supported for materials that contain certain texture types:
68
+ * - Dynamic textures (Paintables): Cloning dynamic textures doesn't clone the canvas context
69
+ * => so the clone is just empty
70
+ * - Render target textures: Disposing the clone will leave the scene in a "not ready" state
71
+ * => this scenario is not fully analyzed yet, but it's not really worth the effort right now, since this kind of
72
+ * of texture is not really used ATM
73
+ */
74
+ static _exchangeMaterial(material) {
75
+ const baseTextures = material.getActiveTextures();
76
+ const hasDynamicTextures = baseTextures.some(texture => texture instanceof index_1.DynamicTexture);
77
+ const hasRenderTargetTextures = baseTextures.some(texture => texture instanceof index_1.RenderTargetTexture);
78
+ if (hasDynamicTextures || hasRenderTargetTextures) {
79
+ const textureTypesString = [
80
+ hasDynamicTextures ? 'Dynamic Textures' : '',
81
+ hasRenderTargetTextures ? 'Render Target Textures' : '',
82
+ ]
83
+ .filter(Boolean)
84
+ .join();
85
+ console.warn(`Couldn't exchange material "${material.name}" in GLB export, as it contains unsupported texture type(s) (${textureTypesString}). The export will still work, but the textures of this material will keep their original size.`);
86
+ return;
87
+ }
88
+ const newName = `${material.name}_clone`;
89
+ const clonedMaterial = material.clone(newName);
90
+ (0, metadataHelper_1.cloneInternalMetadata)(material, clonedMaterial);
91
+ const clonedTextures = clonedMaterial.getActiveTextures();
92
+ // mark all exported textures, so that they will be deleted after the export
93
+ clonedTextures.forEach(texture => (0, metadataHelper_1.setInternalMetadataValue)(texture, 'deleteAfterExport', true));
94
+ (0, metadataHelper_1.setInternalMetadataValue)(material, 'exchangeMaterialWith', clonedMaterial.uniqueId);
95
+ (0, metadataHelper_1.setInternalMetadataValue)(clonedMaterial, 'deleteAfterExport', true);
36
96
  }
37
97
  /**
38
98
  * Exports selected nodes to a file.
@@ -44,7 +104,7 @@ class GltfExportManager {
44
104
  exportGlb(filename = 'glb-export.glb', optimizeForAR = false, excluded) {
45
105
  return __awaiter(this, void 0, void 0, function* () {
46
106
  yield this._exportPreProcess(optimizeForAR, excluded);
47
- const glbData = yield glTFSerializer_1.GLTF2Export.GLBAsync(this.viewer.scene, 'dummy', GltfExportManager._gltfExportOptions(optimizeForAR, excluded));
107
+ const glbData = yield index_1.GLTF2Export.GLBAsync(this.viewer.scene, 'dummy', GltfExportManager._gltfExportOptions(optimizeForAR, excluded));
48
108
  yield this._exportPostProcess(optimizeForAR);
49
109
  const resBlob = glbData.glTFFiles['dummy.glb'];
50
110
  // check if result is valid, according to the typings this could also be a string
@@ -70,7 +130,7 @@ class GltfExportManager {
70
130
  exportGltfToFile(filename, optimizeForAR = false, excluded) {
71
131
  return __awaiter(this, void 0, void 0, function* () {
72
132
  yield this._exportPreProcess(optimizeForAR, excluded);
73
- const gltf = yield glTFSerializer_1.GLTF2Export.GLTFAsync(this.viewer.scene, filename, GltfExportManager._gltfExportOptions(optimizeForAR, excluded));
133
+ const gltf = yield index_1.GLTF2Export.GLTFAsync(this.viewer.scene, filename, GltfExportManager._gltfExportOptions(optimizeForAR, excluded));
74
134
  gltf.downloadFiles();
75
135
  this._exportPostProcess(optimizeForAR);
76
136
  });
@@ -85,7 +145,7 @@ class GltfExportManager {
85
145
  exportGlbToFile(filename, optimizeForAR = false, excluded) {
86
146
  return __awaiter(this, void 0, void 0, function* () {
87
147
  yield this._exportPreProcess(optimizeForAR, excluded);
88
- const glb = yield glTFSerializer_1.GLTF2Export.GLBAsync(this.viewer.scene, filename, GltfExportManager._gltfExportOptions(optimizeForAR, excluded));
148
+ const glb = yield index_1.GLTF2Export.GLBAsync(this.viewer.scene, filename, GltfExportManager._gltfExportOptions(optimizeForAR, excluded));
89
149
  glb.downloadFiles();
90
150
  yield this._exportPostProcess(optimizeForAR);
91
151
  });
@@ -110,14 +170,14 @@ class GltfExportManager {
110
170
  // we don't have to rescale anything if are already on a downscaled device, since the textures are already <= 1024
111
171
  // also we have to be very cautios with copying textures on these devices, since we are potentially very limited
112
172
  // with the available memory
113
- const isScaledDownDevice = (0, deviceHelper_1.getIsScaledDownDevice)();
173
+ const isScaledDownDevice = (0, deviceHelper_1.getIsScaledDownDevice)(this.viewer.viewerSettings.limitTextureSize);
114
174
  if (!isScaledDownDevice) {
115
175
  // the idea is to re-create all textures with a smaller texture size
116
176
  // we have to exchange all materials for this to work
117
177
  this.viewer.engine.clearInternalTexturesCache();
118
178
  this.viewer.engine.getCaps().maxTextureSize = 1024;
119
179
  this.viewer.scene.materials
120
- .filter(material => material instanceof pbrMaterial_1.PBRMaterial)
180
+ .filter(material => material instanceof index_1.PBRMaterial)
121
181
  .forEach(material => GltfExportManager._exchangeMaterial(material));
122
182
  }
123
183
  // since Babylon.js v6 the conversion to right handed GLB coordinate system is done differently
@@ -128,12 +188,10 @@ class GltfExportManager {
128
188
  // the exporter just removes this node as he detects a "noop root node" (implementation details of Babylon.js)
129
189
  // everything beneath this node remains untouched
130
190
  // TODO BJS Update: Test AR export on iPhones as well and double check if we still need this special logic
131
- const exportRootNode = new transformNode_1.TransformNode(GltfExportManager._EXPORT_ROOT_NAME, this.viewer.scene);
132
- exportRootNode.scaling = new math_vector_1.Vector3(-1, 1, 1);
133
- (0, babylonHelper_1.injectMetadata)(exportRootNode, {
134
- [GltfExportManager._METADATA_PROPS.exportNode]: true,
135
- [GltfExportManager._METADATA_PROPS.deleteAfterExport]: true,
136
- });
191
+ const exportRootNode = new index_1.TransformNode(GltfExportManager._EXPORT_ROOT_NAME, this.viewer.scene);
192
+ exportRootNode.scaling = new index_1.Vector3(-1, 1, 1);
193
+ (0, metadataHelper_1.setInternalMetadataValue)(exportRootNode, 'exportNode', true);
194
+ (0, metadataHelper_1.setInternalMetadataValue)(exportRootNode, 'deleteAfterExport', true);
137
195
  // create clones of each node (recursively), optionally exchange with cloned materials and mark these nodes for the
138
196
  // export
139
197
  this.viewer.scene.rootNodes
@@ -158,13 +216,13 @@ class GltfExportManager {
158
216
  }
159
217
  // dispose all nodes, materials and textures that have only been created for the export
160
218
  this.viewer.scene.rootNodes
161
- .filter(rootNode => { var _a; return (_a = rootNode.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.deleteAfterExport]; })
219
+ .filter(rootNode => (0, metadataHelper_1.getInternalMetadataValue)(rootNode, 'deleteAfterExport'))
162
220
  .forEach(rootNode => rootNode.dispose());
163
221
  this.viewer.scene.materials
164
- .filter(mat => { var _a; return !!((_a = mat.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.deleteAfterExport]); })
222
+ .filter(mat => (0, metadataHelper_1.getInternalMetadataValue)(mat, 'deleteAfterExport'))
165
223
  .forEach(material => material.dispose(false, false));
166
224
  this.viewer.scene.textures
167
- .filter(texture => { var _a; return !!((_a = texture.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.deleteAfterExport]); })
225
+ .filter(texture => (0, metadataHelper_1.getInternalMetadataValue)(texture, 'deleteAfterExport'))
168
226
  .forEach(texture => texture.dispose());
169
227
  // reset engines max texture size and resume rendering
170
228
  this.viewer.engine.getCaps().maxTextureSize = this._maxTextureSize;
@@ -176,7 +234,6 @@ class GltfExportManager {
176
234
  * Also switches to the cloned material if required.
177
235
  */
178
236
  _prepareNodeForExport(node, clonedParent, excluded) {
179
- var _a, _b;
180
237
  if (!GltfExportManager._shouldExportNode(node, excluded)) {
181
238
  return;
182
239
  }
@@ -184,21 +241,20 @@ class GltfExportManager {
184
241
  const transformNode = node;
185
242
  // clone original node and create unique name (via uniqueId) for the export
186
243
  const clonedNodeName = `${transformNode.name}_${transformNode.uniqueId}`;
187
- const clonedNode = transformNode instanceof instancedMesh_1.InstancedMesh
244
+ const clonedNode = transformNode instanceof index_1.InstancedMesh
188
245
  ? (0, geometryHelper_1.createMeshFromInstancedMesh)(transformNode, clonedNodeName, clonedParent)
189
246
  : transformNode.clone(clonedNodeName, clonedParent, true);
247
+ (0, metadataHelper_1.cloneInternalMetadata)(transformNode, clonedNode);
190
248
  // exchange material
191
- if (clonedNode instanceof mesh_1.Mesh) {
192
- 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];
249
+ if (clonedNode instanceof index_1.Mesh) {
250
+ const exchangeWithMaterial = clonedNode.material && (0, metadataHelper_1.getInternalMetadataValue)(clonedNode.material, 'exchangeMaterialWith');
193
251
  if (exchangeWithMaterial) {
194
252
  clonedNode.material = this.viewer.scene.getMaterialByUniqueID(exchangeWithMaterial);
195
253
  }
196
254
  }
197
255
  // signalize that this is a cloned node
198
- (0, babylonHelper_1.injectMetadata)(clonedNode, {
199
- [GltfExportManager._METADATA_PROPS.exportNode]: true,
200
- [GltfExportManager._METADATA_PROPS.deleteAfterExport]: true,
201
- });
256
+ (0, metadataHelper_1.setInternalMetadataValue)(clonedNode, 'exportNode', true);
257
+ (0, metadataHelper_1.setInternalMetadataValue)(clonedNode, 'deleteAfterExport', true);
202
258
  // handle children
203
259
  const childs = transformNode.getChildTransformNodes(true);
204
260
  childs.forEach(child => this._prepareNodeForExport(child, clonedNode, excluded));
@@ -211,90 +267,13 @@ class GltfExportManager {
211
267
  if (!meshesOnly) {
212
268
  nodes.push(...this.viewer.scene.transformNodes);
213
269
  }
214
- const filteredNodes = nodes.filter(node => {
215
- var _a;
216
- return !!((_a = node.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.exportNode]) &&
217
- // in the desired use cases we want to exclude the export root node
218
- // maybe add a parameter if we have to include it in certain scenarios in the future
219
- node.name !== GltfExportManager._EXPORT_ROOT_NAME;
220
- });
270
+ const filteredNodes = nodes.filter(node => (0, metadataHelper_1.getInternalMetadataValue)(node, 'exportNode') &&
271
+ // in the desired use cases we want to exclude the export root node
272
+ // maybe add a parameter if we have to include it in certain scenarios in the future
273
+ node.name !== GltfExportManager._EXPORT_ROOT_NAME);
221
274
  return filteredNodes;
222
275
  }
223
- /**
224
- * Defines options for the export.
225
- * We don't allow the user to overwrite certain settings, since we rely on properties like `removeNoopRootNodes` to
226
- * stay `true` in order to make the AR export work.
227
- * We could theoretically allow it if AR optimization is not desired, but this may confuse the user.
228
- */
229
- static _gltfExportOptions(optimizeForAR, excluded) {
230
- return {
231
- shouldExportNode: function (node) {
232
- var _a;
233
- if (optimizeForAR) {
234
- // we explicitely marked nodes, that should be exported in AR mode
235
- return !!((_a = node.metadata) === null || _a === void 0 ? void 0 : _a[GltfExportManager._METADATA_PROPS.exportNode]);
236
- }
237
- else {
238
- // use the default export node check (enabled state, exclusion list, etc...)
239
- return GltfExportManager._shouldExportNode(node, excluded);
240
- }
241
- },
242
- };
243
- }
244
- /**
245
- * Checks if a node should be available in the export
246
- */
247
- static _shouldExportNode(node, excluded) {
248
- if (!(node instanceof transformNode_1.TransformNode)) {
249
- return false;
250
- }
251
- // TODO: think of adding "BackgroundHelper" and nodes with "infiniteDistance" here as well, at least in AR mode
252
- if (!node.isEnabled()) {
253
- return false;
254
- }
255
- if (excluded && (0, structureHelper_1.isNodeIncludedInExclusionList)(node, excluded)) {
256
- return false;
257
- }
258
- return true;
259
- }
260
- /**
261
- * Creates a clone of the material which should be used for the export.
262
- * This is mostly required for recreating textures with lower sizes.
263
- * CAUTION: Material exchanging is not supported for materials that contain certain texture types:
264
- * - Dynamic textures (Paintables): Cloning dynamic textures doesn't clone the canvas context
265
- * => so the clone is just empty
266
- * - Render target textures: Disposing the clone will leave the scene in a "not ready" state
267
- * => this scenario is not fully analyzed yet, but it's not really worth the effort right now, since this kind of
268
- * of texture is not really used ATM
269
- */
270
- static _exchangeMaterial(material) {
271
- const baseTextures = material.getActiveTextures();
272
- const hasDynamicTextures = baseTextures.some(texture => texture instanceof dynamicTexture_1.DynamicTexture);
273
- const hasRenderTargetTextures = baseTextures.some(texture => texture instanceof renderTargetTexture_1.RenderTargetTexture);
274
- if (hasDynamicTextures || hasRenderTargetTextures) {
275
- const textureTypesString = [
276
- hasDynamicTextures ? 'Dynamic Textures' : '',
277
- hasRenderTargetTextures ? 'Render Target Textures' : '',
278
- ]
279
- .filter(Boolean)
280
- .join();
281
- console.warn(`Couldn't exchange material "${material.name}" in GLB export, as it contains unsupported texture type(s) (${textureTypesString}). The export will still work, but the textures of this material will keep their original size.`);
282
- return;
283
- }
284
- const newName = `${material.name}_clone`;
285
- const clonedMaterial = material.clone(newName);
286
- const clonedTextures = clonedMaterial.getActiveTextures();
287
- // mark all exported textures, so that they will be deleted after the export
288
- clonedTextures.forEach(texture => (0, babylonHelper_1.injectMetadata)(texture, { [GltfExportManager._METADATA_PROPS.deleteAfterExport]: true }));
289
- (0, babylonHelper_1.injectMetadata)(material, { [GltfExportManager._METADATA_PROPS.exchangeMaterialWith]: clonedMaterial.uniqueId });
290
- (0, babylonHelper_1.injectMetadata)(clonedMaterial, { [GltfExportManager._METADATA_PROPS.deleteAfterExport]: true });
291
- }
292
276
  }
293
277
  exports.GltfExportManager = GltfExportManager;
294
- GltfExportManager._METADATA_PROPS = {
295
- exportNode: 'exportNode',
296
- deleteAfterExport: 'deleteAfterExport',
297
- exchangeMaterialWith: 'exchangeMaterialWith',
298
- };
299
278
  GltfExportManager._EXPORT_ROOT_NAME = '__export_root__';
300
279
  //# sourceMappingURL=gltfExportManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gltfExportManager.js","sourceRoot":"","sources":["../../../src/manager/gltfExportManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAckB;AAClB,2DAAiE;AACjE,+DAAkH;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BAAiB,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { AbstractMesh, Material, Viewer } from '../index';
2
+ /**
3
+ * Manager for material related tasks
4
+ */
5
+ export declare class MaterialManager {
6
+ protected viewer: Viewer;
7
+ /**
8
+ * CAUTION: this has to be in sync with the Combeenation backend!
9
+ * @internal
10
+ */
11
+ static readonly CBN_FALLBACK_MATERIAL_NAME = "$fallback";
12
+ protected _createMaterialPromises: {
13
+ [materialId: string]: Promise<Material | null>;
14
+ };
15
+ /** @internal */
16
+ constructor(viewer: Viewer);
17
+ /**
18
+ * Assigns material with certain id to desired mesh.\
19
+ * Creates the material if not already available (see {@link getOrCreateMaterial}).
20
+ */
21
+ setMaterialOnMesh(materialId: string, mesh: AbstractMesh): Promise<void>;
22
+ /**
23
+ * Returns material with certain id if already available in the scene.\
24
+ * If this is not the case material is created from a
25
+ * "[Material asset](https://docs.combeenation.com/docs/howto-create-and-use-babylon-and-material-asset)"
26
+ * on the Combeenation server.\
27
+ * Waits until textures of material are fully loaded and shader is compiled. In this way "flickering" effects
28
+ * will be avoided, since the material would be incomplete without its loaded textures.
29
+ *
30
+ * @param mesh Required for shader compilation check, can be omitted if this check should not be done.\
31
+ * Use {@link setMaterialOnMesh} instead if the material should be applied on the mesh immediately.
32
+ */
33
+ getOrCreateMaterial(materialId: string, mesh?: AbstractMesh): Promise<Material>;
34
+ protected _createMaterial(materialId: string, mesh?: AbstractMesh): Promise<Material>;
35
+ }
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.MaterialManager = void 0;
13
+ const index_1 = require("../index");
14
+ const metadataHelper_1 = require("../internal/metadataHelper");
15
+ /**
16
+ * Manager for material related tasks
17
+ */
18
+ class MaterialManager {
19
+ /** @internal */
20
+ constructor(viewer) {
21
+ this.viewer = viewer;
22
+ this._createMaterialPromises = {};
23
+ }
24
+ /**
25
+ * Assigns material with certain id to desired mesh.\
26
+ * Creates the material if not already available (see {@link getOrCreateMaterial}).
27
+ */
28
+ setMaterialOnMesh(materialId, mesh) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ (0, metadataHelper_1.setInternalMetadataValue)(mesh, 'materialToBeSet', materialId);
31
+ const material = yield this.getOrCreateMaterial(materialId, mesh);
32
+ // there may have been later "setMaterialOnMesh" calls with faster material creation
33
+ // make sure to assign the latest material!
34
+ if ((0, metadataHelper_1.getInternalMetadataValue)(mesh, 'materialToBeSet') === materialId) {
35
+ mesh.material = material;
36
+ (0, metadataHelper_1.clearInternalMetadataValue)(mesh, 'materialToBeSet');
37
+ (0, metadataHelper_1.clearInternalMetadataValue)(mesh, 'deferredMaterial');
38
+ }
39
+ });
40
+ }
41
+ /**
42
+ * Returns material with certain id if already available in the scene.\
43
+ * If this is not the case material is created from a
44
+ * "[Material asset](https://docs.combeenation.com/docs/howto-create-and-use-babylon-and-material-asset)"
45
+ * on the Combeenation server.\
46
+ * Waits until textures of material are fully loaded and shader is compiled. In this way "flickering" effects
47
+ * will be avoided, since the material would be incomplete without its loaded textures.
48
+ *
49
+ * @param mesh Required for shader compilation check, can be omitted if this check should not be done.\
50
+ * Use {@link setMaterialOnMesh} instead if the material should be applied on the mesh immediately.
51
+ */
52
+ getOrCreateMaterial(materialId, mesh) {
53
+ var _a;
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ let chosenMaterial = (_a = this.viewer.scene.materials.find(mat => mat.id === materialId)) !== null && _a !== void 0 ? _a : null;
56
+ if (!chosenMaterial) {
57
+ // material not available yet, request it from Combeenation assets
58
+ const existingCreationProm = this._createMaterialPromises[materialId];
59
+ if (existingCreationProm !== undefined) {
60
+ // request is already pending, just wait for the result
61
+ chosenMaterial = yield existingCreationProm;
62
+ }
63
+ else {
64
+ this.viewer.eventManager.fireEvent(index_1.ViewerEvent.MaterialCreationStart, materialId);
65
+ // request not pending, call the dedicated function
66
+ const newCreationProm = this._createMaterial(materialId, mesh);
67
+ // store the promise in a global map, so that subsequent requests can reference it
68
+ this._createMaterialPromises[materialId] = newCreationProm;
69
+ chosenMaterial = yield newCreationProm;
70
+ delete this._createMaterialPromises[materialId];
71
+ const allMaterialsCreated = !Object.entries(this._createMaterialPromises).length;
72
+ // signalize event system that material is created now
73
+ // also check if there are other material creation processes still pending, as this is an important information
74
+ // e.g. for showing load masks
75
+ this.viewer.eventManager.fireEvent(index_1.ViewerEvent.MaterialCreationEnd, materialId, allMaterialsCreated);
76
+ }
77
+ }
78
+ return chosenMaterial;
79
+ });
80
+ }
81
+ _createMaterial(materialId, mesh) {
82
+ var _a;
83
+ return __awaiter(this, void 0, void 0, function* () {
84
+ if (materialId === MaterialManager.CBN_FALLBACK_MATERIAL_NAME) {
85
+ const fallbackMaterial = new index_1.StandardMaterial(MaterialManager.CBN_FALLBACK_MATERIAL_NAME, this.viewer.scene);
86
+ fallbackMaterial.disableLighting = true;
87
+ return fallbackMaterial;
88
+ }
89
+ const materialDefinition = yield ((_a = window.Cbn) === null || _a === void 0 ? void 0 : _a.Assets.getMaterial(materialId));
90
+ // The generic `Material.Parse` actually returns a more specific material like `BABYLON.StandardMaterial`,
91
+ // `BABYLON.PBRMaterial` or stuff like `BABYLON.PBRMetallicRoughnessMaterial` etc. based on the given `customType`
92
+ // within the material JSON definition
93
+ const material = materialDefinition && index_1.Material.Parse(materialDefinition, this.viewer.scene, '');
94
+ if (!material) {
95
+ throw new index_1.ViewerError({
96
+ id: index_1.ViewerErrorIds.MaterialCouldNotBeParsed,
97
+ message: `Material with id "${materialId}" could not be parsed`,
98
+ });
99
+ }
100
+ yield this.viewer.parameterManager.applyParameterValuesToMaterial(material);
101
+ const matReadyProms = [
102
+ new Promise(resolve => index_1.BaseTexture.WhenAllReady(material.getActiveTextures(), resolve)),
103
+ ];
104
+ if (mesh) {
105
+ // this promise should only take some time on the first call of the corresponding shader (eg: PBRMaterial shader)
106
+ // on each other call of the same material/shader type there should be not be a waiting time, or at maximum one
107
+ // frame
108
+ // https://forum.babylonjs.com/t/mesh-flickering-when-setting-material-initially/37312
109
+ matReadyProms.push(material.forceCompilationAsync(mesh));
110
+ }
111
+ // material needs to fulfill 2 criterias before it's ready to use
112
+ // - textures need to be "ready" => downloaded
113
+ // - dedicated shader needs to be compiled
114
+ // if this would not be the case you can see some "flickering" when setting the material
115
+ yield Promise.all(matReadyProms);
116
+ return material;
117
+ });
118
+ }
119
+ }
120
+ exports.MaterialManager = MaterialManager;
121
+ /**
122
+ * CAUTION: this has to be in sync with the Combeenation backend!
123
+ * @internal
124
+ */
125
+ MaterialManager.CBN_FALLBACK_MATERIAL_NAME = '$fallback';
126
+ //# sourceMappingURL=materialManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"materialManager.js","sourceRoot":"","sources":["../../../src/manager/materialManager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCASkB;AAClB,+DAIoC;AAEpC;;GAEG;AACH,MAAa,eAAe;IAS1B,gBAAgB;IAChB,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAHjC,4BAAuB,GAAuD,EAAE,CAAC;IAG7C,CAAC;IAE/C;;;OAGG;IACU,iBAAiB,CAAC,UAAkB,EAAE,IAAkB;;YACnE,IAAA,yCAAwB,EAAC,IAAI,EAAE,iBAAiB,EAAE,UAAU,CAAC,CAAC;YAE9D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;YAElE,oFAAo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;gBACR,iHAAiH;gBACjH,+GAA+G;gBAC/G,QAAQ;gBACR,sFAAsF;gBACtF,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC;aAC1D;YAED,iEAAiE;YACjE,8CAA8C;YAC9C,0CAA0C;YAC1C,wFAAwF;YACxF,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAEjC,OAAO,QAAQ,CAAC;;KACjB;;AAlHH,0CAmHC;AAlHC;;;GAGG;AACoB,0CAA0B,GAAG,WAAW,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { AssetContainer, TransformNode, Viewer } from '../index';
2
+ export declare type ModelAssetDefinition = {
3
+ name: string;
4
+ url: string;
5
+ };
6
+ export declare type ModelVisibilityEntry = {
7
+ name: string;
8
+ visible: boolean;
9
+ };
10
+ /**
11
+ * Callback for renaming nodes when cloning nodes in a model
12
+ */
13
+ export declare type NodeNamingStrategy = (node: TransformNode, newModelName: string) => string;
14
+ /**
15
+ * Callback for renaming tags when cloning nodes in a model
16
+ */
17
+ export declare type TagNamingStrategy = (tag: string, newModelName: string) => string;
18
+ export declare type ModelCloneOptions = {
19
+ nodeNamingStrategy: NodeNamingStrategy;
20
+ tagNamingStrategy: TagNamingStrategy;
21
+ };
22
+ declare type Model = {
23
+ name: string;
24
+ url: string;
25
+ state: ModelAssetState;
26
+ assetContainer: AssetContainer;
27
+ isClone: boolean;
28
+ visibilityCallId?: number;
29
+ };
30
+ declare type ModelAssetState = 'notLoaded' | 'loading' | 'loaded' | 'inScene';
31
+ /**
32
+ * Manager for handling 3d models.\
33
+ * Responsible for loading models and handling their visibility.\
34
+ * Also contains advanced features like model cloning.
35
+ */
36
+ export declare class ModelManager {
37
+ protected viewer: Viewer;
38
+ /**
39
+ * CAUTION: this has to be in sync with the Combeenation backend!
40
+ * @internal
41
+ */
42
+ static readonly CBN_FALLBACK_MODEL_ASSET_NAME = "$fallback";
43
+ protected _modelAssets: {
44
+ [name: string]: Model;
45
+ };
46
+ protected _fallbackModelAsset: Model;
47
+ protected _loadModelPromises: {
48
+ [modelName: string]: Promise<void>;
49
+ };
50
+ get modelNames(): string[];
51
+ /**
52
+ * Nested models were targeted with slash notation previously, as Spec couldn't work with dots.
53
+ * Dots were interpreted as inherited model.
54
+ * Now the Hive viewer parameters are returning slash notated asset names, whereas the asset names from the
55
+ * prepacked asset manager are dot notated.
56
+ * This function converts slash to dot notation, so that models can be target with slash and dot notation alike.
57
+ */
58
+ protected static _replaceSlashes(inputStr: string): string;
59
+ constructor(viewer: Viewer);
60
+ /**
61
+ * Creates content for the fallback model, which is actually just a black cube.
62
+ * This is used for 3d assets that are linked in a data source but not available (yet).
63
+ * The Combeenation backend exchanges the missing 3d asset name with "$fallback", which indicates that we shouldn't
64
+ * throw an error but just show the fallback model instead.
65
+ *
66
+ * @internal
67
+ */
68
+ createFallbackModel(): void;
69
+ /**
70
+ * Register models for 3d viewer, this is required for each model before it can be loaded/shown.\
71
+ * The "viewer control" inside the Combeenation framework calls this function automatically with all assigned
72
+ * 3d assets.
73
+ */
74
+ registerModels(modelAssets: ModelAssetDefinition[]): void;
75
+ /**
76
+ * Loads the model and all it's assigned materials.\
77
+ * This function should be used for "eager loading" of models, so that model switching will be instant in the
78
+ * process.\
79
+ * If you don't plan to do this, just use {@link setModelVisibility} as this function will load the model under the
80
+ * hood the first time the model gets visible.
81
+ */
82
+ loadModel(name: string): Promise<void>;
83
+ /**
84
+ * Enables/disables multiple one or multiple models simultaniously.\
85
+ * All required models are loaded before adjusting the visibility to avoid flashing in the 3d scene.
86
+ *
87
+ * @returns Array of changed visibility status, combined with the corresponding model name
88
+ */
89
+ setModelVisibility(modelVisibility: ModelVisibilityEntry | ModelVisibilityEntry[]): Promise<ModelVisibilityEntry[]>;
90
+ /**
91
+ * Create a clone of an existing model.\
92
+ * Only the geometry (meshes, transform nodes) gets cloned, as materials are typically shared across the whole scene.
93
+ *
94
+ * @param show show model immediately after cloning
95
+ * @param options additional options for the cloning procedure, like renaming algorithms
96
+ */
97
+ cloneModel(name: string, newModelName: string, show?: boolean, options?: ModelCloneOptions): Promise<void>;
98
+ /**
99
+ * Removes a cloned model from the scene and from the internal model storage.\
100
+ * Deleted clones can not be shown again.
101
+ */
102
+ deleteClonedModel(name: string): void;
103
+ /**
104
+ * Removes all cloned models from the scene and the internal model storage.
105
+ */
106
+ deleteAllClonedModels(): void;
107
+ /**
108
+ * Loads and returns the asset container of a certain model.\
109
+ * This can be used to access the models content without having to add it to the scene.\
110
+ * A typical use case is to clone or instantiate a node from a "library" model.
111
+ */
112
+ getAssetContainerOfModel(name: string): Promise<AssetContainer>;
113
+ /**
114
+ * Get model by name
115
+ */
116
+ protected _getModel(name: string): Model | undefined;
117
+ /**
118
+ * Load model into scene, but don't show it immediately
119
+ */
120
+ protected _loadModel(model: Model): Promise<void>;
121
+ /**
122
+ * Apply parameter to the model in the asset container.
123
+ * This is typically done before the model is added to the scene to avoid changes on the visible model, which ensures
124
+ * a smooth model switch behaviour.
125
+ */
126
+ protected _prepareModelForScene(model: Model): Promise<void>;
127
+ /**
128
+ * Add assets of asset container to scene, do the scene preparation if required.
129
+ * CAUTION: model is expected to be in the correct loading state already.
130
+ *
131
+ * @param skipPreparation optionally skip applying parameter values to model before showing it
132
+ * (see {@link _prepareModelForScene})
133
+ */
134
+ protected _showModel(model: Model, skipPreparation?: boolean): Promise<void>;
135
+ /**
136
+ * Remove assets of asset container from scene
137
+ */
138
+ protected _hideModel(model: Model): void;
139
+ /**
140
+ * Creates and assigns each "deferred" material to the corresponding mesh, if the mesh is visible.
141
+ * Model should be ready to use immediately after this function has done it's job.
142
+ */
143
+ protected _applyDeferredMaterialsForAllVisibleMeshes(model: Model): Promise<void>;
144
+ }
145
+ export {};