@babylonjs/shared-ui-components 9.14.0 → 9.16.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/nodeGraphSystem/graphNode.js +5 -10
- package/nodeGraphSystem/graphNode.js.map +1 -1
- package/package.json +1 -1
- package/projects/overrideEntry.d.ts +36 -0
- package/projects/overrideEntry.js +2 -0
- package/projects/overrideEntry.js.map +1 -0
- package/projects/overrideManager.d.ts +176 -0
- package/projects/overrideManager.js +576 -0
- package/projects/overrideManager.js.map +1 -0
- package/projects/projectFile.d.ts +143 -0
- package/projects/projectFile.js +582 -0
- package/projects/projectFile.js.map +1 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { type Scene } from "@babylonjs/core/scene.js";
|
|
2
|
+
import { Observable, type Observer } from "@babylonjs/core/Misc/observable.js";
|
|
3
|
+
import { type IOverrideEntry, type OverrideTargetType } from "./overrideEntry.js";
|
|
4
|
+
/**
|
|
5
|
+
* Stateful handle for a scene's property override registry.
|
|
6
|
+
*
|
|
7
|
+
* Override behavior is exposed through module-level functions rather than
|
|
8
|
+
* class methods so callers can import only the operations they need.
|
|
9
|
+
*
|
|
10
|
+
* Overrides are property diffs applied to scene objects identified by name.
|
|
11
|
+
* They persist across reloads and are typically saved alongside a project
|
|
12
|
+
* file. The override manager is fully independent of any other scene
|
|
13
|
+
* subsystem (SmartAssetManager, loaders, etc.) — it works with any object
|
|
14
|
+
* in the scene's standard collections (meshes, materials, lights, …)
|
|
15
|
+
* regardless of how that object was created.
|
|
16
|
+
*
|
|
17
|
+
* When multiple objects share a name (e.g. two materials both called
|
|
18
|
+
* "Default" loaded from different glTFs), {@link IOverrideEntry.targetIndex}
|
|
19
|
+
* disambiguates: it stores the object's position among same-named siblings
|
|
20
|
+
* at capture time and is used to pick the correct one at apply time.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* AddOverride(scene, {
|
|
25
|
+
* targetType: "materials",
|
|
26
|
+
* targetName: "canPaint",
|
|
27
|
+
* targetIndex: 0,
|
|
28
|
+
* propertyPath: "albedoColor",
|
|
29
|
+
* value: [1, 0, 0],
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type OverrideManager = {
|
|
34
|
+
/**
|
|
35
|
+
* The scene this manager is attached to.
|
|
36
|
+
*/
|
|
37
|
+
readonly scene: Scene;
|
|
38
|
+
/**
|
|
39
|
+
* Fires whenever the override registry or applied state changes.
|
|
40
|
+
*/
|
|
41
|
+
readonly onChangedObservable: Observable<void>;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Returns the OverrideManager attached to the given scene, creating and
|
|
45
|
+
* attaching one if none exists.
|
|
46
|
+
* @param scene - The scene to look up or attach a manager to.
|
|
47
|
+
* @returns The existing or newly created OverrideManager.
|
|
48
|
+
*/
|
|
49
|
+
export declare function GetOverrideManager(scene: Scene): OverrideManager;
|
|
50
|
+
/**
|
|
51
|
+
* Adds an observer that is notified whenever an OverrideManager is created.
|
|
52
|
+
* @param callback - The callback to invoke with each newly created manager.
|
|
53
|
+
* @returns The observer registration.
|
|
54
|
+
*/
|
|
55
|
+
export declare function AddOverrideManagerCreatedObserver(callback: (manager: OverrideManager) => void): Observer<OverrideManager>;
|
|
56
|
+
/**
|
|
57
|
+
* Options for {@link AddOverride}.
|
|
58
|
+
*/
|
|
59
|
+
export type AddOverrideOptions = {
|
|
60
|
+
/**
|
|
61
|
+
* If the `originalValue` field is present, the override is recorded *without*
|
|
62
|
+
* re-applying it (the caller is presumed to have already mutated the entity)
|
|
63
|
+
* and the field's content is captured as the property's pre-override
|
|
64
|
+
* "original" so {@link RemoveOverride} can restore it later.
|
|
65
|
+
*
|
|
66
|
+
* Inspector-driven edits use this: by the time `onPropertyChanged` fires,
|
|
67
|
+
* the binding has already written the new value, but it still has the prior
|
|
68
|
+
* value in hand. Without this seeding path, an override created via
|
|
69
|
+
* Inspector could never be reverted (the manager would have no record of
|
|
70
|
+
* the pre-edit value).
|
|
71
|
+
*
|
|
72
|
+
* If the field is absent, the override is applied normally and the original
|
|
73
|
+
* is captured by reading the property's current value on first apply.
|
|
74
|
+
*/
|
|
75
|
+
readonly originalValue?: unknown;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Adds an override entry and immediately applies it.
|
|
79
|
+
* If an override with the same target coordinates already exists, it is replaced.
|
|
80
|
+
*
|
|
81
|
+
* When the caller has already mutated the target (e.g. an Inspector edit),
|
|
82
|
+
* pass `{ originalValue }` containing the property's prior value — this seeds
|
|
83
|
+
* the original-value map (so {@link RemoveOverride} can restore it) and skips
|
|
84
|
+
* the redundant apply step.
|
|
85
|
+
* @param scene - The scene whose override registry to update.
|
|
86
|
+
* @param entry - The override to add.
|
|
87
|
+
* @param options - Optional behavior modifiers; see {@link AddOverrideOptions}.
|
|
88
|
+
*/
|
|
89
|
+
export declare function AddOverride(scene: Scene, entry: IOverrideEntry, options?: AddOverrideOptions): void;
|
|
90
|
+
/**
|
|
91
|
+
* Removes a single override matching the given coordinates. Restores the
|
|
92
|
+
* original value if one was captured.
|
|
93
|
+
* @param scene - The scene whose override registry to update.
|
|
94
|
+
* @param targetType - The target type.
|
|
95
|
+
* @param targetName - The target object name.
|
|
96
|
+
* @param targetIndex - The target index among same-named siblings.
|
|
97
|
+
* @param propertyPath - The property path to un-override.
|
|
98
|
+
* @returns True if an override was removed.
|
|
99
|
+
*/
|
|
100
|
+
export declare function RemoveOverride(scene: Scene, targetType: OverrideTargetType, targetName: string, targetIndex: number, propertyPath: string): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Returns all overrides currently registered with the scene.
|
|
103
|
+
* @param scene - The scene whose override registry to read.
|
|
104
|
+
* @returns A read-only array of override entries.
|
|
105
|
+
*/
|
|
106
|
+
export declare function GetOverrides(scene: Scene): readonly IOverrideEntry[];
|
|
107
|
+
/**
|
|
108
|
+
* Removes all overrides, optionally restoring original values.
|
|
109
|
+
* @param scene - The scene whose override registry to clear.
|
|
110
|
+
* @param restoreOriginals - If true, restores all captured original values.
|
|
111
|
+
*/
|
|
112
|
+
export declare function ClearOverrides(scene: Scene, restoreOriginals?: boolean): void;
|
|
113
|
+
/**
|
|
114
|
+
* Updates the target coordinates on the override matching a specific (type,
|
|
115
|
+
* old-name, old-index) so it follows an entity rename. Used by capture services
|
|
116
|
+
* to keep overrides attached to a specific object after the user renames it.
|
|
117
|
+
*
|
|
118
|
+
* Only the override at the exact `(targetType, oldName, oldIndex)` slot is
|
|
119
|
+
* updated, so other same-named siblings keep their own overrides untouched.
|
|
120
|
+
*
|
|
121
|
+
* @param scene - The scene whose override registry to update.
|
|
122
|
+
* @param targetType - The target type.
|
|
123
|
+
* @param oldName - The previous name of the renamed entity.
|
|
124
|
+
* @param oldIndex - The previous index of the renamed entity among same-named siblings.
|
|
125
|
+
* @param newName - The new name of the renamed entity.
|
|
126
|
+
* @param newIndex - The new index of the renamed entity among same-named siblings.
|
|
127
|
+
*/
|
|
128
|
+
export declare function RenameOverrideTarget(scene: Scene, targetType: OverrideTargetType, oldName: string, oldIndex: number, newName: string, newIndex: number): void;
|
|
129
|
+
/**
|
|
130
|
+
* Rewrites override *values* that reference an entity by name when that entity
|
|
131
|
+
* has been renamed. Mirrors {@link RenameOverrideTarget} but operates on the
|
|
132
|
+
* `value` field rather than the `targetName` field, so overrides whose value
|
|
133
|
+
* is `"ref:oldName"` (material/light/camera references) or `"texture:oldName"`
|
|
134
|
+
* (non-SmartAsset texture references) follow the rename instead of silently
|
|
135
|
+
* pointing at a non-existent entity.
|
|
136
|
+
*
|
|
137
|
+
* SmartAsset texture references (`"samTexture:<key>"`) are unaffected because
|
|
138
|
+
* the SmartAsset key is decoupled from the texture's runtime `name` field.
|
|
139
|
+
*
|
|
140
|
+
* @param scene - The scene whose override registry to update.
|
|
141
|
+
* @param valueScheme - Which encoded-reference prefix to rewrite: `"ref"` for
|
|
142
|
+
* material/light/camera references, `"texture"` for non-SAM textures.
|
|
143
|
+
* @param oldName - The previous name embedded in the reference.
|
|
144
|
+
* @param newName - The new name embedded in the reference.
|
|
145
|
+
*/
|
|
146
|
+
export declare function RenameOverrideValueReferences(scene: Scene, valueScheme: "ref" | "texture", oldName: string, newName: string): void;
|
|
147
|
+
/**
|
|
148
|
+
* Applies all overrides to their current targets in the scene.
|
|
149
|
+
*
|
|
150
|
+
* Call this after any scene mutation that might have invalidated previously
|
|
151
|
+
* applied state (asset reload, object recreation, project load). The override
|
|
152
|
+
* manager does not auto-subscribe to other scene subsystems — coordination is
|
|
153
|
+
* the caller's responsibility, which keeps the override system independent.
|
|
154
|
+
* @param scene - The scene whose overrides to apply.
|
|
155
|
+
*/
|
|
156
|
+
export declare function ApplyAllOverrides(scene: Scene): void;
|
|
157
|
+
/**
|
|
158
|
+
* Serializes all overrides to a JSON-compatible array.
|
|
159
|
+
* The on-disk shape is identical to the in-memory `IOverrideEntry`.
|
|
160
|
+
* @param scene - The scene whose overrides to serialize.
|
|
161
|
+
* @returns An array of override entries (shallow copies).
|
|
162
|
+
*/
|
|
163
|
+
export declare function SerializeOverrides(scene: Scene): IOverrideEntry[];
|
|
164
|
+
/**
|
|
165
|
+
* Loads overrides from a serialized array and applies them.
|
|
166
|
+
* @param scene - The scene whose override registry to populate.
|
|
167
|
+
* @param data - Array of override entries.
|
|
168
|
+
*/
|
|
169
|
+
export declare function DeserializeAndApplyOverrides(scene: Scene, data: IOverrideEntry[]): void;
|
|
170
|
+
/**
|
|
171
|
+
* Disposes the manager, clearing all overrides and detaching it from its scene.
|
|
172
|
+
* Safe to call multiple times; subsequent calls are no-ops. Automatically invoked when the
|
|
173
|
+
* owning scene is disposed.
|
|
174
|
+
* @param manager - The override manager state.
|
|
175
|
+
*/
|
|
176
|
+
export declare function DisposeOverrideManager(manager: OverrideManager): void;
|