@babylonjs/loaders 7.51.0 → 7.51.2

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 (56) hide show
  1. package/glTF/2.0/Extensions/KHR_animation_pointer.d.ts +1 -0
  2. package/glTF/2.0/Extensions/KHR_animation_pointer.data.d.ts +0 -299
  3. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js +190 -224
  4. package/glTF/2.0/Extensions/KHR_animation_pointer.data.js.map +1 -1
  5. package/glTF/2.0/Extensions/KHR_animation_pointer.js +11 -14
  6. package/glTF/2.0/Extensions/KHR_animation_pointer.js.map +1 -1
  7. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +339 -0
  8. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +1507 -0
  9. package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -0
  10. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.d.ts +33 -0
  11. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js +20 -0
  12. package/glTF/2.0/Extensions/KHR_interactivity/flowGraphGLTFDataProvider.js.map +1 -0
  13. package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +3 -0
  14. package/glTF/2.0/Extensions/KHR_interactivity/index.js +4 -0
  15. package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -0
  16. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +71 -0
  17. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +442 -0
  18. package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -0
  19. package/glTF/2.0/Extensions/KHR_interactivity.d.ts +7 -1
  20. package/glTF/2.0/Extensions/KHR_interactivity.js +105 -7
  21. package/glTF/2.0/Extensions/KHR_interactivity.js.map +1 -1
  22. package/glTF/2.0/Extensions/KHR_node_hoverability.js +153 -0
  23. package/glTF/2.0/Extensions/KHR_node_hoverability.js.map +1 -1
  24. package/glTF/2.0/Extensions/KHR_node_selectability.d.ts +30 -0
  25. package/glTF/2.0/Extensions/KHR_node_selectability.js +123 -0
  26. package/glTF/2.0/Extensions/KHR_node_selectability.js.map +1 -0
  27. package/glTF/2.0/Extensions/KHR_node_visibility.js +25 -0
  28. package/glTF/2.0/Extensions/KHR_node_visibility.js.map +1 -1
  29. package/glTF/2.0/Extensions/gltfPathToObjectConverter.d.ts +5 -2
  30. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +26 -5
  31. package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
  32. package/glTF/2.0/Extensions/index.d.ts +4 -0
  33. package/glTF/2.0/Extensions/index.js +5 -0
  34. package/glTF/2.0/Extensions/index.js.map +1 -1
  35. package/glTF/2.0/Extensions/objectModelMapping.d.ts +289 -0
  36. package/glTF/2.0/Extensions/objectModelMapping.js +801 -0
  37. package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -0
  38. package/glTF/2.0/glTFLoader.d.ts +4 -1
  39. package/glTF/2.0/glTFLoader.js +22 -11
  40. package/glTF/2.0/glTFLoader.js.map +1 -1
  41. package/glTF/2.0/glTFLoaderAnimation.d.ts +12 -10
  42. package/glTF/2.0/glTFLoaderAnimation.js +13 -11
  43. package/glTF/2.0/glTFLoaderAnimation.js.map +1 -1
  44. package/glTF/2.0/index.d.ts +1 -0
  45. package/glTF/2.0/index.js +1 -0
  46. package/glTF/2.0/index.js.map +1 -1
  47. package/package.json +3 -3
  48. package/glTF/2.0/Extensions/interactivityFunctions.d.ts +0 -9
  49. package/glTF/2.0/Extensions/interactivityFunctions.js +0 -198
  50. package/glTF/2.0/Extensions/interactivityFunctions.js.map +0 -1
  51. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.d.ts +0 -9
  52. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js +0 -32
  53. package/glTF/2.0/Extensions/interactivityPathToObjectConverter.js.map +0 -1
  54. package/glTF/2.0/Extensions/interactivityUtils.d.ts +0 -4
  55. package/glTF/2.0/Extensions/interactivityUtils.js +0 -108
  56. package/glTF/2.0/Extensions/interactivityUtils.js.map +0 -1
@@ -0,0 +1,801 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import { Matrix, Quaternion, Vector2 } from "@babylonjs/core/Maths/math.vector.js";
3
+ import { Constants } from "@babylonjs/core/Engines/constants.js";
4
+ import { Color4 } from "@babylonjs/core/Maths/math.color.js";
5
+ import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
6
+ import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter.js";
7
+ const nodesTree = {
8
+ length: {
9
+ type: "number",
10
+ get: (nodes) => nodes.length,
11
+ getTarget: (nodes) => nodes.map((node) => node._babylonTransformNode),
12
+ getPropertyName: [() => "length"],
13
+ },
14
+ __array__: {
15
+ __target__: true,
16
+ translation: {
17
+ type: "Vector3",
18
+ get: (node) => node._babylonTransformNode?.position,
19
+ set: (value, node) => node._babylonTransformNode?.position.copyFrom(value),
20
+ getTarget: (node) => node._babylonTransformNode,
21
+ getPropertyName: [() => "position"],
22
+ },
23
+ rotation: {
24
+ type: "Quaternion",
25
+ get: (node) => node._babylonTransformNode?.rotationQuaternion,
26
+ set: (value, node) => node._babylonTransformNode?.rotationQuaternion?.copyFrom(value),
27
+ getTarget: (node) => node._babylonTransformNode,
28
+ getPropertyName: [() => "rotationQuaternion"],
29
+ },
30
+ scale: {
31
+ type: "Vector3",
32
+ get: (node) => node._babylonTransformNode?.scaling,
33
+ set: (value, node) => node._babylonTransformNode?.scaling.copyFrom(value),
34
+ getTarget: (node) => node._babylonTransformNode,
35
+ getPropertyName: [() => "scaling"],
36
+ },
37
+ weights: {
38
+ length: {
39
+ type: "number",
40
+ get: (node) => node._numMorphTargets,
41
+ getTarget: (node) => node._babylonTransformNode,
42
+ getPropertyName: [() => "influence"],
43
+ },
44
+ __array__: {
45
+ __target__: true,
46
+ type: "number",
47
+ get: (node, index) => (index !== undefined ? node._primitiveBabylonMeshes?.[0].morphTargetManager?.getTarget(index).influence : undefined),
48
+ // set: (value: number, node: INode, index?: number) => node._babylonTransformNode?.getMorphTargetManager()?.getTarget(index)?.setInfluence(value),
49
+ getTarget: (node) => node._babylonTransformNode,
50
+ getPropertyName: [() => "influence"],
51
+ },
52
+ type: "number[]",
53
+ get: (node, index) => [0], // TODO: get the weights correctly
54
+ // set: (value: number, node: INode, index?: number) => node._babylonTransformNode?.getMorphTargetManager()?.getTarget(index)?.setInfluence(value),
55
+ getTarget: (node) => node._babylonTransformNode,
56
+ getPropertyName: [() => "influence"],
57
+ },
58
+ // readonly!
59
+ matrix: {
60
+ type: "Matrix",
61
+ get: (node) => node._babylonTransformNode?.getWorldMatrix(),
62
+ getTarget: (node) => node._babylonTransformNode,
63
+ getPropertyName: [() => "worldMatrix"],
64
+ },
65
+ globalMatrix: {
66
+ type: "Matrix",
67
+ get: (node) => node._babylonTransformNode?.getWorldMatrix(),
68
+ getTarget: (node) => node._babylonTransformNode,
69
+ getPropertyName: [() => "_worldMatrix"],
70
+ isReadOnly: true,
71
+ },
72
+ extensions: {
73
+ EXT_lights_ies: {
74
+ multiplier: {
75
+ type: "number",
76
+ get: (node) => {
77
+ return node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0]?.intensity;
78
+ },
79
+ getTarget: (node) => node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0],
80
+ set: (value, node) => {
81
+ if (node._babylonTransformNode) {
82
+ const light = node._babylonTransformNode.getChildren((child) => child instanceof SpotLight, true)[0];
83
+ if (light) {
84
+ light.intensity = value;
85
+ }
86
+ }
87
+ },
88
+ },
89
+ color: {
90
+ type: "Color3",
91
+ get: (node) => {
92
+ return node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0]?.diffuse;
93
+ },
94
+ getTarget: (node) => node._babylonTransformNode?.getChildren((child) => child instanceof SpotLight, true)[0],
95
+ set: (value, node) => {
96
+ if (node._babylonTransformNode) {
97
+ const light = node._babylonTransformNode.getChildren((child) => child instanceof SpotLight, true)[0];
98
+ if (light) {
99
+ light.diffuse = value;
100
+ }
101
+ }
102
+ },
103
+ },
104
+ },
105
+ },
106
+ },
107
+ };
108
+ const animationsTree = {
109
+ length: {
110
+ type: "number",
111
+ get: (animations) => animations.length,
112
+ getTarget: (animations) => animations.map((animation) => animation._babylonAnimationGroup),
113
+ getPropertyName: [() => "length"],
114
+ },
115
+ __array__: {},
116
+ };
117
+ const meshesTree = {
118
+ length: {
119
+ type: "number",
120
+ get: (meshes) => meshes.length,
121
+ getTarget: (meshes) => meshes.map((mesh) => mesh.primitives[0]._instanceData?.babylonSourceMesh),
122
+ getPropertyName: [() => "length"],
123
+ },
124
+ __array__: {},
125
+ };
126
+ const camerasTree = {
127
+ __array__: {
128
+ __target__: true,
129
+ orthographic: {
130
+ xmag: {
131
+ componentsCount: 2,
132
+ type: "Vector2",
133
+ get: (camera) => new Vector2(camera._babylonCamera?.orthoLeft ?? 0, camera._babylonCamera?.orthoRight ?? 0),
134
+ set: (value, camera) => {
135
+ if (camera._babylonCamera) {
136
+ camera._babylonCamera.orthoLeft = value.x;
137
+ camera._babylonCamera.orthoRight = value.y;
138
+ }
139
+ },
140
+ getTarget: (camera) => camera,
141
+ getPropertyName: [() => "orthoLeft", () => "orthoRight"],
142
+ },
143
+ ymag: {
144
+ componentsCount: 2,
145
+ type: "Vector2",
146
+ get: (camera) => new Vector2(camera._babylonCamera?.orthoBottom ?? 0, camera._babylonCamera?.orthoTop ?? 0),
147
+ set: (value, camera) => {
148
+ if (camera._babylonCamera) {
149
+ camera._babylonCamera.orthoBottom = value.x;
150
+ camera._babylonCamera.orthoTop = value.y;
151
+ }
152
+ },
153
+ getTarget: (camera) => camera,
154
+ getPropertyName: [() => "orthoBottom", () => "orthoTop"],
155
+ },
156
+ zfar: {
157
+ type: "number",
158
+ get: (camera) => camera._babylonCamera?.maxZ,
159
+ set: (value, camera) => {
160
+ if (camera._babylonCamera) {
161
+ camera._babylonCamera.maxZ = value;
162
+ }
163
+ },
164
+ getTarget: (camera) => camera,
165
+ getPropertyName: [() => "maxZ"],
166
+ },
167
+ znear: {
168
+ type: "number",
169
+ get: (camera) => camera._babylonCamera?.minZ,
170
+ set: (value, camera) => {
171
+ if (camera._babylonCamera) {
172
+ camera._babylonCamera.minZ = value;
173
+ }
174
+ },
175
+ getTarget: (camera) => camera,
176
+ getPropertyName: [() => "minZ"],
177
+ },
178
+ },
179
+ perspective: {
180
+ aspectRatio: {
181
+ type: "number",
182
+ get: (camera) => camera._babylonCamera?.getEngine().getAspectRatio(camera._babylonCamera),
183
+ getTarget: (camera) => camera,
184
+ getPropertyName: [() => "aspectRatio"],
185
+ isReadOnly: true, // might not be the case for glTF?
186
+ },
187
+ yfov: {
188
+ type: "number",
189
+ get: (camera) => camera._babylonCamera?.fov,
190
+ set: (value, camera) => {
191
+ if (camera._babylonCamera) {
192
+ camera._babylonCamera.fov = value;
193
+ }
194
+ },
195
+ getTarget: (camera) => camera,
196
+ getPropertyName: [() => "fov"],
197
+ },
198
+ zfar: {
199
+ type: "number",
200
+ get: (camera) => camera._babylonCamera?.maxZ,
201
+ set: (value, camera) => {
202
+ if (camera._babylonCamera) {
203
+ camera._babylonCamera.maxZ = value;
204
+ }
205
+ },
206
+ getTarget: (camera) => camera,
207
+ getPropertyName: [() => "maxZ"],
208
+ },
209
+ znear: {
210
+ type: "number",
211
+ get: (camera) => camera._babylonCamera?.minZ,
212
+ set: (value, camera) => {
213
+ if (camera._babylonCamera) {
214
+ camera._babylonCamera.minZ = value;
215
+ }
216
+ },
217
+ getTarget: (camera) => camera,
218
+ getPropertyName: [() => "minZ"],
219
+ },
220
+ },
221
+ },
222
+ };
223
+ const materialsTree = {
224
+ __array__: {
225
+ __target__: true,
226
+ emissiveFactor: {
227
+ type: "Color3",
228
+ get: (material, index, payload) => _GetMaterial(material, index, payload).emissiveColor,
229
+ set: (value, material, index, payload) => _GetMaterial(material, index, payload).emissiveColor.copyFrom(value),
230
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
231
+ getPropertyName: [() => "emissiveColor"],
232
+ },
233
+ emissiveTexture: {
234
+ extensions: {
235
+ KHR_texture_transform: _GenerateTextureMap("emissiveTexture"),
236
+ },
237
+ },
238
+ normalTexture: {
239
+ scale: {
240
+ type: "number",
241
+ get: (material, index, payload) => _GetTexture(material, payload, "bumpTexture")?.level,
242
+ set: (value, material, index, payload) => {
243
+ const texture = _GetTexture(material, payload, "bumpTexture");
244
+ if (texture) {
245
+ texture.level = value;
246
+ }
247
+ },
248
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
249
+ getPropertyName: [() => "level"],
250
+ },
251
+ extensions: {
252
+ KHR_texture_transform: _GenerateTextureMap("bumpTexture"),
253
+ },
254
+ },
255
+ occlusionTexture: {
256
+ strength: {
257
+ type: "number",
258
+ get: (material, index, payload) => _GetMaterial(material, index, payload).ambientTextureStrength,
259
+ set: (value, material, index, payload) => {
260
+ const mat = _GetMaterial(material, index, payload);
261
+ if (mat) {
262
+ mat.ambientTextureStrength = value;
263
+ }
264
+ },
265
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
266
+ getPropertyName: [() => "ambientTextureStrength"],
267
+ },
268
+ extensions: {
269
+ KHR_texture_transform: _GenerateTextureMap("ambientTexture"),
270
+ },
271
+ },
272
+ pbrMetallicRoughness: {
273
+ baseColorFactor: {
274
+ type: "Color4",
275
+ get: (material, index, payload) => {
276
+ const mat = _GetMaterial(material, index, payload);
277
+ return Color4.FromColor3(mat.albedoColor, mat.alpha);
278
+ },
279
+ set: (value, material, index, payload) => {
280
+ const mat = _GetMaterial(material, index, payload);
281
+ mat.albedoColor.set(value.r, value.g, value.b);
282
+ mat.alpha = value.a;
283
+ },
284
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
285
+ // This is correct on the animation level, but incorrect as a single property of a type Color4
286
+ getPropertyName: [() => "albedoColor", () => "alpha"],
287
+ },
288
+ baseColorTexture: {
289
+ extensions: {
290
+ KHR_texture_transform: _GenerateTextureMap("albedoTexture"),
291
+ },
292
+ },
293
+ metallicFactor: {
294
+ type: "number",
295
+ get: (material, index, payload) => _GetMaterial(material, index, payload).metallic,
296
+ set: (value, material, index, payload) => {
297
+ const mat = _GetMaterial(material, index, payload);
298
+ if (mat) {
299
+ mat.metallic = value;
300
+ }
301
+ },
302
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
303
+ getPropertyName: [() => "metallic"],
304
+ },
305
+ roughnessFactor: {
306
+ type: "number",
307
+ get: (material, index, payload) => _GetMaterial(material, index, payload).roughness,
308
+ set: (value, material, index, payload) => {
309
+ const mat = _GetMaterial(material, index, payload);
310
+ if (mat) {
311
+ mat.roughness = value;
312
+ }
313
+ },
314
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
315
+ getPropertyName: [() => "roughness"],
316
+ },
317
+ metallicRoughnessTexture: {
318
+ extensions: {
319
+ KHR_texture_transform: _GenerateTextureMap("metallicTexture"),
320
+ },
321
+ },
322
+ },
323
+ extensions: {
324
+ KHR_materials_anisotropy: {
325
+ anisotropyStrength: {
326
+ type: "number",
327
+ get: (material, index, payload) => _GetMaterial(material, index, payload).anisotropy.intensity,
328
+ set: (value, material, index, payload) => {
329
+ _GetMaterial(material, index, payload).anisotropy.intensity = value;
330
+ },
331
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
332
+ getPropertyName: [() => "anisotropy.intensity"],
333
+ },
334
+ anisotropyRotation: {
335
+ type: "number",
336
+ get: (material, index, payload) => _GetMaterial(material, index, payload).anisotropy.angle,
337
+ set: (value, material, index, payload) => {
338
+ _GetMaterial(material, index, payload).anisotropy.angle = value;
339
+ },
340
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
341
+ getPropertyName: [() => "anisotropy.angle"],
342
+ },
343
+ anisotropyTexture: {
344
+ extensions: {
345
+ KHR_texture_transform: _GenerateTextureMap("anisotropy", "texture"),
346
+ },
347
+ },
348
+ },
349
+ KHR_materials_clearcoat: {
350
+ clearcoatFactor: {
351
+ type: "number",
352
+ get: (material, index, payload) => _GetMaterial(material, index, payload).clearCoat.intensity,
353
+ set: (value, material, index, payload) => {
354
+ _GetMaterial(material, index, payload).clearCoat.intensity = value;
355
+ },
356
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
357
+ getPropertyName: [() => "clearCoat.intensity"],
358
+ },
359
+ clearcoatRoughnessFactor: {
360
+ type: "number",
361
+ get: (material, index, payload) => _GetMaterial(material, index, payload).clearCoat.roughness,
362
+ set: (value, material, index, payload) => {
363
+ _GetMaterial(material, index, payload).clearCoat.roughness = value;
364
+ },
365
+ getTarget: (material, index, payload) => _GetMaterial(material, index, payload),
366
+ getPropertyName: [() => "clearCoat.roughness"],
367
+ },
368
+ clearcoatTexture: {
369
+ extensions: {
370
+ KHR_texture_transform: _GenerateTextureMap("clearCoat", "texture"),
371
+ },
372
+ },
373
+ clearcoatNormalTexture: {
374
+ scale: {
375
+ type: "number",
376
+ get: (material, index, payload) => _GetMaterial(material, index, payload).clearCoat.bumpTexture?.level,
377
+ getTarget: _GetMaterial,
378
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).clearCoat.bumpTexture.level = value),
379
+ },
380
+ extensions: {
381
+ KHR_texture_transform: _GenerateTextureMap("clearCoat", "bumpTexture"),
382
+ },
383
+ },
384
+ clearcoatRoughnessTexture: {
385
+ extensions: {
386
+ KHR_texture_transform: _GenerateTextureMap("clearCoat", "textureRoughness"),
387
+ },
388
+ },
389
+ },
390
+ KHR_materials_dispersion: {
391
+ dispersion: {
392
+ type: "number",
393
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.dispersion,
394
+ getTarget: _GetMaterial,
395
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).subSurface.dispersion = value),
396
+ },
397
+ },
398
+ KHR_materials_emissive_strength: {
399
+ emissiveStrength: {
400
+ type: "number",
401
+ get: (material, index, payload) => _GetMaterial(material, index, payload).emissiveIntensity,
402
+ getTarget: _GetMaterial,
403
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).emissiveIntensity = value),
404
+ },
405
+ },
406
+ KHR_materials_ior: {
407
+ ior: {
408
+ type: "number",
409
+ get: (material, index, payload) => _GetMaterial(material, index, payload).indexOfRefraction,
410
+ getTarget: _GetMaterial,
411
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).indexOfRefraction = value),
412
+ },
413
+ },
414
+ KHR_materials_iridescence: {
415
+ iridescenceFactor: {
416
+ type: "number",
417
+ get: (material, index, payload) => _GetMaterial(material, index, payload).iridescence.intensity,
418
+ getTarget: _GetMaterial,
419
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).iridescence.intensity = value),
420
+ },
421
+ iridescenceIor: {
422
+ type: "number",
423
+ get: (material, index, payload) => _GetMaterial(material, index, payload).iridescence.indexOfRefraction,
424
+ getTarget: _GetMaterial,
425
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).iridescence.indexOfRefraction = value),
426
+ },
427
+ iridescenceTexture: {
428
+ extensions: {
429
+ KHR_texture_transform: _GenerateTextureMap("iridescence", "texture"),
430
+ },
431
+ },
432
+ iridescenceThicknessMaximum: {
433
+ type: "number",
434
+ get: (material, index, payload) => _GetMaterial(material, index, payload).iridescence.maximumThickness,
435
+ getTarget: _GetMaterial,
436
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).iridescence.maximumThickness = value),
437
+ },
438
+ iridescenceThicknessMinimum: {
439
+ type: "number",
440
+ get: (material, index, payload) => _GetMaterial(material, index, payload).iridescence.minimumThickness,
441
+ getTarget: _GetMaterial,
442
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).iridescence.minimumThickness = value),
443
+ },
444
+ iridescenceThicknessTexture: {
445
+ extensions: {
446
+ KHR_texture_transform: _GenerateTextureMap("iridescence", "thicknessTexture"),
447
+ },
448
+ },
449
+ },
450
+ KHR_materials_sheen: {
451
+ sheenColorFactor: {
452
+ type: "Color3",
453
+ get: (material, index, payload) => _GetMaterial(material, index, payload).sheen.color,
454
+ getTarget: _GetMaterial,
455
+ set: (value, material, index, payload) => _GetMaterial(material, index, payload).sheen.color.copyFrom(value),
456
+ },
457
+ sheenColorTexture: {
458
+ extensions: {
459
+ KHR_texture_transform: _GenerateTextureMap("sheen", "texture"),
460
+ },
461
+ },
462
+ sheenRoughnessFactor: {
463
+ type: "number",
464
+ get: (material, index, payload) => _GetMaterial(material, index, payload).sheen.intensity,
465
+ getTarget: _GetMaterial,
466
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).sheen.intensity = value),
467
+ },
468
+ sheenRoughnessTexture: {
469
+ extensions: {
470
+ KHR_texture_transform: _GenerateTextureMap("sheen", "thicknessTexture"),
471
+ },
472
+ },
473
+ },
474
+ KHR_materials_specular: {
475
+ specularFactor: {
476
+ type: "number",
477
+ get: (material, index, payload) => _GetMaterial(material, index, payload).metallicF0Factor,
478
+ getTarget: _GetMaterial,
479
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).metallicF0Factor = value),
480
+ getPropertyName: [() => "metallicF0Factor"],
481
+ },
482
+ specularColorFactor: {
483
+ type: "Color3",
484
+ get: (material, index, payload) => _GetMaterial(material, index, payload).metallicReflectanceColor,
485
+ getTarget: _GetMaterial,
486
+ set: (value, material, index, payload) => _GetMaterial(material, index, payload).metallicReflectanceColor.copyFrom(value),
487
+ getPropertyName: [() => "metallicReflectanceColor"],
488
+ },
489
+ specularTexture: {
490
+ extensions: {
491
+ KHR_texture_transform: _GenerateTextureMap("metallicReflectanceTexture"),
492
+ },
493
+ },
494
+ specularColorTexture: {
495
+ extensions: {
496
+ KHR_texture_transform: _GenerateTextureMap("reflectanceTexture"),
497
+ },
498
+ },
499
+ },
500
+ KHR_materials_transmission: {
501
+ transmissionFactor: {
502
+ type: "number",
503
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.refractionIntensity,
504
+ getTarget: _GetMaterial,
505
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).subSurface.refractionIntensity = value),
506
+ getPropertyName: [() => "subSurface.refractionIntensity"],
507
+ },
508
+ transmissionTexture: {
509
+ extensions: {
510
+ KHR_texture_transform: _GenerateTextureMap("subSurface", "refractionIntensityTexture"),
511
+ },
512
+ },
513
+ },
514
+ KHR_materials_diffuse_transmission: {
515
+ diffuseTransmissionFactor: {
516
+ type: "number",
517
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.translucencyIntensity,
518
+ getTarget: _GetMaterial,
519
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).subSurface.translucencyIntensity = value),
520
+ },
521
+ diffuseTransmissionTexture: {
522
+ extensions: {
523
+ KHR_texture_transform: _GenerateTextureMap("subSurface", "translucencyIntensityTexture"),
524
+ },
525
+ },
526
+ diffuseTransmissionColorFactor: {
527
+ type: "Color3",
528
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.translucencyColor,
529
+ getTarget: _GetMaterial,
530
+ set: (value, material, index, payload) => value && _GetMaterial(material, index, payload).subSurface.translucencyColor?.copyFrom(value),
531
+ },
532
+ diffuseTransmissionColorTexture: {
533
+ extensions: {
534
+ KHR_texture_transform: _GenerateTextureMap("subSurface", "translucencyColorTexture"),
535
+ },
536
+ },
537
+ },
538
+ KHR_materials_volume: {
539
+ attenuationColor: {
540
+ type: "Color3",
541
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.tintColor,
542
+ getTarget: _GetMaterial,
543
+ set: (value, material, index, payload) => _GetMaterial(material, index, payload).subSurface.tintColor.copyFrom(value),
544
+ },
545
+ attenuationDistance: {
546
+ type: "number",
547
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.tintColorAtDistance,
548
+ getTarget: _GetMaterial,
549
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).subSurface.tintColorAtDistance = value),
550
+ },
551
+ thicknessFactor: {
552
+ type: "number",
553
+ get: (material, index, payload) => _GetMaterial(material, index, payload).subSurface.maximumThickness,
554
+ getTarget: _GetMaterial,
555
+ set: (value, material, index, payload) => (_GetMaterial(material, index, payload).subSurface.maximumThickness = value),
556
+ },
557
+ thicknessTexture: {
558
+ extensions: {
559
+ KHR_texture_transform: _GenerateTextureMap("subSurface", "thicknessTexture"),
560
+ },
561
+ },
562
+ },
563
+ },
564
+ },
565
+ };
566
+ const extensionsTree = {
567
+ KHR_lights_punctual: {
568
+ lights: {
569
+ length: {
570
+ type: "number",
571
+ get: (lights) => lights.length,
572
+ getTarget: (lights) => lights.map((light) => light._babylonLight),
573
+ getPropertyName: [(_lights) => "length"],
574
+ },
575
+ __array__: {
576
+ __target__: true,
577
+ color: {
578
+ type: "Color3",
579
+ get: (light) => light._babylonLight?.diffuse,
580
+ set: (value, light) => light._babylonLight?.diffuse.copyFrom(value),
581
+ getTarget: (light) => light._babylonLight,
582
+ getPropertyName: [(_light) => "diffuse"],
583
+ },
584
+ intensity: {
585
+ type: "number",
586
+ get: (light) => light._babylonLight?.intensity,
587
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.intensity = value) : undefined),
588
+ getTarget: (light) => light._babylonLight,
589
+ getPropertyName: [(_light) => "intensity"],
590
+ },
591
+ range: {
592
+ type: "number",
593
+ get: (light) => light._babylonLight?.range,
594
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.range = value) : undefined),
595
+ getTarget: (light) => light._babylonLight,
596
+ getPropertyName: [(_light) => "range"],
597
+ },
598
+ spot: {
599
+ innerConeAngle: {
600
+ type: "number",
601
+ get: (light) => light._babylonLight?.innerAngle,
602
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.innerAngle = value) : undefined),
603
+ getTarget: (light) => light._babylonLight,
604
+ getPropertyName: [(_light) => "innerConeAngle"],
605
+ },
606
+ outerConeAngle: {
607
+ type: "number",
608
+ get: (light) => light._babylonLight?.angle,
609
+ set: (value, light) => (light._babylonLight ? (light._babylonLight.angle = value) : undefined),
610
+ getTarget: (light) => light._babylonLight,
611
+ getPropertyName: [(_light) => "outerConeAngle"],
612
+ },
613
+ },
614
+ },
615
+ },
616
+ },
617
+ EXT_lights_ies: {
618
+ lights: {
619
+ length: {
620
+ type: "number",
621
+ get: (lights) => lights.length,
622
+ getTarget: (lights) => lights.map((light) => light._babylonLight),
623
+ getPropertyName: [(_lights) => "length"],
624
+ },
625
+ },
626
+ },
627
+ EXT_lights_image_based: {
628
+ lights: {
629
+ length: {
630
+ type: "number",
631
+ get: (lights) => lights.length,
632
+ getTarget: (lights) => lights.map((light) => light._babylonTexture),
633
+ getPropertyName: [(_lights) => "length"],
634
+ },
635
+ __array__: {
636
+ __target__: true,
637
+ intensity: {
638
+ type: "number",
639
+ get: (light) => light._babylonTexture?.level,
640
+ set: (value, light) => {
641
+ if (light._babylonTexture)
642
+ light._babylonTexture.level = value;
643
+ },
644
+ getTarget: (light) => light._babylonTexture,
645
+ },
646
+ rotation: {
647
+ type: "Quaternion",
648
+ get: (light) => light._babylonTexture && Quaternion.FromRotationMatrix(light._babylonTexture?.getReflectionTextureMatrix()),
649
+ set: (value, light) => {
650
+ if (!light._babylonTexture)
651
+ return;
652
+ // Invert the rotation so that positive rotation is counter-clockwise.
653
+ if (!light._babylonTexture.getScene()?.useRightHandedSystem) {
654
+ value = Quaternion.Inverse(value);
655
+ }
656
+ Matrix.FromQuaternionToRef(value, light._babylonTexture.getReflectionTextureMatrix());
657
+ },
658
+ getTarget: (light) => light._babylonTexture,
659
+ },
660
+ },
661
+ },
662
+ },
663
+ };
664
+ function _GetTexture(material, payload, textureType, textureInObject) {
665
+ const babylonMaterial = _GetMaterial(material, payload);
666
+ return textureInObject ? babylonMaterial[textureType][textureInObject] : babylonMaterial[textureType];
667
+ }
668
+ function _GetMaterial(material, _index, payload) {
669
+ return material._data?.[payload?.fillMode ?? Constants.MATERIAL_TriangleFillMode]?.babylonMaterial;
670
+ }
671
+ function _GenerateTextureMap(textureType, textureInObject) {
672
+ return {
673
+ offset: {
674
+ componentsCount: 2,
675
+ // assuming two independent values for u and v, and NOT a Vector2
676
+ type: "Vector2",
677
+ get: (material, _index, payload) => {
678
+ const texture = _GetTexture(material, payload, textureType, textureInObject);
679
+ return new Vector2(texture?.uOffset, texture?.vOffset);
680
+ },
681
+ getTarget: _GetMaterial,
682
+ set: (value, material, _index, payload) => {
683
+ const texture = _GetTexture(material, payload, textureType, textureInObject);
684
+ (texture.uOffset = value.x), (texture.vOffset = value.y);
685
+ },
686
+ getPropertyName: [() => `${textureType}.${textureInObject}.uOffset`, () => `${textureType}.${textureInObject}.vOffset`],
687
+ },
688
+ rotation: {
689
+ type: "number",
690
+ get: (material, _index, payload) => _GetTexture(material, payload, textureType, textureInObject)?.wAng,
691
+ getTarget: _GetMaterial,
692
+ set: (value, material, _index, payload) => (_GetTexture(material, payload, textureType, textureInObject).wAng = value),
693
+ getPropertyName: [() => `${textureType}.${textureInObject}.wAng`],
694
+ },
695
+ scale: {
696
+ componentsCount: 2,
697
+ type: "Vector2",
698
+ get: (material, _index, payload) => {
699
+ const texture = _GetTexture(material, payload, textureType, textureInObject);
700
+ return new Vector2(texture?.uScale, texture?.vScale);
701
+ },
702
+ getTarget: _GetMaterial,
703
+ set: (value, material, index, payload) => {
704
+ const texture = _GetTexture(material, payload, textureType, textureInObject);
705
+ (texture.uScale = value.x), (texture.vScale = value.y);
706
+ },
707
+ getPropertyName: [() => `${textureType}.${textureInObject}.uScale`, () => `${textureType}.${textureInObject}.vScale`],
708
+ },
709
+ };
710
+ }
711
+ const objectModelMapping = {
712
+ cameras: camerasTree,
713
+ nodes: nodesTree,
714
+ materials: materialsTree,
715
+ extensions: extensionsTree,
716
+ animations: animationsTree,
717
+ meshes: meshesTree,
718
+ };
719
+ /**
720
+ * get a path-to-object converter for the given glTF tree
721
+ * @param gltf the glTF tree to use
722
+ * @returns a path-to-object converter for the given glTF tree
723
+ */
724
+ export function GetPathToObjectConverter(gltf) {
725
+ return new GLTFPathToObjectConverter(gltf, objectModelMapping);
726
+ }
727
+ /**
728
+ * This function will return the object accessor for the given key in the object model
729
+ * If the key is not found, it will return undefined
730
+ * @param key the key to get the mapping for, for example /materials/\{\}/emissiveFactor
731
+ * @returns an object accessor for the given key, or undefined if the key is not found
732
+ */
733
+ export function GetMappingForKey(key) {
734
+ // replace every `{}` in key with __array__ to match the object model
735
+ const keyParts = key.split("/").map((part) => part.replace(/{}/g, "__array__"));
736
+ let current = objectModelMapping;
737
+ for (const part of keyParts) {
738
+ // make sure part is not empty
739
+ if (!part) {
740
+ continue;
741
+ }
742
+ current = current[part];
743
+ }
744
+ // validate that current is an object accessor
745
+ if (current && current.type && current.get) {
746
+ return current;
747
+ }
748
+ return undefined;
749
+ }
750
+ /**
751
+ * Set interpolation for a specific key in the object model
752
+ * @param key the key to set, for example /materials/\{\}/emissiveFactor
753
+ * @param interpolation the interpolation elements array
754
+ */
755
+ export function SetInterpolationForKey(key, interpolation) {
756
+ // replace every `{}` in key with __array__ to match the object model
757
+ const keyParts = key.split("/").map((part) => part.replace(/{}/g, "__array__"));
758
+ let current = objectModelMapping;
759
+ for (const part of keyParts) {
760
+ // make sure part is not empty
761
+ if (!part) {
762
+ continue;
763
+ }
764
+ current = current[part];
765
+ }
766
+ // validate that the current object is an object accessor
767
+ if (current && current.type && current.get) {
768
+ current.interpolation = interpolation;
769
+ }
770
+ }
771
+ /**
772
+ * This will ad a new object accessor in the object model at the given key.
773
+ * Note that this will NOT change the typescript types. To do that you will need to change the interface itself (extending it in the module that uses it)
774
+ * @param key the key to add the object accessor at. For example /cameras/\{\}/perspective/aspectRatio
775
+ * @param accessor the object accessor to add
776
+ */
777
+ export function AddObjectAccessorToKey(key, accessor) {
778
+ // replace every `{}` in key with __array__ to match the object model
779
+ const keyParts = key.split("/").map((part) => part.replace(/{}/g, "__array__"));
780
+ let current = objectModelMapping;
781
+ for (const part of keyParts) {
782
+ // make sure part is not empty
783
+ if (!part) {
784
+ continue;
785
+ }
786
+ if (!current[part]) {
787
+ if (part === "?") {
788
+ current.__ignoreObjectTree__ = true;
789
+ continue;
790
+ }
791
+ current[part] = {};
792
+ // if the part is __array__ then add the __target__ property
793
+ if (part === "__array__") {
794
+ current[part].__target__ = true;
795
+ }
796
+ }
797
+ current = current[part];
798
+ }
799
+ Object.assign(current, accessor);
800
+ }
801
+ //# sourceMappingURL=objectModelMapping.js.map