Jump to content

How to set lines mesh vertices positions


mwpowellhtx
 Share

Recommended Posts

Hello,

I want to update the vertices of a lines mesh after it has been created. On a sphere, by contrast, I can do so fairly simply:

mySphere.position.x = myX;
mySphere.position.z = myZ;

But there does not appear to be anything like that for lines mesh:

// myLines.positions is undefined ????
myLines.positions[0].x = myPositions[0].x;
myLines.positions[0].z = myPositions[0].z;
myLines.positions[1].x = myPositions[1].x;
myLines.positions[1].z = myPositions[1].z;
// myLines._positions is null ????
myLines._positions[0].x = myPositions[0].x;
myLines._positions[0].z = myPositions[0].z;
myLines._positions[1].x = myPositions[1].x;
myLines._positions[1].z = myPositions[1].z;

Is the only way to make the mesh updatable and send a new array of points in via the options? Doable, but it's more of a pain, IMO.

Insight appreciated. Thanks!

Link to comment
Share on other sites

Hum...I think there is a misunderstanding here.

This does not change the geometry but just the position of the mesh:

mySphere.position.x = myX;
mySphere.position.z = myZ;

To change the inner vertex buffer, you have to use mesh.getVerticesData.

This article uses it extensively http://doc.babylonjs.com/tutorials/How_to_Merge_Meshes

And you can find tons of samples in the PG:http://doc.babylonjs.com/playground?q=getVerticesData

 

Link to comment
Share on other sites

27 minutes ago, Deltakosh said:

Hum...I think there is a misunderstanding here.

This does not change the geometry but just the position of the mesh:


mySphere.position.x = myX;
mySphere.position.z = myZ;

To change the inner vertex buffer, you have to use mesh.getVerticesData.

This article uses it extensively http://doc.babylonjs.com/tutorials/How_to_Merge_Meshes

And you can find tons of samples in the PG:http://doc.babylonjs.com/playground?q=getVerticesData

 

Perhaps a misunderstanding of the vocabulary.

In the case of the spheres, I want to reposition them; that's exactly what I need.

In the case of the lines, I expect to add vertices to it, or remove vertices from it; at minimum, wholesale replace the vertices, but avoid replacing the mesh itself if I can help it.

Link to comment
Share on other sites

If I call BABYLON.MeshBuilder.CreateLines(...) having set the { updatable: true } option, I should be able to call CreateLines(...) with { points: [...], instance: l }. However, I get several warnings piling up, "WebGL: INVALID_VALUE: bufferSubData: buffer overflow", and when I interact with the lines to set their visibility, I get an exception: "Uncaught TypeError: Cannot read property 'boundingSphere' of undefined".

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...