@babylonjs/inspector 9.30.0 → 9.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/bin/inspector-bridge.mjs +4730 -4446
  2. package/bin/inspector-cli.mjs +4765 -3866
  3. package/lib/components/curveEditor/animatableAnimations.d.ts +27 -0
  4. package/lib/components/properties/nodes/gaussianSplattingProperties.d.ts +13 -2
  5. package/lib/{extensionsListService-DfE1ZOnF.js → extensionsListService-O8zrOnmL.js} +5 -2
  6. package/lib/{extensionsListService-DfE1ZOnF.js.map → extensionsListService-O8zrOnmL.js.map} +1 -1
  7. package/lib/gif-ut7hgn9U.js +45 -0
  8. package/lib/gif-ut7hgn9U.js.map +1 -0
  9. package/lib/{index-CZ1-Y-Rv.js → index-DbbhJJ1G.js} +321 -85
  10. package/lib/index-DbbhJJ1G.js.map +1 -0
  11. package/lib/index.js +4 -1
  12. package/lib/index.js.map +1 -1
  13. package/lib/lite/animationProperties-BKVw6_ls.js +95 -0
  14. package/lib/lite/animationProperties-BKVw6_ls.js.map +1 -0
  15. package/lib/lite/animationUtils.d.ts +47 -0
  16. package/lib/lite/components/properties/animationProperties.d.ts +48 -0
  17. package/lib/lite/directTextureBinding-C5MB2OV2.js +99 -0
  18. package/lib/lite/directTextureBinding-C5MB2OV2.js.map +1 -0
  19. package/lib/lite/dynamicMaterialField-L_nQAxAA.js +107 -0
  20. package/lib/lite/dynamicMaterialField-L_nQAxAA.js.map +1 -0
  21. package/lib/lite/engineExplorerService.d.ts +3 -1
  22. package/lib/lite/{extensionsListService-D1JivcAu.js → extensionsListService-Bl1rTNl1.js} +2 -2
  23. package/lib/lite/{extensionsListService-D1JivcAu.js.map → extensionsListService-Bl1rTNl1.js.map} +1 -1
  24. package/lib/lite/{index-D8vFySa7.js → index-Cy8gzpYG.js} +1453 -394
  25. package/lib/lite/index-Cy8gzpYG.js.map +1 -0
  26. package/lib/lite/index.js +1 -1
  27. package/lib/lite/nodeMaterialProperties-ELFMlzS1.js +182 -0
  28. package/lib/lite/nodeMaterialProperties-ELFMlzS1.js.map +1 -0
  29. package/lib/lite/pbrMaterialProperties-jfJddBxY.js +614 -0
  30. package/lib/lite/pbrMaterialProperties-jfJddBxY.js.map +1 -0
  31. package/lib/lite/services/panes/properties/animationPropertiesService.d.ts +5 -0
  32. package/lib/lite/services/panes/properties/materialPropertiesService.d.ts +3 -1
  33. package/lib/lite/services/panes/properties/materials/directTextureBinding.d.ts +29 -0
  34. package/lib/lite/services/panes/properties/materials/dynamicMaterialField.d.ts +35 -0
  35. package/lib/lite/services/panes/properties/materials/materialAdapterTypes.d.ts +11 -0
  36. package/lib/lite/services/panes/properties/materials/materialReachability.d.ts +9 -0
  37. package/lib/lite/services/panes/properties/materials/nodeMaterialProperties.d.ts +8 -0
  38. package/lib/lite/services/panes/properties/materials/pbrMaterialProperties.d.ts +8 -0
  39. package/lib/lite/services/panes/properties/materials/shaderMaterialProperties.d.ts +8 -0
  40. package/lib/lite/services/panes/properties/materials/standardMaterialProperties.d.ts +8 -0
  41. package/lib/lite/services/panes/properties/materials/useDirectMaterialOperations.d.ts +31 -0
  42. package/lib/lite/services/panes/properties/textureMetadataProperties.d.ts +14 -0
  43. package/lib/lite/services/panes/properties/texturePropertiesService.d.ts +3 -1
  44. package/lib/lite/services/panes/properties/useLatestAsyncOperation.d.ts +24 -0
  45. package/lib/lite/services/panes/scene/animationGroupExplorerService.d.ts +7 -0
  46. package/lib/lite/services/panes/scene/materialExplorerService.d.ts +2 -1
  47. package/lib/lite/services/panes/scene/materialTopologyBindings.d.ts +13 -0
  48. package/lib/lite/services/panes/scene/sceneResourceIndexService.d.ts +36 -0
  49. package/lib/lite/services/panes/scene/sceneResources.d.ts +55 -11
  50. package/lib/lite/services/panes/scene/textureExplorerService.d.ts +2 -1
  51. package/lib/lite/services/pickingService.d.ts +10 -0
  52. package/lib/lite/shaderMaterialProperties-CTH_KfBK.js +229 -0
  53. package/lib/lite/shaderMaterialProperties-CTH_KfBK.js.map +1 -0
  54. package/lib/lite/standardMaterialProperties-BbYdFX86.js +287 -0
  55. package/lib/lite/standardMaterialProperties-BbYdFX86.js.map +1 -0
  56. package/lib/lite/textureMetadataProperties-BdNmp0Pk.js +221 -0
  57. package/lib/lite/textureMetadataProperties-BdNmp0Pk.js.map +1 -0
  58. package/lib/lite/useDirectMaterialOperations-D6V7OtC1.js +83 -0
  59. package/lib/lite/useDirectMaterialOperations-D6V7OtC1.js.map +1 -0
  60. package/lib/lite/useLatestAsyncOperation-k59AgA3B.js +78 -0
  61. package/lib/lite/useLatestAsyncOperation-k59AgA3B.js.map +1 -0
  62. package/lib/{quickCreateToolsService-owfaw163.js → quickCreateToolsService-Cs46Amv7.js} +5 -2
  63. package/lib/{quickCreateToolsService-owfaw163.js.map → quickCreateToolsService-Cs46Amv7.js.map} +1 -1
  64. package/lib/{reflectorService-oIAxxpQt.js → reflectorService-C43FgOiC.js} +5 -2
  65. package/lib/{reflectorService-oIAxxpQt.js.map → reflectorService-C43FgOiC.js.map} +1 -1
  66. package/lib/services/panes/properties/gaussianSplattingDebugController.d.ts +46 -0
  67. package/package.json +8 -8
  68. package/lib/gif-5DieAkSF.js +0 -38
  69. package/lib/gif-5DieAkSF.js.map +0 -1
  70. package/lib/index-CZ1-Y-Rv.js.map +0 -1
  71. package/lib/lite/index-D8vFySa7.js.map +0 -1
@@ -0,0 +1,614 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { getMaterialFamily, isMaterialView, getMaterialSource, getPbrUnlit, getShadowOnly, isPbrGammaAlbedo, isPbrSkybox, getPbrTransmission, getPbrSubsurface, getPbrAnisotropy, getPbrIridescence, getPbrSheen, getPbrClearCoat, getPbrMetallicReflectance, getPbrEmissiveColor, getPbrAlphaCutoff, markMaterialUboDirty, rebuildMaterial, enablePbrLightmap, setPbrLightmap, getTextureMetadata, enableMaterialStencil, setPbrDispersion, setPbrEmissive, setPbrAlphaCutoff, setPbrMetallicReflectance, setPbrClearCoat, setPbrSheen, setPbrIridescence, setPbrAnisotropy, setPbrSubsurface, setPbrTransmission } from '@babylonjs/lite';
3
+ import { Body1 } from '@fluentui/react-components';
4
+ import { useCallback } from 'react';
5
+ import { o as useObservableState, p as usePropertyChangedNotifier, T as TextPropertyLine, C as ComputedProperty, D as DerivedProperty, k as TextInputPropertyLine, q as GetMaterialOwningScenes, n as StringDropdownPropertyLine, N as NumberInputPropertyLine, f as SwitchPropertyLine, l as Color3PropertyLine, V as Vector2PropertyLine, m as NumberDropdownPropertyLine, r as Color4PropertyLine } from './index-Cy8gzpYG.js';
6
+ import { u as useLatestAsyncOperation } from './useLatestAsyncOperation-k59AgA3B.js';
7
+ import { D as DirectTextureBinding } from './directTextureBinding-C5MB2OV2.js';
8
+ import '@babylonjs/core/Misc/observable.js';
9
+ import '@fluentui/react-icons';
10
+ import '@babylonjs/core/Misc/dataStorage.js';
11
+ import '@babylonjs/core/Misc/asyncLock.js';
12
+ import '@babylonjs/core/Misc/deferred.js';
13
+ import '@fluentui-contrib/react-resize-handle';
14
+ import '@fluentui/react-motion-components-preview';
15
+ import '@babylonjs/core/Misc/logger.js';
16
+ import 'react-dom/client';
17
+ import '@fluentui-contrib/react-virtualizer';
18
+ import '@babylonjs/core/Misc/uniqueIdGenerator.js';
19
+ import '@babylonjs/core/Maths/math.color.js';
20
+ import '@babylonjs/core/Maths/math.vector.js';
21
+
22
+ const Rebuild = (apply, frameGraphParticipationChanged = false) => ({ mutation: "R", apply, frameGraphParticipationChanged });
23
+ const Uniform = (apply) => ({ mutation: "U", apply });
24
+ function Require(value, name) {
25
+ if (value == null) {
26
+ throw new Error(`${name} is no longer configured.`);
27
+ }
28
+ return value;
29
+ }
30
+ function ValidateNumber(value, id, min, max, integer = false) {
31
+ if (typeof value !== "number" || !Number.isFinite(value) || (integer && !Number.isInteger(value))) {
32
+ throw new TypeError(`Property "${id}" requires a finite${integer ? " integer" : ""} number.`);
33
+ }
34
+ if (min !== undefined && value < min) {
35
+ throw new RangeError(`Property "${id}" must be at least ${min}.`);
36
+ }
37
+ if (max !== undefined && value > max) {
38
+ throw new RangeError(`Property "${id}" must be at most ${max}.`);
39
+ }
40
+ }
41
+ function CopyTuple(value, length, id) {
42
+ if (!Array.isArray(value) || value.length !== length || value.some((component) => typeof component !== "number" || !Number.isFinite(component))) {
43
+ throw new TypeError(`Property "${id}" requires a ${length}-component finite tuple.`);
44
+ }
45
+ return [...value];
46
+ }
47
+ function SameValue(a, b) {
48
+ return Array.isArray(a) && Array.isArray(b) ? a.length === b.length && a.every((value, index) => Object.is(value, b[index])) : Object.is(a, b);
49
+ }
50
+ const TextureSlots = [
51
+ { id: "pbr.baseColor", label: "Base Color Texture", section: "textures", read: (m) => m.baseColorTexture },
52
+ { id: "pbr.normal", label: "Normal Texture", section: "textures", read: (m) => m.normalTexture },
53
+ { id: "pbr.orm", label: "ORM Texture", section: "textures", read: (m) => m.ormTexture },
54
+ { id: "pbr.occlusion", label: "Occlusion Texture", section: "textures", read: (m) => m.occlusionTexture },
55
+ { id: "pbr.emissive", label: "Emissive Texture", section: "textures", read: (m) => m.emissiveTexture },
56
+ { id: "pbr.specGloss", label: "Specular-Glossiness Texture", section: "textures", read: (m) => m.specGlossTexture },
57
+ { id: "pbr.lightmap", label: "Lightmap Texture", section: "lightmap", read: (m) => m.lightmapTexture, canClear: false, visible: (m) => !!m.lightmapTexture },
58
+ {
59
+ id: "pbr.metallicReflectance",
60
+ label: "Metallic Reflectance Texture",
61
+ section: "metallic-reflectance",
62
+ read: (m) => getPbrMetallicReflectance(m)?.texture,
63
+ canClear: false,
64
+ visible: (m) => !!getPbrMetallicReflectance(m),
65
+ },
66
+ {
67
+ id: "pbr.reflectance",
68
+ label: "Reflectance Texture",
69
+ section: "metallic-reflectance",
70
+ read: (m) => getPbrMetallicReflectance(m)?.reflectanceTexture,
71
+ canClear: false,
72
+ visible: (m) => !!getPbrMetallicReflectance(m),
73
+ },
74
+ { id: "pbr.clearCoat", label: "Clear Coat Texture", section: "clear-coat", read: (m) => getPbrClearCoat(m)?.texture, visible: (m) => !!getPbrClearCoat(m) },
75
+ {
76
+ id: "pbr.clearCoatRoughness",
77
+ label: "Clear Coat Roughness Texture",
78
+ section: "clear-coat",
79
+ read: (m) => getPbrClearCoat(m)?.roughnessTexture,
80
+ visible: (m) => !!getPbrClearCoat(m),
81
+ },
82
+ {
83
+ id: "pbr.clearCoatBump",
84
+ label: "Clear Coat Bump Texture",
85
+ section: "clear-coat",
86
+ read: (m) => getPbrClearCoat(m)?.bumpTexture,
87
+ visible: (m) => !!getPbrClearCoat(m),
88
+ },
89
+ { id: "pbr.sheen", label: "Sheen Color Texture", section: "sheen", read: (m) => getPbrSheen(m)?.texture, visible: (m) => !!getPbrSheen(m) },
90
+ { id: "pbr.sheenRoughness", label: "Sheen Roughness Texture", section: "sheen", read: (m) => getPbrSheen(m)?.roughnessTexture, visible: (m) => !!getPbrSheen(m) },
91
+ { id: "pbr.iridescence", label: "Iridescence Texture", section: "iridescence", read: (m) => getPbrIridescence(m)?.texture, visible: (m) => !!getPbrIridescence(m) },
92
+ {
93
+ id: "pbr.iridescenceThickness",
94
+ label: "Iridescence Thickness Texture",
95
+ section: "iridescence",
96
+ read: (m) => getPbrIridescence(m)?.thicknessTexture,
97
+ visible: (m) => !!getPbrIridescence(m),
98
+ },
99
+ { id: "pbr.anisotropy", label: "Anisotropy Texture", section: "anisotropy", read: (m) => getPbrAnisotropy(m)?.texture, visible: (m) => !!getPbrAnisotropy(m) },
100
+ {
101
+ id: "pbr.translucencyColor",
102
+ label: "Translucency Color Texture",
103
+ section: "subsurface-translucency",
104
+ read: (m) => getPbrSubsurface(m)?.translucency?.colorTexture,
105
+ visible: (m) => !!getPbrSubsurface(m)?.translucency,
106
+ },
107
+ {
108
+ id: "pbr.translucencyIntensity",
109
+ label: "Translucency Intensity Texture",
110
+ section: "subsurface-translucency",
111
+ read: (m) => getPbrSubsurface(m)?.translucency?.intensityTexture,
112
+ visible: (m) => !!getPbrSubsurface(m)?.translucency,
113
+ },
114
+ {
115
+ id: "pbr.thickness",
116
+ label: "Thickness Texture",
117
+ section: "subsurface-thickness",
118
+ read: (m) => getPbrSubsurface(m)?.thickness?.texture,
119
+ visible: (m) => !!getPbrSubsurface(m)?.thickness,
120
+ },
121
+ {
122
+ id: "pbr.transmission",
123
+ label: "Transmission Texture",
124
+ section: "transmission",
125
+ read: (m) => getPbrTransmission(m)?.texture,
126
+ visible: (m) => !!getPbrTransmission(m),
127
+ },
128
+ ];
129
+ function MatchesTexture2d(texture) {
130
+ return getTextureMetadata(texture)?.kind === "2d";
131
+ }
132
+ async function SetPbrTexture(material, id, texture) {
133
+ if (texture && !MatchesTexture2d(texture)) {
134
+ throw new TypeError(`Texture binding "${id}" requires a Texture2D value.`);
135
+ }
136
+ const value = (texture ?? undefined);
137
+ switch (id) {
138
+ case "pbr.baseColor":
139
+ material.baseColorTexture = value;
140
+ return;
141
+ case "pbr.normal":
142
+ material.normalTexture = value;
143
+ return;
144
+ case "pbr.orm":
145
+ material.ormTexture = value;
146
+ return;
147
+ case "pbr.occlusion":
148
+ material.occlusionTexture = value;
149
+ return;
150
+ case "pbr.emissive":
151
+ material.emissiveTexture = value;
152
+ return;
153
+ case "pbr.specGloss":
154
+ material.specGlossTexture = value;
155
+ return;
156
+ case "pbr.lightmap": {
157
+ const lightmap = Require(value, "PBR lightmap texture");
158
+ Require(material.lightmapTexture, "PBR lightmap");
159
+ const options = {
160
+ level: material.lightmapLevel ?? 1,
161
+ coordIndex: material.lightmapCoordIndex ?? 1,
162
+ useAsShadowmap: material.useLightmapAsShadowmap ?? false,
163
+ gamma: material.gammaLightmap ?? false,
164
+ };
165
+ await enablePbrLightmap();
166
+ setPbrLightmap(material, lightmap, options);
167
+ return;
168
+ }
169
+ case "pbr.metallicReflectance":
170
+ await MetallicPlan(material, { texture: Require(value, "PBR metallic reflectance texture") }).apply();
171
+ return;
172
+ case "pbr.reflectance":
173
+ await MetallicPlan(material, { reflectanceTexture: Require(value, "PBR reflectance texture") }).apply();
174
+ return;
175
+ case "pbr.clearCoat":
176
+ await ClearCoatPlan(material, { texture: value }).apply();
177
+ return;
178
+ case "pbr.clearCoatRoughness":
179
+ await ClearCoatPlan(material, { roughnessTexture: value }).apply();
180
+ return;
181
+ case "pbr.clearCoatBump":
182
+ await ClearCoatPlan(material, { bumpTexture: value }).apply();
183
+ return;
184
+ case "pbr.sheen":
185
+ await SheenPlan(material, { texture: value }).apply();
186
+ return;
187
+ case "pbr.sheenRoughness":
188
+ await SheenPlan(material, { roughnessTexture: value }).apply();
189
+ return;
190
+ case "pbr.iridescence":
191
+ await IridescencePlan(material, { texture: value }).apply();
192
+ return;
193
+ case "pbr.iridescenceThickness":
194
+ await IridescencePlan(material, { thicknessTexture: value }).apply();
195
+ return;
196
+ case "pbr.anisotropy":
197
+ await AnisotropyPlan(material, { texture: value }).apply();
198
+ return;
199
+ case "pbr.translucencyColor":
200
+ await SubsurfacePlan(material, "translucency", { colorTexture: value }).apply();
201
+ return;
202
+ case "pbr.translucencyIntensity":
203
+ await SubsurfacePlan(material, "translucency", { intensityTexture: value }).apply();
204
+ return;
205
+ case "pbr.thickness":
206
+ await SubsurfacePlan(material, "thickness", { texture: value }).apply();
207
+ return;
208
+ case "pbr.transmission":
209
+ await TransmissionPlan(material, { texture: value }).apply();
210
+ return;
211
+ }
212
+ }
213
+ const StencilCompareOptions = [
214
+ { value: "never", label: "Never" },
215
+ { value: "less", label: "Less" },
216
+ { value: "equal", label: "Equal" },
217
+ { value: "less-equal", label: "Less or Equal" },
218
+ { value: "greater", label: "Greater" },
219
+ { value: "not-equal", label: "Not Equal" },
220
+ { value: "greater-equal", label: "Greater or Equal" },
221
+ { value: "always", label: "Always" },
222
+ ];
223
+ const StencilOperationOptions = [
224
+ { value: "keep", label: "Keep" },
225
+ { value: "zero", label: "Zero" },
226
+ { value: "replace", label: "Replace" },
227
+ { value: "invert", label: "Invert" },
228
+ { value: "increment-clamp", label: "Increment Clamp" },
229
+ { value: "decrement-clamp", label: "Decrement Clamp" },
230
+ { value: "increment-wrap", label: "Increment Wrap" },
231
+ { value: "decrement-wrap", label: "Decrement Wrap" },
232
+ ];
233
+ const CoordinatesOptions = [
234
+ { value: 0, label: "UV1" },
235
+ { value: 1, label: "UV2" },
236
+ ];
237
+ const PbrRows = (props) => {
238
+ const { target, commit, operations, section } = props;
239
+ const row = (id, label, control) => {
240
+ const operation = operations[id];
241
+ return (jsxs("div", { "aria-busy": operation?.pending, children: [control, operation?.pending ? jsx(Body1, { role: "status", children: `Applying ${label}…` }) : undefined, operation?.error ? jsx(Body1, { role: "alert", children: operation.error }) : undefined] }, id));
242
+ };
243
+ const common = (id, label) => ({
244
+ label,
245
+ uniqueId: id,
246
+ disabled: operations[id]?.pending,
247
+ description: operations[id]?.error ? `Error: ${operations[id].error}` : undefined,
248
+ });
249
+ const number = (id, label, read, prepare, min, max, integer = false) => row(id, label, jsx(DerivedProperty, { component: NumberInputPropertyLine, target: target, getValue: read, setValue: (_, value) => commit(id, read, value, prepare, (next) => ValidateNumber(next, id, min, max, integer)), ...common(id, label), min: min, max: max, step: integer ? 1 : undefined }));
250
+ const toggle = (id, label, read, prepare) => row(id, label, jsx(DerivedProperty, { component: SwitchPropertyLine, target: target, getValue: read, setValue: (_, value) => commit(id, read, value, prepare, (next) => {
251
+ if (typeof next !== "boolean") {
252
+ throw new TypeError(`Property "${id}" requires a boolean.`);
253
+ }
254
+ }), ...common(id, label) }));
255
+ const color3 = (id, label, read, prepare) => row(id, label, jsx(DerivedProperty, { component: Color3PropertyLine, target: target, getValue: read, setValue: (_, value) => commit(id, read, ("r" in value ? [value.r, value.g, value.b] : value), prepare, (next) => CopyTuple(next, 3, id)), ...common(id, label), isLinearMode: true }));
256
+ const color4 = (id, label, read, prepare) => row(id, label, jsx(DerivedProperty, { component: Color4PropertyLine, target: target, getValue: read, setValue: (_, value) => commit(id, read, ("r" in value ? [value.r, value.g, value.b, value.a] : value), prepare, (next) => CopyTuple(next, 4, id)), ...common(id, label), isLinearMode: true }));
257
+ const vector2 = (id, label, read, prepare) => row(id, label, jsx(DerivedProperty, { component: Vector2PropertyLine, target: target, getValue: read, setValue: (_, value) => commit(id, read, ("x" in value ? [value.x, value.y] : value), prepare, (next) => CopyTuple(next, 2, id)), ...common(id, label) }));
258
+ const choice = (id, label, read, prepare) => row(id, label, jsx(DerivedProperty, { component: NumberDropdownPropertyLine, target: target, getValue: read, setValue: (_, value) => commit(id, read, value, prepare, (next) => {
259
+ if (!CoordinatesOptions.some((option) => option.value === next)) {
260
+ throw new RangeError(`Property "${id}" does not accept enum value "${next}".`);
261
+ }
262
+ }), ...common(id, label), options: CoordinatesOptions }));
263
+ const stencil = (id, label, key, options) => target.stencil
264
+ ? row(id, label, jsx(DerivedProperty, { component: StringDropdownPropertyLine, target: target, getValue: (material) => material.stencil?.[key] ?? (key === "compare" ? "always" : "keep"), setValue: (_, value) => commit(id, (material) => material.stencil?.[key] ?? (key === "compare" ? "always" : "keep"), value, (material, next) => {
265
+ const current = Require(material.stencil, "PBR stencil");
266
+ return Rebuild(() => {
267
+ enableMaterialStencil();
268
+ material.stencil = { ...current, [key]: next };
269
+ });
270
+ }, (next) => {
271
+ if (!options.some((option) => option.value === next)) {
272
+ throw new RangeError(`Property "${id}" does not accept enum value "${next}".`);
273
+ }
274
+ }), ...common(id, label), options: options }))
275
+ : row(id, label, jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: () => "Not configured", label: label, uniqueId: id }));
276
+ const stencilMask = (id, label, key) => target.stencil
277
+ ? number(id, label, (material) => material.stencil?.[key] ?? 0xff, (material, value) => {
278
+ const current = Require(material.stencil, "PBR stencil");
279
+ return Rebuild(() => {
280
+ enableMaterialStencil();
281
+ material.stencil = { ...current, [key]: value };
282
+ });
283
+ }, 0, 0xffffffff, true)
284
+ : row(id, label, jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: () => "Not configured", label: label, uniqueId: id }));
285
+ const readOnly = (id, label, read, reason) => row(id, label, jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: (material) => {
286
+ const value = read(material);
287
+ return Array.isArray(value) ? `[${value.join(", ")}]` : String(value);
288
+ }, label: label, uniqueId: id, description: `${reason} is a one-way public mode and has no reversible setter.` }));
289
+ switch (section) {
290
+ case "general":
291
+ return (jsxs(Fragment, { children: [row("material.name", "Name", jsx(DerivedProperty, { component: TextInputPropertyLine, target: target, getValue: (m) => m.name ?? "", setValue: (_, value) => commit("material.name", (m) => m.name ?? "", value, (m, next) => ({ mutation: "A", apply: () => (m.name = next) }), (next) => {
292
+ if (typeof next !== "string") {
293
+ throw new TypeError('Property "material.name" requires a string.');
294
+ }
295
+ }), ...common("material.name", "Name") })), toggle("pbr.doubleSided", "Double Sided", (m) => m.doubleSided ?? false, (m, v) => Rebuild(() => (m.doubleSided = v))), toggle("pbr.alphaBlend", "Alpha Blend", (m) => m.alphaBlend ?? false, (m, v) => Rebuild(() => (m.alphaBlend = v))), toggle("pbr.enableSpecularAA", "Specular Anti-Aliasing", (m) => m.enableSpecularAA ?? false, (m, v) => Rebuild(() => (m.enableSpecularAA = v)))] }));
296
+ case "transparency":
297
+ return (jsxs(Fragment, { children: [number("pbr.alpha", "Alpha", (m) => m.alpha ?? 1, (m, v) => {
298
+ const cutoff = getPbrAlphaCutoff(m) ?? 0;
299
+ return ((m.alpha ?? 1) < 1 && cutoff <= 0) === (v < 1 && cutoff <= 0) ? Uniform(() => (m.alpha = v)) : Rebuild(() => (m.alpha = v));
300
+ }, 0, 1), getPbrAlphaCutoff(target) === undefined
301
+ ? row("pbr.alphaCutOff", "Alpha Cutoff", jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: () => "Not configured", label: "Alpha Cutoff", uniqueId: "pbr.alphaCutOff" }))
302
+ : number("pbr.alphaCutOff", "Alpha Cutoff", (m) => getPbrAlphaCutoff(m) ?? 0, (m, v) => ((getPbrAlphaCutoff(m) ?? 0) > 0 === v > 0 ? Uniform(() => setPbrAlphaCutoff(m, v)) : Rebuild(() => setPbrAlphaCutoff(m, v))))] }));
303
+ case "lighting-colors":
304
+ return (jsxs(Fragment, { children: [target.baseColorFactor
305
+ ? color4("pbr.baseColorFactor", "Base Color Factor", (m) => m.baseColorFactor ?? [1, 1, 1, 1], (m, v) => (m.baseColorFactor === undefined ? Rebuild(() => (m.baseColorFactor = [...v])) : Uniform(() => (m.baseColorFactor = [...v]))))
306
+ : row("pbr.baseColorFactor", "Base Color Factor", jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: () => "Not configured", label: "Base Color Factor", uniqueId: "pbr.baseColorFactor" })), getPbrEmissiveColor(target)
307
+ ? color3("pbr.emissiveColor", "Emissive Color", (m) => getPbrEmissiveColor(m) ?? [0, 0, 0], (m, v) => (getPbrEmissiveColor(m) === undefined ? Rebuild(() => setPbrEmissive(m, [...v])) : Uniform(() => setPbrEmissive(m, [...v]))))
308
+ : row("pbr.emissiveColor", "Emissive Color", jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: () => "Not configured", label: "Emissive Color", uniqueId: "pbr.emissiveColor" })), number("pbr.environmentIntensity", "Environment Intensity", (m) => m.environmentIntensity ?? 1, (m, v) => Uniform(() => (m.environmentIntensity = v))), number("pbr.directIntensity", "Direct Intensity", (m) => m.directIntensity ?? 1, (m, v) => Uniform(() => (m.directIntensity = v))), number("pbr.reflectance", "Reflectance", (m) => m.reflectance ?? 0.04, (m, v) => Uniform(() => (m.reflectance = v))), number("pbr.metallicFactor", "Metallic Factor", (m) => m.metallicFactor ?? 1, (m, v) => Uniform(() => (m.metallicFactor = v))), number("pbr.roughnessFactor", "Roughness Factor", (m) => m.roughnessFactor ?? 1, (m, v) => Uniform(() => (m.roughnessFactor = v))), number("pbr.normalTextureScale", "Normal Texture Scale", (m) => m.normalTextureScale ?? 1, (m, v) => Uniform(() => (m.normalTextureScale = v))), toggle("pbr.usePhysicalLightFalloff", "Use Physical Light Falloff", (m) => m.usePhysicalLightFalloff ?? true, (m, v) => Uniform(() => (m.usePhysicalLightFalloff = v)))] }));
309
+ case "occlusion":
310
+ return (jsxs(Fragment, { children: [number("pbr.occlusionStrength", "Occlusion Strength", (m) => m.occlusionStrength ?? 1, (m, v) => Uniform(() => (m.occlusionStrength = v)), 0, 1), row("pbr.occlusionTexCoord", "Occlusion Coordinates", jsx(ComputedProperty, { component: TextPropertyLine, target: target, getValue: (m) => String(m.occlusionTexCoord ?? 0), label: "Occlusion Coordinates", uniqueId: "pbr.occlusionTexCoord", description: "Changing the occlusion UV set requires a public setter that maintains the UV2 claim." }))] }));
311
+ case "lightmap":
312
+ if (!target.lightmapTexture) {
313
+ return null;
314
+ }
315
+ return (jsxs(Fragment, { children: [number("pbr.lightmapLevel", "Level", (m) => m.lightmapLevel ?? 1, (m, v) => LightmapPlan(m, { level: v })), choice("pbr.lightmapCoordIndex", "Coordinates", (m) => m.lightmapCoordIndex ?? 1, (m, v) => LightmapPlan(m, { coordIndex: v })), toggle("pbr.useLightmapAsShadowmap", "Use as Shadowmap", (m) => m.useLightmapAsShadowmap ?? false, (m, v) => LightmapPlan(m, { useAsShadowmap: v })), toggle("pbr.gammaLightmap", "Gamma Decode", (m) => m.gammaLightmap ?? false, (m, v) => LightmapPlan(m, { gamma: v }))] }));
316
+ case "metallic-reflectance":
317
+ if (!getPbrMetallicReflectance(target)) {
318
+ return null;
319
+ }
320
+ return (jsxs(Fragment, { children: [color3("pbr.metallicReflectanceColor", "Metallic Reflectance Color", (m) => getPbrMetallicReflectance(m)?.color ?? [1, 1, 1], (m, v) => MetallicPlan(m, { color: [...v] })), number("pbr.metallicF0Factor", "Metallic F0 Factor", (m) => getPbrMetallicReflectance(m)?.f0Factor ?? 1, (m, v) => MetallicPlan(m, { f0Factor: v })), number("pbr.specularWeight", "Specular Weight", (m) => getPbrMetallicReflectance(m)?.specularWeight ?? getPbrMetallicReflectance(m)?.f0Factor ?? 1, (m, v) => MetallicPlan(m, { specularWeight: v })), toggle("pbr.useOnlyMetallicFromTexture", "Use Only Metallic From Texture", (m) => getPbrMetallicReflectance(m)?.useOnlyMetallicFromTexture ?? false, (m, v) => MetallicPlan(m, { useOnlyMetallicFromTexture: v }))] }));
321
+ case "clear-coat":
322
+ if (!getPbrClearCoat(target)) {
323
+ return null;
324
+ }
325
+ return (jsxs(Fragment, { children: [toggle("pbr.clearCoat.enabled", "Enabled", (m) => getPbrClearCoat(m)?.isEnabled ?? false, (m, v) => ClearCoatPlan(m, { isEnabled: v })), number("pbr.clearCoat.intensity", "Intensity", (m) => getPbrClearCoat(m)?.intensity ?? 1, (m, v) => ClearCoatPlan(m, { intensity: v }), 0, 1), number("pbr.clearCoat.roughness", "Roughness", (m) => getPbrClearCoat(m)?.roughness ?? 0, (m, v) => ClearCoatPlan(m, { roughness: v }), 0, 1), number("pbr.clearCoat.indexOfRefraction", "Index of Refraction", (m) => getPbrClearCoat(m)?.indexOfRefraction ?? 1.5, (m, v) => ClearCoatPlan(m, { indexOfRefraction: v })), toggle("pbr.clearCoat.useF0Remap", "F0 Remap", (m) => getPbrClearCoat(m)?.useF0Remap ?? true, (m, v) => ClearCoatPlan(m, { useF0Remap: v })), number("pbr.clearCoat.bumpTextureScale", "Bump Texture Scale", (m) => getPbrClearCoat(m)?.bumpTextureScale ?? 1, (m, v) => ClearCoatPlan(m, { bumpTextureScale: v }))] }));
326
+ case "sheen":
327
+ if (!getPbrSheen(target)) {
328
+ return null;
329
+ }
330
+ return (jsxs(Fragment, { children: [toggle("pbr.sheen.enabled", "Enabled", (m) => getPbrSheen(m)?.isEnabled ?? false, (m, v) => SheenPlan(m, { isEnabled: v })), color3("pbr.sheen.color", "Color", (m) => getPbrSheen(m)?.color ?? [1, 1, 1], (m, v) => SheenPlan(m, { color: [...v] })), number("pbr.sheen.roughness", "Roughness", (m) => getPbrSheen(m)?.roughness ?? 0, (m, v) => SheenPlan(m, { roughness: v }), 0, 1), number("pbr.sheen.intensity", "Intensity", (m) => getPbrSheen(m)?.intensity ?? 1, (m, v) => SheenPlan(m, { intensity: v }), 0, 1), toggle("pbr.sheen.albedoScaling", "Albedo Scaling", (m) => getPbrSheen(m)?.albedoScaling ?? false, (m, v) => SheenPlan(m, { albedoScaling: v }))] }));
331
+ case "iridescence":
332
+ if (!getPbrIridescence(target)) {
333
+ return null;
334
+ }
335
+ return (jsxs(Fragment, { children: [toggle("pbr.iridescence.enabled", "Enabled", (m) => getPbrIridescence(m)?.isEnabled ?? false, (m, v) => IridescencePlan(m, { isEnabled: v })), number("pbr.iridescence.intensity", "Intensity", (m) => getPbrIridescence(m)?.intensity ?? 1, (m, v) => IridescencePlan(m, { intensity: v }), 0, 1), number("pbr.iridescence.indexOfRefraction", "Index of Refraction", (m) => getPbrIridescence(m)?.indexOfRefraction ?? 1.3, (m, v) => IridescencePlan(m, { indexOfRefraction: v })), number("pbr.iridescence.minimumThickness", "Minimum Thickness", (m) => getPbrIridescence(m)?.minimumThickness ?? 100, (m, v) => IridescencePlan(m, { minimumThickness: v })), number("pbr.iridescence.maximumThickness", "Maximum Thickness", (m) => getPbrIridescence(m)?.maximumThickness ?? 400, (m, v) => IridescencePlan(m, { maximumThickness: v }))] }));
336
+ case "anisotropy":
337
+ if (!getPbrAnisotropy(target)) {
338
+ return null;
339
+ }
340
+ return (jsxs(Fragment, { children: [toggle("pbr.anisotropy.enabled", "Enabled", (m) => getPbrAnisotropy(m)?.isEnabled ?? false, (m, v) => AnisotropyPlan(m, { isEnabled: v })), number("pbr.anisotropy.intensity", "Intensity", (m) => getPbrAnisotropy(m)?.intensity ?? 1, (m, v) => AnisotropyPlan(m, { intensity: v }), 0, 1), vector2("pbr.anisotropy.direction", "Direction", (m) => getPbrAnisotropy(m)?.direction ?? [1, 0], (m, v) => AnisotropyPlan(m, { direction: [...v] }))] }));
341
+ case "subsurface-translucency":
342
+ if (!getPbrSubsurface(target)?.translucency) {
343
+ return null;
344
+ }
345
+ return (jsxs(Fragment, { children: [number("pbr.translucency.intensity", "Intensity", (m) => getPbrSubsurface(m)?.translucency?.intensity ?? 1, (m, v) => SubsurfacePlan(m, "translucency", { intensity: v }), 0, 1), color3("pbr.translucency.color", "Color", (m) => getPbrSubsurface(m)?.translucency?.color ?? [1, 1, 1], (m, v) => SubsurfacePlan(m, "translucency", { color: [...v] })), color3("pbr.translucency.diffusionDistance", "Diffusion Distance", (m) => getPbrSubsurface(m)?.translucency?.diffusionDistance ?? [1, 1, 1], (m, v) => SubsurfacePlan(m, "translucency", { diffusionDistance: [...v] }))] }));
346
+ case "subsurface-thickness":
347
+ if (!getPbrSubsurface(target)?.thickness) {
348
+ return null;
349
+ }
350
+ return (jsxs(Fragment, { children: [number("pbr.thickness.min", "Minimum", (m) => getPbrSubsurface(m)?.thickness?.min ?? 0, (m, v) => SubsurfacePlan(m, "thickness", { min: v })), number("pbr.thickness.max", "Maximum", (m) => getPbrSubsurface(m)?.thickness?.max ?? 1, (m, v) => SubsurfacePlan(m, "thickness", { max: v })), toggle("pbr.thickness.useGlTFChannel", "Use glTF Channel", (m) => getPbrSubsurface(m)?.thickness?.useGlTFChannel ?? false,
351
+ // eslint-disable-next-line @typescript-eslint/naming-convention
352
+ (m, v) => SubsurfacePlan(m, "thickness", { useGlTFChannel: v }))] }));
353
+ case "subsurface-tint":
354
+ if (!getPbrSubsurface(target)?.tint) {
355
+ return null;
356
+ }
357
+ return (jsxs(Fragment, { children: [color3("pbr.tint.color", "Color", (m) => getPbrSubsurface(m)?.tint?.color ?? [1, 1, 1], (m, v) => SubsurfacePlan(m, "tint", { color: [...v] })), number("pbr.tint.atDistance", "Distance", (m) => getPbrSubsurface(m)?.tint?.atDistance ?? 1, (m, v) => SubsurfacePlan(m, "tint", { atDistance: v }))] }));
358
+ case "transmission":
359
+ if (!getPbrTransmission(target)) {
360
+ return null;
361
+ }
362
+ return (jsxs(Fragment, { children: [number("pbr.transmission.intensity", "Intensity", (m) => getPbrTransmission(m)?.intensity ?? 0, (m, v) => TransmissionPlan(m, { intensity: v }), 0, 1), number("pbr.transmission.indexOfRefraction", "Index of Refraction", (m) => getPbrTransmission(m)?.indexOfRefraction ?? 1.5, (m, v) => TransmissionPlan(m, { indexOfRefraction: v })), toggle("pbr.transmission.useThicknessAsDepth", "Use Thickness as Depth", (m) => getPbrTransmission(m)?.useThicknessAsDepth ?? false, (m, v) => TransmissionPlan(m, { useThicknessAsDepth: v })), getPbrTransmission(target)?.dispersion !== undefined
363
+ ? number("pbr.transmission.dispersion", "Dispersion", (m) => getPbrTransmission(m)?.dispersion ?? 0, (m, v) => {
364
+ Require(getPbrTransmission(m)?.dispersion, "PBR dispersion");
365
+ return Rebuild(() => setPbrDispersion(m, v));
366
+ })
367
+ : null] }));
368
+ case "special-modes": {
369
+ const unlit = getPbrUnlit(target);
370
+ const shadowOnly = getShadowOnly(target);
371
+ return (jsxs(Fragment, { children: [unlit ? readOnly("pbr.mode.unlit", "Unlit", () => true, "Unlit") : null, unlit ? readOnly("pbr.mode.unlitColor", "Unlit Color", (m) => getPbrUnlit(m) ?? [0, 0, 0], "Unlit tint") : null, isPbrGammaAlbedo(target) ? readOnly("pbr.mode.gammaAlbedo", "Gamma Albedo", () => true, "Gamma albedo") : null, isPbrSkybox(target) ? readOnly("pbr.mode.skybox", "Skybox", () => true, "Skybox") : null, shadowOnly ? readOnly("pbr.mode.shadowOnly", "Shadow Only", () => true, "Shadow-only") : null, shadowOnly ? readOnly("pbr.mode.shadowOnlyColor", "Shadow Color", (m) => getShadowOnly(m)?.color ?? [0, 0, 0], "Shadow-only color") : null, shadowOnly ? readOnly("pbr.mode.shadowOnlyOpacity", "Shadow Opacity", (m) => getShadowOnly(m)?.opacity ?? 0, "Shadow-only opacity") : null, shadowOnly ? readOnly("pbr.mode.shadowOnlyFalloff", "Shadow Falloff", (m) => getShadowOnly(m)?.falloff ?? 0, "Shadow-only falloff") : null] }));
372
+ }
373
+ case "stencil":
374
+ return (jsxs(Fragment, { children: [stencil("pbr.stencil.compare", "Stencil Compare", "compare", StencilCompareOptions), stencil("pbr.stencil.passOp", "Stencil Pass Operation", "passOp", StencilOperationOptions), stencil("pbr.stencil.failOp", "Stencil Fail Operation", "failOp", StencilOperationOptions), stencil("pbr.stencil.depthFailOp", "Stencil Depth Fail Operation", "depthFailOp", StencilOperationOptions), stencilMask("pbr.stencil.readMask", "Stencil Read Mask", "readMask"), stencilMask("pbr.stencil.writeMask", "Stencil Write Mask", "writeMask")] }));
375
+ default:
376
+ return null;
377
+ }
378
+ };
379
+ function LightmapPlan(material, patch) {
380
+ const texture = Require(material.lightmapTexture, "PBR lightmap");
381
+ const options = {
382
+ level: material.lightmapLevel ?? 1,
383
+ coordIndex: material.lightmapCoordIndex ?? 1,
384
+ useAsShadowmap: material.useLightmapAsShadowmap ?? false,
385
+ gamma: material.gammaLightmap ?? false,
386
+ ...patch,
387
+ };
388
+ return Rebuild(async () => {
389
+ await enablePbrLightmap();
390
+ setPbrLightmap(material, texture, options);
391
+ });
392
+ }
393
+ function MetallicPlan(material, patch) {
394
+ const current = Require(getPbrMetallicReflectance(material), "PBR metallic reflectance");
395
+ return Rebuild(() => setPbrMetallicReflectance(material, {
396
+ color: [...(current.color ?? [1, 1, 1])],
397
+ texture: current.texture,
398
+ reflectanceTexture: current.reflectanceTexture,
399
+ f0Factor: current.f0Factor ?? 1,
400
+ specularWeight: current.specularWeight ?? current.f0Factor ?? 1,
401
+ useOnlyMetallicFromTexture: current.useOnlyMetallicFromTexture ?? false,
402
+ ...patch,
403
+ }));
404
+ }
405
+ function ClearCoatPlan(material, patch) {
406
+ const current = Require(getPbrClearCoat(material), "PBR clear coat");
407
+ return Rebuild(() => setPbrClearCoat(material, {
408
+ isEnabled: current.isEnabled ?? false,
409
+ intensity: current.intensity ?? 1,
410
+ roughness: current.roughness ?? 0,
411
+ indexOfRefraction: current.indexOfRefraction ?? 1.5,
412
+ texture: current.texture,
413
+ roughnessTexture: current.roughnessTexture,
414
+ bumpTexture: current.bumpTexture,
415
+ bumpTextureScale: current.bumpTextureScale ?? 1,
416
+ useF0Remap: current.useF0Remap ?? true,
417
+ ...patch,
418
+ }));
419
+ }
420
+ function SheenPlan(material, patch) {
421
+ const current = Require(getPbrSheen(material), "PBR sheen");
422
+ return Rebuild(() => setPbrSheen(material, {
423
+ isEnabled: current.isEnabled ?? false,
424
+ color: [...(current.color ?? [1, 1, 1])],
425
+ roughness: current.roughness ?? 0,
426
+ intensity: current.intensity ?? 1,
427
+ texture: current.texture,
428
+ roughnessTexture: current.roughnessTexture,
429
+ albedoScaling: current.albedoScaling ?? false,
430
+ ...patch,
431
+ }));
432
+ }
433
+ function IridescencePlan(material, patch) {
434
+ const current = Require(getPbrIridescence(material), "PBR iridescence");
435
+ return Rebuild(() => setPbrIridescence(material, {
436
+ isEnabled: current.isEnabled ?? false,
437
+ intensity: current.intensity ?? 1,
438
+ indexOfRefraction: current.indexOfRefraction ?? 1.3,
439
+ minimumThickness: current.minimumThickness ?? 100,
440
+ maximumThickness: current.maximumThickness ?? 400,
441
+ texture: current.texture,
442
+ thicknessTexture: current.thicknessTexture,
443
+ ...patch,
444
+ }));
445
+ }
446
+ function AnisotropyPlan(material, patch) {
447
+ const current = Require(getPbrAnisotropy(material), "PBR anisotropy");
448
+ return Rebuild(() => setPbrAnisotropy(material, {
449
+ isEnabled: current.isEnabled ?? false,
450
+ intensity: current.intensity ?? 1,
451
+ direction: [...(current.direction ?? [1, 0])],
452
+ texture: current.texture,
453
+ ...patch,
454
+ }));
455
+ }
456
+ function SubsurfacePlan(material, key, patch) {
457
+ const current = Require(getPbrSubsurface(material), "PBR subsurface");
458
+ Require(current[key], `PBR ${key}`);
459
+ const subsurface = {
460
+ translucency: current.translucency
461
+ ? {
462
+ intensity: current.translucency.intensity ?? 1,
463
+ color: [...(current.translucency.color ?? [1, 1, 1])],
464
+ colorTexture: current.translucency.colorTexture,
465
+ intensityTexture: current.translucency.intensityTexture,
466
+ diffusionDistance: [...(current.translucency.diffusionDistance ?? [1, 1, 1])],
467
+ }
468
+ : undefined,
469
+ scattering: current.scattering ? { ...current.scattering } : undefined,
470
+ thickness: current.thickness
471
+ ? {
472
+ texture: current.thickness.texture,
473
+ // eslint-disable-next-line @typescript-eslint/naming-convention
474
+ useGlTFChannel: current.thickness.useGlTFChannel ?? false,
475
+ min: current.thickness.min ?? 0,
476
+ max: current.thickness.max ?? 1,
477
+ }
478
+ : undefined,
479
+ tint: current.tint ? { color: [...(current.tint.color ?? [1, 1, 1])], atDistance: current.tint.atDistance } : undefined,
480
+ refraction: current.refraction ? { ...current.refraction } : undefined,
481
+ };
482
+ Object.assign(subsurface[key], patch);
483
+ return Rebuild(() => setPbrSubsurface(material, subsurface));
484
+ }
485
+ function TransmissionPlan(material, patch) {
486
+ const current = Require(getPbrTransmission(material), "PBR transmission");
487
+ const next = {
488
+ intensity: current.intensity ?? 0,
489
+ texture: current.texture,
490
+ indexOfRefraction: current.indexOfRefraction ?? 1.5,
491
+ useThicknessAsDepth: current.useThicknessAsDepth ?? false,
492
+ dispersion: current.dispersion,
493
+ ...patch,
494
+ };
495
+ const active = (current.intensity ?? 0) > 0;
496
+ return Rebuild(() => setPbrTransmission(material, next), active !== next.intensity > 0);
497
+ }
498
+ /**
499
+ * Renders PBR property rows and texture bindings directly from Lite.
500
+ * @param props The selected PBR material, section, and instance services.
501
+ * @returns The PBR property rows for the requested section.
502
+ */
503
+ const PbrMaterialAdapter = (props) => {
504
+ const { material, section, resourceIndexService, selectionService } = props;
505
+ const getSource = () => {
506
+ try {
507
+ return getMaterialSource(material);
508
+ }
509
+ catch {
510
+ return undefined;
511
+ }
512
+ };
513
+ const source = getSource();
514
+ const getRecord = useCallback(() => (source && !resourceIndexService.isDisposed ? resourceIndexService.getMaterialRecord(source) : undefined), [source, resourceIndexService]);
515
+ const record = useObservableState(getRecord, resourceIndexService.onChanged);
516
+ const isDisposed = useCallback(() => resourceIndexService.isDisposed, [resourceIndexService]);
517
+ const [operations, runLatestOperation] = useLatestAsyncOperation(material, [resourceIndexService.onDisposed, selectionService.onSelectedEntityChanged], isDisposed);
518
+ const notifyPropertyChanged = usePropertyChangedNotifier();
519
+ const target = material;
520
+ const commit = (id, read, value, prepare, validate) => {
521
+ runLatestOperation({
522
+ id,
523
+ operationAsync: async () => {
524
+ validate?.(value);
525
+ const current = getRecord();
526
+ if (!current || current.family !== "pbr" || !source) {
527
+ throw new Error("This material is no longer available in an inspected scene.");
528
+ }
529
+ const scenes = GetMaterialOwningScenes(current, material);
530
+ if (!scenes.length) {
531
+ throw new Error("This material is no longer reachable from an inspected scene.");
532
+ }
533
+ const oldValue = read(target);
534
+ const plan = prepare(target, value);
535
+ if (SameValue(oldValue, value)) {
536
+ return { changed: false, oldValue };
537
+ }
538
+ await plan.apply();
539
+ if (plan.mutation === "U") {
540
+ markMaterialUboDirty(target);
541
+ }
542
+ else if (plan.mutation === "R") {
543
+ await Promise.all(scenes.map(async (scene) => {
544
+ await rebuildMaterial(scene, target, { rebuildViews: true, rebuildFrameGraph: plan.frameGraphParticipationChanged === true });
545
+ }));
546
+ }
547
+ return { changed: true, oldValue };
548
+ },
549
+ onSuccess: ({ changed, oldValue }) => {
550
+ if (changed && source) {
551
+ const key = id === "material.name" ? "name" : id.slice(id.lastIndexOf(".") + 1);
552
+ notifyPropertyChanged(material, Reflect.has(material, key) ? key : id, oldValue, value);
553
+ }
554
+ resourceIndexService.refresh();
555
+ },
556
+ getErrorMessage: (error) => (error instanceof Error ? error.message : "The material change failed."),
557
+ });
558
+ };
559
+ const commitTexture = (change) => {
560
+ const { id, oldValue, newValue, apply, invalidate, rebuildFrameGraph } = change;
561
+ runLatestOperation({
562
+ id,
563
+ operationAsync: async () => {
564
+ const current = getRecord();
565
+ if (!current || current.family !== "pbr" || !source) {
566
+ throw new Error("This material is no longer available in an inspected scene.");
567
+ }
568
+ const scenes = GetMaterialOwningScenes(current, material);
569
+ if (!scenes.length) {
570
+ throw new Error("This material is no longer reachable from an inspected scene.");
571
+ }
572
+ if (SameValue(oldValue, newValue)) {
573
+ return false;
574
+ }
575
+ await apply();
576
+ if (invalidate === "ubo") {
577
+ markMaterialUboDirty(target);
578
+ }
579
+ else if (invalidate === "rebuild") {
580
+ await Promise.all(scenes.map(async (scene) => {
581
+ await rebuildMaterial(scene, target, { rebuildViews: true, rebuildFrameGraph: rebuildFrameGraph === true });
582
+ }));
583
+ }
584
+ return true;
585
+ },
586
+ onSuccess: (changed) => {
587
+ if (changed && source) {
588
+ const key = `${id.slice("pbr.".length)}Texture`;
589
+ notifyPropertyChanged(material, id.startsWith("pbr.") && Reflect.has(material, key) ? key : id, oldValue, newValue);
590
+ }
591
+ resourceIndexService.refresh();
592
+ },
593
+ getErrorMessage: (error) => (error instanceof Error ? error.message : "The material texture change failed."),
594
+ });
595
+ };
596
+ if (!record || !source) {
597
+ return jsx(TextPropertyLine, { label: "Error", value: "This material is no longer available in an inspected scene." });
598
+ }
599
+ if (record.family !== "pbr" || getMaterialFamily(source) !== "pbr") {
600
+ return jsx(TextPropertyLine, { label: "Error", value: `The material family changed from pbr to ${record.family ?? "unknown"}.` });
601
+ }
602
+ return (jsxs(Fragment, { children: [section === "general" ? (jsxs(Fragment, { children: [jsx(TextPropertyLine, { label: "Family", value: "pbr" }), jsx(TextPropertyLine, { label: "Selection", value: isMaterialView(material) ? "MaterialView" : "Material" }), isMaterialView(material) ? jsx(TextPropertyLine, { label: "Source", value: record.displayName }) : undefined] })) : undefined, jsx(PbrRows, { target: target, section: section, operations: operations, commit: commit }), TextureSlots.filter((slot) => slot.section === section && (!("visible" in slot) || slot.visible(target))).map((slot) => {
603
+ const value = slot.read(target);
604
+ return (jsx(DirectTextureBinding, { id: slot.id, label: slot.label, record: record, resourceIndexService: resourceIndexService, selectionService: selectionService, operations: operations, commit: commitTexture, value: value, read: () => slot.read(target), acceptedKinds: ["2d"], canClear: !("canClear" in slot) || slot.canClear, invalidate: "rebuild", apply: async (texture) => {
605
+ if ((slot.read(target) ?? null) !== (value ?? null)) {
606
+ throw new Error(`Texture binding "${slot.id}" is stale.`);
607
+ }
608
+ await SetPbrTexture(target, slot.id, texture);
609
+ } }, slot.id));
610
+ })] }));
611
+ };
612
+
613
+ export { PbrMaterialAdapter };
614
+ //# sourceMappingURL=pbrMaterialProperties-jfJddBxY.js.map