@babylonjs/loaders 9.31.0 → 9.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SPLAT/gaussianSplattingDownloadManager.d.ts +10 -9
- package/SPLAT/gaussianSplattingDownloadManager.js +64 -53
- package/SPLAT/gaussianSplattingDownloadManager.js.map +1 -1
- package/SPLAT/gaussianSplattingResidencyPages.d.ts +49 -0
- package/SPLAT/gaussianSplattingResidencyPages.js +93 -0
- package/SPLAT/gaussianSplattingResidencyPages.js.map +1 -0
- package/SPLAT/gaussianSplattingStream.d.ts +154 -15
- package/SPLAT/gaussianSplattingStream.js +407 -25
- package/SPLAT/gaussianSplattingStream.js.map +1 -1
- package/SPLAT/gaussianSplattingWorkBuffer.d.ts +3 -1
- package/SPLAT/gaussianSplattingWorkBuffer.js +51 -14
- package/SPLAT/gaussianSplattingWorkBuffer.js.map +1 -1
- package/SPLAT/gaussianSplattingWorkBufferShaders.d.ts +6 -6
- package/SPLAT/gaussianSplattingWorkBufferShaders.js +12 -6
- package/SPLAT/gaussianSplattingWorkBufferShaders.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js +24 -9
- package/glTF/2.0/Extensions/KHR_animation_pointer.data.pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.d.ts +6 -1
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js +66 -40
- package/glTF/2.0/Extensions/KHR_interactivity/declarationMapper.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.d.ts +26 -0
- package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.js +44 -0
- package/glTF/2.0/Extensions/KHR_interactivity/flowGraphDelayReferenceBlock.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/index.d.ts +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/index.js +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/index.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphExporter.js +7 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphExporter.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.d.ts +2 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js +75 -6
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphModel.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.d.ts +9 -0
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js +35 -5
- package/glTF/2.0/Extensions/KHR_interactivity/interactivityGraphParser.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity/pure.d.ts +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/pure.js +1 -0
- package/glTF/2.0/Extensions/KHR_interactivity/pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_interactivity.pure.js +27 -6
- package/glTF/2.0/Extensions/KHR_interactivity.pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js +2 -0
- package/glTF/2.0/Extensions/KHR_node_hoverability.pure.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_node_selectability.pure.js +11 -0
- package/glTF/2.0/Extensions/KHR_node_selectability.pure.js.map +1 -1
- package/glTF/2.0/Extensions/gltfAreaLightDimensions.d.ts +26 -0
- package/glTF/2.0/Extensions/gltfAreaLightDimensions.js +49 -0
- package/glTF/2.0/Extensions/gltfAreaLightDimensions.js.map +1 -0
- package/glTF/2.0/Extensions/gltfPathToObjectConverter.js +3 -0
- package/glTF/2.0/Extensions/gltfPathToObjectConverter.js.map +1 -1
- package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.d.ts +1 -1
- package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js +5 -2
- package/glTF/2.0/Extensions/interactivityAssetPathToObjectConverter.js.map +1 -1
- package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js +1 -2
- package/glTF/2.0/Extensions/interactivityRefPathToObjectConverter.js.map +1 -1
- package/glTF/2.0/Extensions/objectModelMapping.d.ts +16 -13
- package/glTF/2.0/Extensions/objectModelMapping.js +157 -108
- package/glTF/2.0/Extensions/objectModelMapping.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +2 -0
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/package.json +3 -3
|
@@ -5,6 +5,7 @@ import { Color4 } from "@babylonjs/core/Maths/math.color.pure.js";
|
|
|
5
5
|
import { SpotLight } from "@babylonjs/core/Lights/spotLight.pure.js";
|
|
6
6
|
import { FlowGraphInteger } from "@babylonjs/core/FlowGraph/CustomTypes/flowGraphInteger.pure.js";
|
|
7
7
|
import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter.js";
|
|
8
|
+
import { _GetAreaLightDimensions } from "./gltfAreaLightDimensions.js";
|
|
8
9
|
/**
|
|
9
10
|
* Builds an accessor for an array `length` pointer (e.g. `/nodes.length`, `/meshes/{}/primitives.length`).
|
|
10
11
|
*
|
|
@@ -19,6 +20,7 @@ import { GLTFPathToObjectConverter } from "./gltfPathToObjectConverter.js";
|
|
|
19
20
|
function _CreateLengthAccessor(getLength, getTarget) {
|
|
20
21
|
return {
|
|
21
22
|
type: "FlowGraphInteger" /* FlowGraphTypes.Integer */,
|
|
23
|
+
isReadOnly: true,
|
|
22
24
|
get: (target) => {
|
|
23
25
|
const length = getLength(target);
|
|
24
26
|
return length === undefined ? undefined : FlowGraphInteger.FromValue(length);
|
|
@@ -53,13 +55,12 @@ const nodesTree = {
|
|
|
53
55
|
getPropertyName: [() => "scaling"],
|
|
54
56
|
},
|
|
55
57
|
weights: {
|
|
56
|
-
//
|
|
57
|
-
// but accessible via the Babylon MorphTargetManager on the INode's meshes
|
|
58
|
+
// Weights may come from mesh defaults rather than an authored node property.
|
|
58
59
|
__passThroughTarget__: true,
|
|
59
60
|
length: _CreateLengthAccessor((node) => {
|
|
60
61
|
const found = _findNodeMorphTargets(node);
|
|
61
|
-
return found ? found.mtm.numTargets : node?.mesh !== undefined ? 0 : undefined;
|
|
62
|
-
}, (node) => node?._babylonTransformNode),
|
|
62
|
+
return found ? found.mtm.numTargets : node?.mesh !== undefined ? (node._morphTargetWeights?.length ?? 0) : undefined;
|
|
63
|
+
}, (node) => node?._babylonTransformNode ?? node?._morphTargetWeights),
|
|
63
64
|
__array__: {
|
|
64
65
|
__target__: true,
|
|
65
66
|
type: "number",
|
|
@@ -68,12 +69,20 @@ const nodesTree = {
|
|
|
68
69
|
if (found && index !== undefined && index >= 0 && index < found.mtm.numTargets) {
|
|
69
70
|
return _roundFloat32Artifact(found.mtm.getTarget(index).influence);
|
|
70
71
|
}
|
|
72
|
+
if (!found && index !== undefined) {
|
|
73
|
+
return node?._morphTargetWeights?.[index];
|
|
74
|
+
}
|
|
71
75
|
return undefined;
|
|
72
76
|
},
|
|
73
77
|
set: (value, node, index) => {
|
|
74
78
|
const numValue = typeof value === "number" ? value : typeof value?.value === "number" ? value.value : value;
|
|
75
79
|
const found = _findNodeMorphTargets(node);
|
|
76
|
-
|
|
80
|
+
const count = found?.mtm.numTargets ?? node?._morphTargetWeights?.length ?? 0;
|
|
81
|
+
if (index === undefined || index < 0 || index >= count) {
|
|
82
|
+
throw new Error("Morph target weight index is out of range.");
|
|
83
|
+
}
|
|
84
|
+
if (!found) {
|
|
85
|
+
node._morphTargetWeights[index] = numValue;
|
|
77
86
|
return;
|
|
78
87
|
}
|
|
79
88
|
// Fan out to every mesh that shares this morph target manager so
|
|
@@ -90,15 +99,15 @@ const nodesTree = {
|
|
|
90
99
|
if (found && index !== undefined && index >= 0 && index < found.mtm.numTargets) {
|
|
91
100
|
return found.mtm.getTarget(index);
|
|
92
101
|
}
|
|
93
|
-
return node?._babylonTransformNode;
|
|
102
|
+
return node?._babylonTransformNode ?? node?._morphTargetWeights;
|
|
94
103
|
},
|
|
95
|
-
getPropertyName: [() => "influence"],
|
|
104
|
+
getPropertyName: [(node, index) => (_findNodeMorphTargets(node) ? "influence" : String(index))],
|
|
96
105
|
},
|
|
97
106
|
type: "number[]",
|
|
98
107
|
get: (node) => {
|
|
99
108
|
const found = _findNodeMorphTargets(node);
|
|
100
109
|
if (!found) {
|
|
101
|
-
return [];
|
|
110
|
+
return node?._morphTargetWeights?.slice() ?? [];
|
|
102
111
|
}
|
|
103
112
|
const weights = [];
|
|
104
113
|
for (let i = 0; i < found.mtm.numTargets; i++) {
|
|
@@ -106,7 +115,7 @@ const nodesTree = {
|
|
|
106
115
|
}
|
|
107
116
|
return weights;
|
|
108
117
|
},
|
|
109
|
-
getTarget: (node) => node?._babylonTransformNode,
|
|
118
|
+
getTarget: (node) => node?._babylonTransformNode ?? node?._morphTargetWeights,
|
|
110
119
|
getPropertyName: [() => "influence"],
|
|
111
120
|
},
|
|
112
121
|
// readonly!
|
|
@@ -281,28 +290,28 @@ const camerasTree = {
|
|
|
281
290
|
orthographic: {
|
|
282
291
|
xmag: {
|
|
283
292
|
componentsCount: 2,
|
|
284
|
-
type: "
|
|
285
|
-
get: (camera) =>
|
|
293
|
+
type: "number",
|
|
294
|
+
get: (camera) => camera._babylonCamera?.orthoRight ?? 0,
|
|
286
295
|
set: (value, camera) => {
|
|
287
296
|
if (camera._babylonCamera) {
|
|
288
|
-
camera._babylonCamera.orthoLeft = value
|
|
289
|
-
camera._babylonCamera.orthoRight = value
|
|
297
|
+
camera._babylonCamera.orthoLeft = -value;
|
|
298
|
+
camera._babylonCamera.orthoRight = value;
|
|
290
299
|
}
|
|
291
300
|
},
|
|
292
|
-
getTarget: (camera) => camera,
|
|
301
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
293
302
|
getPropertyName: [() => "orthoLeft", () => "orthoRight"],
|
|
294
303
|
},
|
|
295
304
|
ymag: {
|
|
296
305
|
componentsCount: 2,
|
|
297
|
-
type: "
|
|
298
|
-
get: (camera) =>
|
|
306
|
+
type: "number",
|
|
307
|
+
get: (camera) => camera._babylonCamera?.orthoTop ?? 0,
|
|
299
308
|
set: (value, camera) => {
|
|
300
309
|
if (camera._babylonCamera) {
|
|
301
|
-
camera._babylonCamera.orthoBottom = value
|
|
302
|
-
camera._babylonCamera.orthoTop = value
|
|
310
|
+
camera._babylonCamera.orthoBottom = -value;
|
|
311
|
+
camera._babylonCamera.orthoTop = value;
|
|
303
312
|
}
|
|
304
313
|
},
|
|
305
|
-
getTarget: (camera) => camera,
|
|
314
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
306
315
|
getPropertyName: [() => "orthoBottom", () => "orthoTop"],
|
|
307
316
|
},
|
|
308
317
|
zfar: {
|
|
@@ -313,7 +322,7 @@ const camerasTree = {
|
|
|
313
322
|
camera._babylonCamera.maxZ = value;
|
|
314
323
|
}
|
|
315
324
|
},
|
|
316
|
-
getTarget: (camera) => camera,
|
|
325
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
317
326
|
getPropertyName: [() => "maxZ"],
|
|
318
327
|
},
|
|
319
328
|
znear: {
|
|
@@ -324,7 +333,7 @@ const camerasTree = {
|
|
|
324
333
|
camera._babylonCamera.minZ = value;
|
|
325
334
|
}
|
|
326
335
|
},
|
|
327
|
-
getTarget: (camera) => camera,
|
|
336
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
328
337
|
getPropertyName: [() => "minZ"],
|
|
329
338
|
},
|
|
330
339
|
},
|
|
@@ -332,7 +341,7 @@ const camerasTree = {
|
|
|
332
341
|
aspectRatio: {
|
|
333
342
|
type: "number",
|
|
334
343
|
get: (camera) => camera._babylonCamera?.getEngine().getAspectRatio(camera._babylonCamera),
|
|
335
|
-
getTarget: (camera) => camera,
|
|
344
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
336
345
|
getPropertyName: [() => "aspectRatio"],
|
|
337
346
|
isReadOnly: true, // might not be the case for glTF?
|
|
338
347
|
},
|
|
@@ -344,7 +353,7 @@ const camerasTree = {
|
|
|
344
353
|
camera._babylonCamera.fov = value;
|
|
345
354
|
}
|
|
346
355
|
},
|
|
347
|
-
getTarget: (camera) => camera,
|
|
356
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
348
357
|
getPropertyName: [() => "fov"],
|
|
349
358
|
},
|
|
350
359
|
zfar: {
|
|
@@ -355,7 +364,7 @@ const camerasTree = {
|
|
|
355
364
|
camera._babylonCamera.maxZ = value;
|
|
356
365
|
}
|
|
357
366
|
},
|
|
358
|
-
getTarget: (camera) => camera,
|
|
367
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
359
368
|
getPropertyName: [() => "maxZ"],
|
|
360
369
|
},
|
|
361
370
|
znear: {
|
|
@@ -366,44 +375,42 @@ const camerasTree = {
|
|
|
366
375
|
camera._babylonCamera.minZ = value;
|
|
367
376
|
}
|
|
368
377
|
},
|
|
369
|
-
getTarget: (camera) => camera,
|
|
378
|
+
getTarget: (camera) => camera._babylonCamera,
|
|
370
379
|
getPropertyName: [() => "minZ"],
|
|
371
380
|
},
|
|
372
381
|
},
|
|
373
382
|
},
|
|
374
383
|
};
|
|
375
384
|
const materialsTree = {
|
|
376
|
-
length: _CreateLengthAccessor((materials) => materials.length, (materials) => materials.map((material) => material
|
|
385
|
+
length: _CreateLengthAccessor((materials) => materials.length, (materials) => materials.map((material) => GetMaterial(material))),
|
|
377
386
|
__array__: {
|
|
378
387
|
__target__: true,
|
|
379
388
|
doubleSided: {
|
|
380
389
|
type: "boolean",
|
|
381
390
|
get: (material, index, payload) => !GetMaterial(material, index, payload)?.backFaceCulling,
|
|
382
|
-
set: (value,
|
|
383
|
-
const mat = GetMaterial(material, index, payload);
|
|
391
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
384
392
|
if (mat) {
|
|
385
393
|
mat.backFaceCulling = !value;
|
|
386
394
|
}
|
|
387
|
-
},
|
|
395
|
+
}),
|
|
388
396
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
389
397
|
getPropertyName: [() => "backFaceCulling"],
|
|
390
398
|
},
|
|
391
399
|
alphaCutoff: {
|
|
392
400
|
type: "number",
|
|
393
401
|
get: (material, index, payload) => GetMaterial(material, index, payload)?.alphaCutOff,
|
|
394
|
-
set: (value,
|
|
395
|
-
const mat = GetMaterial(material, index, payload);
|
|
402
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
396
403
|
if (mat) {
|
|
397
404
|
mat.alphaCutOff = value;
|
|
398
405
|
}
|
|
399
|
-
},
|
|
406
|
+
}),
|
|
400
407
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
401
408
|
getPropertyName: [() => "alphaCutOff"],
|
|
402
409
|
},
|
|
403
410
|
emissiveFactor: {
|
|
404
411
|
type: "Color3",
|
|
405
412
|
get: (material, index, payload) => GetMaterial(material, index, payload).emissiveColor,
|
|
406
|
-
set: (value,
|
|
413
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => mat.emissiveColor.copyFrom(value)),
|
|
407
414
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
408
415
|
getPropertyName: [() => "emissiveColor"],
|
|
409
416
|
},
|
|
@@ -416,14 +423,14 @@ const materialsTree = {
|
|
|
416
423
|
scale: {
|
|
417
424
|
type: "number",
|
|
418
425
|
get: (material, index, payload) => GetTexture(material, payload, "bumpTexture")?.level,
|
|
419
|
-
set: (value,
|
|
420
|
-
const texture =
|
|
426
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
427
|
+
const texture = _GetMaterialTexture(mat, "bumpTexture");
|
|
421
428
|
if (texture) {
|
|
422
429
|
texture.level = value;
|
|
423
430
|
}
|
|
424
|
-
},
|
|
431
|
+
}),
|
|
425
432
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
426
|
-
getPropertyName: [() => "level"],
|
|
433
|
+
getPropertyName: [() => "bumpTexture.level"],
|
|
427
434
|
},
|
|
428
435
|
extensions: {
|
|
429
436
|
KHR_texture_transform: GenerateTextureMap("bumpTexture"),
|
|
@@ -433,12 +440,11 @@ const materialsTree = {
|
|
|
433
440
|
strength: {
|
|
434
441
|
type: "number",
|
|
435
442
|
get: (material, index, payload) => GetMaterial(material, index, payload).ambientTextureStrength,
|
|
436
|
-
set: (value,
|
|
437
|
-
const mat = GetMaterial(material, index, payload);
|
|
443
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
438
444
|
if (mat) {
|
|
439
445
|
mat.ambientTextureStrength = value;
|
|
440
446
|
}
|
|
441
|
-
},
|
|
447
|
+
}),
|
|
442
448
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
443
449
|
getPropertyName: [() => "ambientTextureStrength"],
|
|
444
450
|
},
|
|
@@ -453,11 +459,10 @@ const materialsTree = {
|
|
|
453
459
|
const mat = GetMaterial(material, index, payload);
|
|
454
460
|
return Color4.FromColor3(mat.albedoColor, mat.alpha);
|
|
455
461
|
},
|
|
456
|
-
set: (value,
|
|
457
|
-
const mat = GetMaterial(material, index, payload);
|
|
462
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
458
463
|
mat.albedoColor.set(value.r, value.g, value.b);
|
|
459
464
|
mat.alpha = value.a;
|
|
460
|
-
},
|
|
465
|
+
}),
|
|
461
466
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
462
467
|
// This is correct on the animation level, but incorrect as a single property of a type Color4
|
|
463
468
|
getPropertyName: [() => "albedoColor", () => "alpha"],
|
|
@@ -470,24 +475,22 @@ const materialsTree = {
|
|
|
470
475
|
metallicFactor: {
|
|
471
476
|
type: "number",
|
|
472
477
|
get: (material, index, payload) => GetMaterial(material, index, payload).metallic,
|
|
473
|
-
set: (value,
|
|
474
|
-
const mat = GetMaterial(material, index, payload);
|
|
478
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
475
479
|
if (mat) {
|
|
476
480
|
mat.metallic = value;
|
|
477
481
|
}
|
|
478
|
-
},
|
|
482
|
+
}),
|
|
479
483
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
480
484
|
getPropertyName: [() => "metallic"],
|
|
481
485
|
},
|
|
482
486
|
roughnessFactor: {
|
|
483
487
|
type: "number",
|
|
484
488
|
get: (material, index, payload) => GetMaterial(material, index, payload).roughness,
|
|
485
|
-
set: (value,
|
|
486
|
-
const mat = GetMaterial(material, index, payload);
|
|
489
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
487
490
|
if (mat) {
|
|
488
491
|
mat.roughness = value;
|
|
489
492
|
}
|
|
490
|
-
},
|
|
493
|
+
}),
|
|
491
494
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
492
495
|
getPropertyName: [() => "roughness"],
|
|
493
496
|
},
|
|
@@ -502,24 +505,22 @@ const materialsTree = {
|
|
|
502
505
|
anisotropyStrength: {
|
|
503
506
|
type: "number",
|
|
504
507
|
get: (material, index, payload) => GetMaterial(material, index, payload)?.anisotropy?.intensity,
|
|
505
|
-
set: (value,
|
|
506
|
-
const mat = GetMaterial(material, index, payload);
|
|
508
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
507
509
|
if (mat) {
|
|
508
510
|
mat.anisotropy.intensity = value;
|
|
509
511
|
}
|
|
510
|
-
},
|
|
512
|
+
}),
|
|
511
513
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
512
514
|
getPropertyName: [() => "anisotropy.intensity"],
|
|
513
515
|
},
|
|
514
516
|
anisotropyRotation: {
|
|
515
517
|
type: "number",
|
|
516
518
|
get: (material, index, payload) => GetMaterial(material, index, payload)?.anisotropy?.angle,
|
|
517
|
-
set: (value,
|
|
518
|
-
const mat = GetMaterial(material, index, payload);
|
|
519
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
519
520
|
if (mat) {
|
|
520
521
|
mat.anisotropy.angle = value;
|
|
521
522
|
}
|
|
522
|
-
},
|
|
523
|
+
}),
|
|
523
524
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
524
525
|
getPropertyName: [() => "anisotropy.angle"],
|
|
525
526
|
},
|
|
@@ -533,18 +534,18 @@ const materialsTree = {
|
|
|
533
534
|
clearcoatFactor: {
|
|
534
535
|
type: "number",
|
|
535
536
|
get: (material, index, payload) => GetMaterial(material, index, payload).clearCoat.intensity,
|
|
536
|
-
set: (value,
|
|
537
|
-
|
|
538
|
-
},
|
|
537
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
538
|
+
mat.clearCoat.intensity = value;
|
|
539
|
+
}),
|
|
539
540
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
540
541
|
getPropertyName: [() => "clearCoat.intensity"],
|
|
541
542
|
},
|
|
542
543
|
clearcoatRoughnessFactor: {
|
|
543
544
|
type: "number",
|
|
544
545
|
get: (material, index, payload) => GetMaterial(material, index, payload).clearCoat.roughness,
|
|
545
|
-
set: (value,
|
|
546
|
-
|
|
547
|
-
},
|
|
546
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => {
|
|
547
|
+
mat.clearCoat.roughness = value;
|
|
548
|
+
}),
|
|
548
549
|
getTarget: (material, index, payload) => GetMaterial(material, index, payload),
|
|
549
550
|
getPropertyName: [() => "clearCoat.roughness"],
|
|
550
551
|
},
|
|
@@ -558,7 +559,7 @@ const materialsTree = {
|
|
|
558
559
|
type: "number",
|
|
559
560
|
get: (material, index, payload) => GetMaterial(material, index, payload).clearCoat.bumpTexture?.level,
|
|
560
561
|
getTarget: GetMaterial,
|
|
561
|
-
set: (value,
|
|
562
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.clearCoat.bumpTexture.level = value)),
|
|
562
563
|
},
|
|
563
564
|
extensions: {
|
|
564
565
|
KHR_texture_transform: GenerateTextureMap("clearCoat", "bumpTexture"),
|
|
@@ -575,7 +576,7 @@ const materialsTree = {
|
|
|
575
576
|
type: "number",
|
|
576
577
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.dispersion,
|
|
577
578
|
getTarget: GetMaterial,
|
|
578
|
-
set: (value,
|
|
579
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.subSurface.dispersion = value)),
|
|
579
580
|
},
|
|
580
581
|
},
|
|
581
582
|
KHR_materials_emissive_strength: {
|
|
@@ -583,7 +584,7 @@ const materialsTree = {
|
|
|
583
584
|
type: "number",
|
|
584
585
|
get: (material, index, payload) => GetMaterial(material, index, payload).emissiveIntensity,
|
|
585
586
|
getTarget: GetMaterial,
|
|
586
|
-
set: (value,
|
|
587
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.emissiveIntensity = value)),
|
|
587
588
|
},
|
|
588
589
|
},
|
|
589
590
|
KHR_materials_ior: {
|
|
@@ -591,7 +592,7 @@ const materialsTree = {
|
|
|
591
592
|
type: "number",
|
|
592
593
|
get: (material, index, payload) => GetMaterial(material, index, payload).indexOfRefraction,
|
|
593
594
|
getTarget: GetMaterial,
|
|
594
|
-
set: (value,
|
|
595
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.indexOfRefraction = value)),
|
|
595
596
|
},
|
|
596
597
|
},
|
|
597
598
|
KHR_materials_iridescence: {
|
|
@@ -599,13 +600,13 @@ const materialsTree = {
|
|
|
599
600
|
type: "number",
|
|
600
601
|
get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.intensity,
|
|
601
602
|
getTarget: GetMaterial,
|
|
602
|
-
set: (value,
|
|
603
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.iridescence.intensity = value)),
|
|
603
604
|
},
|
|
604
605
|
iridescenceIor: {
|
|
605
606
|
type: "number",
|
|
606
607
|
get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.indexOfRefraction,
|
|
607
608
|
getTarget: GetMaterial,
|
|
608
|
-
set: (value,
|
|
609
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.iridescence.indexOfRefraction = value)),
|
|
609
610
|
},
|
|
610
611
|
iridescenceTexture: {
|
|
611
612
|
extensions: {
|
|
@@ -616,13 +617,13 @@ const materialsTree = {
|
|
|
616
617
|
type: "number",
|
|
617
618
|
get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.maximumThickness,
|
|
618
619
|
getTarget: GetMaterial,
|
|
619
|
-
set: (value,
|
|
620
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.iridescence.maximumThickness = value)),
|
|
620
621
|
},
|
|
621
622
|
iridescenceThicknessMinimum: {
|
|
622
623
|
type: "number",
|
|
623
624
|
get: (material, index, payload) => GetMaterial(material, index, payload).iridescence.minimumThickness,
|
|
624
625
|
getTarget: GetMaterial,
|
|
625
|
-
set: (value,
|
|
626
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.iridescence.minimumThickness = value)),
|
|
626
627
|
},
|
|
627
628
|
iridescenceThicknessTexture: {
|
|
628
629
|
extensions: {
|
|
@@ -635,7 +636,7 @@ const materialsTree = {
|
|
|
635
636
|
type: "Color3",
|
|
636
637
|
get: (material, index, payload) => GetMaterial(material, index, payload).sheen.color,
|
|
637
638
|
getTarget: GetMaterial,
|
|
638
|
-
set: (value,
|
|
639
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => mat.sheen.color.copyFrom(value)),
|
|
639
640
|
},
|
|
640
641
|
sheenColorTexture: {
|
|
641
642
|
extensions: {
|
|
@@ -644,9 +645,10 @@ const materialsTree = {
|
|
|
644
645
|
},
|
|
645
646
|
sheenRoughnessFactor: {
|
|
646
647
|
type: "number",
|
|
647
|
-
get: (material, index, payload) => GetMaterial(material, index, payload).sheen.
|
|
648
|
+
get: (material, index, payload) => GetMaterial(material, index, payload).sheen.roughness ?? 0,
|
|
648
649
|
getTarget: GetMaterial,
|
|
649
|
-
set: (value,
|
|
650
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.sheen.roughness = value)),
|
|
651
|
+
getPropertyName: [() => "sheen.roughness"],
|
|
650
652
|
},
|
|
651
653
|
sheenRoughnessTexture: {
|
|
652
654
|
extensions: {
|
|
@@ -659,14 +661,14 @@ const materialsTree = {
|
|
|
659
661
|
type: "number",
|
|
660
662
|
get: (material, index, payload) => GetMaterial(material, index, payload).metallicF0Factor,
|
|
661
663
|
getTarget: GetMaterial,
|
|
662
|
-
set: (value,
|
|
664
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.metallicF0Factor = value)),
|
|
663
665
|
getPropertyName: [() => "metallicF0Factor"],
|
|
664
666
|
},
|
|
665
667
|
specularColorFactor: {
|
|
666
668
|
type: "Color3",
|
|
667
669
|
get: (material, index, payload) => GetMaterial(material, index, payload).metallicReflectanceColor,
|
|
668
670
|
getTarget: GetMaterial,
|
|
669
|
-
set: (value,
|
|
671
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => mat.metallicReflectanceColor.copyFrom(value)),
|
|
670
672
|
getPropertyName: [() => "metallicReflectanceColor"],
|
|
671
673
|
},
|
|
672
674
|
specularTexture: {
|
|
@@ -685,7 +687,7 @@ const materialsTree = {
|
|
|
685
687
|
type: "number",
|
|
686
688
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.refractionIntensity,
|
|
687
689
|
getTarget: GetMaterial,
|
|
688
|
-
set: (value,
|
|
690
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.subSurface.refractionIntensity = value)),
|
|
689
691
|
getPropertyName: [() => "subSurface.refractionIntensity"],
|
|
690
692
|
},
|
|
691
693
|
transmissionTexture: {
|
|
@@ -702,7 +704,7 @@ const materialsTree = {
|
|
|
702
704
|
type: "number",
|
|
703
705
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.translucencyIntensity,
|
|
704
706
|
getTarget: GetMaterial,
|
|
705
|
-
set: (value,
|
|
707
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.subSurface.translucencyIntensity = value)),
|
|
706
708
|
},
|
|
707
709
|
diffuseTransmissionTexture: {
|
|
708
710
|
extensions: {
|
|
@@ -716,7 +718,7 @@ const materialsTree = {
|
|
|
716
718
|
type: "Color3",
|
|
717
719
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.translucencyColor,
|
|
718
720
|
getTarget: GetMaterial,
|
|
719
|
-
set: (value,
|
|
721
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => value && mat.subSurface.translucencyColor?.copyFrom(value)),
|
|
720
722
|
},
|
|
721
723
|
diffuseTransmissionColorTexture: {
|
|
722
724
|
extensions: {
|
|
@@ -732,19 +734,19 @@ const materialsTree = {
|
|
|
732
734
|
type: "Color3",
|
|
733
735
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.tintColor,
|
|
734
736
|
getTarget: GetMaterial,
|
|
735
|
-
set: (value,
|
|
737
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => mat.subSurface.tintColor.copyFrom(value)),
|
|
736
738
|
},
|
|
737
739
|
attenuationDistance: {
|
|
738
740
|
type: "number",
|
|
739
741
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.tintColorAtDistance,
|
|
740
742
|
getTarget: GetMaterial,
|
|
741
|
-
set: (value,
|
|
743
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.subSurface.tintColorAtDistance = value)),
|
|
742
744
|
},
|
|
743
745
|
thicknessFactor: {
|
|
744
746
|
type: "number",
|
|
745
747
|
get: (material, index, payload) => GetMaterial(material, index, payload).subSurface.maximumThickness,
|
|
746
748
|
getTarget: GetMaterial,
|
|
747
|
-
set: (value,
|
|
749
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, mat) => (mat.subSurface.maximumThickness = value)),
|
|
748
750
|
},
|
|
749
751
|
thicknessTexture: {
|
|
750
752
|
extensions: {
|
|
@@ -785,17 +787,17 @@ const extensionsTree = {
|
|
|
785
787
|
spot: {
|
|
786
788
|
innerConeAngle: {
|
|
787
789
|
type: "number",
|
|
788
|
-
get: (light) => light._babylonLight?.innerAngle,
|
|
789
|
-
set: (value, light) => (light._babylonLight ? (light._babylonLight.innerAngle = value) : undefined),
|
|
790
|
+
get: (light) => light._babylonLight?.innerAngle / 2,
|
|
791
|
+
set: (value, light) => (light._babylonLight ? (light._babylonLight.innerAngle = value * 2) : undefined),
|
|
790
792
|
getTarget: (light) => light._babylonLight,
|
|
791
|
-
getPropertyName: [(
|
|
793
|
+
getPropertyName: [() => "innerAngle"],
|
|
792
794
|
},
|
|
793
795
|
outerConeAngle: {
|
|
794
796
|
type: "number",
|
|
795
|
-
get: (light) => light._babylonLight?.angle,
|
|
796
|
-
set: (value, light) => (light._babylonLight ? (light._babylonLight.angle = value) : undefined),
|
|
797
|
+
get: (light) => light._babylonLight?.angle / 2,
|
|
798
|
+
set: (value, light) => (light._babylonLight ? (light._babylonLight.angle = value * 2) : undefined),
|
|
797
799
|
getTarget: (light) => light._babylonLight,
|
|
798
|
-
getPropertyName: [(
|
|
800
|
+
getPropertyName: [() => "angle"],
|
|
799
801
|
},
|
|
800
802
|
},
|
|
801
803
|
},
|
|
@@ -822,18 +824,28 @@ const extensionsTree = {
|
|
|
822
824
|
},
|
|
823
825
|
size: {
|
|
824
826
|
type: "number",
|
|
825
|
-
get: (light) => light
|
|
826
|
-
set: (value, light) =>
|
|
827
|
-
|
|
828
|
-
|
|
827
|
+
get: (light) => _GetAreaLightDimensions(light)?.size,
|
|
828
|
+
set: (value, light) => {
|
|
829
|
+
const target = _GetAreaLightDimensions(light);
|
|
830
|
+
if (target) {
|
|
831
|
+
target.size = value;
|
|
832
|
+
}
|
|
833
|
+
},
|
|
834
|
+
getTarget: _GetAreaLightDimensions,
|
|
835
|
+
getPropertyName: [() => "size"],
|
|
829
836
|
},
|
|
830
837
|
rect: {
|
|
831
838
|
aspect: {
|
|
832
839
|
type: "number",
|
|
833
|
-
get: (light) => light
|
|
834
|
-
set: (value, light) =>
|
|
835
|
-
|
|
836
|
-
|
|
840
|
+
get: (light) => _GetAreaLightDimensions(light)?.aspect,
|
|
841
|
+
set: (value, light) => {
|
|
842
|
+
const target = _GetAreaLightDimensions(light);
|
|
843
|
+
if (target) {
|
|
844
|
+
target.aspect = value;
|
|
845
|
+
}
|
|
846
|
+
},
|
|
847
|
+
getTarget: _GetAreaLightDimensions,
|
|
848
|
+
getPropertyName: [() => "aspect"],
|
|
837
849
|
},
|
|
838
850
|
},
|
|
839
851
|
},
|
|
@@ -879,11 +891,37 @@ const extensionsTree = {
|
|
|
879
891
|
},
|
|
880
892
|
};
|
|
881
893
|
function GetTexture(material, payload, textureType, textureInObject) {
|
|
882
|
-
|
|
883
|
-
|
|
894
|
+
return _GetMaterialTexture(GetMaterial(material, undefined, payload), textureType, textureInObject);
|
|
895
|
+
}
|
|
896
|
+
function _GetMaterialTexture(material, textureType, textureInObject) {
|
|
897
|
+
return textureInObject ? material[textureType][textureInObject] : material[textureType];
|
|
884
898
|
}
|
|
885
899
|
function GetMaterial(material, _index, payload) {
|
|
886
|
-
|
|
900
|
+
let target = material._data?.[payload?.fillMode ?? Constants.MATERIAL_TriangleFillMode]?.babylonMaterial;
|
|
901
|
+
if (!target && payload?.fillMode === undefined) {
|
|
902
|
+
for (const fillMode in material._data) {
|
|
903
|
+
target = material._data[Number(fillMode)].babylonMaterial;
|
|
904
|
+
break;
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return target;
|
|
908
|
+
}
|
|
909
|
+
function _CreateMaterialSetter(setValue) {
|
|
910
|
+
return (value, material, index, payload) => {
|
|
911
|
+
if (payload?.fillMode !== undefined) {
|
|
912
|
+
setValue(value, GetMaterial(material, index, payload), material);
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
let found = false;
|
|
916
|
+
for (const fillMode in material._data) {
|
|
917
|
+
found = true;
|
|
918
|
+
setValue(value, material._data[Number(fillMode)].babylonMaterial, material);
|
|
919
|
+
}
|
|
920
|
+
if (!found) {
|
|
921
|
+
// Preserve each accessor's existing handling of unloaded materials.
|
|
922
|
+
setValue(value, GetMaterial(material, index, payload), material);
|
|
923
|
+
}
|
|
924
|
+
};
|
|
887
925
|
}
|
|
888
926
|
function _getNodeMorphTargetManager(node) {
|
|
889
927
|
const tn = node?._babylonTransformNode;
|
|
@@ -1056,8 +1094,8 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1056
1094
|
return new Vector2(0, 0);
|
|
1057
1095
|
},
|
|
1058
1096
|
getTarget: GetMaterial,
|
|
1059
|
-
set: (value,
|
|
1060
|
-
const texture =
|
|
1097
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, target, material) => {
|
|
1098
|
+
const texture = _GetMaterialTexture(target, textureType, textureInObject);
|
|
1061
1099
|
if (texture) {
|
|
1062
1100
|
texture.uOffset = value.x;
|
|
1063
1101
|
texture.vOffset = value.y;
|
|
@@ -1068,7 +1106,7 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1068
1106
|
xform.offset = [value.x, value.y];
|
|
1069
1107
|
}
|
|
1070
1108
|
}
|
|
1071
|
-
},
|
|
1109
|
+
}),
|
|
1072
1110
|
getPropertyName: [
|
|
1073
1111
|
() => `${textureType}${textureInObject ? "." + textureInObject : ""}.uOffset`,
|
|
1074
1112
|
() => `${textureType}${textureInObject ? "." + textureInObject : ""}.vOffset`,
|
|
@@ -1079,7 +1117,7 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1079
1117
|
get: (material, _index, payload) => {
|
|
1080
1118
|
const texture = GetTexture(material, payload, textureType, textureInObject);
|
|
1081
1119
|
if (texture) {
|
|
1082
|
-
return texture.wAng;
|
|
1120
|
+
return -texture.wAng;
|
|
1083
1121
|
}
|
|
1084
1122
|
if (gltfPath) {
|
|
1085
1123
|
const xform = _gltfTextureTransform(material, gltfPath, false);
|
|
@@ -1088,10 +1126,10 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1088
1126
|
return 0;
|
|
1089
1127
|
},
|
|
1090
1128
|
getTarget: GetMaterial,
|
|
1091
|
-
set: (value,
|
|
1092
|
-
const texture =
|
|
1129
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, target, material) => {
|
|
1130
|
+
const texture = _GetMaterialTexture(target, textureType, textureInObject);
|
|
1093
1131
|
if (texture) {
|
|
1094
|
-
texture.wAng = value;
|
|
1132
|
+
texture.wAng = -value;
|
|
1095
1133
|
}
|
|
1096
1134
|
if (gltfPath) {
|
|
1097
1135
|
const xform = _gltfTextureTransform(material, gltfPath, true);
|
|
@@ -1099,7 +1137,7 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1099
1137
|
xform.rotation = value;
|
|
1100
1138
|
}
|
|
1101
1139
|
}
|
|
1102
|
-
},
|
|
1140
|
+
}),
|
|
1103
1141
|
getPropertyName: [() => `${textureType}${textureInObject ? "." + textureInObject : ""}.wAng`],
|
|
1104
1142
|
},
|
|
1105
1143
|
scale: {
|
|
@@ -1118,8 +1156,8 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1118
1156
|
return new Vector2(1, 1);
|
|
1119
1157
|
},
|
|
1120
1158
|
getTarget: GetMaterial,
|
|
1121
|
-
set: (value,
|
|
1122
|
-
const texture =
|
|
1159
|
+
set: /*#__PURE__*/ _CreateMaterialSetter((value, target, material) => {
|
|
1160
|
+
const texture = _GetMaterialTexture(target, textureType, textureInObject);
|
|
1123
1161
|
if (texture) {
|
|
1124
1162
|
texture.uScale = value.x;
|
|
1125
1163
|
texture.vScale = value.y;
|
|
@@ -1130,7 +1168,7 @@ function GenerateTextureMap(textureType, textureInObject, gltfPath) {
|
|
|
1130
1168
|
xform.scale = [value.x, value.y];
|
|
1131
1169
|
}
|
|
1132
1170
|
}
|
|
1133
|
-
},
|
|
1171
|
+
}),
|
|
1134
1172
|
getPropertyName: [
|
|
1135
1173
|
() => `${textureType}${textureInObject ? "." + textureInObject : ""}.uScale`,
|
|
1136
1174
|
() => `${textureType}${textureInObject ? "." + textureInObject : ""}.vScale`,
|
|
@@ -1231,6 +1269,17 @@ function _cloneObjectModelMapping(value) {
|
|
|
1231
1269
|
* @returns a path-to-object converter for the given glTF tree
|
|
1232
1270
|
*/
|
|
1233
1271
|
export function GetPathToObjectConverter(gltf, configure) {
|
|
1272
|
+
// Off-scene nodes have no Babylon meshes, but their weights remain part of the object model.
|
|
1273
|
+
for (const node of gltf?.nodes ?? []) {
|
|
1274
|
+
if (node._babylonTransformNode || node.mesh === undefined || node._morphTargetWeights) {
|
|
1275
|
+
continue;
|
|
1276
|
+
}
|
|
1277
|
+
const mesh = gltf.meshes?.[node.mesh];
|
|
1278
|
+
if (mesh) {
|
|
1279
|
+
const count = mesh.primitives[0]?.targets?.length ?? 0;
|
|
1280
|
+
node._morphTargetWeights = Array.from({ length: count }, (_, index) => node.weights?.[index] ?? mesh.weights?.[index] ?? 0);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1234
1283
|
if (!configure) {
|
|
1235
1284
|
return new GLTFPathToObjectConverter(gltf, objectModelMapping);
|
|
1236
1285
|
}
|