@liveroom-tech/react-immersive 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -59
- package/dist/index.d.mts +44 -6
- package/dist/index.d.ts +44 -6
- package/dist/index.js +390 -324
- package/dist/index.mjs +398 -334
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52,9 +52,11 @@ __export(index_exports, {
|
|
|
52
52
|
MATERIAL_SIDES: () => MATERIAL_SIDES,
|
|
53
53
|
ModelViewer: () => ModelViewer,
|
|
54
54
|
SimpleModelViewer: () => SimpleModelViewer,
|
|
55
|
+
material: () => material,
|
|
56
|
+
patchBindings: () => patchBindings,
|
|
55
57
|
useObjectBinding: () => useObjectBinding,
|
|
56
58
|
useObjectBindingIds: () => useObjectBindingIds,
|
|
57
|
-
|
|
59
|
+
useObjectBindings: () => useObjectBindings,
|
|
58
60
|
useShareableViewerState: () => useShareableViewerState,
|
|
59
61
|
useViewerActions: () => useViewerActions,
|
|
60
62
|
useViewerAnimations: () => useViewerAnimations,
|
|
@@ -433,9 +435,9 @@ function addTriangleEdges(edges, triangle, indexed) {
|
|
|
433
435
|
addEdge(edges, triangle[1], triangle[2], indexed);
|
|
434
436
|
addEdge(edges, triangle[2], triangle[0], indexed);
|
|
435
437
|
}
|
|
436
|
-
function materialForIndex(
|
|
437
|
-
if (!Array.isArray(
|
|
438
|
-
return
|
|
438
|
+
function materialForIndex(material2, materialIndex) {
|
|
439
|
+
if (!Array.isArray(material2)) return material2;
|
|
440
|
+
return material2[materialIndex] ?? null;
|
|
439
441
|
}
|
|
440
442
|
function collectUvLayouts(scene) {
|
|
441
443
|
const layouts = /* @__PURE__ */ new Map();
|
|
@@ -454,16 +456,16 @@ function collectUvLayouts(scene) {
|
|
|
454
456
|
const groups = geometry.groups.length > 0 ? geometry.groups : [{ start: 0, count: elementCount, materialIndex: 0 }];
|
|
455
457
|
for (const group of groups) {
|
|
456
458
|
const materialIndex = group.materialIndex ?? 0;
|
|
457
|
-
const
|
|
458
|
-
if (!
|
|
459
|
-
let layout = layouts.get(
|
|
459
|
+
const material2 = materialForIndex(mesh.material, materialIndex);
|
|
460
|
+
if (!material2) continue;
|
|
461
|
+
let layout = layouts.get(material2.uuid);
|
|
460
462
|
if (!layout) {
|
|
461
463
|
unnamedMaterialIndex += 1;
|
|
462
464
|
layout = {
|
|
463
|
-
name:
|
|
465
|
+
name: material2.name || `Material ${unnamedMaterialIndex}`,
|
|
464
466
|
layers: /* @__PURE__ */ new Map()
|
|
465
467
|
};
|
|
466
|
-
layouts.set(
|
|
468
|
+
layouts.set(material2.uuid, layout);
|
|
467
469
|
}
|
|
468
470
|
let layer = layout.layers.get(mesh.uuid);
|
|
469
471
|
if (!layer) {
|
|
@@ -2362,14 +2364,14 @@ function resolveAnimationClips(clips) {
|
|
|
2362
2364
|
|
|
2363
2365
|
// src/components/model/materialUtils.ts
|
|
2364
2366
|
var import_three11 = require("three");
|
|
2365
|
-
function isMeshStandardMaterial(
|
|
2367
|
+
function isMeshStandardMaterial(material2) {
|
|
2366
2368
|
return Boolean(
|
|
2367
|
-
|
|
2369
|
+
material2 && typeof material2 === "object" && "clone" in material2 && "color" in material2 && "metalness" in material2 && "roughness" in material2
|
|
2368
2370
|
);
|
|
2369
2371
|
}
|
|
2370
|
-
function isMeshPhysicalMaterial(
|
|
2372
|
+
function isMeshPhysicalMaterial(material2) {
|
|
2371
2373
|
return Boolean(
|
|
2372
|
-
|
|
2374
|
+
material2 && typeof material2 === "object" && "isMeshPhysicalMaterial" in material2 && material2.isMeshPhysicalMaterial
|
|
2373
2375
|
);
|
|
2374
2376
|
}
|
|
2375
2377
|
function isMeshNode(object) {
|
|
@@ -2405,8 +2407,8 @@ var SRGB_TEXTURE_KEYS = /* @__PURE__ */ new Set([
|
|
|
2405
2407
|
function colorSpaceForTextureKey(key) {
|
|
2406
2408
|
return SRGB_TEXTURE_KEYS.has(key) ? import_three11.SRGBColorSpace : import_three11.NoColorSpace;
|
|
2407
2409
|
}
|
|
2408
|
-
function getMaterialTexturePath(
|
|
2409
|
-
return
|
|
2410
|
+
function getMaterialTexturePath(material2, key) {
|
|
2411
|
+
return material2?.[key]?.path;
|
|
2410
2412
|
}
|
|
2411
2413
|
function sideFromConfig(side) {
|
|
2412
2414
|
if (side === "back") return import_three11.BackSide;
|
|
@@ -2440,10 +2442,10 @@ function getClipLoopMode(clipConfig) {
|
|
|
2440
2442
|
|
|
2441
2443
|
// src/components/model/materialFactory.ts
|
|
2442
2444
|
var import_three12 = require("three");
|
|
2443
|
-
function toStandardMaterial(
|
|
2444
|
-
if (isMeshStandardMaterial(
|
|
2445
|
-
if (!
|
|
2446
|
-
const src =
|
|
2445
|
+
function toStandardMaterial(material2) {
|
|
2446
|
+
if (isMeshStandardMaterial(material2)) return material2;
|
|
2447
|
+
if (!material2 || typeof material2 !== "object") return null;
|
|
2448
|
+
const src = material2;
|
|
2447
2449
|
const std = new import_three12.MeshStandardMaterial();
|
|
2448
2450
|
if (typeof src.name === "string") std.name = src.name;
|
|
2449
2451
|
std.metalness = 0;
|
|
@@ -2624,69 +2626,69 @@ function snapshotBaseMaterial(cloned) {
|
|
|
2624
2626
|
|
|
2625
2627
|
// src/components/model/applyMaterialConfig.ts
|
|
2626
2628
|
var import_three13 = require("three");
|
|
2627
|
-
function applyMaterialConfig(
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
toSafeVector2(
|
|
2629
|
+
function applyMaterialConfig(material2, configuredMaterial, resolvedBaseColor) {
|
|
2630
|
+
material2.map = material2.userData.baseMap ?? null;
|
|
2631
|
+
material2.color.copy(material2.userData.baseColor);
|
|
2632
|
+
material2.metalness = material2.userData.baseMetalness ?? material2.metalness;
|
|
2633
|
+
material2.metalnessMap = material2.userData.baseMetalnessMap ?? null;
|
|
2634
|
+
material2.roughness = material2.userData.baseRoughness ?? material2.roughness;
|
|
2635
|
+
material2.roughnessMap = material2.userData.baseRoughnessMap ?? null;
|
|
2636
|
+
material2.emissive.copy(material2.userData.baseEmissive ?? new import_three13.Color(0, 0, 0));
|
|
2637
|
+
material2.emissiveIntensity = material2.userData.baseEmissiveIntensity ?? material2.emissiveIntensity;
|
|
2638
|
+
material2.emissiveMap = material2.userData.baseEmissiveMap ?? null;
|
|
2639
|
+
material2.opacity = material2.userData.baseOpacity ?? 1;
|
|
2640
|
+
material2.transparent = material2.userData.baseTransparent ?? false;
|
|
2641
|
+
material2.alphaMap = material2.userData.baseAlphaMap ?? null;
|
|
2642
|
+
material2.alphaTest = material2.userData.baseAlphaTest ?? 0;
|
|
2643
|
+
material2.alphaHash = material2.userData.baseAlphaHash ?? false;
|
|
2644
|
+
material2.dithering = material2.userData.baseDithering ?? false;
|
|
2645
|
+
material2.blending = material2.userData.baseBlending ?? import_three13.NormalBlending;
|
|
2646
|
+
material2.depthWrite = material2.userData.baseDepthWrite ?? true;
|
|
2647
|
+
material2.side = material2.userData.baseSide ?? import_three13.FrontSide;
|
|
2648
|
+
material2.normalMap = material2.userData.baseNormalMap ?? null;
|
|
2649
|
+
material2.normalScale.copy(toSafeVector2(material2.userData.baseNormalScale));
|
|
2650
|
+
material2.bumpMap = material2.userData.baseBumpMap ?? null;
|
|
2651
|
+
material2.bumpScale = material2.userData.baseBumpScale ?? material2.bumpScale;
|
|
2652
|
+
material2.aoMap = material2.userData.baseAoMap ?? null;
|
|
2653
|
+
material2.aoMapIntensity = material2.userData.baseAoMapIntensity ?? material2.aoMapIntensity;
|
|
2654
|
+
material2.displacementMap = material2.userData.baseDisplacementMap ?? null;
|
|
2655
|
+
material2.displacementScale = material2.userData.baseDisplacementScale ?? material2.displacementScale;
|
|
2656
|
+
material2.displacementBias = material2.userData.baseDisplacementBias ?? material2.displacementBias;
|
|
2657
|
+
material2.clearcoat = material2.userData.baseClearcoat ?? material2.clearcoat;
|
|
2658
|
+
material2.clearcoatMap = material2.userData.baseClearcoatMap ?? null;
|
|
2659
|
+
material2.clearcoatRoughness = material2.userData.baseClearcoatRoughness ?? material2.clearcoatRoughness;
|
|
2660
|
+
material2.clearcoatRoughnessMap = material2.userData.baseClearcoatRoughnessMap ?? null;
|
|
2661
|
+
material2.clearcoatNormalMap = material2.userData.baseClearcoatNormalMap ?? null;
|
|
2662
|
+
material2.clearcoatNormalScale.copy(
|
|
2663
|
+
toSafeVector2(material2.userData.baseClearcoatNormalScale)
|
|
2662
2664
|
);
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2665
|
+
material2.sheen = material2.userData.baseSheen ?? material2.sheen;
|
|
2666
|
+
material2.sheenColor.copy(
|
|
2667
|
+
material2.userData.baseSheenColor ?? new import_three13.Color(0, 0, 0)
|
|
2666
2668
|
);
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2669
|
+
material2.sheenColorMap = material2.userData.baseSheenColorMap ?? null;
|
|
2670
|
+
material2.sheenRoughness = material2.userData.baseSheenRoughness ?? material2.sheenRoughness;
|
|
2671
|
+
material2.sheenRoughnessMap = material2.userData.baseSheenRoughnessMap ?? null;
|
|
2672
|
+
material2.anisotropy = material2.userData.baseAnisotropy ?? material2.anisotropy;
|
|
2673
|
+
material2.anisotropyRotation = material2.userData.baseAnisotropyRotation ?? material2.anisotropyRotation;
|
|
2674
|
+
material2.anisotropyMap = material2.userData.baseAnisotropyMap ?? null;
|
|
2675
|
+
material2.transmission = material2.userData.baseTransmission ?? material2.transmission;
|
|
2676
|
+
material2.transmissionMap = material2.userData.baseTransmissionMap ?? null;
|
|
2677
|
+
material2.thickness = material2.userData.baseThickness ?? material2.thickness;
|
|
2678
|
+
material2.thicknessMap = material2.userData.baseThicknessMap ?? null;
|
|
2679
|
+
material2.attenuationColor.copy(
|
|
2680
|
+
material2.userData.baseAttenuationColor ?? new import_three13.Color("#ffffff")
|
|
2679
2681
|
);
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2682
|
+
material2.attenuationDistance = material2.userData.baseAttenuationDistance ?? material2.attenuationDistance;
|
|
2683
|
+
material2.reflectivity = material2.userData.baseReflectivity ?? material2.reflectivity;
|
|
2684
|
+
material2.specularIntensity = material2.userData.baseSpecularIntensity ?? material2.specularIntensity;
|
|
2685
|
+
material2.specularIntensityMap = material2.userData.baseSpecularIntensityMap ?? null;
|
|
2686
|
+
material2.specularColor.copy(
|
|
2687
|
+
material2.userData.baseSpecularColor ?? new import_three13.Color("#ffffff")
|
|
2686
2688
|
);
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2689
|
+
material2.specularColorMap = material2.userData.baseSpecularColorMap ?? null;
|
|
2690
|
+
material2.flatShading = material2.userData.baseFlatShading ?? material2.flatShading;
|
|
2691
|
+
material2.envMapIntensity = material2.userData.baseEnvMapIntensity ?? material2.envMapIntensity;
|
|
2690
2692
|
const texturePath = getMaterialTexturePath(configuredMaterial, "texture");
|
|
2691
2693
|
const metalnessMapPath = getMaterialTexturePath(
|
|
2692
2694
|
configuredMaterial,
|
|
@@ -2749,180 +2751,180 @@ function applyMaterialConfig(material, configuredMaterial, resolvedBaseColor) {
|
|
|
2749
2751
|
"specularColorMap"
|
|
2750
2752
|
);
|
|
2751
2753
|
if (texturePath) {
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
+
material2.map = getOrCreateTexture(texturePath, import_three13.SRGBColorSpace);
|
|
2755
|
+
material2.color.set(resolvedBaseColor ?? "#ffffff");
|
|
2754
2756
|
} else if (resolvedBaseColor) {
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
+
material2.map = null;
|
|
2758
|
+
material2.color.set(resolvedBaseColor);
|
|
2757
2759
|
}
|
|
2758
2760
|
if (metalnessMapPath) {
|
|
2759
|
-
|
|
2761
|
+
material2.metalnessMap = getOrCreateTexture(metalnessMapPath);
|
|
2760
2762
|
}
|
|
2761
2763
|
if (configuredMaterial?.metalness !== void 0) {
|
|
2762
|
-
|
|
2764
|
+
material2.metalness = configuredMaterial.metalness;
|
|
2763
2765
|
}
|
|
2764
2766
|
if (roughnessMapPath) {
|
|
2765
|
-
|
|
2767
|
+
material2.roughnessMap = getOrCreateTexture(roughnessMapPath);
|
|
2766
2768
|
}
|
|
2767
2769
|
if (configuredMaterial?.roughness !== void 0) {
|
|
2768
|
-
|
|
2770
|
+
material2.roughness = configuredMaterial.roughness;
|
|
2769
2771
|
}
|
|
2770
2772
|
if (configuredMaterial?.emissive) {
|
|
2771
|
-
|
|
2773
|
+
material2.emissive.set(configuredMaterial.emissive);
|
|
2772
2774
|
} else if (emissiveMapPath) {
|
|
2773
|
-
|
|
2775
|
+
material2.emissive.set("#ffffff");
|
|
2774
2776
|
}
|
|
2775
2777
|
if (configuredMaterial?.emissiveIntensity !== void 0) {
|
|
2776
|
-
|
|
2778
|
+
material2.emissiveIntensity = configuredMaterial.emissiveIntensity;
|
|
2777
2779
|
}
|
|
2778
2780
|
if (emissiveMapPath) {
|
|
2779
|
-
|
|
2781
|
+
material2.emissiveMap = getOrCreateTexture(emissiveMapPath, import_three13.SRGBColorSpace);
|
|
2780
2782
|
}
|
|
2781
2783
|
if (configuredMaterial?.opacity !== void 0) {
|
|
2782
|
-
|
|
2784
|
+
material2.opacity = configuredMaterial.opacity;
|
|
2783
2785
|
}
|
|
2784
2786
|
if (alphaMapPath) {
|
|
2785
|
-
|
|
2787
|
+
material2.alphaMap = getOrCreateTexture(alphaMapPath);
|
|
2786
2788
|
}
|
|
2787
2789
|
if (configuredMaterial?.alphaTest !== void 0) {
|
|
2788
|
-
|
|
2790
|
+
material2.alphaTest = configuredMaterial.alphaTest;
|
|
2789
2791
|
}
|
|
2790
2792
|
if (configuredMaterial?.alphaHash !== void 0) {
|
|
2791
|
-
|
|
2793
|
+
material2.alphaHash = configuredMaterial.alphaHash;
|
|
2792
2794
|
}
|
|
2793
2795
|
if (configuredMaterial?.dithering !== void 0) {
|
|
2794
|
-
|
|
2796
|
+
material2.dithering = configuredMaterial.dithering;
|
|
2795
2797
|
}
|
|
2796
2798
|
if (configuredMaterial?.blendingMode) {
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
+
material2.blending = blendingFromConfig(configuredMaterial.blendingMode);
|
|
2800
|
+
material2.depthWrite = configuredMaterial.blendingMode !== "additive";
|
|
2799
2801
|
}
|
|
2800
2802
|
if (configuredMaterial?.side) {
|
|
2801
|
-
|
|
2803
|
+
material2.side = sideFromConfig(configuredMaterial.side);
|
|
2802
2804
|
}
|
|
2803
2805
|
if (normalMapPath) {
|
|
2804
|
-
|
|
2806
|
+
material2.normalMap = getOrCreateTexture(normalMapPath);
|
|
2805
2807
|
}
|
|
2806
2808
|
if (normalMapPath || configuredMaterial?.normalScale !== void 0) {
|
|
2807
|
-
const normalScale = configuredMaterial?.normalScale ?? Math.abs(toSafeVector2(
|
|
2808
|
-
|
|
2809
|
+
const normalScale = configuredMaterial?.normalScale ?? Math.abs(toSafeVector2(material2.userData.baseNormalScale).x);
|
|
2810
|
+
material2.normalScale.set(
|
|
2809
2811
|
normalScale,
|
|
2810
2812
|
configuredMaterial?.flipNormalY ? -normalScale : normalScale
|
|
2811
2813
|
);
|
|
2812
2814
|
}
|
|
2813
2815
|
if (bumpMapPath) {
|
|
2814
|
-
|
|
2816
|
+
material2.bumpMap = getOrCreateTexture(bumpMapPath);
|
|
2815
2817
|
}
|
|
2816
2818
|
if (configuredMaterial?.bumpScale !== void 0) {
|
|
2817
|
-
|
|
2819
|
+
material2.bumpScale = configuredMaterial.bumpScale;
|
|
2818
2820
|
}
|
|
2819
2821
|
if (aoMapPath) {
|
|
2820
|
-
|
|
2822
|
+
material2.aoMap = getOrCreateTexture(aoMapPath);
|
|
2821
2823
|
}
|
|
2822
2824
|
if (configuredMaterial?.aoMapIntensity !== void 0) {
|
|
2823
|
-
|
|
2825
|
+
material2.aoMapIntensity = configuredMaterial.aoMapIntensity;
|
|
2824
2826
|
}
|
|
2825
2827
|
if (displacementMapPath) {
|
|
2826
|
-
|
|
2828
|
+
material2.displacementMap = getOrCreateTexture(displacementMapPath);
|
|
2827
2829
|
}
|
|
2828
2830
|
if (configuredMaterial?.displacementScale !== void 0) {
|
|
2829
|
-
|
|
2831
|
+
material2.displacementScale = configuredMaterial.displacementScale;
|
|
2830
2832
|
}
|
|
2831
2833
|
if (configuredMaterial?.displacementBias !== void 0) {
|
|
2832
|
-
|
|
2834
|
+
material2.displacementBias = configuredMaterial.displacementBias;
|
|
2833
2835
|
}
|
|
2834
2836
|
if (clearcoatMapPath) {
|
|
2835
|
-
|
|
2837
|
+
material2.clearcoatMap = getOrCreateTexture(clearcoatMapPath);
|
|
2836
2838
|
}
|
|
2837
2839
|
if (configuredMaterial?.clearcoat !== void 0) {
|
|
2838
|
-
|
|
2840
|
+
material2.clearcoat = configuredMaterial.clearcoat;
|
|
2839
2841
|
}
|
|
2840
2842
|
if (clearcoatRoughnessMapPath) {
|
|
2841
|
-
|
|
2843
|
+
material2.clearcoatRoughnessMap = getOrCreateTexture(
|
|
2842
2844
|
clearcoatRoughnessMapPath
|
|
2843
2845
|
);
|
|
2844
2846
|
}
|
|
2845
2847
|
if (configuredMaterial?.clearcoatRoughness !== void 0) {
|
|
2846
|
-
|
|
2848
|
+
material2.clearcoatRoughness = configuredMaterial.clearcoatRoughness;
|
|
2847
2849
|
}
|
|
2848
2850
|
if (clearcoatNormalMapPath) {
|
|
2849
|
-
|
|
2851
|
+
material2.clearcoatNormalMap = getOrCreateTexture(clearcoatNormalMapPath);
|
|
2850
2852
|
}
|
|
2851
2853
|
if (clearcoatNormalMapPath || configuredMaterial?.clearcoatNormalScale !== void 0) {
|
|
2852
|
-
const clearcoatNormalScale = configuredMaterial?.clearcoatNormalScale ?? Math.abs(toSafeVector2(
|
|
2853
|
-
|
|
2854
|
+
const clearcoatNormalScale = configuredMaterial?.clearcoatNormalScale ?? Math.abs(toSafeVector2(material2.userData.baseClearcoatNormalScale).x);
|
|
2855
|
+
material2.clearcoatNormalScale.set(
|
|
2854
2856
|
clearcoatNormalScale,
|
|
2855
2857
|
configuredMaterial?.flipClearcoatNormalY ? -clearcoatNormalScale : clearcoatNormalScale
|
|
2856
2858
|
);
|
|
2857
2859
|
}
|
|
2858
2860
|
if (configuredMaterial?.sheen !== void 0) {
|
|
2859
|
-
|
|
2861
|
+
material2.sheen = configuredMaterial.sheen;
|
|
2860
2862
|
}
|
|
2861
2863
|
if (configuredMaterial?.sheenColor) {
|
|
2862
|
-
|
|
2864
|
+
material2.sheenColor.set(configuredMaterial.sheenColor);
|
|
2863
2865
|
}
|
|
2864
2866
|
if (sheenColorMapPath) {
|
|
2865
|
-
|
|
2867
|
+
material2.sheenColorMap = getOrCreateTexture(
|
|
2866
2868
|
sheenColorMapPath,
|
|
2867
2869
|
import_three13.SRGBColorSpace
|
|
2868
2870
|
);
|
|
2869
2871
|
}
|
|
2870
2872
|
if (configuredMaterial?.sheenRoughness !== void 0) {
|
|
2871
|
-
|
|
2873
|
+
material2.sheenRoughness = configuredMaterial.sheenRoughness;
|
|
2872
2874
|
}
|
|
2873
2875
|
if (sheenRoughnessMapPath) {
|
|
2874
|
-
|
|
2876
|
+
material2.sheenRoughnessMap = getOrCreateTexture(sheenRoughnessMapPath);
|
|
2875
2877
|
}
|
|
2876
2878
|
if (configuredMaterial?.anisotropy !== void 0) {
|
|
2877
|
-
|
|
2879
|
+
material2.anisotropy = configuredMaterial.anisotropy;
|
|
2878
2880
|
}
|
|
2879
2881
|
if (configuredMaterial?.anisotropyRotation !== void 0) {
|
|
2880
|
-
|
|
2882
|
+
material2.anisotropyRotation = configuredMaterial.anisotropyRotation;
|
|
2881
2883
|
}
|
|
2882
2884
|
if (anisotropyMapPath) {
|
|
2883
|
-
|
|
2885
|
+
material2.anisotropyMap = getOrCreateTexture(anisotropyMapPath);
|
|
2884
2886
|
}
|
|
2885
2887
|
if (configuredMaterial?.transmission !== void 0) {
|
|
2886
|
-
|
|
2888
|
+
material2.transmission = configuredMaterial.transmission;
|
|
2887
2889
|
}
|
|
2888
2890
|
if (transmissionMapPath) {
|
|
2889
|
-
|
|
2891
|
+
material2.transmissionMap = getOrCreateTexture(transmissionMapPath);
|
|
2890
2892
|
}
|
|
2891
2893
|
if (configuredMaterial?.thickness !== void 0) {
|
|
2892
|
-
|
|
2894
|
+
material2.thickness = configuredMaterial.thickness;
|
|
2893
2895
|
}
|
|
2894
2896
|
if (thicknessMapPath) {
|
|
2895
|
-
|
|
2897
|
+
material2.thicknessMap = getOrCreateTexture(thicknessMapPath);
|
|
2896
2898
|
}
|
|
2897
2899
|
if (configuredMaterial?.attenuationColor) {
|
|
2898
|
-
|
|
2900
|
+
material2.attenuationColor.set(configuredMaterial.attenuationColor);
|
|
2899
2901
|
}
|
|
2900
2902
|
if (configuredMaterial?.attenuationDistance !== void 0) {
|
|
2901
|
-
|
|
2903
|
+
material2.attenuationDistance = configuredMaterial.attenuationDistance;
|
|
2902
2904
|
}
|
|
2903
2905
|
if (configuredMaterial?.reflectivity !== void 0) {
|
|
2904
|
-
|
|
2906
|
+
material2.reflectivity = configuredMaterial.reflectivity;
|
|
2905
2907
|
}
|
|
2906
2908
|
if (configuredMaterial?.specularIntensity !== void 0) {
|
|
2907
|
-
|
|
2909
|
+
material2.specularIntensity = configuredMaterial.specularIntensity;
|
|
2908
2910
|
}
|
|
2909
2911
|
if (specularIntensityMapPath) {
|
|
2910
|
-
|
|
2912
|
+
material2.specularIntensityMap = getOrCreateTexture(
|
|
2911
2913
|
specularIntensityMapPath
|
|
2912
2914
|
);
|
|
2913
2915
|
}
|
|
2914
2916
|
if (configuredMaterial?.specularColor) {
|
|
2915
|
-
|
|
2917
|
+
material2.specularColor.set(configuredMaterial.specularColor);
|
|
2916
2918
|
}
|
|
2917
2919
|
if (specularColorMapPath) {
|
|
2918
|
-
|
|
2920
|
+
material2.specularColorMap = getOrCreateTexture(
|
|
2919
2921
|
specularColorMapPath,
|
|
2920
2922
|
import_three13.SRGBColorSpace
|
|
2921
2923
|
);
|
|
2922
2924
|
}
|
|
2923
|
-
|
|
2924
|
-
if (!
|
|
2925
|
-
|
|
2925
|
+
material2.transparent = material2.opacity < 1 || material2.transmission > 0 || material2.blending !== import_three13.NormalBlending || Boolean((alphaMapPath || material2.alphaMap) && material2.alphaTest <= 0);
|
|
2926
|
+
if (!material2.transparent) {
|
|
2927
|
+
material2.depthWrite = true;
|
|
2926
2928
|
}
|
|
2927
2929
|
}
|
|
2928
2930
|
|
|
@@ -3065,8 +3067,8 @@ function Model({
|
|
|
3065
3067
|
}, [perNodeMaterials, materialRefsOut]);
|
|
3066
3068
|
(0, import_react11.useEffect)(() => {
|
|
3067
3069
|
return () => {
|
|
3068
|
-
for (const
|
|
3069
|
-
|
|
3070
|
+
for (const material2 of Object.values(perNodeMaterials)) {
|
|
3071
|
+
material2.dispose();
|
|
3070
3072
|
}
|
|
3071
3073
|
};
|
|
3072
3074
|
}, [perNodeMaterials]);
|
|
@@ -3078,15 +3080,15 @@ function Model({
|
|
|
3078
3080
|
const perNodeBasicMaterials = (0, import_react11.useMemo)(() => {
|
|
3079
3081
|
const map = {};
|
|
3080
3082
|
if (shadingMode !== "unlit") return map;
|
|
3081
|
-
for (const [nodeName,
|
|
3083
|
+
for (const [nodeName, material2] of Object.entries(perNodeMaterials)) {
|
|
3082
3084
|
const basic = new import_three14.MeshBasicMaterial();
|
|
3083
|
-
basic.color.copy(
|
|
3084
|
-
basic.map =
|
|
3085
|
-
basic.alphaMap =
|
|
3086
|
-
basic.alphaTest =
|
|
3087
|
-
basic.transparent =
|
|
3088
|
-
basic.opacity =
|
|
3089
|
-
basic.side =
|
|
3085
|
+
basic.color.copy(material2.color);
|
|
3086
|
+
basic.map = material2.map;
|
|
3087
|
+
basic.alphaMap = material2.alphaMap;
|
|
3088
|
+
basic.alphaTest = material2.alphaTest;
|
|
3089
|
+
basic.transparent = material2.transparent;
|
|
3090
|
+
basic.opacity = material2.opacity;
|
|
3091
|
+
basic.side = material2.side;
|
|
3090
3092
|
map[nodeName] = basic;
|
|
3091
3093
|
}
|
|
3092
3094
|
return map;
|
|
@@ -3103,25 +3105,25 @@ function Model({
|
|
|
3103
3105
|
const map = {};
|
|
3104
3106
|
if (shadingMode !== "lit" || rendererMode !== "matcap") return map;
|
|
3105
3107
|
const matcapTexture = getMatcapTexture();
|
|
3106
|
-
for (const [nodeName,
|
|
3108
|
+
for (const [nodeName, material2] of Object.entries(perNodeMaterials)) {
|
|
3107
3109
|
const matcap = new import_three14.MeshMatcapMaterial();
|
|
3108
3110
|
matcap.matcap = matcapTexture;
|
|
3109
|
-
matcap.color.copy(
|
|
3110
|
-
matcap.alphaMap =
|
|
3111
|
-
matcap.alphaTest =
|
|
3112
|
-
matcap.side =
|
|
3111
|
+
matcap.color.copy(material2.color);
|
|
3112
|
+
matcap.alphaMap = material2.alphaMap;
|
|
3113
|
+
matcap.alphaTest = material2.alphaTest;
|
|
3114
|
+
matcap.side = material2.side;
|
|
3113
3115
|
map[nodeName] = matcap;
|
|
3114
3116
|
}
|
|
3115
3117
|
return map;
|
|
3116
3118
|
}, [perNodeMaterials, shadingMode, rendererMode]);
|
|
3117
3119
|
(0, import_react11.useEffect)(() => {
|
|
3118
3120
|
return () => {
|
|
3119
|
-
for (const
|
|
3120
|
-
|
|
3121
|
-
for (const
|
|
3122
|
-
|
|
3123
|
-
for (const
|
|
3124
|
-
|
|
3121
|
+
for (const material2 of Object.values(perNodeBasicMaterials))
|
|
3122
|
+
material2.dispose();
|
|
3123
|
+
for (const material2 of Object.values(perNodeNormalMaterials))
|
|
3124
|
+
material2.dispose();
|
|
3125
|
+
for (const material2 of Object.values(perNodeMatcapMaterials))
|
|
3126
|
+
material2.dispose();
|
|
3125
3127
|
};
|
|
3126
3128
|
}, [perNodeBasicMaterials, perNodeNormalMaterials, perNodeMatcapMaterials]);
|
|
3127
3129
|
const materialForNode = (nodeName) => {
|
|
@@ -3167,8 +3169,8 @@ function Model({
|
|
|
3167
3169
|
const node = nodeMap[glbNodeName];
|
|
3168
3170
|
if (!isMeshNode(node)) continue;
|
|
3169
3171
|
node.visible = binding.visible !== false;
|
|
3170
|
-
const
|
|
3171
|
-
if (!
|
|
3172
|
+
const material2 = perNodeMaterials[nodeName];
|
|
3173
|
+
if (!material2) continue;
|
|
3172
3174
|
if (rendererMode !== "uv-checker") {
|
|
3173
3175
|
const activeMaterial = materialForNode(nodeName);
|
|
3174
3176
|
if (activeMaterial) {
|
|
@@ -3205,19 +3207,19 @@ function Model({
|
|
|
3205
3207
|
delete appliedTextureUrls.current[nodeName];
|
|
3206
3208
|
}
|
|
3207
3209
|
const resolvedBaseColor = itemMat?.hex ?? configuredMaterial?.baseColor;
|
|
3208
|
-
applyMaterialConfig(
|
|
3210
|
+
applyMaterialConfig(material2, configuredMaterial, resolvedBaseColor);
|
|
3209
3211
|
if (isHighlightedByHover) {
|
|
3210
|
-
|
|
3212
|
+
material2.emissive?.add(HIGHLIGHT_EMISSIVE_TINT);
|
|
3211
3213
|
}
|
|
3212
|
-
|
|
3214
|
+
material2.needsUpdate = true;
|
|
3213
3215
|
if (basicMaterial) {
|
|
3214
|
-
basicMaterial.color.copy(
|
|
3215
|
-
basicMaterial.map =
|
|
3216
|
-
basicMaterial.alphaMap =
|
|
3217
|
-
basicMaterial.alphaTest =
|
|
3218
|
-
basicMaterial.transparent =
|
|
3219
|
-
basicMaterial.opacity =
|
|
3220
|
-
basicMaterial.side =
|
|
3216
|
+
basicMaterial.color.copy(material2.color);
|
|
3217
|
+
basicMaterial.map = material2.map;
|
|
3218
|
+
basicMaterial.alphaMap = material2.alphaMap;
|
|
3219
|
+
basicMaterial.alphaTest = material2.alphaTest;
|
|
3220
|
+
basicMaterial.transparent = material2.transparent;
|
|
3221
|
+
basicMaterial.opacity = material2.opacity;
|
|
3222
|
+
basicMaterial.side = material2.side;
|
|
3221
3223
|
basicMaterial.needsUpdate = true;
|
|
3222
3224
|
}
|
|
3223
3225
|
if (normalMaterial) normalMaterial.needsUpdate = true;
|
|
@@ -3225,14 +3227,14 @@ function Model({
|
|
|
3225
3227
|
if (isHighlightedByHover || isSelected) {
|
|
3226
3228
|
matcapMaterial.color.set(HIGHLIGHT.color);
|
|
3227
3229
|
} else {
|
|
3228
|
-
matcapMaterial.color.copy(
|
|
3230
|
+
matcapMaterial.color.copy(material2.color);
|
|
3229
3231
|
}
|
|
3230
|
-
matcapMaterial.map =
|
|
3231
|
-
matcapMaterial.alphaMap =
|
|
3232
|
-
matcapMaterial.alphaTest =
|
|
3233
|
-
matcapMaterial.transparent =
|
|
3234
|
-
matcapMaterial.opacity =
|
|
3235
|
-
matcapMaterial.side =
|
|
3232
|
+
matcapMaterial.map = material2.map;
|
|
3233
|
+
matcapMaterial.alphaMap = material2.alphaMap;
|
|
3234
|
+
matcapMaterial.alphaTest = material2.alphaTest;
|
|
3235
|
+
matcapMaterial.transparent = material2.transparent;
|
|
3236
|
+
matcapMaterial.opacity = material2.opacity;
|
|
3237
|
+
matcapMaterial.side = material2.side;
|
|
3236
3238
|
matcapMaterial.needsUpdate = true;
|
|
3237
3239
|
}
|
|
3238
3240
|
}
|
|
@@ -3278,14 +3280,14 @@ function Model({
|
|
|
3278
3280
|
const sourceMaterials = Array.isArray(original) ? original : [original];
|
|
3279
3281
|
const hasUv0 = Boolean(object.geometry.getAttribute("uv"));
|
|
3280
3282
|
const diagnosticMaterials = sourceMaterials.map((source, index) => {
|
|
3281
|
-
const
|
|
3283
|
+
const material2 = new import_three14.MeshBasicMaterial({
|
|
3282
3284
|
color: hasUv0 ? "#ffffff" : "#ff00ff",
|
|
3283
3285
|
map: hasUv0 ? checkerTexture : null,
|
|
3284
3286
|
side: source.side
|
|
3285
3287
|
});
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
return
|
|
3288
|
+
material2.name = `${object.name || "mesh"}-uv-checker-${index}`;
|
|
3289
|
+
material2.toneMapped = false;
|
|
3290
|
+
return material2;
|
|
3289
3291
|
});
|
|
3290
3292
|
const diagnostic = Array.isArray(original) ? diagnosticMaterials : diagnosticMaterials[0];
|
|
3291
3293
|
object.material = diagnostic;
|
|
@@ -3296,7 +3298,7 @@ function Model({
|
|
|
3296
3298
|
for (const { node, original, diagnostic } of swaps) {
|
|
3297
3299
|
node.material = original;
|
|
3298
3300
|
const materials = Array.isArray(diagnostic) ? diagnostic : [diagnostic];
|
|
3299
|
-
for (const
|
|
3301
|
+
for (const material2 of materials) material2.dispose();
|
|
3300
3302
|
}
|
|
3301
3303
|
invalidate();
|
|
3302
3304
|
};
|
|
@@ -13205,8 +13207,8 @@ function MaterialSection({
|
|
|
13205
13207
|
{
|
|
13206
13208
|
label: pbrWorkflow === "specular" ? "Albedo color" : "Base color",
|
|
13207
13209
|
value: selectedMaterial?.baseColor ?? "#ffffff",
|
|
13208
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13209
|
-
...
|
|
13210
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13211
|
+
...material2,
|
|
13210
13212
|
baseColor: value
|
|
13211
13213
|
}))
|
|
13212
13214
|
}
|
|
@@ -13220,8 +13222,8 @@ function MaterialSection({
|
|
|
13220
13222
|
min: 0,
|
|
13221
13223
|
max: 1,
|
|
13222
13224
|
step: 0.01,
|
|
13223
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13224
|
-
...
|
|
13225
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13226
|
+
...material2,
|
|
13225
13227
|
metalness: value
|
|
13226
13228
|
}))
|
|
13227
13229
|
}
|
|
@@ -13244,8 +13246,8 @@ function MaterialSection({
|
|
|
13244
13246
|
min: 0,
|
|
13245
13247
|
max: 1,
|
|
13246
13248
|
step: 0.01,
|
|
13247
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13248
|
-
...
|
|
13249
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13250
|
+
...material2,
|
|
13249
13251
|
specularIntensity: value
|
|
13250
13252
|
}))
|
|
13251
13253
|
}
|
|
@@ -13255,8 +13257,8 @@ function MaterialSection({
|
|
|
13255
13257
|
{
|
|
13256
13258
|
label: "Specular color",
|
|
13257
13259
|
value: selectedMaterial?.specularColor ?? "#ffffff",
|
|
13258
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13259
|
-
...
|
|
13260
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13261
|
+
...material2,
|
|
13260
13262
|
specularColor: value
|
|
13261
13263
|
}))
|
|
13262
13264
|
}
|
|
@@ -13296,8 +13298,8 @@ function MaterialSection({
|
|
|
13296
13298
|
min: 0,
|
|
13297
13299
|
max: 1,
|
|
13298
13300
|
step: 0.01,
|
|
13299
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13300
|
-
...
|
|
13301
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13302
|
+
...material2,
|
|
13301
13303
|
reflectivity: value
|
|
13302
13304
|
}))
|
|
13303
13305
|
}
|
|
@@ -13308,8 +13310,8 @@ function MaterialSection({
|
|
|
13308
13310
|
{
|
|
13309
13311
|
label: "Base color",
|
|
13310
13312
|
value: selectedMaterial?.baseColor ?? "#ffffff",
|
|
13311
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13312
|
-
...
|
|
13313
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13314
|
+
...material2,
|
|
13313
13315
|
baseColor: value
|
|
13314
13316
|
}))
|
|
13315
13317
|
}
|
|
@@ -13322,8 +13324,8 @@ function MaterialSection({
|
|
|
13322
13324
|
min: 0,
|
|
13323
13325
|
max: 1,
|
|
13324
13326
|
step: 0.01,
|
|
13325
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13326
|
-
...
|
|
13327
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13328
|
+
...material2,
|
|
13327
13329
|
metalness: value
|
|
13328
13330
|
}))
|
|
13329
13331
|
}
|
|
@@ -13366,8 +13368,8 @@ function MaterialSection({
|
|
|
13366
13368
|
min: 0,
|
|
13367
13369
|
max: 1,
|
|
13368
13370
|
step: 0.01,
|
|
13369
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13370
|
-
...
|
|
13371
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13372
|
+
...material2,
|
|
13371
13373
|
roughness: value
|
|
13372
13374
|
}))
|
|
13373
13375
|
}
|
|
@@ -13379,8 +13381,8 @@ function MaterialSection({
|
|
|
13379
13381
|
min: 0,
|
|
13380
13382
|
max: 1,
|
|
13381
13383
|
step: 0.01,
|
|
13382
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13383
|
-
...
|
|
13384
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13385
|
+
...material2,
|
|
13384
13386
|
roughness: value === void 0 ? void 0 : 1 - value
|
|
13385
13387
|
}))
|
|
13386
13388
|
}
|
|
@@ -13412,8 +13414,8 @@ function MaterialSection({
|
|
|
13412
13414
|
label: "Emissive color",
|
|
13413
13415
|
value: selectedMaterial?.emissive ?? "#000000",
|
|
13414
13416
|
fallback: "#000000",
|
|
13415
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13416
|
-
...
|
|
13417
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13418
|
+
...material2,
|
|
13417
13419
|
emissive: value
|
|
13418
13420
|
}))
|
|
13419
13421
|
}
|
|
@@ -13426,8 +13428,8 @@ function MaterialSection({
|
|
|
13426
13428
|
min: 0,
|
|
13427
13429
|
max: 10,
|
|
13428
13430
|
step: 0.1,
|
|
13429
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13430
|
-
...
|
|
13431
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13432
|
+
...material2,
|
|
13431
13433
|
emissiveIntensity: value
|
|
13432
13434
|
}))
|
|
13433
13435
|
}
|
|
@@ -13461,8 +13463,8 @@ function MaterialSection({
|
|
|
13461
13463
|
min: 0,
|
|
13462
13464
|
max: 1,
|
|
13463
13465
|
step: 0.01,
|
|
13464
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13465
|
-
...
|
|
13466
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13467
|
+
...material2,
|
|
13466
13468
|
opacity: value
|
|
13467
13469
|
}))
|
|
13468
13470
|
}
|
|
@@ -13475,8 +13477,8 @@ function MaterialSection({
|
|
|
13475
13477
|
min: 0,
|
|
13476
13478
|
max: 1,
|
|
13477
13479
|
step: 0.01,
|
|
13478
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13479
|
-
...
|
|
13480
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13481
|
+
...material2,
|
|
13480
13482
|
alphaTest: value
|
|
13481
13483
|
}))
|
|
13482
13484
|
}
|
|
@@ -13496,8 +13498,8 @@ function MaterialSection({
|
|
|
13496
13498
|
label: "Blending mode",
|
|
13497
13499
|
value: selectedMaterial?.blendingMode ?? "normal",
|
|
13498
13500
|
options: MATERIAL_BLENDING_MODES,
|
|
13499
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13500
|
-
...
|
|
13501
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13502
|
+
...material2,
|
|
13501
13503
|
blendingMode: value
|
|
13502
13504
|
}))
|
|
13503
13505
|
}
|
|
@@ -13509,8 +13511,8 @@ function MaterialSection({
|
|
|
13509
13511
|
{
|
|
13510
13512
|
label: "Use alpha hash",
|
|
13511
13513
|
checked: selectedMaterial?.alphaHash ?? false,
|
|
13512
|
-
onChange: (checked) => updateSelectedMaterial(selectedItem, (
|
|
13513
|
-
...
|
|
13514
|
+
onChange: (checked) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13515
|
+
...material2,
|
|
13514
13516
|
alphaHash: checked
|
|
13515
13517
|
}))
|
|
13516
13518
|
}
|
|
@@ -13523,8 +13525,8 @@ function MaterialSection({
|
|
|
13523
13525
|
{
|
|
13524
13526
|
label: "Use dithering",
|
|
13525
13527
|
checked: selectedMaterial?.dithering ?? false,
|
|
13526
|
-
onChange: (checked) => updateSelectedMaterial(selectedItem, (
|
|
13527
|
-
...
|
|
13528
|
+
onChange: (checked) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13529
|
+
...material2,
|
|
13528
13530
|
dithering: checked
|
|
13529
13531
|
}))
|
|
13530
13532
|
}
|
|
@@ -13561,8 +13563,8 @@ function MaterialSection({
|
|
|
13561
13563
|
min: 0,
|
|
13562
13564
|
max: 5,
|
|
13563
13565
|
step: 0.01,
|
|
13564
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13565
|
-
...
|
|
13566
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13567
|
+
...material2,
|
|
13566
13568
|
normalScale: value
|
|
13567
13569
|
}))
|
|
13568
13570
|
}
|
|
@@ -13584,8 +13586,8 @@ function MaterialSection({
|
|
|
13584
13586
|
min: 0,
|
|
13585
13587
|
max: 5,
|
|
13586
13588
|
step: 0.01,
|
|
13587
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13588
|
-
...
|
|
13589
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13590
|
+
...material2,
|
|
13589
13591
|
bumpScale: value
|
|
13590
13592
|
}))
|
|
13591
13593
|
}
|
|
@@ -13596,8 +13598,8 @@ function MaterialSection({
|
|
|
13596
13598
|
{
|
|
13597
13599
|
label: "Flip normal Y",
|
|
13598
13600
|
checked: selectedMaterial?.flipNormalY ?? false,
|
|
13599
|
-
onChange: (checked) => updateSelectedMaterial(selectedItem, (
|
|
13600
|
-
...
|
|
13601
|
+
onChange: (checked) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13602
|
+
...material2,
|
|
13601
13603
|
flipNormalY: checked
|
|
13602
13604
|
}))
|
|
13603
13605
|
}
|
|
@@ -13631,8 +13633,8 @@ function MaterialSection({
|
|
|
13631
13633
|
min: -5,
|
|
13632
13634
|
max: 5,
|
|
13633
13635
|
step: 0.01,
|
|
13634
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13635
|
-
...
|
|
13636
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13637
|
+
...material2,
|
|
13636
13638
|
displacementScale: value
|
|
13637
13639
|
}))
|
|
13638
13640
|
}
|
|
@@ -13645,8 +13647,8 @@ function MaterialSection({
|
|
|
13645
13647
|
min: -5,
|
|
13646
13648
|
max: 5,
|
|
13647
13649
|
step: 0.01,
|
|
13648
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13649
|
-
...
|
|
13650
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13651
|
+
...material2,
|
|
13650
13652
|
displacementBias: value
|
|
13651
13653
|
}))
|
|
13652
13654
|
}
|
|
@@ -13680,8 +13682,8 @@ function MaterialSection({
|
|
|
13680
13682
|
min: 0,
|
|
13681
13683
|
max: 5,
|
|
13682
13684
|
step: 0.01,
|
|
13683
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13684
|
-
...
|
|
13685
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13686
|
+
...material2,
|
|
13685
13687
|
aoMapIntensity: value
|
|
13686
13688
|
}))
|
|
13687
13689
|
}
|
|
@@ -13716,8 +13718,8 @@ function MaterialSection({
|
|
|
13716
13718
|
min: 0,
|
|
13717
13719
|
max: 1,
|
|
13718
13720
|
step: 0.01,
|
|
13719
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13720
|
-
...
|
|
13721
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13722
|
+
...material2,
|
|
13721
13723
|
clearcoat: value
|
|
13722
13724
|
}))
|
|
13723
13725
|
}
|
|
@@ -13743,8 +13745,8 @@ function MaterialSection({
|
|
|
13743
13745
|
min: 0,
|
|
13744
13746
|
max: 1,
|
|
13745
13747
|
step: 0.01,
|
|
13746
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13747
|
-
...
|
|
13748
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13749
|
+
...material2,
|
|
13748
13750
|
clearcoatRoughness: value
|
|
13749
13751
|
}))
|
|
13750
13752
|
}
|
|
@@ -13766,8 +13768,8 @@ function MaterialSection({
|
|
|
13766
13768
|
min: 0,
|
|
13767
13769
|
max: 5,
|
|
13768
13770
|
step: 0.01,
|
|
13769
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13770
|
-
...
|
|
13771
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13772
|
+
...material2,
|
|
13771
13773
|
clearcoatNormalScale: value
|
|
13772
13774
|
}))
|
|
13773
13775
|
}
|
|
@@ -13778,8 +13780,8 @@ function MaterialSection({
|
|
|
13778
13780
|
{
|
|
13779
13781
|
label: "Flip clearcoat normal Y",
|
|
13780
13782
|
checked: selectedMaterial?.flipClearcoatNormalY ?? false,
|
|
13781
|
-
onChange: (checked) => updateSelectedMaterial(selectedItem, (
|
|
13782
|
-
...
|
|
13783
|
+
onChange: (checked) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13784
|
+
...material2,
|
|
13783
13785
|
flipClearcoatNormalY: checked
|
|
13784
13786
|
}))
|
|
13785
13787
|
}
|
|
@@ -13804,8 +13806,8 @@ function MaterialSection({
|
|
|
13804
13806
|
min: 0,
|
|
13805
13807
|
max: 1,
|
|
13806
13808
|
step: 0.01,
|
|
13807
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13808
|
-
...
|
|
13809
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13810
|
+
...material2,
|
|
13809
13811
|
sheen: value
|
|
13810
13812
|
}))
|
|
13811
13813
|
}
|
|
@@ -13815,8 +13817,8 @@ function MaterialSection({
|
|
|
13815
13817
|
{
|
|
13816
13818
|
label: "Sheen color",
|
|
13817
13819
|
value: selectedMaterial?.sheenColor ?? "#ffffff",
|
|
13818
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13819
|
-
...
|
|
13820
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13821
|
+
...material2,
|
|
13820
13822
|
sheenColor: value
|
|
13821
13823
|
}))
|
|
13822
13824
|
}
|
|
@@ -13838,8 +13840,8 @@ function MaterialSection({
|
|
|
13838
13840
|
min: 0,
|
|
13839
13841
|
max: 1,
|
|
13840
13842
|
step: 0.01,
|
|
13841
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13842
|
-
...
|
|
13843
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13844
|
+
...material2,
|
|
13843
13845
|
sheenRoughness: value
|
|
13844
13846
|
}))
|
|
13845
13847
|
}
|
|
@@ -13873,8 +13875,8 @@ function MaterialSection({
|
|
|
13873
13875
|
min: 0,
|
|
13874
13876
|
max: 1,
|
|
13875
13877
|
step: 0.01,
|
|
13876
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13877
|
-
...
|
|
13878
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13879
|
+
...material2,
|
|
13878
13880
|
anisotropy: value
|
|
13879
13881
|
}))
|
|
13880
13882
|
}
|
|
@@ -13896,8 +13898,8 @@ function MaterialSection({
|
|
|
13896
13898
|
min: 0,
|
|
13897
13899
|
max: 6.28,
|
|
13898
13900
|
step: 0.01,
|
|
13899
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13900
|
-
...
|
|
13901
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13902
|
+
...material2,
|
|
13901
13903
|
anisotropyRotation: value
|
|
13902
13904
|
}))
|
|
13903
13905
|
}
|
|
@@ -13931,8 +13933,8 @@ function MaterialSection({
|
|
|
13931
13933
|
min: 0,
|
|
13932
13934
|
max: 1,
|
|
13933
13935
|
step: 0.01,
|
|
13934
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13935
|
-
...
|
|
13936
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13937
|
+
...material2,
|
|
13936
13938
|
transmission: value
|
|
13937
13939
|
}))
|
|
13938
13940
|
}
|
|
@@ -13954,8 +13956,8 @@ function MaterialSection({
|
|
|
13954
13956
|
min: 0,
|
|
13955
13957
|
max: 5,
|
|
13956
13958
|
step: 0.01,
|
|
13957
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13958
|
-
...
|
|
13959
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13960
|
+
...material2,
|
|
13959
13961
|
thickness: value
|
|
13960
13962
|
}))
|
|
13961
13963
|
}
|
|
@@ -13974,8 +13976,8 @@ function MaterialSection({
|
|
|
13974
13976
|
{
|
|
13975
13977
|
label: "Volume tint",
|
|
13976
13978
|
value: selectedMaterial?.attenuationColor ?? "#ffffff",
|
|
13977
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13978
|
-
...
|
|
13979
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13980
|
+
...material2,
|
|
13979
13981
|
attenuationColor: value
|
|
13980
13982
|
}))
|
|
13981
13983
|
}
|
|
@@ -13988,8 +13990,8 @@ function MaterialSection({
|
|
|
13988
13990
|
min: 0,
|
|
13989
13991
|
step: 0.01,
|
|
13990
13992
|
placeholder: "Infinity when unset",
|
|
13991
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
13992
|
-
...
|
|
13993
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
13994
|
+
...material2,
|
|
13993
13995
|
attenuationDistance: value
|
|
13994
13996
|
}))
|
|
13995
13997
|
}
|
|
@@ -14011,8 +14013,8 @@ function MaterialSection({
|
|
|
14011
14013
|
label: "Side",
|
|
14012
14014
|
value: selectedMaterial?.side ?? "front",
|
|
14013
14015
|
options: MATERIAL_SIDES,
|
|
14014
|
-
onChange: (value) => updateSelectedMaterial(selectedItem, (
|
|
14015
|
-
...
|
|
14016
|
+
onChange: (value) => updateSelectedMaterial(selectedItem, (material2) => ({
|
|
14017
|
+
...material2,
|
|
14016
14018
|
side: value
|
|
14017
14019
|
}))
|
|
14018
14020
|
}
|
|
@@ -15011,9 +15013,9 @@ function formatVector3(position) {
|
|
|
15011
15013
|
|
|
15012
15014
|
// src/components/BindingBuilder/utils/exportAssets.ts
|
|
15013
15015
|
function collectTexturePaths(binding) {
|
|
15014
|
-
const
|
|
15015
|
-
if (!
|
|
15016
|
-
return Object.values(
|
|
15016
|
+
const material2 = binding.style?.material;
|
|
15017
|
+
if (!material2) return [];
|
|
15018
|
+
return Object.values(material2).filter(
|
|
15017
15019
|
(value) => !!value && typeof value === "object" && typeof value.path === "string" && value.path.trim().length > 0
|
|
15018
15020
|
).map((value) => value.path);
|
|
15019
15021
|
}
|
|
@@ -15131,30 +15133,30 @@ function materialFieldHasValue(value) {
|
|
|
15131
15133
|
}
|
|
15132
15134
|
return false;
|
|
15133
15135
|
}
|
|
15134
|
-
function normalizeMaterialForStorage(
|
|
15135
|
-
if (!
|
|
15136
|
-
return Object.values(
|
|
15136
|
+
function normalizeMaterialForStorage(material2) {
|
|
15137
|
+
if (!material2) return void 0;
|
|
15138
|
+
return Object.values(material2).some(materialFieldHasValue) ? material2 : void 0;
|
|
15137
15139
|
}
|
|
15138
|
-
function isMaterialPanelEnabled(
|
|
15139
|
-
if (!
|
|
15140
|
+
function isMaterialPanelEnabled(material2, panel) {
|
|
15141
|
+
if (!material2) return false;
|
|
15140
15142
|
return MATERIAL_PANEL_FIELDS[panel].some(
|
|
15141
|
-
(field) => materialFieldHasValue(
|
|
15143
|
+
(field) => materialFieldHasValue(material2[field])
|
|
15142
15144
|
);
|
|
15143
15145
|
}
|
|
15144
|
-
function createMaterialPanelEnabledState(
|
|
15146
|
+
function createMaterialPanelEnabledState(material2) {
|
|
15145
15147
|
return {
|
|
15146
|
-
pbr: isMaterialPanelEnabled(
|
|
15147
|
-
roughness: isMaterialPanelEnabled(
|
|
15148
|
-
emission: isMaterialPanelEnabled(
|
|
15149
|
-
opacity: isMaterialPanelEnabled(
|
|
15150
|
-
normalBump: isMaterialPanelEnabled(
|
|
15151
|
-
displacement: isMaterialPanelEnabled(
|
|
15152
|
-
ao: isMaterialPanelEnabled(
|
|
15153
|
-
clearcoat: isMaterialPanelEnabled(
|
|
15154
|
-
sheen: isMaterialPanelEnabled(
|
|
15155
|
-
anisotropy: isMaterialPanelEnabled(
|
|
15156
|
-
transmission: isMaterialPanelEnabled(
|
|
15157
|
-
faces: isMaterialPanelEnabled(
|
|
15148
|
+
pbr: isMaterialPanelEnabled(material2, "pbr"),
|
|
15149
|
+
roughness: isMaterialPanelEnabled(material2, "roughness"),
|
|
15150
|
+
emission: isMaterialPanelEnabled(material2, "emission"),
|
|
15151
|
+
opacity: isMaterialPanelEnabled(material2, "opacity"),
|
|
15152
|
+
normalBump: isMaterialPanelEnabled(material2, "normalBump"),
|
|
15153
|
+
displacement: isMaterialPanelEnabled(material2, "displacement"),
|
|
15154
|
+
ao: isMaterialPanelEnabled(material2, "ao"),
|
|
15155
|
+
clearcoat: isMaterialPanelEnabled(material2, "clearcoat"),
|
|
15156
|
+
sheen: isMaterialPanelEnabled(material2, "sheen"),
|
|
15157
|
+
anisotropy: isMaterialPanelEnabled(material2, "anisotropy"),
|
|
15158
|
+
transmission: isMaterialPanelEnabled(material2, "transmission"),
|
|
15159
|
+
faces: isMaterialPanelEnabled(material2, "faces")
|
|
15158
15160
|
};
|
|
15159
15161
|
}
|
|
15160
15162
|
function withMaterial(binding, nextMaterial) {
|
|
@@ -15171,9 +15173,9 @@ function withMaterial(binding, nextMaterial) {
|
|
|
15171
15173
|
style: Object.keys(rest).length > 0 ? rest : void 0
|
|
15172
15174
|
};
|
|
15173
15175
|
}
|
|
15174
|
-
function removeMaterialPanelFields(
|
|
15175
|
-
if (!
|
|
15176
|
-
const nextMaterial = { ...
|
|
15176
|
+
function removeMaterialPanelFields(material2, panel) {
|
|
15177
|
+
if (!material2) return void 0;
|
|
15178
|
+
const nextMaterial = { ...material2 };
|
|
15177
15179
|
for (const field of MATERIAL_PANEL_FIELDS[panel]) {
|
|
15178
15180
|
delete nextMaterial[field];
|
|
15179
15181
|
}
|
|
@@ -15431,8 +15433,8 @@ function BindingBuilder({ licenseKey }) {
|
|
|
15431
15433
|
});
|
|
15432
15434
|
};
|
|
15433
15435
|
const setSelectedTexturePath = (nodeKey, key, value) => {
|
|
15434
|
-
updateSelectedMaterial(nodeKey, (
|
|
15435
|
-
...
|
|
15436
|
+
updateSelectedMaterial(nodeKey, (material2) => ({
|
|
15437
|
+
...material2,
|
|
15436
15438
|
[key]: value ? { path: value } : void 0
|
|
15437
15439
|
}));
|
|
15438
15440
|
};
|
|
@@ -16062,8 +16064,8 @@ function BindingBuilder({ licenseKey }) {
|
|
|
16062
16064
|
MaterialPresetGallery,
|
|
16063
16065
|
{
|
|
16064
16066
|
disabled: !selectedItem,
|
|
16065
|
-
onApply: (preset) => selectedItem && updateSelectedMaterial(selectedItem, (
|
|
16066
|
-
...
|
|
16067
|
+
onApply: (preset) => selectedItem && updateSelectedMaterial(selectedItem, (material2) => ({
|
|
16068
|
+
...material2,
|
|
16067
16069
|
...preset
|
|
16068
16070
|
}))
|
|
16069
16071
|
}
|
|
@@ -17591,71 +17593,126 @@ function useObjectBindingIds(objectBindings) {
|
|
|
17591
17593
|
);
|
|
17592
17594
|
}
|
|
17593
17595
|
|
|
17594
|
-
// src/hooks/
|
|
17596
|
+
// src/hooks/useObjectBindings.ts
|
|
17595
17597
|
var import_react44 = require("react");
|
|
17598
|
+
|
|
17599
|
+
// src/utils/patchBindings.ts
|
|
17600
|
+
function isPlainObject2(value) {
|
|
17601
|
+
if (typeof value !== "object" || value === null) return false;
|
|
17602
|
+
const prototype = Object.getPrototypeOf(value);
|
|
17603
|
+
return prototype === Object.prototype || prototype === null;
|
|
17604
|
+
}
|
|
17605
|
+
function isBindingEditArray(value) {
|
|
17606
|
+
return Array.isArray(value) && value.length > 0 && typeof value[0] !== "string";
|
|
17607
|
+
}
|
|
17608
|
+
function deepMerge(base, patch) {
|
|
17609
|
+
if (!isPlainObject2(patch)) return patch;
|
|
17610
|
+
const target = isPlainObject2(base) ? { ...base } : {};
|
|
17611
|
+
for (const key of Object.keys(patch)) {
|
|
17612
|
+
const value = patch[key];
|
|
17613
|
+
target[key] = isPlainObject2(value) ? deepMerge(target[key], value) : value;
|
|
17614
|
+
}
|
|
17615
|
+
return target;
|
|
17616
|
+
}
|
|
17617
|
+
function patchBindings(bindings, objectIdOrEdits, patch) {
|
|
17618
|
+
const edits = isBindingEditArray(objectIdOrEdits) ? objectIdOrEdits : [{ ids: objectIdOrEdits, patch: patch ?? {} }];
|
|
17619
|
+
let next = bindings;
|
|
17620
|
+
for (const edit of edits) {
|
|
17621
|
+
const ids = Array.isArray(edit.ids) ? edit.ids : [edit.ids];
|
|
17622
|
+
for (const id of ids) {
|
|
17623
|
+
const bindingKey = resolveBindingKey(next, id);
|
|
17624
|
+
if (!bindingKey) continue;
|
|
17625
|
+
const binding = next[bindingKey];
|
|
17626
|
+
if (!binding) continue;
|
|
17627
|
+
const patchedBinding = deepMerge(binding, edit.patch);
|
|
17628
|
+
if (next === bindings) next = { ...bindings };
|
|
17629
|
+
next[bindingKey] = patchedBinding;
|
|
17630
|
+
}
|
|
17631
|
+
}
|
|
17632
|
+
return next;
|
|
17633
|
+
}
|
|
17634
|
+
function material(value) {
|
|
17635
|
+
return { style: { material: value } };
|
|
17636
|
+
}
|
|
17637
|
+
|
|
17638
|
+
// src/hooks/useObjectBindings.ts
|
|
17596
17639
|
function getHiddenObjects(objectBindings) {
|
|
17597
17640
|
return Object.fromEntries(
|
|
17598
17641
|
Object.entries(objectBindings).filter(([, binding]) => binding.visible === false).map(([bindingKey]) => [bindingKey, true])
|
|
17599
17642
|
);
|
|
17600
17643
|
}
|
|
17601
|
-
function
|
|
17602
|
-
const
|
|
17603
|
-
|
|
17644
|
+
function useObjectBindings(initialBindings) {
|
|
17645
|
+
const [objectBindings, setObjectBindings] = (0, import_react44.useState)(initialBindings);
|
|
17646
|
+
const patch = (0, import_react44.useCallback)(
|
|
17647
|
+
(objectIdOrEdits, patchValue) => {
|
|
17648
|
+
setObjectBindings(
|
|
17649
|
+
(current) => patchValue === void 0 ? patchBindings(current, objectIdOrEdits) : patchBindings(
|
|
17650
|
+
current,
|
|
17651
|
+
objectIdOrEdits,
|
|
17652
|
+
patchValue
|
|
17653
|
+
)
|
|
17654
|
+
);
|
|
17655
|
+
},
|
|
17656
|
+
[]
|
|
17657
|
+
);
|
|
17658
|
+
const setMaterial = (0, import_react44.useCallback)(
|
|
17659
|
+
(objectId, value) => patch(objectId, material(value)),
|
|
17660
|
+
[patch]
|
|
17661
|
+
);
|
|
17662
|
+
const setBaseColor = (0, import_react44.useCallback)(
|
|
17663
|
+
(objectId, color) => setMaterial(objectId, { baseColor: color }),
|
|
17664
|
+
[setMaterial]
|
|
17665
|
+
);
|
|
17666
|
+
const resetMaterial = (0, import_react44.useCallback)(
|
|
17667
|
+
(objectId) => patch(objectId, { style: { material: void 0 } }),
|
|
17668
|
+
[patch]
|
|
17669
|
+
);
|
|
17670
|
+
const getMaterial = (0, import_react44.useCallback)(
|
|
17671
|
+
(objectId) => {
|
|
17604
17672
|
const bindingKey = resolveBindingKey(objectBindings, objectId);
|
|
17605
|
-
|
|
17606
|
-
const targetBinding = objectBindings[bindingKey];
|
|
17607
|
-
if (!targetBinding) return;
|
|
17608
|
-
onObjectBindingsChange({
|
|
17609
|
-
...objectBindings,
|
|
17610
|
-
[bindingKey]: {
|
|
17611
|
-
...targetBinding,
|
|
17612
|
-
visible
|
|
17613
|
-
}
|
|
17614
|
-
});
|
|
17673
|
+
return bindingKey ? objectBindings[bindingKey]?.style?.material ?? null : null;
|
|
17615
17674
|
},
|
|
17616
|
-
[objectBindings
|
|
17675
|
+
[objectBindings]
|
|
17617
17676
|
);
|
|
17618
17677
|
const hideObject = (0, import_react44.useCallback)(
|
|
17619
|
-
(objectId) =>
|
|
17620
|
-
[
|
|
17678
|
+
(objectId) => patch(objectId, { visible: false }),
|
|
17679
|
+
[patch]
|
|
17621
17680
|
);
|
|
17622
17681
|
const showObject = (0, import_react44.useCallback)(
|
|
17623
|
-
(objectId) =>
|
|
17624
|
-
[
|
|
17682
|
+
(objectId) => patch(objectId, { visible: true }),
|
|
17683
|
+
[patch]
|
|
17625
17684
|
);
|
|
17626
17685
|
const toggleObjectVisibility = (0, import_react44.useCallback)(
|
|
17627
17686
|
(objectId) => {
|
|
17628
|
-
|
|
17629
|
-
|
|
17630
|
-
|
|
17631
|
-
|
|
17632
|
-
|
|
17633
|
-
|
|
17634
|
-
|
|
17635
|
-
|
|
17636
|
-
|
|
17637
|
-
|
|
17687
|
+
setObjectBindings((current) => {
|
|
17688
|
+
const objectIds = Array.isArray(objectId) ? objectId : [objectId];
|
|
17689
|
+
const edits = objectIds.reduce((acc, id) => {
|
|
17690
|
+
const bindingKey = resolveBindingKey(current, id);
|
|
17691
|
+
const binding = bindingKey ? current[bindingKey] : null;
|
|
17692
|
+
if (!bindingKey || !binding) return acc;
|
|
17693
|
+
acc.push({
|
|
17694
|
+
ids: bindingKey,
|
|
17695
|
+
patch: { visible: binding.visible === false }
|
|
17696
|
+
});
|
|
17697
|
+
return acc;
|
|
17698
|
+
}, []);
|
|
17699
|
+
return patchBindings(current, edits);
|
|
17638
17700
|
});
|
|
17639
17701
|
},
|
|
17640
|
-
[
|
|
17702
|
+
[setObjectBindings]
|
|
17641
17703
|
);
|
|
17642
17704
|
const clearHiddenObjects = (0, import_react44.useCallback)(() => {
|
|
17643
|
-
|
|
17644
|
-
Object.
|
|
17645
|
-
Object.entries(objectBindings).map(([bindingKey, binding]) => [
|
|
17646
|
-
bindingKey,
|
|
17647
|
-
{ ...binding, visible: true }
|
|
17648
|
-
])
|
|
17649
|
-
)
|
|
17705
|
+
setObjectBindings(
|
|
17706
|
+
(current) => patchBindings(current, Object.keys(current), { visible: true })
|
|
17650
17707
|
);
|
|
17651
|
-
}, [
|
|
17708
|
+
}, [setObjectBindings]);
|
|
17652
17709
|
const hiddenObjects = (0, import_react44.useMemo)(
|
|
17653
17710
|
() => getHiddenObjects(objectBindings),
|
|
17654
17711
|
[objectBindings]
|
|
17655
17712
|
);
|
|
17656
17713
|
const hiddenObjectIds = (0, import_react44.useMemo)(
|
|
17657
|
-
() => Object.
|
|
17658
|
-
(
|
|
17714
|
+
() => Object.keys(hiddenObjects).map(
|
|
17715
|
+
(bindingKey) => objectBindings[bindingKey]?.id ?? bindingKey
|
|
17659
17716
|
),
|
|
17660
17717
|
[hiddenObjects, objectBindings]
|
|
17661
17718
|
);
|
|
@@ -17667,6 +17724,13 @@ function useObjectVisibility(objectBindings, onObjectBindingsChange) {
|
|
|
17667
17724
|
[objectBindings]
|
|
17668
17725
|
);
|
|
17669
17726
|
return {
|
|
17727
|
+
objectBindings,
|
|
17728
|
+
setObjectBindings,
|
|
17729
|
+
patch,
|
|
17730
|
+
setMaterial,
|
|
17731
|
+
setBaseColor,
|
|
17732
|
+
resetMaterial,
|
|
17733
|
+
getMaterial,
|
|
17670
17734
|
hiddenObjects,
|
|
17671
17735
|
hiddenObjectIds,
|
|
17672
17736
|
hideObject,
|
|
@@ -17961,9 +18025,11 @@ function useShareableViewerState({
|
|
|
17961
18025
|
MATERIAL_SIDES,
|
|
17962
18026
|
ModelViewer,
|
|
17963
18027
|
SimpleModelViewer,
|
|
18028
|
+
material,
|
|
18029
|
+
patchBindings,
|
|
17964
18030
|
useObjectBinding,
|
|
17965
18031
|
useObjectBindingIds,
|
|
17966
|
-
|
|
18032
|
+
useObjectBindings,
|
|
17967
18033
|
useShareableViewerState,
|
|
17968
18034
|
useViewerActions,
|
|
17969
18035
|
useViewerAnimations,
|