N1warhead Posted June 28, 2016 Share Posted June 28, 2016 Hey guys, I am just plainly getting fed up with this, sorry for saying that. But here's the main issue, and I swear it just has to be a bug. Okay, I can load up a babylon scene file of my mesh, okay works perfectly fine. I can do it with SceneLoader.Load and ImportMesh. Works perfectly fine. However, the second I try to export an Animation from max (with the Exporter). It goes crazy, it no longer recognizes the engine.runRenderLoop(function () { scene.render(); }); With both Load and ImportMesh. I just plainly don't know what else to do. it works in SandBox. But it refuses to load on the Website. Well it says it creates the model (via console log). But it just plainly doesn't like the above snipper of code, it keeps saying Camera isn't defined. When it fact it is (I created one in Max Scene), I also try to create one via code, and it just crashes and says it doesn't recognize any of this // var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5, -10), scene); // camera.attachControl(canvas, false); // scene.camera = camera; // scene.activeCamera.attachControl(canvas); Yes they are commented out, because it doesn't like them. In fact 95% of my code is commented out because it doesn't like any of these two things // BABYLON.SceneLoader.Load("", "Model/WomanBabylonConvert/Woman.babylon", engine, function (scene) { BABYLON.SceneLoader.ImportMesh("character1", "AnimationStock/", "Woman.babylon", scene, function (newMeshes, particleSystems, skeletons) { Here is the entire code. window.addEventListener('DOMContentLoaded', function(){ var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); // BABYLON.SceneLoader.Load("", "Model/WomanBabylonConvert/Woman.babylon", engine, function (scene) { BABYLON.SceneLoader.ImportMesh("character1", "AnimationStock/", "Woman.babylon", scene, function (newMeshes, particleSystems, skeletons) { // Wait for textures and shaders to be ready var mesh = newMeshes[0]; mesh.rotation.y = Math.PI; mesh.position = new BABYLON.Vector3(0, 0, 0); scene.beginAnimation(skeletons[0], 0, 100, true, 1.0); scene.executeWhenReady(function () { // Attach camera to canvas inputs var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(1, 0, 1), scene); // var camera = new BABYLON.FreeCamera('camera1', new BABYLON.Vector3(0, 5, -10), scene); // camera.attachControl(canvas, false); // scene.camera = camera; // scene.activeCamera.attachControl(canvas); // var mesh = scene.mesh; //mesh.position = new BABYLON.Vector3(0, 0, -8); // var sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 2, scene); // scene.meshes[0].scaling = new BABYLON.Vector3(1, 1, 1); //mesh.scaling = new BABYLON.Vector3(20, 20, 20); // console.log(scene.cameras[0]); console.log(scene.meshes[0]); //scene.meshes[0].convertToFlatShadedMesh(); //scene.meshes[0].showBoundingBox = true; light.groundColor = new BABYLON.Color3(0.2, 0, 0.3); var ground = BABYLON.Mesh.CreateGround('ground1', 6, 6, 2, scene); // Once the scene is loaded, just register a render loop to render it // engine.runRenderLoop(function () { // scene.render(); // }); }); }, function (progress) { // To do: give progress feedback to user }); return scene; } var scene = createScene(); // Once the scene is loaded, just register a render loop to render it engine.runRenderLoop(function () { scene.render(); }); // window.addEventListener("resize", function () { // scene.resize(); // }); }); I seriously don't know what else to do. All I am trying to do is load a .babylon file that has an Animation... (IT WORKS WITHOUT ANIMATION). But not with an animation. Please help me. Sorry if I sounded kinda rude, been at this single problem for 14 hours today. Quote Link to comment Share on other sites More sharing options...
N1warhead Posted June 28, 2016 Author Share Posted June 28, 2016 Go ahead and delete this mods. I got it working, and don't even know how I got it working. Just started over, for the fourth time and now it works. Quote Link to comment Share on other sites More sharing options...
Nabroski Posted June 28, 2016 Share Posted June 28, 2016 Hello Good to hear after 14h you get it to work Just a quick note: You add your scene (importmesh) to the one you are creating as more global var(iable) scene = ect., no need to add extras like light etc. in the scene that you are importing, when you already export them through your 3d Program. you are run in troubels if your add new extras/objects/function and calls when their are scoped, and not visible by the global scenehttp://www.w3schools.com/js/js_scope.aspscene.executeWhenReady(function () { is just a control structures like if else if importmesh has fully loaded then do stuff. beginanimation should be in the scope of executeWhenReady ... best Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.