renderLine with layers

So now with pc.Layer, we have to specify which layer the line is rendered to:

app.renderLine(start, end, color, {
  layer: app.scene.layers.getLayerById(pc.LAYERID_WORLD)

But, when using this code, the entire “World” layer is overridden by line rendering. Same when using “UI” layer etc. Also, when I tried to create a new layer and render the lines into it, the lines were not rendered. Has anyone had this issue?

You don’t “have to” specify layer, but you can.

If you don’t, it will render just like before Layers system.

Oh, okay, the API docs mystifyed me, because I was using app.renderLine(start, end, startColor, endColor); and that was causing an error with layers (so I thought the layer is mandatory), because now the 4th parametr is not endColor, but target layer.

Anyhow, that still does not solve the problem with overwriting whole predefined layers / not drawing to new layers.

Yes, layers are so mysterious. Only somebody from devs could answer that.

1 Like

renderLine needs to use the Immediate layer to draw lines. If you want to render lines on a different layer then create a custom layer and set the same options as the built-in immediate layer. Don’t use the World layer or other built-in layers because that’s not how it’s meant to work.