Hi guys, i’m very new to Babylon.js but i’m impressed with it’s stability but still if found it very confusing to work with in some cases so i want to ask community for best approaches.
So here is my code:
`var canvas = document.getElementById(“renderCanvas”);
var engine = null;
var scene = null;
var sceneToRender = null;
var createDefaultEngine = function() { return new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true }); };
var delayCreateScene = function () {
// Create a scene.
var scene = new BABYLON.Scene(engine);
// Create a default skybox with an environment.
var hdrTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("textures/environment.dds", scene);
var currentSkybox = scene.createDefaultSkybox(hdrTexture, true);
var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 0, new BABYLON.Vector3(0, 0, 0 ), scene);
camera.setPosition(new BABYLON.Vector3(0, 0, 70));
// Append glTF model to scene.
BABYLON.SceneLoader.ImportMesh(
null,
"scene/",
"scene.gltf",
scene,
function (meshes) {
// Create a default arc rotate camera and light.
// scene.createDefaultCameraOrLight(true, true, true);
meshes[0].rotation = new BABYLON.Vector3(1, 0, 0);
// The default camera looks at the back of the asset.
// Rotate the camera by 180 degrees to the front of the asset.
// scene.activeCamera.alpha += Math.PI;
});
return scene;
};
var engine;
try {
engine = createDefaultEngine();
} catch(e) {
console.log("the available createEngine function failed. Creating the default engine instead");
engine = createDefaultEngine();
}
if (!engine) throw 'engine should not be null.';
scene = delayCreateScene();;
sceneToRender = scene
engine.runRenderLoop(function () {
if (sceneToRender) {
sceneToRender.render();
}
});
// Resize
window.addEventListener("resize", function () {
engine.resize();
});`
What i want to achieve is the simple rotation loop for imported mesh.