Hi all,
I’m new to BabylonJS so forgive the obvious question. But what’s the difference?
Regards,
Mark
Hi all,
I’m new to BabylonJS so forgive the obvious question. But what’s the difference?
Regards,
Mark
Basically, Append loads the whole file, meshes, lights, cameras, skeletons, & materials.
ImportMesh was primarily to only get certain meshes. The argument is an array of the mesh names, or a string for 1, though en empty string gets the all of them. As it works thru the meshes requested, it gets any materials or skeletons that the mesh needs, but never any lights or cameras.
If you are starting out, try Append first. If it loads stuff you do not want, then use ImportMesh. There is also Load, but I would not encourage that. It also creates the scene, but that causes problems if you wish to load more than one file. Better to do multiple Appends, then put a ready block after rather than try doing stuff post load stuff in callbacks:
const canvas = document.getElementById("renderCanvas");
const engine = new BABYLON.Engine(canvas, true);
const scene = new BABYLON.Scene(engine);
BABYLON.SceneLoader.Append("./", "fileA.babylon", scene);
BABYLON.SceneLoader.Append("./", "fileB.babylon", scene);
scene.executeWhenReady(function () {
// get stuff by name or ID & do stuff
skeleton = scene.getSkeletonByName("base_male1");
skeleton.beginAnimation("base08_11x94", true);
// Attach imported camera to canvas inputs
scene.activeCamera.attachControl(canvas);
// Once the scene is loaded, register a render loop
engine.runRenderLoop(function() {
scene.render();
});
});