Skip to content

Experiment: Edit non-main composites - #1324

Open
nearnshaw wants to merge 4 commits into
mainfrom
edit-asset
Open

Experiment: Edit non-main composites#1324
nearnshaw wants to merge 4 commits into
mainfrom
edit-asset

Conversation

@nearnshaw

@nearnshaw nearnshaw commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

Adds a dropdown next to the scene name that lets you pick a composite file other than main.composite. The selected composite is what the inspector edits.

Screenshot 2026-05-21 at 3 17 16 PM

These alternative composites are meant to describe items that can be added dynamically to a scene at runtime via js-sdk-toolchain#1333. Changing a composite doesn't retroactively update instances already placed in main.composite, but it affects any new ones spawned dynamically once the scene starts.

What the dropdown does

  • Lists every composite file under assets/ (main scene + alt composites discovered by recursive scan, with corrupted composite.json files filtered out).
  • Create New Composite… prompts for a name and scaffolds assets/custom/<slug>/composite.json with a single core-schema::Name component on the root entity.
  • Manage Composites… opens a modal where each alt composite has a kebab menu with Duplicate… (copies the whole folder and strips any data.json so the duplicate gets its own identity) and Delete (removes just the composite file; assets in the same folder are kept).

What's different when editing an alternative composite

Scene-level concepts don't apply when you're authoring a single item, so the UI hides or repurposes them:

  • The parcel grid is hidden, and Babylon's BackgroundPlane ground is disabled so the item isn't half-buried at y=0.
  • Spawn-point visuals (spawn_points node) are disabled.
  • The Player and Camera entities, the spawn-point tree, and SceneInspector are not rendered.
  • Out-of-bounds detection is short-circuited (isEntityOutsideLayout returns false), so no entities get the yellow "outside layout" material or warning icons.
  • Thumbnail screenshots are skipped on Back / Publish / Deploy — those buttons still publish the whole project, they just don't snapshot the alt-composite view.
  • The camera frames the loaded item via editorCamera.centerViewOnEntity(sceneContext.rootNode) on the first onDataLoadedObservable fire.
  • The root entity:
    • Shows its Name component value as the label (falls back to "Scene" if absent).
    • Can be renamed via right-click → Rename or the entity header's More Options menu.
    • Accepts any component from the AddComponent dropdown (the ROOT_COMPOSITE filter is bypassed for ROOT in alt mode).
    • Has no Transform by default — it's just an empty entity the user can build out.

Asset placement

When dropping assets while editing an alt composite, files go into the composite's folder rather than the project-wide assets/asset-packs / assets/custom:

  • Catalog assets land at <compositeBaseFolder>/<assetPackageName>/.
  • Custom-item drops land at <compositeBaseFolder>/<assetPackageName>/.
  • New scripts created via the Script component land at <compositeBaseFolder>/Scripts/.

Loading alt composites into the engine

Alt-composite files (composite.json under assets/custom/... or assets/asset-packs/...) aren't picked up by the existing .composite-only scan, so composite-provider.ts falls back to reading them directly and resolving smart-item placeholders before handing them to Composite.fromJson:

  • {self} → numeric component id allocated from a counter seeded from the existing Counter.value on entity 0 (and the final value is written back into the composite JSON before instancing, so we don't mutate the engine before Composite.instance runs).
  • {self:ComponentName} / {N:ComponentName} → resolved against the same id map.
  • core-schema::Sync-Components.componentIds entries that are stored as component name strings → resolved to numeric component ids via engine.getComponent(name).componentId (mirroring parseSyncComponents from add-asset). Unregistered components are dropped rather than crashing the stream.
  • {assetPath} → replaced with the composite's parent folder in every string in the composite, including JSON-encoded action payloads like '{"src":"{assetPath}/fireworkexplode.mp3"}'.

Test plan

  • Open an existing project — dropdown shows "Main scene"; everything else behaves like main.
  • Click Create New Composite…, enter a name, confirm — new folder appears under assets/custom/<slug>/, the inspector reloads into the new composite, and the root entity is labeled with the name you typed.
  • In the new alt composite: drop a smart item (e.g. confetti), drop a custom item, create a script — all files land under assets/custom/<slug>/.
  • Verify the alt-composite UI: no grid, no ground, no out-of-bounds warnings, no Player/Camera entries, no spawn points, no scene metadata inspector, camera frames the item.
  • Right-click the root entity → Rename works; the entity header shows the + AddComponent dropdown for the root.
  • Open an asset-packs composite (e.g. assets/asset-packs/confetti/composite.json) — placeholders resolve, GLBs load, no BigInt errors.
  • Open Manage Composites… → kebab menu shows Duplicate… and Delete. Duplicate creates a new folder; the resulting composite shows up in the dropdown. Delete removes the composite file and keeps sibling assets.
  • Switch back to Main scene — grid returns, spawn points render, out-of-bounds works again, all main-scene behavior unchanged.
  • Run Preview / Publish — no behavior change; thumbnails skipped only when alt composite is selected.

🤖 Generated with Claude Code

@nearnshaw nearnshaw changed the title Edit asset Edit non-main composites May 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test @dcl/asset-packs package

  • Install via NPM:
    npm install "https://sdk-team-cdn.decentraland.org/creator-hub/branch/edit-asset/@dcl/asset-packs/dcl-asset-packs-2.15.4-commit-b539241a581913fca72867ea3c2573e6262f7557.tgz"

Note: If new assets are added in this PR, they won't be available on the CDN until the PR is merged. This package can be used to test changes to the library code or catalog.json, but won't work for testing newly added items.

@github-actions

Copy link
Copy Markdown
Contributor

Test @dcl/inspector package

  • Preview: link
  • Install via NPM:
    npm install "https://sdk-team-cdn.decentraland.org/creator-hub/branch/edit-asset/@dcl/inspector/dcl-inspector-7.34.4-commit-b539241a581913fca72867ea3c2573e6262f7557.tgz"

@github-actions

Copy link
Copy Markdown
Contributor

Test this pull request on macos-latest

Download the correct version for your architecture:

mac-x64
mac-arm64

Click here if you don't know which version to download

For running this unsigned version of the app, you will need to run the xattr command on it:

  1. Extract the app from the downloaded .dmg file (double-click it)
  2. Place the extracted app anywhere you like in your file system
  3. Open a terminal on the directory where the app is
  4. Run xattr -c app-name, replacing "app-name" for the actual name of the app
  5. Double-click the app ✅

@github-actions

Copy link
Copy Markdown
Contributor

Test this pull request on windows-latest

Download the correct version for your architecture:

win-x64

@nearnshaw nearnshaw changed the title Edit non-main composites Experiment: Edit non-main composites Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant