Skip to content

Commit

Permalink
bounding boxes (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
nearnshaw authored Oct 31, 2024
1 parent eaaef48 commit 55d3dab
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
34 changes: 18 additions & 16 deletions content/creator/3d-modeling/meshes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,39 @@ weight: 2

3D models have a _mesh_ composed of triangular _faces_. These faces meet each other on _edges_ (the lines along which they touch) and _vertices_ (the points where their corners join).

# **Space Limitations**
## **Space Limitations**

All 3D models in your scene must fit within the limits of its parcels. If they extend beyond these limits when running a preview, the meshes will be marked in red by a bounding box.
All 3D models in your scene must fit within the limits of its parcels. If any part of your models extend beyond these limits when running a preview, these parts that extend will be cut off and not rendered.

For performance reasons, Decentraland checks the positions of the *bounding boxes* around meshes (not the vertices in the meshes themselves) to verify that they are within the scene’s limits.
<img src="/images/editor/cut-train.png" width="600" />

<img src="/images/3d-models-and-animations/3d-essentials/06-scene-limits.png" width="900" />
In the Creator Hub editor, you will see the model tinted red and its bounding box marked in red.

If you have a model that has all of its vertices neatly inside the scene area, but that has large bounding boxes that are mostly empty and extend beyond the scene limits, the entire model will be marked as outside the scene limits.
<img src="/images/editor/train-out-of-bounds.png" width="600" />

To avoid this problem, you can clean up your 3D models to reset positions and rotations of meshes so that bounding boxes don’t extend beyond the meshes they wrap.
{{< hint info >}}
**📔 Note**: In the older Web client of Decentraland, for performance reasons, if any part of a 3D model was out of bounds, even if just the bounding box, then the entire model was not rendered. As of the Decentraland 2.0 desktop client, only the parts of a model that are out of bounds are cut off. The parts of the model that are within the scene are rendered.
{{< /hint >}}

<img src="/images/3d-models-and-animations/3d-essentials/07-apply-rotations.gif" width="600" />
## **Bounding Boxes**

_On Blender you can do that by selecting the objects, pressing Ctrl+A and then Apply “All transforms”._
If you have a model that has all of its vertices neatly inside the scene area, but that has large bounding boxes that are mostly empty and extend beyond the scene limits, the entire model will be marked as outside the scene limits in the Creator Hub. The parts of the model that are inside your parcels will be rendered correctly, and you will be allowed to publish your scene.

## **Bounding Boxes**
Every mesh has a bounding box, that surrounds the limits of the shape. To make a 3D model more usable inside Decentraland, make sure that its bounding boxes don’t extend beyond the model more than necessary.

Every mesh has a bounding box, that surrounds the limits of the shape. Keep in mind that the bounding boxes of all 3D models in a Decentraland scene must fit inside the scene limits, see **[position entities](https://docs.decentraland.org/creator/development-guide/entity-positioning/#scene-boundaries)** for more details.
To avoid this problem, you can clean up your 3D models to reset positions and rotations of meshes so that bounding boxes don’t extend beyond the meshes they wrap.

To make a 3D model more usable inside Decentraland, make sure that its bounding boxes don’t extend beyond the model more than necessary.
<img src="/images/3d-models-and-animations/3d-essentials/07-apply-rotations.gif" width="600" />

<img src="/images/3d-models-and-animations/3d-essentials/09-boundig-box.png" width="600" />
_On Blender you can do that by selecting the objects, pressing Ctrl+A and then Apply “All transforms”._

For example, be cautious when rotating a sub-mesh near the border of your model. Since bounding boxes are cubes, even if the mesh is round, the corners of its bounding box might end up sticking out after rotating it 45°.

<img src="/images/3d-models-and-animations/3d-essentials/10-apply-rotation.png" width="600" />

We recommend that you bake the rotation and scale of every mesh in the model, to make sure that there are no unwanted bounding boxes extending beyond the size they need to have.

# **Triangle Limitations**
## **Triangle Limitations**

Because Decentraland is an open world full of different scenes and objects that are being downloaded on the fly (in the same 3D space) is important to optimize our meshes in order to have a good performance while playing. In that sense, there are some scene limitations that we always need to keep in mind when it comes to meshes:

Expand All @@ -65,7 +67,7 @@ A valuable tip is to always keep on track of the polycount of your models. To do

{{< /hint >}}

# **Meshes On Large Scenes**
## **Meshes On Large Scenes**

When creating meshes, we should keep in mind these 2 best practices:

Expand All @@ -88,7 +90,7 @@ _A maze-like indoor level. This normal scene view shows all visible Game Objects

_Regular frustum culling only renders objects within the camera’s view. This is automatic and always happens._

# **Instancing Objects vs Duplicating Objects**
## **Instancing Objects vs Duplicating Objects**

In Blender, duplicating an object creates a completely separate copy of the object, while instancing an object creates a duplicate that shares the same data as the original object.

Expand Down Expand Up @@ -137,7 +139,7 @@ _When we export these models, we will still have the same number of draw calls (

_To keep things organized you can simply instance collections in your scene, this way allows you to control all instances from one single folder and source._

# **Mesh Naming**
## **Mesh Naming**

Use meaningful names for your meshes. Name should give context of where the asset is used or to which part of the object it relates.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ As an alternative, you can run `dcl deploy --skip-build` to skip the running of

### Issue: Once deployed, some 3d models are missing

- Make sure the 3d models are all within the scene boundaries, even their bounding boxes. When running in preview, any 3d models that extend beyond the scene boundaries are marked in red and their bounding boxes are marked. In the deployed scene, these models aren't rendered at all, as they could be intruding into the parcels of your neighbors.
- Make sure the 3d models are all within the scene boundaries, even their bounding boxes. If any part of your models extend beyond these limits when running a preview, these parts that extend will be cut off and not rendered, both when running a preview and on the published scene.

### Issue: Once deployed, my 3d models look different

Expand Down
8 changes: 6 additions & 2 deletions content/creator/scene-editor/scene-editor-essentials.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,15 @@ You can expand this menu to view details.
**💡 Tip**: If you're building a Decentraland World, you can always increase the [scene size]({{< ref "/content/creator/scene-editor/scene-editor-essentials.md#scene-sizes" >}}) to increase your limits.
{{< /hint >}}

The content in a Decentraland scene must also avoid spilling onto neighbor parcels. If any of the models in your scene extend beyond the limits, the Scene Editor will mark these in red.
The content in a Decentraland scene must also avoid spilling onto neighbor parcels. If any part of the models in your scene extend beyond the limits, when you open the scene preview you will see these parts cut off. The Scene Editor will mark the entire model in red, but you should only really worry about the parts of the model that extend beyond the scene limits.

<img src="/images/editor/out-of-bounds.png" width="250" />

These checks don't look at the visible geometry of the meshes, but rather they look at the bounding boxes of these meshes, as this is more performant. Learn more about [Bounding Boxes]({{< ref "/content/creator/3d-modeling/meshes.md#bounding-boxes" >}}).
{{< hint info >}}
**💡 Tip**: If the models you want to display don't fit, you may want to increase the size of your scene. See [scene size]({{< ref "/content/creator/scene-editor/scene-editor-essentials.md#scene-sizes" >}}) to enlarge your scene.
{{< /hint >}}

Even if the whole geometry of the 3D model fits in your scene, a model might be marked in red if the model's Bounding Box extends beyond the area. If this is the case, you can ignore the warnings, as the entire model will be displayed correctly. Learn more about [Bounding Boxes]({{< ref "/content/creator/3d-modeling/meshes.md#bounding-boxes" >}}).

## Scene settings

Expand Down
8 changes: 1 addition & 7 deletions content/creator/sdk7/3d-essentials/entity-positioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ See other ways to fetch other user's IDs in [Get Player Data]({{< ref "/content/
All entities in your scene must fit within the scene boundaries, as what's outside those boundaries is parcels of land that are owned by other players.
When running a preview of your scene, any entities outside the scene's parcels are colored red and their colliders are removed. When deployed to Decentraland, any entities outside the parcels will not be rendered at all by the engine.
If any part of your models extend beyond these limits when running a preview, these parts that extend will be cut off and not rendered, both when running a preview and on the published scene.
The position of entities in your scene is constantly being checked as they move, if an entity leaves the scene and then returns it will be removed and then rendered normally again.
Expand All @@ -521,9 +521,3 @@ A grid on the scene's ground shows the limits of the scene, which by default rag
{{< hint info >}}
**💡 Tip**: If your scene needs more parcels, you can add them in the project's `scene.json` file. See [Scene metadata]({{< ref "/content/creator/sdk7/projects/scene-metadata.md" >}}) for instructions. Once added, you should see the grid extend to cover the additional parcels.
{{< /hint >}}
It's important to note that the _entire_ 3D model must be within the scene's bounds. This includes the model's _bounding box_. Some 3D models may have bounding boxes that unnecessarily extend beyond the meshes themselves, and it can sometimes be tricky to tell when this happens. When an entity extends beyond the scene's boundaries, in the preview you'll see a cube that marks these bounding boxes. The entire cube must fit within your scene.
<img src="/images/media/bounding-box.png" alt="nested entities" width="300"/>
If an entity's cube extends beyond the shape of its meshes, you might need to edit the 3D model in an external editor to reduce these margins, or to _bake_ the rotation and scale of the meshes in the model.
2 changes: 1 addition & 1 deletion content/creator/sdk7/debugging/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ As an alternative, you can run `npm run deploy --skip-build` to skip the running

### Issue: Once deployed, some 3D models are missing

- Make sure the 3D models are all within the scene boundaries, even their bounding boxes. When running in preview, any 3D models that extend beyond the scene boundaries are marked in red and their bounding boxes are marked. In the deployed scene, these models aren't rendered at all, as they could be intruding into the parcels of your neighbors.
- Make sure the 3D models are all within the scene boundaries, even their bounding boxes. If any part of your models extend beyond these limits when running a preview, these parts that extend will be cut off and not rendered, both when running a preview and on the published scene.

### Issue: Once deployed, my 3D models look different

Expand Down
Binary file added static/images/editor/cut-train.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/images/editor/train-out-of-bounds.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 55d3dab

Please sign in to comment.