Hello, I’m a long time user of Babylon but first time poster here
I am having some issues using greased lines in my project. I think I found a bug or at least unexpected behavior. Please point me in the right direction if this is not a bug.
Long story short, I am using greased lines in multiple different places in my project, and I use BABYLON.CreateGreasedLine
to create the lines. Below is simplified version of what I’m trying to do. (You can find the link to the playground further below).
const points1 = [-1, 0, 0, 1, 0, 0];
const line1 = BABYLON.CreateGreasedLine("line1", { points: points1 }, {
color: BABYLON.Color3.Red(),
sizeAttenuation: true,
width: 5,
materialType: BABYLON.GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE,
});
const points2 = [-1, 1, 0, 1, 1, 0];
const line2 = BABYLON.CreateGreasedLine("line2", { points: points2 }, {
color: BABYLON.Color3.Green(),
sizeAttenuation: true,
width: 5,
materialType: BABYLON.GreasedLineMeshMaterialType.MATERIAL_TYPE_SIMPLE,
});
This all works fine, until I want to dispose one of the lines.
When I call line1.dispose()
the line is disposed as expected. The material that was created for line1
is not disposed, this is also expected.
However, I want to dispose the material.
To dispose the material, we would need to do the following:
line1.dispose(/*doNotRecurse*/ false, /*disposeMaterialAndTextures*/ true)
// Or simply
line1.material.dispose()
line1.dispose()
When I do this, line2
also disappears. However, both the node and material for line2
can still be found in the Babylon inspector. I cannot find any linkage between the materials for line1
and line2
that would explain this.
Here is a minimal reproducible example playground: https://playground.babylonjs.com/#ME2NKI#6
At the start we have line1
(red) and line2
(green)
Pressing dispose line
behaves as expected. The material for line1
is still there, and line2
is untouched.
Starting from scratch and pressing dispose line + material
removes both lines, but the inspector shows that the node and material for line2
still exists.
I would expect line2
to still be rendered in this case.
Any help would be greatly appreciated