Closed cazala closed 11 months ago
Important details about rationale behind engine.defineComponent
and how this feature was planned to work around it in the ADR-165 @cazala
This conversation has been moved over here: https://github.com/decentraland/sdk/issues/933
This conversation has been moved over here: https://github.com/decentraland/sdk/issues/933
Background
Items used to be only a GLB + Transform, but that would only allow us to create static scenes. In the legacy Builder we had the concept of "smart items" that had some interactivity baked in and enabled users to create some flows and simple game logic.
Now items can have more components than only GltfContainer, like Triggers and Actions, but when using those, they need specialized systems to be running, and custom components to be added to the engine.
The original plan to support this was the following:
@dcl/asset-packs@1.0.0
)package.json
), and the necessary components are created with their values (exposed by the itemdata.json
)bin/index.js
on the web editor, on the vscode editor we would need to add the imports to the entrypoint@dcl/inspector
's engineSome of the problems found:
engine.defineComponent
) because the we need to run this not only on the deployed scene, but also on the@dcl/inspector
engine itself, and also we need to namespace the name of the component with the package name and version otherwise they could clash@swc/wasm
but we could not manage to make it work with our current build system inesbuild
.@dcl-sdk/utils
.What we ended up doing:
@dcl/asset-packs
. It can have its own dependencies like@dcl-sdk/utils
.bin/index.js
file and publishes in the npm package along with the components needed by the@dcl/inspector
engine@dcl/inspector
installs the@dcl/asset-packs
dependency and it uses those components on its own engine, and it publishes thebin/index.js
from that dependency along with the other static assets in its own@dcl/inspector
npm package@dcl/inspector
(ie. the Builder) can pass abinIndexJsUrl
param that tells the inspector from where to get thebin/index.js
, since the builder serves the static assets from the@dcl/inspector
(html, css, etc) it also serves thebin/index.js
, so it passes the public url of that bin/index.js as thebinIndexJsUrl
.bin/index.js
elsewhere (ie. a server that compiles the js) we could simply change this url to the service that will return the compiled js.asset-packs
repo using the available components without having to release a new@dcl/inspector
but if we want to add new functionality or new components/systems, we need to add them to the@dcl/asset-packs
repo, and then upgrade the depdency (and might need to create UI components for them) in ther@dcl/inspector
.