TrailMesh shape / height?

I’m trying to use a TrailMesh to create the tire tracks behind a car in the sand. I use a textured material with 2 separate tracks on it for each side of the car.

I got it working, but I notice the trail is setup like a triangle, which distorts the texture a bit, when moving diagonally.

Is there a way to make the trailmesh to be lower (or even flat on the ground) ?

I also tried using CreateRibbon to create the tire tracks, but I couldn’t get this working. The updating of the vertices was a bit too complex for me.

Hi @BobDylan
Can you please do a repro in a PG?

In this example, you can move a box with WASD-keys. You can see the trail is shaped like a diamond.
In my game, I have the point origin of my mesh set to the center-bottom of the mesh, so it appeared as a triangle to me.

I would like to ‘flatten’ the triangle, to make the trail mesh not appear as a threedimensional shape, but as a flat ribbon on the ground.

Hope this is clear :slight_smile:

something like this ?

Thanks a lot, I couldn’t find how to set the number of sections. The constructor I used, doesn’t have this. Unfortunately VSCode with Typescript doesn’t accept the other constructor with the options-parameter.

Would you happen to know how to set the options in another way than in the constructor?

Did you check this page? Babylon.js docs
I’ve also opened the 2nd PG demoed in the page.

Yes I saw the documentation. The problem is that there are 2 kinds of constructors for TrailMesh :

constructor TrailMesh(name: string, generator: BABYLON.TransformNode, scene?: BABYLON.Scene | undefined, diameter?: number | undefined, length?: number | undefined, autoStart?: boolean | undefined): BABYLON.TrailMesh


constructor BABYLON.TrailMesh(name: string, generator: BABYLON.TransformNode, scene?: BABYLON.Scene, options?: BABYLON.ITrailMeshOptions): BABYLON.TrailMesh

I cannot use the last one, because VSCode / eslint doesn’t allow me to. It gives an error, since it expects the TrailMesh to be created with diameter and length as parameters, instead of with the options object.

There must be a way to set the number of sections in another way, I think?

Might be an issue we can fix then? @RaananW

After upgrading BabylonJS from 7.0.0 to 7.13.0 in my project the error disappeared! Now VSCode somehow recognizes both kinds of constructors.

But when I try to use 7.13.1 (latest version), I see no trail at all with the same code, so maybe there’s still a problem there.

can you reproduce that? sorry, I just joined the conversation so I might have missed something along the way :slight_smile:

Internally, the constructor is checking what the type of the variable is and makes sure to initialize the class with the right parameters. in JS it should work without an issue, in typescript as well (though it infers the type from the parameters passed, so you need to be sure you are passing the right type/object).

Well, the problem with VSCode not recognizing both constructors is solved now (since upgrading the BabylonJS version). My Vite/eslint setup gave a warning about it, but not anymore.

I can’t reproduce the empy trailmesh I got with 7.13.1, so I guess this is solved too.