@combeenation/3d-viewer 6.5.0 → 7.0.0-beta2

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 (118) hide show
  1. package/README.md +111 -111
  2. package/dist/lib-cjs/api/classes/animationInterface.d.ts +8 -8
  3. package/dist/lib-cjs/api/classes/animationInterface.js +2 -2
  4. package/dist/lib-cjs/api/classes/dottedPath.d.ts +79 -79
  5. package/dist/lib-cjs/api/classes/dottedPath.js +166 -166
  6. package/dist/lib-cjs/api/classes/element.d.ts +153 -149
  7. package/dist/lib-cjs/api/classes/element.js +670 -669
  8. package/dist/lib-cjs/api/classes/element.js.map +1 -1
  9. package/dist/lib-cjs/api/classes/event.d.ts +396 -342
  10. package/dist/lib-cjs/api/classes/event.js +419 -365
  11. package/dist/lib-cjs/api/classes/event.js.map +1 -1
  12. package/dist/lib-cjs/api/classes/eventBroadcaster.d.ts +26 -26
  13. package/dist/lib-cjs/api/classes/eventBroadcaster.js +49 -49
  14. package/dist/lib-cjs/api/classes/fuzzyMap.d.ts +7 -0
  15. package/dist/lib-cjs/api/classes/fuzzyMap.js +22 -0
  16. package/dist/lib-cjs/api/classes/fuzzyMap.js.map +1 -0
  17. package/dist/lib-cjs/api/classes/parameter.d.ts +351 -339
  18. package/dist/lib-cjs/api/classes/parameter.js +517 -464
  19. package/dist/lib-cjs/api/classes/parameter.js.map +1 -1
  20. package/dist/lib-cjs/api/classes/parameterObservable.d.ts +36 -36
  21. package/dist/lib-cjs/api/classes/parameterObservable.js +72 -97
  22. package/dist/lib-cjs/api/classes/parameterObservable.js.map +1 -1
  23. package/dist/lib-cjs/api/classes/parameterizable.d.ts +15 -15
  24. package/dist/lib-cjs/api/classes/parameterizable.js +102 -102
  25. package/dist/lib-cjs/api/classes/placementAnimation.d.ts +45 -45
  26. package/dist/lib-cjs/api/classes/placementAnimation.js +176 -176
  27. package/dist/lib-cjs/api/classes/variant.d.ts +253 -234
  28. package/dist/lib-cjs/api/classes/variant.js +843 -818
  29. package/dist/lib-cjs/api/classes/variant.js.map +1 -1
  30. package/dist/lib-cjs/api/classes/variantInstance.d.ts +53 -44
  31. package/dist/lib-cjs/api/classes/variantInstance.js +125 -105
  32. package/dist/lib-cjs/api/classes/variantInstance.js.map +1 -1
  33. package/dist/lib-cjs/api/classes/variantParameterizable.d.ts +17 -17
  34. package/dist/lib-cjs/api/classes/variantParameterizable.js +88 -88
  35. package/dist/lib-cjs/api/classes/viewer.d.ts +199 -185
  36. package/dist/lib-cjs/api/classes/viewer.js +670 -619
  37. package/dist/lib-cjs/api/classes/viewer.js.map +1 -1
  38. package/dist/lib-cjs/api/classes/viewerLight.d.ts +66 -66
  39. package/dist/lib-cjs/api/classes/viewerLight.js +348 -348
  40. package/dist/lib-cjs/api/classes/viewerLight.js.map +1 -1
  41. package/dist/lib-cjs/api/internal/lensRendering.d.ts +8 -8
  42. package/dist/lib-cjs/api/internal/lensRendering.js +11 -11
  43. package/dist/lib-cjs/api/internal/sceneSetup.d.ts +13 -13
  44. package/dist/lib-cjs/api/internal/sceneSetup.js +226 -226
  45. package/dist/lib-cjs/api/manager/animationManager.d.ts +30 -30
  46. package/dist/lib-cjs/api/manager/animationManager.js +126 -126
  47. package/dist/lib-cjs/api/manager/animationManager.js.map +1 -1
  48. package/dist/lib-cjs/api/manager/gltfExportManager.d.ts +78 -78
  49. package/dist/lib-cjs/api/manager/gltfExportManager.js +241 -241
  50. package/dist/lib-cjs/api/manager/sceneManager.d.ts +33 -33
  51. package/dist/lib-cjs/api/manager/sceneManager.js +130 -130
  52. package/dist/lib-cjs/api/manager/sceneManager.js.map +1 -1
  53. package/dist/lib-cjs/api/manager/tagManager.d.ts +108 -0
  54. package/dist/lib-cjs/api/manager/tagManager.js +420 -0
  55. package/dist/lib-cjs/api/manager/tagManager.js.map +1 -0
  56. package/dist/lib-cjs/api/manager/textureLoadManager.d.ts +22 -22
  57. package/dist/lib-cjs/api/manager/textureLoadManager.js +97 -97
  58. package/dist/lib-cjs/api/manager/variantInstanceManager.d.ts +102 -92
  59. package/dist/lib-cjs/api/manager/variantInstanceManager.js +284 -260
  60. package/dist/lib-cjs/api/manager/variantInstanceManager.js.map +1 -1
  61. package/dist/lib-cjs/api/store/specStorage.d.ts +32 -24
  62. package/dist/lib-cjs/api/store/specStorage.js +65 -50
  63. package/dist/lib-cjs/api/store/specStorage.js.map +1 -1
  64. package/dist/lib-cjs/api/util/babylonHelper.d.ts +235 -206
  65. package/dist/lib-cjs/api/util/babylonHelper.js +745 -668
  66. package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
  67. package/dist/lib-cjs/api/util/globalTypes.d.ts +432 -387
  68. package/dist/lib-cjs/api/util/globalTypes.js +1 -1
  69. package/dist/lib-cjs/api/util/resourceHelper.d.ts +58 -58
  70. package/dist/lib-cjs/api/util/resourceHelper.js +203 -203
  71. package/dist/lib-cjs/api/util/sceneLoaderHelper.d.ts +44 -43
  72. package/dist/lib-cjs/api/util/sceneLoaderHelper.js +173 -155
  73. package/dist/lib-cjs/api/util/sceneLoaderHelper.js.map +1 -1
  74. package/dist/lib-cjs/api/util/stringHelper.d.ts +13 -13
  75. package/dist/lib-cjs/api/util/stringHelper.js +32 -32
  76. package/dist/lib-cjs/api/util/structureHelper.d.ts +9 -9
  77. package/dist/lib-cjs/api/util/structureHelper.js +48 -48
  78. package/dist/lib-cjs/buildinfo.json +3 -3
  79. package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
  80. package/dist/lib-cjs/index.d.ts +53 -52
  81. package/dist/lib-cjs/index.js +114 -112
  82. package/dist/lib-cjs/index.js.map +1 -1
  83. package/package.json +81 -81
  84. package/src/api/classes/animationInterface.ts +10 -10
  85. package/src/api/classes/dottedPath.ts +181 -181
  86. package/src/api/classes/element.ts +731 -717
  87. package/src/api/classes/event.ts +452 -385
  88. package/src/api/classes/eventBroadcaster.ts +52 -52
  89. package/src/api/classes/fuzzyMap.ts +21 -0
  90. package/src/api/classes/parameter.ts +554 -497
  91. package/src/api/classes/parameterObservable.ts +73 -100
  92. package/src/api/classes/parameterizable.ts +87 -87
  93. package/src/api/classes/placementAnimation.ts +162 -162
  94. package/src/api/classes/variant.ts +933 -884
  95. package/src/api/classes/variantInstance.ts +123 -97
  96. package/src/api/classes/variantParameterizable.ts +85 -85
  97. package/src/api/classes/viewer.ts +743 -691
  98. package/src/api/classes/viewerLight.ts +339 -339
  99. package/src/api/internal/debugViewer.ts +90 -90
  100. package/src/api/internal/lensRendering.ts +9 -9
  101. package/src/api/internal/sceneSetup.ts +205 -205
  102. package/src/api/manager/animationManager.ts +143 -143
  103. package/src/api/manager/gltfExportManager.ts +236 -236
  104. package/src/api/manager/sceneManager.ts +136 -132
  105. package/src/api/manager/tagManager.ts +451 -0
  106. package/src/api/manager/textureLoadManager.ts +95 -95
  107. package/src/api/manager/variantInstanceManager.ts +297 -265
  108. package/src/api/store/specStorage.ts +68 -51
  109. package/src/api/util/babylonHelper.ts +817 -739
  110. package/src/api/util/globalTypes.ts +499 -437
  111. package/src/api/util/resourceHelper.ts +191 -191
  112. package/src/api/util/sceneLoaderHelper.ts +170 -151
  113. package/src/api/util/stringHelper.ts +30 -30
  114. package/src/api/util/structureHelper.ts +49 -49
  115. package/src/buildinfo.json +3 -3
  116. package/src/dev.ts +62 -60
  117. package/src/index.ts +100 -98
  118. package/src/types.d.ts +35 -28
@@ -1,437 +1,499 @@
1
- // global accessible types imported from 3d-viewer
2
- type Viewer = import('../classes/viewer').Viewer;
3
- type Variant = import('../classes/variant').Variant;
4
- type VariantInstance = import('../classes/variantInstance').VariantInstance;
5
- /**
6
- * Alias for {@link Element} which can be used to prevent name clashes with the web APIs
7
- * [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
8
- */
9
- type VariantElement = import('../classes/element').Element;
10
- type DottedPath = import('../classes/dottedPath').DottedPath;
11
- type ViewerLight = import('../classes/viewerLight').ViewerLight;
12
- type SceneManager = import('../manager/sceneManager').SceneManager;
13
-
14
- // global accessible types imported from BabylonJS
15
- type Scene = import('@babylonjs/core/scene').Scene;
16
- type Vector3 = import('@babylonjs/core/Maths/math.vector').Vector3;
17
- type Color3 = import('@babylonjs/core/Maths/math.color').Color3;
18
- type Color4 = import('@babylonjs/core/Maths/math.color').Color4;
19
- type Material = import('@babylonjs/core/Materials/material').Material;
20
- type PBRMaterial = import('@babylonjs/core/Materials/PBR/pbrMaterial').PBRMaterial;
21
- type StandardMaterial = import('@babylonjs/core/Materials/standardMaterial').StandardMaterial;
22
- type DynamicTexture = import('@babylonjs/core/Materials/Textures/dynamicTexture').DynamicTexture;
23
- type Mesh = import('@babylonjs/core/Meshes/mesh').Mesh;
24
- type AbstractMesh = import('@babylonjs/core/Meshes/abstractMesh').AbstractMesh;
25
- type InstancedMesh = import('@babylonjs/core/Meshes/instancedMesh').InstancedMesh;
26
- type TransformNode = import('@babylonjs/core/Meshes/transformNode').TransformNode;
27
- type Engine = import('@babylonjs/core/Engines/engine').Engine;
28
- type EngineOptions = import('@babylonjs/core/Engines/thinEngine').EngineOptions;
29
- type ArcRotateCamera = import('@babylonjs/core/Cameras/arcRotateCamera').ArcRotateCamera;
30
- type IScreenshotSize = import('@babylonjs/core/Misc/interfaces/screenshotSize').IScreenshotSize;
31
- type BabylonAnimation = import('@babylonjs/core/Animations/animation').Animation;
32
- type CubeTexture = import('@babylonjs/core/Materials/Textures/cubeTexture').CubeTexture;
33
- type MeshBuilder = typeof import('@babylonjs/core/Meshes/meshBuilder').MeshBuilder;
34
- type Texture = import('@babylonjs/core/Materials/Textures/texture').Texture;
35
- type HemisphericLight = import('@babylonjs/core/Lights/hemisphericLight').HemisphericLight;
36
- type DirectionalLight = import('@babylonjs/core/Lights/directionalLight').DirectionalLight;
37
- type IInspectorOptions = import('@babylonjs/core/Debug').IInspectorOptions;
38
- // Node is already defined in lib.dom.d.ts, so it can't be declared that way
39
- // type Node = import("@babylonjs/core/node").Node;
40
-
41
- type IExportOptions = import('@babylonjs/serializers/glTF/2.0').IExportOptions;
42
-
43
- type EventEmitter = import('eventemitter3');
44
-
45
- // some more global accessible types
46
- type PathDefinitions = {
47
- include: string[];
48
- exclude?: string[];
49
- };
50
-
51
- type TraceableDefinition = {
52
- path: string;
53
- };
54
-
55
- type TraceableDefinitions = {
56
- [name: string]: TraceableDefinition;
57
- };
58
-
59
- type PaintableDefinition = {
60
- path: string;
61
- textureOptions:
62
- | {
63
- width: number;
64
- height: number;
65
- }
66
- | number;
67
- };
68
-
69
- type PaintableDefinitions = {
70
- [name: string]: PaintableDefinition;
71
- };
72
-
73
- type Asset = {
74
- rootUrl: string;
75
- fileName: string | undefined;
76
- };
77
-
78
- type ElementDefinitions = {
79
- [name: string]: ElementDefinition | string[];
80
- };
81
-
82
- type ElementDefinition = {
83
- paths: PathDefinitions;
84
- traceables?: TraceableDefinitions;
85
- paintables?: PaintableDefinitions;
86
- };
87
-
88
- type TransformationDefinition = {
89
- scaling: Vector3;
90
- position: Vector3;
91
- rotation: Vector3;
92
- };
93
-
94
- type EnvironmentDefinition = {
95
- environmentColor?: Color3;
96
- environmentIntensity?: number;
97
- environment?: string;
98
- environmentBackground?: string;
99
- environmentRotation?: number;
100
- environmentUseDefault?: boolean;
101
- };
102
-
103
- type StructureJson = {
104
- /**
105
- * `scene` describes the visualisation of the Babylon `scene` such as the incidence of light and camera position. If a
106
- * string is given, the {@link Viewer} will resolve the URL or path and pass the parsed JSON to this property.
107
- */
108
- scene?: string | SceneJson;
109
- /**
110
- * `setup` is a kind of construction plan for the {@link Viewer}. You can pass a {@link SetupJson} or a string, which
111
- * must represent a valid URL or path. If a string is given, the {@link Viewer} will resolve the URL or path and pass
112
- * the parsed JSON to this property. The {@link SetupJson} is responsible for managing a list of
113
- * {@link VariantInstanceDefinition}s. These definitions define the instances that should be instantiated during the
114
- * bootstrapping process. Each instance has a name and a reference to it's {@link Variant}.
115
- */
116
- setup?: string | SetupJson;
117
- file?: string;
118
- glTF?: Asset | string;
119
- parameterDeclaration?: ParameterDeclarations;
120
- parameters?: ParameterBag;
121
- elements?: ElementDefinitions;
122
- lights?: LightDefinitions;
123
- grounds?: GroundDefinitions;
124
- /**
125
- * `variants` is a declarative description of 3D-model variations in the configurator. Each variant itself is a
126
- * {@link StructureJson} which must at least define a `name` in the key of the list and the properties `glTF` and
127
- * `elements` in the value. FYI: BabylonJS's sandbox can show you the path of the 3D-model to properly define the
128
- * `paths`.
129
- *
130
- * Example Code
131
- * ```js
132
- * variants: {
133
- * 'My Pretty Variant' {
134
- * glTF: {
135
- * rootUrl: 'https:/my.awesome.domain/path/to/my/project/',
136
- * fileName: 'my_3d_model_file.glb',
137
- * },
138
- * elements: {
139
- * 'My Little Element': {
140
- * paths: {
141
- * includes: ['__root__.MeshName']
142
- * }
143
- * }
144
- * }
145
- * }
146
- * }
147
- * ```
148
- * `MeshName` has to be identical to the path in the glb-file of the 3D-model.
149
- */
150
- variants?: {
151
- [id: string]: StructureJson;
152
- };
153
- };
154
-
155
- type SceneJson = {
156
- parameterDeclaration?: ParameterDeclarations;
157
- parameters?: ParameterBag;
158
- meshPicking?: boolean;
159
- /**
160
- * Information about [EngineOptions](https://doc.babylonjs.com/typedoc/interfaces/babylon.engineoptions).
161
- */
162
- engine?: {
163
- antialiasing?: boolean;
164
- options?: EngineOptions;
165
- };
166
- scene: SceneDefinition;
167
- animations?: AnimationDefinitions;
168
- placements?: PlacementDefinitions;
169
- /**
170
- * Information about [material cloning](pages/Release%20Notes/releases/4-3-0.html#material-cloning-on-mutation)
171
- */
172
- cloneMaterialsOnMutation?: boolean;
173
- };
174
-
175
- type SceneDefinition = {
176
- globals: SceneGlobals;
177
- cameras?: CameraDefinitions;
178
- };
179
-
180
- type SceneGlobals = {
181
- 'shadows'?: {
182
- enabled: boolean;
183
- type: 'contact';
184
- settings: [];
185
- generator: [];
186
- receiver: [];
187
- };
188
- /**
189
- * `aa` or anti aliasing is not needed if hard edges are desired.\
190
- * FYI: aa smooths edges and avoids stairs-effects.
191
- */
192
- 'aa'?: 'fxaa';
193
- 'tone-mapping'?: boolean;
194
- /**
195
- * @bloom is widely known as glow. There you can define it’s size (Specifies the size of the bloom blur kernel,
196
- * relative to the final output size) and threshold (The luminance threshold to find bright areas of the image to
197
- * bloom).
198
- * Further Information under [BloomEffect](https://doc.babylonjs.com/typedoc/classes/babylon.bloomeffect).
199
- *
200
- * @dof short for "depth-of-field" defines the focus in the view. Parameters in settings are listed in [Depth of Field and Other Lens Effects link](https://doc.babylonjs.com/divingDeeper/postProcesses/dofLenseEffects).
201
- * @exposure specifies the intensity of the lightning of the view (not 3D-Model).
202
- * @sharpen´s parameter `settings` are listed in [Default Rendering Pipeline Sharpening link](https://doc.babylonjs.com/divingDeeper/postProcesses/defaultRenderingPipeline#sharpening).
203
- */
204
- 'camera-settings'?: {
205
- contrast: number;
206
- exposure: number;
207
- bloom?: {
208
- enabled: boolean;
209
- size?: number;
210
- threshold?: number;
211
- };
212
- dof?: {
213
- enabled: boolean;
214
- settings: {};
215
- };
216
- sharpen?: {
217
- enabled: boolean;
218
- settings: {};
219
- };
220
- };
221
- };
222
-
223
- /**
224
- * {@link Viewer.screenshot} internally uses Babylons [ScreenshotTools.CreateScreenshotUsingRenderTarget](https://doc.babylonjs.com/typedoc/classes/babylon.screenshottools#createscreenshotusingrendertarget). \
225
- * See this link for additional info about the properties.
226
- */
227
- type ScreenshotSettings = {
228
- /** Defaults to canvas width & height */
229
- size?: IScreenshotSize;
230
- /**
231
- * Default `image/png`
232
- *
233
- * **Info regarding JPEG:** \
234
- * Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
235
- * Also ensure that {@link Scene.clearColor | viewer.scene.clearColor} has an alpha value of `1` as jpeg's don't
236
- * support transparency. Otherwise background will always be black for jpeg's.
237
- */
238
- mimeType?: string;
239
- /** Default `1` */
240
- samples?: number;
241
- /** Default `false` */
242
- antialiasing?: boolean;
243
- /** Default `screenshot.png` */
244
- fileName?: string;
245
- /** Default `false` */
246
- renderSprites?: boolean;
247
- };
248
-
249
- /**
250
- * Use this to define geometry to be excluded from autofocus, GLB export, etc.
251
- */
252
- type ExcludedGeometry = Mesh | AbstractMesh | VariantInstance | Variant | VariantElement | Node;
253
- type ExcludedGeometryList = ExcludedGeometry[];
254
-
255
- type AutofocusSettings = {
256
- /**
257
- * Can be used to customize the margins shown around the 3d model when calling {@link Viewer.autofocusActiveCamera}.\
258
- * Defaults to 1.5 when not set explicitly.
259
- */
260
- radiusFactor?: number;
261
- adjustWheelPrecision?: boolean;
262
- adjustPanningSensibility?: boolean;
263
- adjustPinchPrecision?: boolean;
264
- /** Desired horizontal camera angle, this won't be overwritten by the autofocus function */
265
- alpha?: number;
266
- /** Desired vertical camera angle, this won't be overwritten by the autofocus function */
267
- beta?: number;
268
- /** Optional animation for the focusing camera movement */
269
- animation?: string | AnimationDefinition;
270
- /** Optional list of geometry to be excluded from consideration */
271
- exclude?: ExcludedGeometryList;
272
- };
273
-
274
- type LightDefinitions = {
275
- [name: string]: LightDefinition | string;
276
- };
277
-
278
- type LightDefinition = {
279
- type: 'baked' | 'hemispheric' | 'point' | 'directional' | 'spot';
280
- path?: string;
281
- shadowGenerator?: ShadowGeneratorDefinition;
282
- };
283
-
284
- type ShadowGeneratorDefinition = {
285
- mapSize: number;
286
- [others: string]: any;
287
- /**
288
- * Further properties like `usePoissonSampling` are set directly on the ShadowGenerator object.
289
- * [Shadows](https://doc.babylonjs.com/divingDeeper/lights/shadows)
290
- */
291
- };
292
-
293
- type GroundDefinitions = {
294
- [ground: string]: GroundDefinition;
295
- };
296
-
297
- type GroundDefinition = {
298
- type: 'baked' | 'ground' | 'heightmap';
299
- meshId?: string;
300
- url?: string;
301
- width?: number;
302
- height?: number;
303
- subdivisions?: number;
304
- receiveShadows?: boolean;
305
- minHeight?: number;
306
- maxHeight?: number;
307
- alphaFilter?: number;
308
- onReady?: any;
309
- };
310
-
311
- type CameraDefinitions = {
312
- [camera: string]: CameraDefinition;
313
- };
314
-
315
- type CameraDefinition = {
316
- /**
317
- * `fov` or "Field Of View" defines as it says the view of the scene. Further information about its [theory](https://en.wikipedia.org/wiki/Field_of_view) and [implementation](https://doc.babylonjs.com/typedoc/classes/babylon.camera#fov).
318
- */
319
- fov?: number;
320
- active?: boolean;
321
- /**
322
- * `arc` is a default camera position where the 3D-model is the center and the camera rotates around the 3D-model.
323
- * More Information about `arc` in [ArcRotateCamera](https://doc.babylonjs.com/typedoc/classes/babylon.arcrotatecamera).
324
- *
325
- * NOTE: While "baked" camera definitions from a GLB or babylon file can currently not be instatiated within the
326
- * `Specification`, it's still possible to use them in the viewer.\
327
- * For the moment all camera definitions inside these files are automatically added to the scene and can be actived
328
- * using the {@link Viewer.switchCamera} function.\
329
- * The `newCamera` input has to match the name of the camera node inside the GLB/babylon file.
330
- */
331
- type: 'arc';
332
- /**
333
- * `target` overrides `arc`´s position and repositions the camera. The string has the syntax (x?: number, y?: number, z?: number) like [Vector3](https://doc.babylonjs.com/typedoc/classes/babylon.vector3).
334
- */
335
- target?: string;
336
- };
337
-
338
- type VariantInstanceDefinition = {
339
- name?: string;
340
- variant: DottedPathArgument;
341
- parameters?: ParameterBag;
342
- lazy?: boolean;
343
- };
344
-
345
- type SetupJson = {
346
- instances: VariantInstanceDefinition[];
347
- };
348
-
349
- type ParameterDeclarations = {
350
- [name: string]: ParameterDeclaration;
351
- };
352
-
353
- type ParameterDeclaration = {
354
- type: 'string' | 'boolean' | 'number' | 'color' | 'select' | 'vector' | 'csl';
355
- parser?: any;
356
- options?: ParameterValue[];
357
- };
358
-
359
- type ParameterValue = string | number | boolean;
360
-
361
- type ParameterBag = {
362
- [name: string]: ParameterValue;
363
- };
364
-
365
- type ParsedParameterBag = {
366
- [name: string]: any;
367
- };
368
-
369
- type DottedPathArgument = string | string[] | DottedPath;
370
-
371
- type ParameterObserver = (object: any, oldValue: ParameterValue, newValue: ParameterValue) => void;
372
-
373
- type PlacementDefinitions = {
374
- [name: string]: PlacementDefinition;
375
- };
376
-
377
- type PlacementDefinition = {
378
- position?: string | Vector3;
379
- alpha?: number;
380
- beta?: number;
381
- radius?: number;
382
- target?: string | Vector3;
383
- };
384
-
385
- type AnimationDefinitions = {
386
- [name: string]: AnimationDefinition;
387
- };
388
-
389
- /**
390
- * See [GSAP API Docs](https://greensock.com/docs/v3/GSAP/Tween/vars) for description of `GSAPTWeenVars`.
391
- *
392
- * You can use the [GreenSock Ease Visualizer](https://greensock.com/ease-visualizer/) to create an animation of your
393
- * liking and simply copy the `ease` function shown at the bottom of the visualizer into the `ease` property of your
394
- * {@link AnimationDefinition}.
395
- *
396
- * The `GSAPTWeenVars` are extended by the `shortestWay` property.\
397
- * This property defines if the camera should move to the target position within the shortest possible distance.\
398
- * If `shortestWay` is `false`, the camera moves the whole difference between the current camera position and the target
399
- * position and that could be > 360, which can appear very unconvenient to the operator.\
400
- * The default value of this flag is `true`.
401
- *
402
- * Example usage in {@link SceneJson | SceneJson.animations}:
403
- *
404
- * ```js
405
- * // ...
406
- * scene: {
407
- * // ...
408
- * animations: {
409
- * DefaultCameraAnimation: {
410
- * ease: 'Power3.easeInOut',
411
- * duration: 0.8,
412
- * },
413
- * },
414
- * // ...
415
- * }
416
- * // ...
417
- * ```
418
- */
419
- type AnimationDefinition = GSAPTweenVars & { shortestWay?: boolean };
420
-
421
- /**
422
- * Extends Babylon JSs {@link IExportOptions} by some viewer specific settings
423
- */
424
- interface IExportOptionsExtended extends IExportOptions {
425
- /**
426
- * In certain situations multiple meshes in the viewer scene have the same name (e.g. when cloning instances).\
427
- * If this option is set, the exporter adjusts all mesh names before export to have a unique name.\
428
- * This is required e.g. if the exported file is used to show an AR scene with the model viewer which requires all
429
- * meshes to have unique names.
430
- */
431
- createUniqueMeshNames?: boolean;
432
- }
433
-
434
- type SpecGenerationData = {
435
- name: string;
436
- url: string;
437
- };
1
+ // global accessible types imported from 3d-viewer
2
+ type Viewer = import('../classes/viewer').Viewer;
3
+ type Variant = import('../classes/variant').Variant;
4
+ type VariantInstance = import('../classes/variantInstance').VariantInstance;
5
+ type VariantParameterizable = import('../classes/variantParameterizable').VariantParameterizable;
6
+ /**
7
+ * Alias for {@link Element} which can be used to prevent name clashes with the web APIs
8
+ * [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) class
9
+ */
10
+ type VariantElement = import('../classes/element').Element;
11
+ type DottedPath = import('../classes/dottedPath').DottedPath;
12
+ type ViewerLight = import('../classes/viewerLight').ViewerLight;
13
+ type SceneManager = import('../manager/sceneManager').SceneManager;
14
+
15
+ type FuzzyMap<K, V> = import('../classes/fuzzyMap').FuzzyMap<K, V>;
16
+
17
+ // global accessible types imported from BabylonJS
18
+ type Scene = import('@babylonjs/core/scene').Scene;
19
+ type Vector3 = import('@babylonjs/core/Maths/math.vector').Vector3;
20
+ type Color3 = import('@babylonjs/core/Maths/math.color').Color3;
21
+ type Color4 = import('@babylonjs/core/Maths/math.color').Color4;
22
+ type Material = import('@babylonjs/core/Materials/material').Material;
23
+ type PBRMaterial = import('@babylonjs/core/Materials/PBR/pbrMaterial').PBRMaterial;
24
+ type StandardMaterial = import('@babylonjs/core/Materials/standardMaterial').StandardMaterial;
25
+ type DynamicTexture = import('@babylonjs/core/Materials/Textures/dynamicTexture').DynamicTexture;
26
+ type Mesh = import('@babylonjs/core/Meshes/mesh').Mesh;
27
+ type AbstractMesh = import('@babylonjs/core/Meshes/abstractMesh').AbstractMesh;
28
+ type InstancedMesh = import('@babylonjs/core/Meshes/instancedMesh').InstancedMesh;
29
+ type TransformNode = import('@babylonjs/core/Meshes/transformNode').TransformNode;
30
+ type Engine = import('@babylonjs/core/Engines/engine').Engine;
31
+ type EngineOptions = import('@babylonjs/core/Engines/thinEngine').EngineOptions;
32
+ type ArcRotateCamera = import('@babylonjs/core/Cameras/arcRotateCamera').ArcRotateCamera;
33
+ type IScreenshotSize = import('@babylonjs/core/Misc/interfaces/screenshotSize').IScreenshotSize;
34
+ type BabylonAnimation = import('@babylonjs/core/Animations/animation').Animation;
35
+ type CubeTexture = import('@babylonjs/core/Materials/Textures/cubeTexture').CubeTexture;
36
+ type MeshBuilder = typeof import('@babylonjs/core/Meshes/meshBuilder').MeshBuilder;
37
+ type Texture = import('@babylonjs/core/Materials/Textures/texture').Texture;
38
+ type HemisphericLight = import('@babylonjs/core/Lights/hemisphericLight').HemisphericLight;
39
+ type DirectionalLight = import('@babylonjs/core/Lights/directionalLight').DirectionalLight;
40
+ type IInspectorOptions = import('@babylonjs/core/Debug').IInspectorOptions;
41
+ // Node is already defined in lib.dom.d.ts, so it can't be declared that way
42
+ // type Node = import("@babylonjs/core/node").Node;
43
+
44
+ type IExportOptions = import('@babylonjs/serializers/glTF/2.0').IExportOptions;
45
+
46
+ type EventEmitter = import('eventemitter3');
47
+
48
+ type Undefinable<T> = T | undefined;
49
+
50
+ type Nullable<T> = T | null;
51
+
52
+ // some more global accessible types
53
+ type PathDefinitions = {
54
+ include: string[];
55
+ exclude?: string[];
56
+ };
57
+
58
+ type TraceableDefinition = {
59
+ path: string;
60
+ };
61
+
62
+ type TraceableDefinitions = {
63
+ [name: string]: TraceableDefinition;
64
+ };
65
+
66
+ type PaintableDefinition = {
67
+ path: string;
68
+ textureOptions:
69
+ | {
70
+ width: number;
71
+ height: number;
72
+ }
73
+ | number;
74
+ };
75
+
76
+ type PaintableDefinitions = {
77
+ [name: string]: PaintableDefinition;
78
+ };
79
+
80
+ type Asset = {
81
+ rootUrl: string;
82
+ fileName: string | undefined;
83
+ };
84
+
85
+ type ElementDefinitions = {
86
+ [name: string]: ElementDefinition | string[];
87
+ };
88
+
89
+ type ElementDefinition = {
90
+ paths: PathDefinitions;
91
+ traceables?: TraceableDefinitions;
92
+ paintables?: PaintableDefinitions;
93
+ };
94
+
95
+ type TransformationDefinition = {
96
+ scaling: Vector3;
97
+ position: Vector3;
98
+ rotation: Vector3;
99
+ };
100
+
101
+ type EnvironmentDefinition = {
102
+ environmentColor?: Color3;
103
+ environmentIntensity?: number;
104
+ environment?: string;
105
+ environmentBackground?: string;
106
+ environmentRotation?: number;
107
+ environmentUseDefault?: boolean;
108
+ };
109
+
110
+ type StructureJson = {
111
+ /**
112
+ * `scene` describes the visualisation of the babylon `scene` such as the incidence of light and camera position. If a
113
+ * string is given, the {@link Viewer} will resolve the URL or path and pass the parsed JSON to this property.
114
+ */
115
+ scene?: string | SceneJson;
116
+ /**
117
+ * `setup` is a kind of construction plan for the {@link Viewer}. You can pass a {@link SetupJson} or a string, which
118
+ * must represent a valid URL or path. If a string is given, the {@link Viewer} will resolve the URL or path and pass
119
+ * the parsed JSON to this property. The {@link SetupJson} is responsible for managing a list of
120
+ * {@link VariantInstanceDefinition}s. These definitions define the instances that should be instantiated during the
121
+ * bootstrapping process. Each instance has a name and a reference to it's {@link Variant}.
122
+ */
123
+ setup?: string | SetupJson;
124
+ file?: string;
125
+ glTF?: Asset | string;
126
+ parameterDeclaration?: ParameterDeclarations;
127
+ parameters?: ParameterBag;
128
+ elements?: ElementDefinitions;
129
+ lights?: LightDefinitions;
130
+ grounds?: GroundDefinitions;
131
+ /**
132
+ * `variants` is a declarative description of 3D-model variations in the configurator. Each variant itself is a
133
+ * {@link StructureJson} which must at least define a `name` in the key of the list and the properties `glTF` and
134
+ * `elements` in the value. FYI: Babylon.js's sandbox can show you the path of the 3D-model to properly define the
135
+ * `paths`.
136
+ *
137
+ * Example Code
138
+ * ```js
139
+ * variants: {
140
+ * 'My Pretty Variant' {
141
+ * glTF: {
142
+ * rootUrl: 'https:/my.awesome.domain/path/to/my/project/',
143
+ * fileName: 'my_3d_model_file.glb',
144
+ * },
145
+ * elements: {
146
+ * 'My Little Element': {
147
+ * paths: {
148
+ * includes: ['__root__.MeshName']
149
+ * }
150
+ * }
151
+ * }
152
+ * }
153
+ * }
154
+ * ```
155
+ * `MeshName` has to be identical to the path in the glb-file of the 3D-model.
156
+ */
157
+ variants?: {
158
+ [id: string]: StructureJson;
159
+ };
160
+ };
161
+
162
+ type AutoSpecStructureJson = StructureJson & {
163
+ scene: SceneJson;
164
+ setup: SetupJson;
165
+ variants: { [id: string]: StructureJson };
166
+ };
167
+
168
+ type SceneJson = {
169
+ parameterDeclaration?: ParameterDeclarations;
170
+ parameters?: ParameterBag;
171
+ meshPicking?: boolean;
172
+ /**
173
+ * Information about [EngineOptions](https://doc.babylonjs.com/typedoc/interfaces/babylon.engineoptions).
174
+ */
175
+ engine?: {
176
+ antialiasing?: boolean;
177
+ options?: EngineOptions;
178
+ };
179
+ scene: SceneDefinition;
180
+ animations?: AnimationDefinitions;
181
+ placements?: PlacementDefinitions;
182
+ /**
183
+ * Information about [material cloning](pages/Release%20Notes/releases/4-3-0.html#material-cloning-on-mutation).
184
+ * Default value is `false`.
185
+ */
186
+ cloneMaterialsOnMutation?: boolean;
187
+ };
188
+
189
+ type SceneDefinition = {
190
+ globals: SceneGlobals;
191
+ cameras?: CameraDefinitions;
192
+ };
193
+
194
+ type SceneGlobals = {
195
+ 'shadows'?: {
196
+ enabled: boolean;
197
+ type: 'contact';
198
+ settings: [];
199
+ generator: [];
200
+ receiver: [];
201
+ };
202
+ /**
203
+ * `aa` or anti aliasing is not needed if hard edges are desired.\
204
+ * FYI: aa smooths edges and avoids stairs-effects.
205
+ */
206
+ 'aa'?: 'fxaa';
207
+ 'tone-mapping'?: boolean;
208
+ /**
209
+ * @bloom is widely known as glow. There you can define it’s size (Specifies the size of the bloom blur kernel,
210
+ * relative to the final output size) and threshold (The luminance threshold to find bright areas of the image to
211
+ * bloom).
212
+ * Further Information under [BloomEffect](https://doc.babylonjs.com/typedoc/classes/babylon.bloomeffect).
213
+ *
214
+ * @dof short for "depth-of-field" defines the focus in the view. Parameters in settings are listed in [Depth of Field and Other Lens Effects link](https://doc.babylonjs.com/divingDeeper/postProcesses/dofLenseEffects).
215
+ * @exposure specifies the intensity of the lightning of the view (not 3D-Model).
216
+ * @sharpen´s parameter `settings` are listed in [Default Rendering Pipeline Sharpening link](https://doc.babylonjs.com/divingDeeper/postProcesses/defaultRenderingPipeline#sharpening).
217
+ */
218
+ 'camera-settings'?: {
219
+ contrast: number;
220
+ exposure: number;
221
+ bloom?: {
222
+ enabled: boolean;
223
+ size?: number;
224
+ threshold?: number;
225
+ };
226
+ dof?: {
227
+ enabled: boolean;
228
+ settings: {};
229
+ };
230
+ sharpen?: {
231
+ enabled: boolean;
232
+ settings: {};
233
+ };
234
+ };
235
+ };
236
+
237
+ /**
238
+ * {@link Viewer.screenshot} internally uses Babylon.js [ScreenshotTools.CreateScreenshotUsingRenderTarget](https://doc.babylonjs.com/typedoc/classes/babylon.screenshottools#createscreenshotusingrendertarget). \
239
+ * See this link for additional info about the properties.
240
+ */
241
+ type ScreenshotSettings = {
242
+ /** Defaults to canvas width & height */
243
+ size?: IScreenshotSize;
244
+ /**
245
+ * Default `image/png`
246
+ *
247
+ * **Info regarding JPEG:** \
248
+ * Use mimeType `image/jpeg` (**not** `image/jpg`) when creating jpeg's. \
249
+ * Also ensure that {@link Scene.clearColor | viewer.scene.clearColor} has an alpha value of `1` as jpeg's don't
250
+ * support transparency. Otherwise background will always be black for jpeg's.
251
+ */
252
+ mimeType?: string;
253
+ /** Default `1` */
254
+ samples?: number;
255
+ /** Default `false` */
256
+ antialiasing?: boolean;
257
+ /** Default `screenshot.png` */
258
+ fileName?: string;
259
+ /** Default `false` */
260
+ renderSprites?: boolean;
261
+ };
262
+
263
+ /**
264
+ * Use this to define geometry to be excluded from autofocus, GLB export, etc.
265
+ */
266
+ type ExcludedGeometry = Mesh | AbstractMesh | VariantInstance | Variant | VariantElement | Node;
267
+ type ExcludedGeometryList = ExcludedGeometry[];
268
+
269
+ type AutofocusSettings = {
270
+ /**
271
+ * Can be used to customize the margins shown around the 3d model when calling {@link Viewer.autofocusActiveCamera}.\
272
+ * Defaults to 1.5 when not set explicitly.
273
+ */
274
+ radiusFactor?: number;
275
+ adjustWheelPrecision?: boolean;
276
+ adjustPanningSensibility?: boolean;
277
+ adjustPinchPrecision?: boolean;
278
+ /** Desired horizontal camera angle, this won't be overwritten by the autofocus function */
279
+ alpha?: number;
280
+ /** Desired vertical camera angle, this won't be overwritten by the autofocus function */
281
+ beta?: number;
282
+ /** Optional animation for the focusing camera movement */
283
+ animation?: string | AnimationDefinition;
284
+ /** Optional list of geometry to be excluded from consideration */
285
+ exclude?: ExcludedGeometryList;
286
+ };
287
+
288
+ type LightDefinitions = {
289
+ [name: string]: LightDefinition | string;
290
+ };
291
+
292
+ type LightDefinition = {
293
+ type: 'baked' | 'hemispheric' | 'point' | 'directional' | 'spot';
294
+ path?: string;
295
+ shadowGenerator?: ShadowGeneratorDefinition;
296
+ };
297
+
298
+ type ShadowGeneratorDefinition = {
299
+ mapSize: number;
300
+ [others: string]: any;
301
+ /**
302
+ * Further properties like `usePoissonSampling` are set directly on the ShadowGenerator object.
303
+ * [Shadows](https://doc.babylonjs.com/divingDeeper/lights/shadows)
304
+ */
305
+ };
306
+
307
+ type GroundDefinitions = {
308
+ [ground: string]: GroundDefinition;
309
+ };
310
+
311
+ type GroundDefinition = {
312
+ type: 'baked' | 'ground' | 'heightmap';
313
+ meshId?: string;
314
+ url?: string;
315
+ width?: number;
316
+ height?: number;
317
+ subdivisions?: number;
318
+ receiveShadows?: boolean;
319
+ minHeight?: number;
320
+ maxHeight?: number;
321
+ alphaFilter?: number;
322
+ onReady?: any;
323
+ };
324
+
325
+ type CameraDefinitions = {
326
+ [camera: string]: CameraDefinition;
327
+ };
328
+
329
+ type CameraDefinition = {
330
+ /**
331
+ * `fov` or "Field Of View" defines as it says the view of the scene. Further information about its [theory](https://en.wikipedia.org/wiki/Field_of_view) and [implementation](https://doc.babylonjs.com/typedoc/classes/babylon.camera#fov).
332
+ */
333
+ fov?: number;
334
+ active?: boolean;
335
+ /**
336
+ * `arc` is a default camera position where the 3D-model is the center and the camera rotates around the 3D-model.
337
+ * More Information about `arc` in [ArcRotateCamera](https://doc.babylonjs.com/typedoc/classes/babylon.arcrotatecamera).
338
+ *
339
+ * NOTE: While "baked" camera definitions from a GLB or babylon file can currently not be instatiated within the
340
+ * `Specification`, it's still possible to use them in the viewer.\
341
+ * For the moment all camera definitions inside these files are automatically added to the scene and can be actived
342
+ * using the {@link Viewer.switchCamera} function.\
343
+ * The `newCamera` input has to match the name of the camera node inside the GLB/babylon file.
344
+ */
345
+ type: 'arc';
346
+ /**
347
+ * `target` overrides `arc`´s position and repositions the camera. The string has the syntax (x?: number, y?: number, z?: number) like [Vector3](https://doc.babylonjs.com/typedoc/classes/babylon.vector3).
348
+ */
349
+ target?: string;
350
+ };
351
+
352
+ type VariantInstanceDefinition = {
353
+ name?: string;
354
+ variant: DottedPathArgument;
355
+ parameters?: ParameterBag;
356
+ lazy?: boolean;
357
+ };
358
+
359
+ type SetupJson = {
360
+ instances: VariantInstanceDefinition[];
361
+ };
362
+
363
+ type ParameterDeclarations = {
364
+ [name: string]: ParameterDeclaration;
365
+ };
366
+
367
+ type ParameterDeclaration = {
368
+ type: 'string' | 'boolean' | 'number' | 'color' | 'select' | 'vector' | 'csl';
369
+ parser?: any;
370
+ options?: ParameterValue[];
371
+ };
372
+
373
+ type ParameterValue = string | number | boolean;
374
+
375
+ type ParameterBag = {
376
+ [name: string]: ParameterValue;
377
+ };
378
+
379
+ type ParsedParameterBag = {
380
+ [name: string]: any;
381
+ };
382
+
383
+ type DottedPathArgument = string | string[] | DottedPath;
384
+
385
+ type ParameterObserverResult = any;
386
+
387
+ type ParameterObserver = (
388
+ payload: any,
389
+ oldValue: Undefinable<ParameterValue>,
390
+ newValue: ParameterValue
391
+ ) => ParameterObserverResult;
392
+
393
+ type PlacementDefinitions = {
394
+ [name: string]: PlacementDefinition;
395
+ };
396
+
397
+ type PlacementDefinition = {
398
+ position?: string | Vector3;
399
+ alpha?: number;
400
+ beta?: number;
401
+ radius?: number;
402
+ target?: string | Vector3;
403
+ };
404
+
405
+ type AnimationDefinitions = {
406
+ [name: string]: AnimationDefinition;
407
+ };
408
+
409
+ /**
410
+ * See [GSAP API Docs](https://greensock.com/docs/v3/GSAP/Tween/vars) for description of `GSAPTWeenVars`.
411
+ *
412
+ * You can use the [GreenSock Ease Visualizer](https://greensock.com/ease-visualizer/) to create an animation of your
413
+ * liking and simply copy the `ease` function shown at the bottom of the visualizer into the `ease` property of your
414
+ * {@link AnimationDefinition}.
415
+ *
416
+ * The `GSAPTWeenVars` are extended by the `shortestWay` property.\
417
+ * This property defines if the camera should move to the target position within the shortest possible distance.\
418
+ * If `shortestWay` is `false`, the camera moves the whole difference between the current camera position and the target
419
+ * position and that could be > 360, which can appear very unconvenient to the operator.\
420
+ * The default value of this flag is `true`.
421
+ *
422
+ * Example usage in {@link SceneJson | SceneJson.animations}:
423
+ *
424
+ * ```js
425
+ * // ...
426
+ * scene: {
427
+ * // ...
428
+ * animations: {
429
+ * DefaultCameraAnimation: {
430
+ * ease: 'Power3.easeInOut',
431
+ * duration: 0.8,
432
+ * },
433
+ * },
434
+ * // ...
435
+ * }
436
+ * // ...
437
+ * ```
438
+ */
439
+ type AnimationDefinition = GSAPTweenVars & { shortestWay?: boolean };
440
+
441
+ /**
442
+ * Extends Babylon.js's {@link IExportOptions} by some viewer specific settings
443
+ */
444
+ interface IExportOptionsExtended extends IExportOptions {
445
+ /**
446
+ * In certain situations multiple meshes in the viewer scene have the same name (e.g. when cloning instances).\
447
+ * If this option is set, the exporter adjusts all mesh names before export to have a unique name.\
448
+ * This is required e.g. if the exported file is used to show an AR scene with the model viewer which requires all
449
+ * meshes to have unique names.
450
+ */
451
+ createUniqueMeshNames?: boolean;
452
+ }
453
+
454
+ type SpecGenerationData = {
455
+ name: string;
456
+ url: string;
457
+ };
458
+
459
+ type TagMapping = {
460
+ [tagName: string]: string;
461
+ };
462
+
463
+ type TagManagerSubject = {
464
+ tagName?: string;
465
+ nodeName?: string;
466
+ };
467
+
468
+ type TagManagerParameterObserver = (payload: TagManagerParameterObserverPayload) => ParameterObserverResult;
469
+
470
+ type TagManagerParameterBag = FuzzyMap<TagManagerSubject, ParameterBag>;
471
+
472
+ type TagManagerParameterObserverBag = Map<string, TagManagerParameterObserver>;
473
+
474
+ type TagManagerParameterObserverPayload = {
475
+ subject: TagManagerSubject;
476
+ nodes: TransformNode[];
477
+ newValue: ParameterValue;
478
+ oldValue: Undefinable<ParameterValue>;
479
+ };
480
+
481
+ type TagManagerParameterValue = {
482
+ tagName?: string;
483
+ nodeName?: string;
484
+ parameterName: string;
485
+ value: ParameterValue;
486
+ };
487
+
488
+ type NodeNamingStrategyPayload = {
489
+ variantInstance: VariantInstance;
490
+ variant: Variant;
491
+ variantParameterizable: VariantParameterizable;
492
+ };
493
+
494
+ type NodeNamingStrategyHandler = (node: TransformNode, payload: NodeNamingStrategyPayload) => string;
495
+
496
+ type NodeNamingStrategy = {
497
+ handler: NodeNamingStrategyHandler;
498
+ payload: NodeNamingStrategyPayload;
499
+ };