@onerjs/gui-editor 8.53.5 → 8.53.6

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.
@@ -2158,6 +2158,370 @@ export interface ISplitContainerProps {
2158
2158
  */
2159
2159
  export const SplitContainer: React.FC<PropsWithChildren<ISplitContainerProps>>;
2160
2160
 
2161
+ }
2162
+ declare module "@onerjs/gui-editor/projects/projectFile" {
2163
+ import "@onerjs/core/Loading/Plugins/babylonFileLoader";
2164
+ import { Scene } from "@onerjs/core/scene";
2165
+ import { ISerializedSmartAssetMap } from "@onerjs/core/SmartAssets/smartAssetSerializer";
2166
+ import { IOverrideEntry } from "@onerjs/gui-editor/projects/overrideEntry";
2167
+ /**
2168
+ * ## `.babylonproj` project file format
2169
+ *
2170
+ * The `.babylonproj` zip on disk packages three layers:
2171
+ * 1. **SmartAsset registry** — URL references to external assets (glb/gltf/textures
2172
+ * loaded via SAM). Local blob/data assets are bundled inside the zip and
2173
+ * extracted to fresh blob URLs on load.
2174
+ * 2. **OverrideManager state** — declarative property overrides applied after load.
2175
+ * 3. **Companion `.babylon`** — meshes, lights, cameras, transform nodes, and
2176
+ * materials that are *not* tracked by SAM (i.e. user-created scene content).
2177
+ * Plus a `companionBindings` side table mapping material texture slots back
2178
+ * to SAM-tracked textures so re-attachment works without embedding texture
2179
+ * bytes in the companion.
2180
+ *
2181
+ * ### What round-trips cleanly
2182
+ * - SAM-tracked assets (re-fetched from their URLs or extracted from the zip)
2183
+ * - User-created `Mesh` geometry, `Material`s (Standard/PBR/Multi/Node), and
2184
+ * `*Texture` slot bindings to SAM textures
2185
+ * - `Light`s, `Camera`s, `TransformNode`s, scene/material image processing,
2186
+ * clear color, fog, environment intensity
2187
+ * - Property overrides on any of the above
2188
+ *
2189
+ * ### Known gaps (not preserved on save/load)
2190
+ * - `PostProcess` attachments to cameras (a post-process attaches to a *specific*
2191
+ * camera instance; we dispose+recreate cameras, leaving post-processes orphaned).
2192
+ * - `AdvancedDynamicTexture` GUI controls — not in `.babylon` format.
2193
+ * - Audio (`Sound` / `AudioEngine` state).
2194
+ * - Particle systems with runtime state, baked vertex animations.
2195
+ * - Complex shader-driven content like GaussianSplatting: the mesh round-trips
2196
+ * but its companion utility materials (`gaussianSplattingDepth`, `ProxyMaterial`)
2197
+ * get duplicated on each load cycle.
2198
+ * - Skeleton animation playback state.
2199
+ *
2200
+ * If you hit a "the scene looks different after load" issue, it's almost
2201
+ * certainly one of the gaps above rather than camera or mesh state drift.
2202
+ */
2203
+ /**
2204
+ * Reserved smart asset key for user-created objects (materials, lights, cameras)
2205
+ * that are persisted as a companion `.babylon` file alongside the project JSON.
2206
+ */
2207
+ export const ProjectLocalsKey = "__project_locals__";
2208
+ /**
2209
+ * The result of serializing a project. Contains the project JSON and,
2210
+ * if the scene has user-created objects, a companion `.babylon` blob.
2211
+ */
2212
+ export interface IProjectBundle {
2213
+ /** The project JSON document (assets + overrides, no embedded scene data). */
2214
+ readonly project: ISerializedProject;
2215
+ /**
2216
+ * A companion `.babylon` file containing user-created objects not owned by
2217
+ * any smart asset. Undefined if there are no such objects.
2218
+ */
2219
+ readonly companionBabylon?: Blob;
2220
+ }
2221
+ /**
2222
+ * Maps each user-created material (by name) to its texture-slot bindings.
2223
+ * A binding records "this `*Texture` slot on this material should be
2224
+ * re-attached to the SmartAsset registered under this key" so that texture
2225
+ * references survive a save/load round-trip without embedding the texture
2226
+ * data inside the companion `.babylon`.
2227
+ */
2228
+ export type CompanionTextureBindings = Record<string, Record<string, string>>;
2229
+ /**
2230
+ * A versioned project file that composes a smart asset map with overrides.
2231
+ * This is the unified on-disk format for persisting a complete project.
2232
+ */
2233
+ export interface ISerializedProject {
2234
+ /** Schema version. Must be 2 for the current version. */
2235
+ readonly version: 2;
2236
+ /** Smart asset key→URL mappings (from SmartAssetManager). */
2237
+ readonly assets: ISerializedSmartAssetMap["assets"];
2238
+ /** Property overrides (from OverrideManager). */
2239
+ readonly overrides: IOverrideEntry[];
2240
+ /**
2241
+ * Optional bindings that re-attach SmartAsset-tracked textures to
2242
+ * user-created material slots after the companion `.babylon` loads.
2243
+ * Omitted when no user-created material references a SmartAsset texture.
2244
+ */
2245
+ readonly companionBindings?: CompanionTextureBindings;
2246
+ }
2247
+ /**
2248
+ * Serializes a scene's smart asset map and override registry into a project
2249
+ * bundle. User-created objects (materials, lights, cameras not owned by any
2250
+ * smart asset) are serialized into a companion `.babylon` file rather than
2251
+ * embedded in the project JSON.
2252
+ *
2253
+ * Both managers are looked up (and created if missing) via their respective
2254
+ * `Get…Manager(scene)` accessors, so this function can be called on any scene.
2255
+ *
2256
+ * @param scene - The scene to serialize.
2257
+ * @param baseUrl - Optional base URL for making asset paths relative.
2258
+ * @returns A project bundle containing the JSON document and optional companion file.
2259
+ */
2260
+ export function SerializeProject(scene: Scene, baseUrl?: string): IProjectBundle;
2261
+ /**
2262
+ * Loads a project file from a URL, File, or pre-parsed object.
2263
+ * Registers all asset entries on the scene's SmartAssetManager, loads all
2264
+ * assets (including the companion `.babylon` for user-created objects), then
2265
+ * applies all overrides via the OverrideManager.
2266
+ *
2267
+ * For loading the `.babylonproj` zip on-disk format, use {@link LoadProjectFileAsync}
2268
+ * instead — it extracts the zip and then calls this function with the embedded
2269
+ * JSON document.
2270
+ *
2271
+ * @param scene - The scene to populate.
2272
+ * @param source - A URL string, File object, or pre-parsed ISerializedProject.
2273
+ * @param rootUrl - Optional root URL for resolving relative asset paths.
2274
+ */
2275
+ export function LoadProjectAsync(scene: Scene, source: string | File | ISerializedProject, rootUrl?: string): Promise<void>;
2276
+ /**
2277
+ * Validates and parses a serialized project document.
2278
+ * @param data - The raw data to validate (typically parsed JSON).
2279
+ * @returns The validated project document.
2280
+ * @throws If the data does not conform to the expected schema.
2281
+ */
2282
+ export function DeserializeProject(data: unknown): ISerializedProject;
2283
+ /**
2284
+ * Serializes a scene's project (smart assets + overrides) into a `.babylonproj`
2285
+ * zip bundle.
2286
+ *
2287
+ * The zip contains:
2288
+ * - `project.json` — the project document (assets + overrides)
2289
+ * - `__project_locals__.babylon` — companion file for user-created objects (if any)
2290
+ * - Bundled local asset files (blobs the user dragged in from disk)
2291
+ *
2292
+ * Remote URLs (http/https) are left as references and not bundled.
2293
+ *
2294
+ * @param scene - The scene to serialize.
2295
+ * @returns A Blob containing the zip bundle.
2296
+ */
2297
+ export function SaveProjectFileAsync(scene: Scene): Promise<Blob>;
2298
+ /**
2299
+ * Loads a `.babylonproj` zip bundle into a scene. Extracts all files, creates
2300
+ * blob URLs for bundled assets, and loads the project through SAM.
2301
+ *
2302
+ * @param scene - The scene to load the project into.
2303
+ * @param zipFile - The `.babylonproj` zip file to load.
2304
+ */
2305
+ export function LoadProjectFileAsync(scene: Scene, zipFile: File): Promise<void>;
2306
+
2307
+ }
2308
+ declare module "@onerjs/gui-editor/projects/overrideManager" {
2309
+ import { Scene } from "@onerjs/core/scene";
2310
+ import { Observable, Observer } from "@onerjs/core/Misc/observable";
2311
+ import { IOverrideEntry, OverrideTargetType } from "@onerjs/gui-editor/projects/overrideEntry";
2312
+ /**
2313
+ * Stateful handle for a scene's property override registry.
2314
+ *
2315
+ * Override behavior is exposed through module-level functions rather than
2316
+ * class methods so callers can import only the operations they need.
2317
+ *
2318
+ * Overrides are property diffs applied to scene objects identified by name.
2319
+ * They persist across reloads and are typically saved alongside a project
2320
+ * file. The override manager is fully independent of any other scene
2321
+ * subsystem (SmartAssetManager, loaders, etc.) — it works with any object
2322
+ * in the scene's standard collections (meshes, materials, lights, …)
2323
+ * regardless of how that object was created.
2324
+ *
2325
+ * When multiple objects share a name (e.g. two materials both called
2326
+ * "Default" loaded from different glTFs), {@link IOverrideEntry.targetIndex}
2327
+ * disambiguates: it stores the object's position among same-named siblings
2328
+ * at capture time and is used to pick the correct one at apply time.
2329
+ *
2330
+ * @example
2331
+ * ```typescript
2332
+ * AddOverride(scene, {
2333
+ * targetType: "materials",
2334
+ * targetName: "canPaint",
2335
+ * targetIndex: 0,
2336
+ * propertyPath: "albedoColor",
2337
+ * value: [1, 0, 0],
2338
+ * });
2339
+ * ```
2340
+ */
2341
+ export type OverrideManager = {
2342
+ /**
2343
+ * The scene this manager is attached to.
2344
+ */
2345
+ readonly scene: Scene;
2346
+ /**
2347
+ * Fires whenever the override registry or applied state changes.
2348
+ */
2349
+ readonly onChangedObservable: Observable<void>;
2350
+ };
2351
+ /**
2352
+ * Returns the OverrideManager attached to the given scene, creating and
2353
+ * attaching one if none exists.
2354
+ * @param scene - The scene to look up or attach a manager to.
2355
+ * @returns The existing or newly created OverrideManager.
2356
+ */
2357
+ export function GetOverrideManager(scene: Scene): OverrideManager;
2358
+ /**
2359
+ * Adds an observer that is notified whenever an OverrideManager is created.
2360
+ * @param callback - The callback to invoke with each newly created manager.
2361
+ * @returns The observer registration.
2362
+ */
2363
+ export function AddOverrideManagerCreatedObserver(callback: (manager: OverrideManager) => void): Observer<OverrideManager>;
2364
+ /**
2365
+ * Options for {@link AddOverride}.
2366
+ */
2367
+ export type AddOverrideOptions = {
2368
+ /**
2369
+ * If the `originalValue` field is present, the override is recorded *without*
2370
+ * re-applying it (the caller is presumed to have already mutated the entity)
2371
+ * and the field's content is captured as the property's pre-override
2372
+ * "original" so {@link RemoveOverride} can restore it later.
2373
+ *
2374
+ * Inspector-driven edits use this: by the time `onPropertyChanged` fires,
2375
+ * the binding has already written the new value, but it still has the prior
2376
+ * value in hand. Without this seeding path, an override created via
2377
+ * Inspector could never be reverted (the manager would have no record of
2378
+ * the pre-edit value).
2379
+ *
2380
+ * If the field is absent, the override is applied normally and the original
2381
+ * is captured by reading the property's current value on first apply.
2382
+ */
2383
+ readonly originalValue?: unknown;
2384
+ };
2385
+ /**
2386
+ * Adds an override entry and immediately applies it.
2387
+ * If an override with the same target coordinates already exists, it is replaced.
2388
+ *
2389
+ * When the caller has already mutated the target (e.g. an Inspector edit),
2390
+ * pass `{ originalValue }` containing the property's prior value — this seeds
2391
+ * the original-value map (so {@link RemoveOverride} can restore it) and skips
2392
+ * the redundant apply step.
2393
+ * @param scene - The scene whose override registry to update.
2394
+ * @param entry - The override to add.
2395
+ * @param options - Optional behavior modifiers; see {@link AddOverrideOptions}.
2396
+ */
2397
+ export function AddOverride(scene: Scene, entry: IOverrideEntry, options?: AddOverrideOptions): void;
2398
+ /**
2399
+ * Removes a single override matching the given coordinates. Restores the
2400
+ * original value if one was captured.
2401
+ * @param scene - The scene whose override registry to update.
2402
+ * @param targetType - The target type.
2403
+ * @param targetName - The target object name.
2404
+ * @param targetIndex - The target index among same-named siblings.
2405
+ * @param propertyPath - The property path to un-override.
2406
+ * @returns True if an override was removed.
2407
+ */
2408
+ export function RemoveOverride(scene: Scene, targetType: OverrideTargetType, targetName: string, targetIndex: number, propertyPath: string): boolean;
2409
+ /**
2410
+ * Returns all overrides currently registered with the scene.
2411
+ * @param scene - The scene whose override registry to read.
2412
+ * @returns A read-only array of override entries.
2413
+ */
2414
+ export function GetOverrides(scene: Scene): readonly IOverrideEntry[];
2415
+ /**
2416
+ * Removes all overrides, optionally restoring original values.
2417
+ * @param scene - The scene whose override registry to clear.
2418
+ * @param restoreOriginals - If true, restores all captured original values.
2419
+ */
2420
+ export function ClearOverrides(scene: Scene, restoreOriginals?: boolean): void;
2421
+ /**
2422
+ * Updates the target coordinates on the override matching a specific (type,
2423
+ * old-name, old-index) so it follows an entity rename. Used by capture services
2424
+ * to keep overrides attached to a specific object after the user renames it.
2425
+ *
2426
+ * Only the override at the exact `(targetType, oldName, oldIndex)` slot is
2427
+ * updated, so other same-named siblings keep their own overrides untouched.
2428
+ *
2429
+ * @param scene - The scene whose override registry to update.
2430
+ * @param targetType - The target type.
2431
+ * @param oldName - The previous name of the renamed entity.
2432
+ * @param oldIndex - The previous index of the renamed entity among same-named siblings.
2433
+ * @param newName - The new name of the renamed entity.
2434
+ * @param newIndex - The new index of the renamed entity among same-named siblings.
2435
+ */
2436
+ export function RenameOverrideTarget(scene: Scene, targetType: OverrideTargetType, oldName: string, oldIndex: number, newName: string, newIndex: number): void;
2437
+ /**
2438
+ * Rewrites override *values* that reference an entity by name when that entity
2439
+ * has been renamed. Mirrors {@link RenameOverrideTarget} but operates on the
2440
+ * `value` field rather than the `targetName` field, so overrides whose value
2441
+ * is `"ref:oldName"` (material/light/camera references) or `"texture:oldName"`
2442
+ * (non-SmartAsset texture references) follow the rename instead of silently
2443
+ * pointing at a non-existent entity.
2444
+ *
2445
+ * SmartAsset texture references (`"samTexture:<key>"`) are unaffected because
2446
+ * the SmartAsset key is decoupled from the texture's runtime `name` field.
2447
+ *
2448
+ * @param scene - The scene whose override registry to update.
2449
+ * @param valueScheme - Which encoded-reference prefix to rewrite: `"ref"` for
2450
+ * material/light/camera references, `"texture"` for non-SAM textures.
2451
+ * @param oldName - The previous name embedded in the reference.
2452
+ * @param newName - The new name embedded in the reference.
2453
+ */
2454
+ export function RenameOverrideValueReferences(scene: Scene, valueScheme: "ref" | "texture", oldName: string, newName: string): void;
2455
+ /**
2456
+ * Applies all overrides to their current targets in the scene.
2457
+ *
2458
+ * Call this after any scene mutation that might have invalidated previously
2459
+ * applied state (asset reload, object recreation, project load). The override
2460
+ * manager does not auto-subscribe to other scene subsystems — coordination is
2461
+ * the caller's responsibility, which keeps the override system independent.
2462
+ * @param scene - The scene whose overrides to apply.
2463
+ */
2464
+ export function ApplyAllOverrides(scene: Scene): void;
2465
+ /**
2466
+ * Serializes all overrides to a JSON-compatible array.
2467
+ * The on-disk shape is identical to the in-memory `IOverrideEntry`.
2468
+ * @param scene - The scene whose overrides to serialize.
2469
+ * @returns An array of override entries (shallow copies).
2470
+ */
2471
+ export function SerializeOverrides(scene: Scene): IOverrideEntry[];
2472
+ /**
2473
+ * Loads overrides from a serialized array and applies them.
2474
+ * @param scene - The scene whose override registry to populate.
2475
+ * @param data - Array of override entries.
2476
+ */
2477
+ export function DeserializeAndApplyOverrides(scene: Scene, data: IOverrideEntry[]): void;
2478
+ /**
2479
+ * Disposes the manager, clearing all overrides and detaching it from its scene.
2480
+ * Safe to call multiple times; subsequent calls are no-ops. Automatically invoked when the
2481
+ * owning scene is disposed.
2482
+ * @param manager - The override manager state.
2483
+ */
2484
+ export function DisposeOverrideManager(manager: OverrideManager): void;
2485
+
2486
+ }
2487
+ declare module "@onerjs/gui-editor/projects/overrideEntry" {
2488
+ /**
2489
+ * Defines the shape of an override entry — a property diff applied to a
2490
+ * scene object identified by name. Overrides target any object in the
2491
+ * scene's standard collections (meshes, materials, lights, etc.) regardless
2492
+ * of how that object was created.
2493
+ */
2494
+ export interface IOverrideEntry {
2495
+ /** The type of object to target (e.g., "meshes", "materials", "lights"). */
2496
+ readonly targetType: OverrideTargetType;
2497
+ /** The name of the target object. Use "" for scene-level overrides. */
2498
+ readonly targetName: string;
2499
+ /**
2500
+ * Disambiguator for when multiple objects in `scene[targetType]` share the
2501
+ * same `targetName`. The override applies to the N-th match (0-based) at
2502
+ * apply time. When names are unique, use 0.
2503
+ */
2504
+ readonly targetIndex: number;
2505
+ /** Dot-separated property path on the target (e.g., "albedoColor", "position.x"). */
2506
+ readonly propertyPath: string;
2507
+ /** The override value. */
2508
+ readonly value: OverrideValue;
2509
+ }
2510
+ /**
2511
+ * The types of scene objects that can be targeted by overrides.
2512
+ */
2513
+ export type OverrideTargetType = "meshes" | "transformNodes" | "materials" | "textures" | "lights" | "cameras" | "animationGroups" | "scene";
2514
+ /**
2515
+ * An override value. Supports scalars, color/vector arrays, object references,
2516
+ * and null (used to clear a slot, e.g. removing a material assignment).
2517
+ * - number: scalar property (e.g., intensity, alpha)
2518
+ * - string: string property, or "ref:name" / "samTexture:key" / "texture:name" object reference
2519
+ * - boolean: boolean property
2520
+ * - number[]: array property mapped to Vector3, Color3, Color4, etc.
2521
+ * - null: explicitly clear an object-typed slot
2522
+ */
2523
+ export type OverrideValue = number | string | boolean | number[] | null;
2524
+
2161
2525
  }
2162
2526
  declare module "@onerjs/gui-editor/nodeGraphSystem/typeLedger" {
2163
2527
  import { INodeContainer } from "@onerjs/gui-editor/nodeGraphSystem/interfaces/nodeContainer";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onerjs/gui-editor",
3
- "version": "8.53.5",
3
+ "version": "8.53.6",
4
4
  "main": "dist/babylon.guiEditor.js",
5
5
  "module": "dist/babylon.guiEditor.js",
6
6
  "esnext": "dist/babylon.guiEditor.js",
@@ -24,8 +24,8 @@
24
24
  "@types/react-dom": ">=16.0.9"
25
25
  },
26
26
  "devDependencies": {
27
- "@onerjs/core": "8.53.5",
28
- "@onerjs/gui": "8.53.5",
27
+ "@onerjs/core": "8.53.6",
28
+ "@onerjs/gui": "8.53.6",
29
29
  "react": "^18.2.0",
30
30
  "react-dom": "^18.2.0"
31
31
  },