zen85 Posted November 16, 2018 Share Posted November 16, 2018 hy, i am quite new to babylon.js and i am trying out stuff. I managed to get babylon.js running on my webspace and i can successfully reproduce for example the animation example from the playground. however i am actually after the animation blending feature with the model from mixamo. it works great on the playground - but when i copy the the code from there and change the links to the dummy3.babylon file in the playground/scenes/ folder it gives me the following error: Quote BJS - [22:11:01]: Unable to import meshes from ./scenes/dummy3.babylon: Error in onSuccess callback it drives me crazy since i can not find a solution to this and i think i am overlooking something really obvious here. can anybody give me a hint? i attached my code below: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/> <title>Babylon - Getting Started</title> <!--- Link to the last version of BabylonJS ---> <script src="https://cdn.babylonjs.com/babylon.js"></script> <style> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; } #renderCanvas { width : 100%; height : 100%; touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> window.addEventListener('DOMContentLoaded', function(){ // get the canvas DOM element var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); var delayCreateScene = function () { // Model by Mixamo engine.enableOfflineSupport = false; // This is really important to tell Babylon.js to use decomposeLerp and matrix interpolation BABYLON.Animation.AllowMatricesInterpolation = true; var scene = new BABYLON.Scene(engine); var camera = new BABYLON.ArcRotateCamera("camera1", Math.PI / 2, Math.PI / 4, 3, new BABYLON.Vector3(0, 1, 0), scene); camera.attachControl(canvas, true); camera.lowerRadiusLimit = 2; camera.upperRadiusLimit = 10; camera.wheelDeltaPercentage = 0.01; var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); light.intensity = 0.6; light.specular = BABYLON.Color3.Black(); var light2 = new BABYLON.DirectionalLight("dir01", new BABYLON.Vector3(0, -0.5, -1.0), scene); light2.position = new BABYLON.Vector3(0, 5, 5); // Shadows var shadowGenerator = new BABYLON.ShadowGenerator(1024, light2); shadowGenerator.useBlurExponentialShadowMap = true; shadowGenerator.blurKernel = 32; engine.displayLoadingUI(); BABYLON.SceneLoader.ImportMesh("", "./scenes/", "dummy3.babylon", scene, function (newMeshes, particleSystems, skeletons) { var skeleton = skeletons[0]; shadowGenerator.addShadowCaster(scene.meshes[0], true); for (var index = 0; index < newMeshes.length; index++) { newMeshes[index].receiveShadows = false;; } var helper = scene.createDefaultEnvironment({ enableGroundShadow: true }); helper.setMainColor(BABYLON.Color3.Gray()); helper.ground.position.y += 0.01; // ROBOT skeleton.animationPropertiesOverride = new BABYLON.AnimationPropertiesOverride(); skeleton.animationPropertiesOverride.enableBlending = true; skeleton.animationPropertiesOverride.blendingSpeed = 0.05; skeleton.animationPropertiesOverride.loopMode = 1; var idleRange = skeleton.getAnimationRange("YBot_Idle"); var walkRange = skeleton.getAnimationRange("YBot_Walk"); var runRange = skeleton.getAnimationRange("YBot_Run"); var leftRange = skeleton.getAnimationRange("YBot_LeftStrafeWalk"); var rightRange = skeleton.getAnimationRange("YBot_RightStrafeWalk"); // IDLE if (idleRange) scene.beginAnimation(skeleton, idleRange.from, idleRange.to, true); // UI var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI("UI"); var UiPanel = new BABYLON.GUI.StackPanel(); UiPanel.width = "220px"; UiPanel.fontSize = "14px"; UiPanel.horizontalAlignment = BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_RIGHT; UiPanel.verticalAlignment = BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER; advancedTexture.addControl(UiPanel); // .. var button = BABYLON.GUI.Button.CreateSimpleButton("but1", "Play Idle"); button.paddingTop = "10px"; button.width = "100px"; button.height = "50px"; button.color = "white"; button.background = "green"; button.onPointerDownObservable.add(()=> { if (idleRange) scene.beginAnimation(skeleton, idleRange.from, idleRange.to, true); }); UiPanel.addControl(button); // .. var button1 = BABYLON.GUI.Button.CreateSimpleButton("but2", "Play Walk"); button1.paddingTop = "10px"; button1.width = "100px"; button1.height = "50px"; button1.color = "white"; button1.background = "green"; button1.onPointerDownObservable.add(()=> { if (walkRange) scene.beginAnimation(skeleton, walkRange.from, walkRange.to, true); }); UiPanel.addControl(button1); // .. var button1 = BABYLON.GUI.Button.CreateSimpleButton("but3", "Play Run"); button1.paddingTop = "10px"; button1.width = "100px"; button1.height = "50px"; button1.color = "white"; button1.background = "green"; button1.onPointerDownObservable.add(()=> { if (runRange) scene.beginAnimation(skeleton, runRange.from, runRange.to, true); }); UiPanel.addControl(button1); // .. var button1 = BABYLON.GUI.Button.CreateSimpleButton("but4", "Play Left"); button1.paddingTop = "10px"; button1.width = "100px"; button1.height = "50px"; button1.color = "white"; button1.background = "green"; button1.onPointerDownObservable.add(()=> { if (leftRange) scene.beginAnimation(skeleton, leftRange.from, leftRange.to, true); }); UiPanel.addControl(button1); // .. var button1 = BABYLON.GUI.Button.CreateSimpleButton("but5", "Play Right"); button1.paddingTop = "10px"; button1.width = "100px"; button1.height = "50px"; button1.color = "white"; button1.background = "green"; button1.onPointerDownObservable.add(()=> { if (rightRange) scene.beginAnimation(skeleton, rightRange.from, rightRange.to, true); }); UiPanel.addControl(button1); // .. var button1 = BABYLON.GUI.Button.CreateSimpleButton("but6", "Play Blend"); button1.paddingTop = "10px"; button1.width = "100px"; button1.height = "50px"; button1.color = "white"; button1.background = "green"; button1.onPointerDownObservable.add(()=> { if (walkRange && leftRange) { scene.stopAnimation(skeleton); var walkAnim = scene.beginWeightedAnimation(skeleton, walkRange.from, walkRange.to, 0.5, true); var leftAnim = scene.beginWeightedAnimation(skeleton, leftRange.from, leftRange.to, 0.5, true); // Note: Sync Speed Ratio With Master Walk Animation walkAnim.syncWith(null); leftAnim.syncWith(walkAnim); } }); UiPanel.addControl(button1); engine.hideLoadingUI(); }); return scene; }; // call the createScene function var scene = delayCreateScene(); // run the render loop engine.runRenderLoop(function(){ scene.render(); }); // the canvas/window resize event handler window.addEventListener('resize', function(){ engine.resize(); }); }); </script> </body> </html> Quote Link to comment Share on other sites More sharing options...
ssaket Posted November 16, 2018 Share Posted November 16, 2018 Hi, Welcome to the forum you are missing to load the GUI module, It's not included in the babylonjs cdn, hence you need to load it separately (https://www.npmjs.com/package/babylonjs-gui). Running code - https://codesandbox.io/s/0qq5jyj740, though I changed the dummy3 to rabbit. Quote Link to comment Share on other sites More sharing options...
JohnK Posted November 16, 2018 Share Posted November 16, 2018 Hi @zen85 and welcome to the forum. In the playgound BABYLON.SceneLoader.ImportMesh("", "./scenes/", "dummy3.babylon", scene, ./scenes/ gives the relative path to the image dummy3.babylon. within the playground file structure. If your file structure does not include the file dummy.babylon within a folder called scenes at the same location as your html file then SceneLoader will not be able to find the file. The second parameter must contain the relative or absolute path of the actual location of the named file. EDIT correction made as per ssaket post following this one. Quote Link to comment Share on other sites More sharing options...
ssaket Posted November 16, 2018 Share Posted November 16, 2018 1 hour ago, JohnK said: If your file structure does not include the file dummy.babylon.js within a folder called scenes at the same location as your html file then SceneLoader will not be able to find the file. Hello @JohnK, one small correction - file name should be dummy.babylon not dummy.babylon.js. Cheers Quote Link to comment Share on other sites More sharing options...
zen85 Posted November 16, 2018 Author Share Posted November 16, 2018 wow. yes. that made it work... ! thanks!... now i will figure out a proper pipeline from daz3d to babylon... wish me luck Quote Link to comment Share on other sites More sharing options...
Guest Posted November 16, 2018 Share Posted November 16, 2018 Can you flag this issue as solved? 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.