This script is attached to an empty entity in my scene.
So, how do i define device ?
The script :
var MeshGeneration = pc.createScript('meshGeneration');
// initialize code called once per entity
MeshGeneration.prototype.initialize = function() {
// Render a single, unindexed triangle
var mesh = new pc.Mesh(device);
var positions = [0, 0, 0, 1, 0, 0, 1, 1, 0];
mesh.setPositions(positions);
mesh.update();
};
Wouldn’t that make it impossible to troubleshoot from the console? eg pc.app.scene.root.findByName won’t be possible from console. Or is it only possible to use in the console?
It’s not public API in the sense that it isn’t officially supported and could change at any time. In this case where we are creating a mesh in a pc.script, this.app should be used instead.
If needed globally, please use pc.Application.getApplication() instead as that is public API.