Jump to content

# How to leave a trace behind a moving mesh?

## Recommended Posts

Hi, I'm moving a sphere (red ball) managing its x,y,z positions but I need that the ball leaves a trace of the same color.

What could be the best way to achieve this?

Thank you.

##### Share on other sites

Are you looking for a fading 'trace' or one which remains? Also, do these need to be strait lines, or follow the object precisely?

DB

##### Share on other sites

@dbawel

Hi, I need one which remains (solid color) that follows the object precisely with its 3 coordinates.

##### Share on other sites

I solved it (at least temporarily). I used sprites for each sphere location, is not fancy but it shows the complete path of my sphere, you can check it here:

##### Share on other sites

Hi Hit2501,

Well 3 solutions come to my mind:

1. Yes you can use sprites. I would recommend to reduce the sprite locations to have a minimum distance (so they don't overlap, which isn't fancy). See the Street Hoops 3D demo on babylonjs.com when you aim the basket ball you see a trail of dots for an example. Hint: Put the Vector3 points into a Path3D to get more useful properties about the trajectory for free.
2. You can also use the Line mesh to draw a line through the points. See https://doc.babylonjs.com/how_to/parametric_shapes#lines If you have multiple trajectories you can use the LineSystem (and give each ball line a different color etc.).
3. Finally you can use a Ribbon or mesh extrusion along a Path3D if you want the line to have some sort 'shape' in 3D. E.g. for a ball which is a sphere your line shape will be an extruded Circle to create a (bended) tube. Demo's http://jerome.bousquie.fr/BJS/demos/rollercoaster.html see the track that is constructed along the line path. Also see the docs on extruding a shape along a path.

Maybe there are more ways, but these 3 will probably help you get started.

I use option #2 (for debug) an #3 for my Model Train Simulator game to construct the rail track path.

Enjoy.

Q

##### Share on other sites

Thank you Quintus, I'll try your suggestions. I didnt know the Line option, it seems more eficient.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
• ### Recently Browsing   0 members

• No registered users viewing this page.
×
×
• Create New...