decentraland / sdk

PM repository for SDK
Apache License 2.0
4 stars 4 forks source link

Raycasts should only run after initial frame meshes are loaded #734

Closed nearnshaw closed 1 year ago

nearnshaw commented 1 year ago

In this example scene, you can see that the raycasts don't work because the floor is not yet loaded when the rays are fired. However, when we do hot-reload, since the model of the floor was already in memory, the raycasts work well. https://github.com/decentraland/sdk7-goerli-plaza/tree/main/bird-field

This PR to an ADR makes very relevant clarifications about the topic: https://github.com/decentraland/adr/pull/222/files

The first frame of a scene is either sent by the scene code or by the runtime (via main.crdt as stated in ADR-133). The physics phase of this initial frame MUST only be executed after all its messages have been processed and all the models have been loaded.

This enables the scene to embed Raycast queries that will hit the models being loaded in this first frame.

pravusjif commented 1 year ago

I'll see if I can implement something not too costly for waiting to have at least 1st-frame meshes loaded first.