mwpowellhtx Posted May 10, 2016 Share Posted May 10, 2016 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! Quote Link to comment Share on other sites More sharing options...
mwpowellhtx Posted May 10, 2016 Author Share Posted May 10, 2016 The nearest thing I can see potentially being able to do this is, line._geometry.setIndices, but with the underscore, I am hesitant to accept that without knowing a bit more about the context. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 10, 2016 Share Posted May 10, 2016 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 Quote Link to comment Share on other sites More sharing options...
adam Posted May 10, 2016 Share Posted May 10, 2016 https://www.google.com/search?q=update+linesmesh+babylonjs&oq=update+linesmesh+babylonjs&aqs=chrome..69i57.17070j0j4&sourceid=chrome&ie=UTF-8 Quote Link to comment Share on other sites More sharing options...
mwpowellhtx Posted May 10, 2016 Author Share Posted May 10, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 10, 2016 Share Posted May 10, 2016 Ok I get your point So getVerticesData and updateVerticesData are the way to go Quote Link to comment Share on other sites More sharing options...
mwpowellhtx Posted May 10, 2016 Author Share Posted May 10, 2016 @Deltakosh Alright, so it sounds like a stupid question, but when I want to update the BABYLON.Vector3 points in the lines mesh, which Kind do I use? Quote Link to comment Share on other sites More sharing options...
mwpowellhtx Posted May 11, 2016 Author Share Posted May 11, 2016 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". Quote Link to comment Share on other sites More sharing options...
adam Posted May 11, 2016 Share Posted May 11, 2016 http://www.babylonjs-playground.com/#24PQRQ Quote Link to comment Share on other sites More sharing options...
jerome Posted May 11, 2016 Share Posted May 11, 2016 maybe : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.