Keyboard Interaction of Objects in View

Posting for reference the proposed way on doing a visibility check on a mesh instance:

var MeshVisScript = pc.createScript('meshVisScript');

MeshVisScript.prototype.initialize = function() {
 
    this.app.scene.layers.getLayerByName("World").onPostCull = (cameraIndex) => {
        var entity = this.app.root.findByName("Box");
        var meshInstance = entity.model.model.meshInstances[0];
        console.log("visible: " + meshInstance.visibleThisFrame);
    }    
};
2 Likes