Skip to content

Instantly share code, notes, and snippets.

@CedricGuillemet
Created January 20, 2021 14:02
Show Gist options
  • Save CedricGuillemet/4d4d103910844818a559beb326739e35 to your computer and use it in GitHub Desktop.
Save CedricGuillemet/4d4d103910844818a559beb326739e35 to your computer and use it in GitHub Desktop.
var trailMesh = BABYLON.MeshBuilder.CreateGround("trail", {width: 0.1, height: 0.010, subdivisionsY:256}, scene);
trailMesh.setBoundingInfo(new BABYLON.BoundingInfo(new BABYLON.Vector3(-1000,-1000,-1000), new BABYLON.Vector3(1000,1000,1000)));
trailMaterial.backFaceCulling = true;
trailMesh.material = trailMaterial;
var trackSampler0Block = trailMaterial.getBlockByPredicate((b) => b.name === "tailSampler0");
var trackSampler1Block = trailMaterial.getBlockByPredicate((b) => b.name === "tailSampler1");
var data = new Array(trailLength * 4);
for (let i = 0; i < trailLength; i++)
{
var newPos = posFunction((-255.5 + i) * timeStep + 10)
data[i*4] = newPos.x;
data[i*4+1] = newPos.y;
data[i*4+2] = newPos.z;
data[i*4+3] = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment