Jump to content

How to make a VertexBuffer updatable?


adam
 Share

Recommended Posts

My mesh is from a model I created in Blender.

I used to be able to do this:

var vb = mesh.getVertexBuffer(BABYLON.VertexBuffer.PositionKind);
vb._updatable = true;

var vertices = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind);

and then update the vertices array directly.  It doesn't seem to work anymore.

Link to comment
Share on other sites

I'm now using the export file from Tower of Babel.

The vertex buffer isUpdatable() is returning true, but the geometry doesn't update when I update the positions array.  Vertices are moving now that I'm using the updateMeshPositions function.

I noticed that the length of the vertex positions array is almost 3 times the length of the positions array that was used when creating the vertex positions.  (1974 vs 5616)

So even if it updated, I'd probably be referencing the wrong positions. (the difference in array length was because I converted my mesh to flat shaded)

Link to comment
Share on other sites

Do your flat shading in Blender.  Your JS file will be bigger, but will correct your problem.  In QI.Mesh proper there is:

/** @override */
public convertToFlatShadedMesh() : void {
    if (this._shapeKeyGroups.length > 0){
         BABYLON.Tools.Error("QI.Mesh:  Flat shading must be done on export with shape keys");
         return null;
            
    }else super.convertToFlatShadedMesh();
}

 

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...