I am having some issues when exporting GreasedLine.
gltf (download via inspector Debug Tab):
When I export this scene https://playground.babylonjs.com/#H1LRZ3#98 as gltf and import it in sandbox.playground.com I can see the nodes and they have vertices, but they will not be shown in the viewport. I do not expect to have an extension for gltf, but it would rather be nice, if it exports like normal LineMesh, which would be shown as a hairline with colors.
You can’t export a GreasedLineMesh to GLTF. GRL uses specific materials - vertex shaders to move the vertices to the desired positions and to display the line correctly (always facing the camera, variable width, etc) and specific fragment shaders to achieve dashing, coloring, visibility, etc.
However you can serialize a GreasedLineMesh for later use.
The only way to correctly export a GreasedLineMesh is to write a custom exporter which could create the resulting mesh on the CPU.
Hi roland,
yes that is what I thought and why it would be easier to maybe export it as a simple line. For those who want to have it exported, i guess your proposal is better suited. And others would need to use my approach of just making a LinesMesh copy for export. That is probably the cleaner approach.
(In my case i am more interested in the actual line data from point to point and not the visualisation. Since its rather CAD related. So LinesMesh is good enough.)
Since there is already some work done on reconstructing the line surface taking the variable widths into account on the CPU side for picking purposes, it would help a lot while making a GLTF exporter. I believe it will do no harm if you ask for such functionality in the Feature requests category.
Ah, I didn’t catch the ask on the first read. It’s true that we cannot correctly export a GreasedLineMesh because of its custom shaders.
However, the greased line *vertex data itself should be available on export. It’s not visible because its fill mode defaults to TRIANGLES when, practically speaking, it should be LINES. We make this change already when exporting LineMesh– maybe we can throw in a quick check for GreasedLineMesh at the same time. The output won’t be correct, but at least it will be a little less incorrect