Yes @yaustar i guessed it was those, but i don’t get why since no lights are shown and the code should disable them.
EDIT: checked with some breakpoints, the code is executed correctly, the lights turn off but it still says 12 lights.
That output of the lights is from going through all the entities in the game when it is running, checking if it’s a light and whether the entity is enabled or not.
When you turn off the lights, do you disable the Entity or the light component or a parent Entity?
Edit: Something is either creating them again or enabling them as they are enabled when the game is running.
When i turn off the lights i disable the light component the parent entity has just a change of texture, here is the full daynight cycle code (it’s called every 30 mins)
Game.prototype.daynight= function() {
this.timestart=Date.now();
if (this.hour==='day') {
this.hour='night';
this.cubenight.loadFaces = true;
this.app.scene.skybox=this.cubenight.resource;
this.app.scene.skyboxIntensity=0.1;
this.app.scene.fogColor=new pc.Color(0,0,0);
this.app.scene.fog='linear';
this.app.scene.skyboxMip = 1;
this.light.light.color= new pc.Color(0,0.1,0.3);
var lamp=this.app.root.findByTag('light');
var lamp1=this.app.root.findByTag('lamp');
for (var i=0; i<lamp.length;i++) {
lamp[i].light.enabled=true;
lamp1[i].model.model.meshInstances[7].material = this.texLamp[1].resource;
}
this.app.lightmapper.bake(null, pc.BAKE_COLORDIR);
} else {
this.hour='day';
this.cubemap.loadFaces = true;
this.app.scene.skybox=this.cubemap.resource;
this.app.scene.skyboxIntensity=1;
this.app.scene.fogColor=new pc.Color(0.3,0.4,0.5);
this.app.scene.skyboxMip = 1;
this.light.light.color= new pc.Color(0.7,0.7,0.7);
var lamp=this.app.root.findByTag('light');
var lamp1=this.app.root.findByTag('lamp');
for (var i=0; i<lamp.length;i++) {
lamp[i].light.enabled=false;
lamp1[i].model.model.meshInstances[7].material = this.texLamp[0].resource;
}
this.app.lightmapper.bake(null, pc.BAKE_COLORDIR);
}
};
Ehm no during day cycle just 1…at night they became 12 (11 without shadows), can’t turn on just one coz when play in first person you will see the far lights.
EDIT: i reduce the cycle day/night to 30 seconds
Anyway seems it’s just a bug of the profiler, all lights works fine and the game is not affected…also if something is slowing down the frame rate, is it possible to use an old version of ammo?
You can do (find an older release from the Ammo.js GitHub and replace the project files) but chances are that it will be slower than the WASM module that is currently there.
A quick profiler shows that ~90% of your frame is spent in physics so if it’s the terrain that’s causing the issue (branch the code and find a fast way to test), you really need to find a way to restructure the code to effectively get around it.
Is it all one large terrain? Have you tried to divide that up into much smaller pieces so you only have a few pieces loaded at once over all 900k polys?
They can be static indeed, if it doesn’t affect the re-location when changing scenes, triangles are now 200k but still 10fps instead 35fps of old scripts, so i thought ammo version is the issue.
If the scenes are exactly the same with exactly the same settings, it could be worth trying an older version of the engine to see if there has been change in how Ammo is used.
Ammo hasn’t changed that much but there has been some refactors around the physics code.
Do you have a link to the old version of the project?