Hi there,
I’m not sure if anyone is sort of familiar with Barba JS. Each page has a canvas and the idea is to load a different scene on every page (same one at the moment). This is the function to load the scene:
var canvas;
var engine = null,
scene = null;
function preloadEvents(container) {
var canvas = container.querySelector("#canvas_place");
var createDefaultEngine = function() { return new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true }); };
var createScene = function () {
var scene = new BABYLON.Scene(engine);
scene.clearColor = new BABYLON.Color4(0, 0, 0, 0);
var spot = new BABYLON.HemisphericLight("spot", new BABYLON.Vector3(-0.3, 2.4, -2), scene);
spot.intensity = 1;
spot.diffuse = new BABYLON.Color3(1, 1, 1);
spot.specular = new BABYLON.Color3(0, 0, 0);
function createSidesForGroundMesh(ground, bottomY) {}
var assetsManager = new BABYLON.AssetsManager(scene);
babylonJsAssetsToLoad.forEach((obj) => {});
var camera = new BABYLON.ArcRotateCamera("Camera", -40, 1.2, 140, BABYLON.Vector3.Zero(), scene);
camera.setTarget(new BABYLON.Vector3(0, -15, 0));
camera.attachControl(canvas, true);
var groundMaterial = new BABYLON.StandardMaterial("ground", scene);
groundMaterial.diffuseTexture = new BABYLON.Texture("xxxxx.jpg", scene);
var ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "xxxx.png", 100, 70, 250, 0, 5, scene, true, successCallback);
function successCallback() {}
assetsManager.onFinish = function (tasks) {
engine.runRenderLoop(function () {
if (scene) {
scene.render();
}
});
};
assetsManager.load();
return scene;
}
engine = createDefaultEngine();
scene = createScene();
engine.runRenderLoop(function () {
if (scene) {
scene.render();
}
});
window.addEventListener("resize", function () { engine.resize(); });
}
And this is the Barba function that deals with all the calls:
barba.init({
debug: true,
transitions: [{
once(data) {
preloadEvents(data.next.container);
},
leave({current}) {
current.container.remove();
},
beforeEnter(data) {
scene.dispose();
canvas = null;
delete canvas;
preloadEvents(data.next.container);
}
}]
});
I’m not sure if this is the right way to update scenes on Babylon so any help would be much appreciated
Thanks

the only thing you have to do is dispose the current engine and create a new one for the given canvas. THen all good 


Thanks for your help and sorry about the whole thing with GSAP. The version I was using before wasn’t even that old but who knows