ConstCheck if a prefab provider is registered for the given guid.
The guid to check
Returns a list of all registered prefab provider keys (guids). Useful for debugging to see which prefabs are available for networked instantiation.
Register a prefab provider that resolves objects by guid for networked instantiation.
When a remote syncInstantiate event is received, the engine uses this to find the prefab
to clone on the receiving client.
The guid to register the provider for
Callback that returns the prefab Object3D for the given guid
Unregister a previously registered prefab provider.
The guid to unregister
import { Prefabs, ObjectUtils } from "@needle-tools/engine";
const cookie = ObjectUtils.createPrimitive("Cube", { color: 0xff8c00 });
cookie.guid = "cookie-prefab";
Prefabs.register("cookie-prefab", async () => cookie);
console.log(Prefabs.list()); // ["cookie-prefab"]
Prefabs.unregister("cookie-prefab");
Prefab registry for networked instantiation.
When a remote syncInstantiate event is received, the engine looks up the prefab by its guid using this registry. Both GLB-loaded objects and runtime-created objects can be registered here.
Note: syncInstantiate auto-registers prefabs if no provider exists for their guid, so manual registration is only needed for custom resolution logic.