I want to build a changing world event (with come back to previous world) when a camera collide a mesh…
So far so good… but i lost keyboard event… i need some help…
/////////////////////////////////////
camera.onCollide = function (collidedMesh){
// I fist check colide Id etc…
BABYLON.SceneLoader.LoadAsync (“root”,“file.babylon”, engine).then(function (scene){
scene.executeWhenReady(function (){
scene.activeCamera.attachControl(canvas, true);
worlds.currentWorld.scene = scene;
worlds.currentWorld.isReady = true;
});
});
}
/////////////////////////////////////////
// then i swith my world scene
engine.runRenderLoop(function () {
if (worlds.currentWorld && worlds.currentWorld.isReady) {
worlds.currentWorld.scene.render();
}
});
////////////////////////////////////////
So, it’s working fine but i lost the keyboard event for my freeCam… (still have mouse event) What is strange is that if i refresh the Dom, Clicking outside the page or navigating in the bowser inspector that work again…
Any suggestion ???
It looks like the focus is not the canvas anymore after loading the second scene so keyboard events are not going through. Actually clicking outside the browser then in makes it works again. I wonder if the loading screen is not capturing inputs somehow.
Could you try forcing the focus on the canvas after load ?
[Violation] Added non-passive event listener to a scroll-blocking ‘wheel’ event. Consider marking event handler as ‘passive’ to make the page more responsive. See Passive event listeners - Chrome Platform Status
YES that Work ;)))) Thanks a lot ;))))
But, well now i need the clean the engine of the unused scene,
Actually the engine.scenes is populated by all the scene histories… (not very clean
So, i try to use scene.dispose() but it make it crash… is there a proper way or location to to this cleaning ?