How to properly update mesh vertex?

I have initialed a line mesh entity but was unable to update the position of the mesh vertex.

// Create mesh instance
    var meshInstance = new pc.MeshInstance(node, mesh, material);

    // Create model
    var model = new pc.Model();
    model.graph = node;
    model.meshInstances = [meshInstance];

    // Create child entity
    var childEntity = new pc.Entity(); = "LineEntity";
    childEntity.addComponent('model', {
        type: 'asset'

    childEntity.model.model = model;

    // Add the child entity to the current entity

    // Store the child entity for future use (e.g., to enable/disable it)
    this.lineEntity = childEntity;

I would like to update the vertex in game but I couldn’t access the mesh and got undefined error in meshInstance.mesh

// an array for use in mesh vertex array
        var positions = new Float32Array([
            pos0.x, pos0.y, pos0.z, // pos 0
            pos1.x, pos1.y, pos1.z, // pos 1
            pos2.x, pos2.y, pos2.z, // pos 2
            pos3.x, pos3.y, pos3.z  // pos 3

        // update mesh Position if lineEntity is ready
        if (this.lineEntity) {

Hi @Heiwa,

The proper property is meshInstances and it’s an array:


Also consider using the newer render component instead of model (model is deprecated, not receiving updates).

thanks, after a few debug I have managed to update to mesh position

1 Like