Rolling a striped tube so 3 stripes are always visible

Hi everyone-

I am color coding diagramming lines in my models and I want to have the color codes, which are 3 stripes, the same width regardless of where the camera is.

I’m trying to do this with tubes that have a decal on them. The tubes get rotated by mesh.billboardmode which works great for the vertical one but not the ones on x or z axes. Any ideas re what going wrong?

Thanks and a big 'sup y’all from New Jersey


@Evgeni_Popov might have some idea?

It does work, but the camera is rotated 90° around Y at start, so the x axis is coming outside the screen instead of going right compared to the true world axis.

If you move the camera so that it aligns with the world axis, so like this:

Then, rotating around X (left clicking + moving the cursor up and down), you will see that the tube which is aligned with the X axis (the one going from left to right) is behaving as expected.

Same thing for the tube aligned with the Z axis, but for this one you will need to change camera.upVector to be able to rotate around the Z axis (I don’t think we can perform this rotation with the mouse?).

Thanks Carol and Evgeni-

Evgeni, I think I may be having a fundamental misunderstanding of what billboardmode does.

Here’s a playground that does exactly what I want using math.

This does what I thought billboardmode did: apply the angle between the camera and the mesh to the mesh on a specific axis. I’ll accept this approach as the solution unless anyone has a better approach.

I also need to figure out a way to display the colors on the stripes without any lighting effects. Like it’s light from all sides and has no reflections, but this applies only to the specific meshes and not others on my mode. Ideas?

And for you, Carol: :stuck_out_tongue_winking_eye:


If you want to have a look at how we factor billboard modes into computing the world matrix, the code is here:

It’s a bit complicated, though!

You can use the emissive texture and disable lighting on the material: