Have issue with
console.log(this.entity.model.meshInstances[3259]);
not displaying the object, not displaying anything
Hi @grzesiekmq,
What are you trying to do?
Do you actually have a model with 3259 plus mesh instances? That’s too many.
And then you are trying to print information for meshInstance with index 3259?
console.log('ok');
not displaying too
yes the model has 3259 and more mesh instances
yes the object it is mesh instance with index 3259
Can you share a bit more of your code or a project url to take a look?
var TestMaterials = pc.createScript('testMaterials');
// initialize code called once per entity
TestMaterials.prototype.initialize = function() {
console.log(this.entity.model.meshInstances[3259]);
console.log('ok');
};
// update code called every frame
TestMaterials.prototype.update = function(dt) {
};
this script is attached to entity of car
As long as your entity has a model component and it’s enabled, this script should work and print something to the console.
If it’s still not working, do post a project url to take a look.
https://playcanvas.com/editor/scene/909187
nothing displaying don’t know why
in engine-only console.log() works for me
So, it’s difficult to navigate in editor. It seems the combination of high-poly models with 200+ materials each is slowing the down the editor. I think you will have to optimize your assets/scene setup to have this app/game run with a decent FPS and load times.
For your current issue, I am not sure what’s the cause, difficult to navigate in editor and check the entities. On which entity is the testMaterial.js script attached to?
testMaterials.js is attached to r32 body entity
I also temporarily turn off the model of map
cars->rb r32->r32 body
So, it seems you are missing a last step when editing your script, pressing Save (Ctrl+S).
Even though you added the code in the code editor, the script executing with the app is empty:
yes I thought it saves automatically as is show in the lower left corner ‘Saved’
thank you
Good point, actually it saves the changes to the cloud/collaborate end point since I was able to see the two lines that you added.
But that’s different from saving the changes to the actual script asset in editor. This allows for collaborating coding, multiple people editing the same script.
A post was merged into an existing topic: SketchFab asset store isn’t working