Not able to create polyline with new Communicator.MeshData(),

// Leader line. Make it fixed coords - we scale it later based on the position
        const leaderLineVertices = [0, 0, 0, 1, 1, 1]
        const leaderMeshData = new Communicator.MeshData()
        leaderMeshData.addPolyline(leaderLineVertices);
        const leaderMeshId = await this._viewer.model.createMesh(leaderMeshData)

        const leaderMeshInstanceData = new Communicator.MeshInstanceData(
            leaderMeshId, 
        )
        leaderMeshInstanceData.setCreationFlags(
            Communicator.MeshInstanceCreationFlags.ExcludeBounding
        )
        leaderMeshInstanceData.setLineColor(this.hexToRgb(textSettings.borderColor))
        const leaderInstanceId = await this._viewer.model.createMeshInstance(
            leaderMeshInstanceData
        )

I have used this code from 3dTextbox Example, I am not able to see the line in my viewer.

1 Like

Hello @swaminarayan.sharma,

Welcome to the Tech Soft 3D forum !

The code snippet that you provided is very specific to the 3D Text Insertion example that is included in the Communicator package. In particular is this line:

leaderMeshInstanceData.setLineColor(this.hexToRgb(textSettings.borderColor))

Does your viewer also have code to handle textSettings object? Also, are you getting any errors in the web browser console?

Thanks,
Tino

Hello @tino ,
I am not getting any errors in console
Also how can i check my viewer has code for handling textSettings.
I am adding the screenshot of my console, my client side viewer pics in which i have updated the styling of mesh but border of the textbox which we generate by “addPolyline”
image


This is the screenshot of my viewer in which, I am not able to render leaderline

Hello @swaminarayan.sharma,

Based on the screenshot you attached, it looks like your viewer is largely similar to the 3D Text Insertion example. In which case, it is recognizing the textSettings object.

I think the issue is one of unit scale. So rather than setting the vertices to this:
const leaderLineVertices = [0, 0, 0, 1, 1, 1];

Please try something much larger, for example:
const leaderLineVertices = [0, 0, 0, 100000, 100000, 100000];

I don’t have the model used in your screenshot so I can’t say for sure the appropriate order of magnitude.

Thanks,
Tino

1 Like