How can I pass sth from array to update?

I want to pass meshInst to update
I have outside of initialize
var meshInst;
and in initialize:

if (nodeName.includes('road')) { meshInst = mesh;

I want to pass meshInst to update like
C1.prototype.update = function(dt, meshInst) { this.renderBoundingBox(meshInst._aabb); };
but not working meshInst is not detected
the mesh is pc.MeshInstance and from
this.meshes.map(function (mesh) {

Hi @grzesiekmq,

You can’t pass additional arguments in the update method, since it’s called internally by the engine.

Not sure I understand what you are trying to do, mainly … pass it from where?

Can you provide your full script or at least a bigger part of it?

1 Like

from here:

this.meshes.map(function (mesh) {
        var matName = mesh.material.name;
        var nodeName = mesh.node.name;

        var item = includeItems.find(function (item) {
            return nodeName.includes(item);
        });

        var key = keys.find(function (key) {
            return nodeName.includes(key);
        });

        if (nodeName.includes(item)) {
            mesh.material = this.matBuilding.resource;

        }



        if (nodeName.includes(key)) {
            var mat = matLookup(key);
            mesh.material = mat;

        }

        if (nodeName.includes('road')) {
                    meshInst = mesh;

to update
ok probably know what
this.meshInst and in update type it

The .map() method populates the this.meshes array with elements. So usually that runs once and fills the array with elements.

The .update() method runs per frame, why would you like to combine the two?