Sailarg Posted December 29, 2017 Share Posted December 29, 2017 good afternoon, I had not gone through here for work because I'm already a bit free again and I want to continue learning ^^. Note that they have made many changes so I started again from the basics. That is why I have an animation that a friend made for me made in untity, try to export it to .babylon but I can not do it, so I opened it in blender and exported it from there, the problem is that I can not load it correctly, it is say load the model and its textures if they load, but your animation does not, I tried it in the sandbox and the same thing happens, seeing the element inspector notice this error: "babylon.js:3 BJS - [17:36:30]: Unable to import meshes from Scenes/Planeta/Planeta.babylon: Error in onSuccess callback t._ErrorEnabled @ babylon.js:3 f @ babylon.js:32 p @ babylon.js:32 (anonymous) @ babylon.js:32 m @ babylon.js:32 p @ babylon.js:3 XMLHttpRequest.send (async) s @ babylon.js:3 d @ babylon.js:3 t.LoadFile @ babylon.js:3 b @ babylon.js:32 i @ babylon.js:33 (anonymous) @ babylon.js:33 XMLHttpRequest.send (async) t.checkManifestFile @ babylon.js:33 t @ babylon.js:33 i._loadData @ babylon.js:32 i.ImportMesh @ babylon.js:32 createScene @ (index):71 (anonymous) @ (index):97 babylon.js:3 XHR finished loading: GET "http://babylon-uno/Scenes/Planeta/Planeta.babylon"." here is code. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Babylon.js sample code</title> <!-- Babylon.js --> <script src="https://www.babylonjs.com/hand.minified-1.2.js"></script> <script src="https://preview.babylonjs.com/babylon.js"></script> <script src="https://preview.babylonjs.com/gui/babylon.gui.min.js"></script> <script src="https://preview.babylonjs.com/cannon.js"></script> <script src="https://preview.babylonjs.com/oimo.js"></script> <script src="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.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> var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); // var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 5, -10), scene); var camera = new BABYLON.ArcRotateCamera("Camera", 0, 0, 10, new BABYLON.Vector3(0, 30, 0), scene); camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(canvas, true); var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); light.intensity = 0.7; var model; var skeleton; BABYLON.SceneLoader.ImportMesh("", "Scenes/Planeta/", "Planeta.babylon", scene, function (newMeshes, particleSystems, skeletons) { model = newMeshes[0]; skeleton = skeletons[0]; model.rotation.y = Math.PI; model.scaling = new BABYLON.Vector3(10,10,10); model.position = new BABYLON.Vector3(0, 0, 0); skeleton.position = new BABYLON.Vector3(0, 0, 0); skeleton.scaling = new BABYLON.Vector3(10,10,10); scene.beginAnimation(skeletons[0], 0, 100, true, 1.0); }); return scene; }; var scene = createScene(); scene.debugLayer.show(); engine.runRenderLoop(function () { scene.render(); }); // Resize window.addEventListener("resize", function () { engine.resize(); }); </script> </body> </html> I tried loading the model Dude and rabbit and these if they load everything well, so I do not know if it's a problem of how I export it, a problem with the plugin or something else I should do: here id the .fbx and de model exported : https://drive.google.com/file/d/1J9BYfEpCm_96cmn9_y4LpkntliEMNqlz/view?usp=sharing Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 2, 2018 Share Posted January 2, 2018 Hi Sailarg! Sorry for the slow replies. Loading mesh can sometimes be difficult. Would you try something for me? BABYLON.SceneLoader.ImportMesh("", "Scenes/Planeta/", "Planeta.babylon", scene, function (newMeshes, particleSystems, skeletons) {try { model = newMeshes[0]; skeleton = skeletons[0]; model.rotation.y = Math.PI; model.scaling = new BABYLON.Vector3(10,10,10); model.position = new BABYLON.Vector3(0, 0, 0); skeleton.position = new BABYLON.Vector3(0, 0, 0); skeleton.scaling = new BABYLON.Vector3(10,10,10); scene.beginAnimation(skeletons[0], 0, 100, true, 1.0);} catch(e) { console.log("error: ", e) } }); Add those red lines of code. Then run it, and watch the JS console in your browser... see if there are 'onSuccess' errors. It seems that Planeta.babylon IS loading properly, but there is an error AFTER the load-in. Perhaps skeletons[0] doesn't exist. Your mesh might not have bones/skeletons. Perhaps newMeshes[0].animations array... is empty for some reason. The 'wrap in try/catch' method I have showed you... SHOULD help us learn more things. Report back, please. Thx. JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 2, 2018 Share Posted January 2, 2018 Of all the exporters, Blender should have the least 'doubt'. It automatically generates a log file of exactly what it did with warnings & vertiices statistics. It does not export all types of animation from Blender(not all are even defined in a .babylon). Of those it does export, there is only one case which cannot be completely solved during export. It involves a scene where there are multiple meshes which have animations. This is side-stepped using specific values for action names. First, check your .babylon against the sandbox. Animations will not play there, but will validate everything else. Next, get rid of all lines but ' scene.beginAnimation(skeletons[0], 0, 100, true, 1.0);' in your callback. This removes all doubt. If you need additional changes beyond that, that is your problem so solve wherever in your workflow you wish. FYI, these lines below are complete crap. A skeleton in BJS is just a class with an array of bone objects. It has no position or scaling, though I do not think that adding them will cause an exception. They just do not do anything. skeleton.position = new BABYLON.Vector3(0, 0, 0); skeleton.scaling = new BABYLON.Vector3(10,10,10); GameMonetize and JackFalcon 2 Quote Link to comment Share on other sites More sharing options...
Sailarg Posted January 4, 2018 Author Share Posted January 4, 2018 On 1/1/2018 at 11:09 PM, Wingnut said: Hi Sailarg! Sorry for the slow replies. Loading mesh can sometimes be difficult. Would you try something for me? BABYLON.SceneLoader.ImportMesh("", "Scenes/Planeta/", "Planeta.babylon", scene, function (newMeshes, particleSystems, skeletons) {try { model = newMeshes[0]; skeleton = skeletons[0]; model.rotation.y = Math.PI; model.scaling = new BABYLON.Vector3(10,10,10); model.position = new BABYLON.Vector3(0, 0, 0); skeleton.position = new BABYLON.Vector3(0, 0, 0); skeleton.scaling = new BABYLON.Vector3(10,10,10); scene.beginAnimation(skeletons[0], 0, 100, true, 1.0);} catch(e) { console.log("error: ", e) } }); Add those red lines of code. Then run it, and watch the JS console in your browser... see if there are 'onSuccess' errors. It seems that Planeta.babylon IS loading properly, but there is an error AFTER the load-in. Perhaps skeletons[0] doesn't exist. Your mesh might not have bones/skeletons. Perhaps newMeshes[0].animations array... is empty for some reason. The 'wrap in try/catch' method I have showed you... SHOULD help us learn more things. Report back, please. Thx. Thanks for the reply, the error is: error: TypeError: Cannot read property 'animations' of undefined at i.beginAnimation (babylon.js:12) at (index):60 at p (babylon.js:32) at babylon.js:32 at m (babylon.js:32) at XMLHttpRequest.p (babylon.js:3) Yes, just as you say the array with the animations is empty, so it must be a problem of how to export truth? since that animation does have them, in fact I managed to load it using threeJS Quote Of all the exporters, Blender should have the least 'doubt'. It automatically generates a log file of exactly what it did with warnings & vertiices statistics. It does not export all types of animation from Blender(not all are even defined in a .babylon). Of those it does export, there is only one case which cannot be completely solved during export. It involves a scene where there are multiple meshes which have animations. This is side-stepped using specific values for action names I'm sorry to have doubts, but I have rarely used blender or any other similar: I saw the log but I did not see anything out of the ordinary Exporter version: 4.6.1, Blender version: 2.79 (sub 0) ========= Conversion from Blender to Babylon.js ========= Scene settings used: selected layers only: false flat shading entire scene: false inline textures: false texture directory: C:\xampp\htdocs\pixeloide\planeta\ Python World class constructor completed processing begun of node: control general processing begun of mesh: Tierra low processing begun of Standard material: tierra Diffuse texture found "Map #8" Image texture found, type: diffuseTexture, mapped using: "UVChannel_1" num positions : 2772 num normals : 2772 num uvs : 5544 num uvs2 : 0 num colors : 0 num indices : 14982 processing begun of node: mar processing begun of mesh: Mar low processing begun of Standard material: mar Diffuse texture found "Map #7" Image texture found, type: diffuseTexture, mapped using: "UVChannel_1" num positions : 1707 num normals : 1707 num uvs : 3414 num uvs2 : 0 num colors : 0 num indices : 8988 processing begun of node: capa 3 abajo animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: Capa 3 abajo processing begun of Standard material: capa 3 Diffuse texture found "Map #9.003" Image texture found, type: diffuseTexture, mapped using: "UVChannel_1" num positions : 2048 num normals : 2048 num uvs : 4096 num uvs2 : 0 num colors : 0 num indices : 7779 processing begun of node: capa 2 abajo animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: Capa 2 abajo processing begun of Standard material: capa 2 Diffuse texture found "Map #9.002" Image texture found, type: diffuseTexture, mapped using: "UVChannel_1" num positions : 1651 num normals : 1651 num uvs : 3302 num uvs2 : 0 num colors : 0 num indices : 7110 processing begun of node: capa 1 abajo animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: Capa 1 abajo processing begun of Standard material: capa 1 Diffuse texture found "Map #9.001" Image texture found, type: diffuseTexture, mapped using: "UVChannel_1" num positions : 537 num normals : 537 num uvs : 1074 num uvs2 : 0 num colors : 0 num indices : 2256 processing begun of node: capa 4 abajo animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: Capa 4 labajo processing begun of Standard material: capa 4 Diffuse texture found "Map #9" Image texture found, type: diffuseTexture, mapped using: "UVChannel_1" num positions : 1811 num normals : 1811 num uvs : 3622 num uvs2 : 0 num colors : 0 num indices : 5703 processing begun of node: capa 3 arriba animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: capa 3 arriba.001 registered as also a user of material: capa 3 num positions : 2062 num normals : 2062 num uvs : 4124 num uvs2 : 0 num colors : 0 num indices : 7470 processing begun of node: capa 2 arriba animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: capa 2 arriba.001 registered as also a user of material: capa 2 num positions : 1831 num normals : 1831 num uvs : 3662 num uvs2 : 0 num colors : 0 num indices : 7488 processing begun of node: capa 1 arriba animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: capa 1 arriba.001 registered as also a user of material: capa 1 num positions : 941 num normals : 941 num uvs : 1882 num uvs2 : 0 num colors : 0 num indices : 3720 processing begun of node: capa 4 arriba animation processing begun processing action capa 1 abajo|Take 001|BaseLayer: in[1 - 178], out[0 - 178] processing action capa 1 arriba|Take 001|BaseLayer: in[1 - 178], out[190 - 368] processing action capa 2 abajo|Take 001|BaseLayer: in[109 - 293], out[380 - 673] processing action capa 2 arriba|Take 001|BaseLayer: in[109 - 293], out[680 - 973] processing action capa 3 abajo|Take 001|BaseLayer: in[178 - 362], out[980 - 1342] processing action capa 3 arriba|Take 001|BaseLayer: in[178 - 362], out[1350 - 1712] processing action capa 4 abajo|Take 001|BaseLayer: in[293 - 470], out[1720 - 2190] processing action capa 4 arriba|Take 001|BaseLayer: in[293 - 470], out[2200 - 2670] processing begun of mesh: capa 4 arriba.001 registered as also a user of material: capa 4 num positions : 1701 num normals : 1701 num uvs : 3402 num uvs2 : 0 num colors : 0 num indices : 6300 processing begun of camera (FreeCamera): Camera processing begun of light (POINT): Lamp ========= Writing of scene file started ========= ========= Writing of scene file completed ========= ========= end of processing ========= elapsed time: 0 min, 3.3193 secs Quote First, check your .babylon against the sandbox. Animations will not play there, but will validate everything else. I tried the animation there too and the same thing happened, then I tried the animation of the Dude and did not run the animations either, so I assumed that the animations or something similar in the sandbox were not enabled, that's why I went to the example and try to do it myself Quote Link to comment Share on other sites More sharing options...
Wingnut Posted January 4, 2018 Share Posted January 4, 2018 3 hours ago, Sailarg said: scene.beginAnimation(skeletons[0], 0, 100, true, 1.0); 3 hours ago, Sailarg said: error: TypeError: Cannot read property 'animations' of undefined Hi. The mesh used for the animation... is 'undefined'. skeletons[0] is undefined. So perhaps try... scene.beginAnimation(model, 0, 100, true, 1.0); You can always do a console.log(model.animations); ...check if model.animations exists and has substance. The 'undefined' is the important thing. skeletons[0] is undefined, it seems. 3 hours ago, Sailarg said: array with the animations is empty Not precisely true. skeletons[0] is undefined, so IT doesn't exist. Does 'model' exist? Perhaps disable beginAnimation line... and add console.log(model) before beginAnimation line. Make sure 'model' exists. Keep experimenting... you'll be successful soon. (I hope) Again, make sure you try scene.beginAnimation(model, 0, 100, true, 1.0); Perhaps even try scene.beginAnimation(scene.getMeshByName('capa 3 arriba'), 0, 100, true, 1.0); *shrug* Interesting test. Perhaps we can get some help from others. I don't have a lot of experience with importing mesh with animations. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 4, 2018 Share Posted January 4, 2018 A little busy, but looking at your log file, I see no skeletons exported & a number of actions (animations) exported against 4 different Node objects. You are sure there is an armature in the .blend? Something with a bone icon in the outliner window. Since you have multiple objects with blender actions (animations), the names have to be in the format of object-action. This is the exception I mentioned in my above post. Your names are close 'capa 1 abajo|Take 001|BaseLayer' would need to become 'capa 1-abajo|Take 001|BaseLayer'. While this is trivial, Blender has a very big UI. Blender is not a tool meant to be an: install it import something export it in something else barely knowing anything about Blender Since you have Unity, why not just figure out how to use the .babylon exporter from there? Or use three.JS for this? JackFalcon 1 Quote Link to comment Share on other sites More sharing options...
JackFalcon Posted January 5, 2018 Share Posted January 5, 2018 Recently used .blender export to great effect. No doubts. .Babylon is really excellent. But yeah -> had to muscle Blender to figure it out. Precisely exporting animation was tough... but once solved, clear sailing for subsequent animations. This is rocket-science. btw. Couple things: 1) Got to go step by step until you get Blender figured out. 2) Example: Object > Apply > Location & Rotation & Scale (or every animation will spaghetify - until an animation needs reference to 0,0,0 -> then don't! ). memorized. Explodes lots of exports. 3) Yep, skeletons not always be passing through (I remember) -> at first. debugger; Just do it. Because .... 4) Sometimes you accidentally export multiple skeletons (blender) and the skeleton at [0] is not the one you need. Same with meshes[]. Gotta a step in and look sometimes. 5) Other times, if you put code in the callback, that fails, borks executions... like animations. Looks like bad export but not... as Wingnut points out. 6) Exporting Animations from Blender to .babylon - gotta get crafty to be advanced. Example: Made 7 (unusual) IKs in blender animating, but none after export... the 8th worked. Troubleshooting only way. 7) Browser Refresh is cached for .babylon. So either manifest switch permissions so refresh reloads export updates... (idk), OR update the file version every export. Often hits 10. nbd. 8) ...100 problems. 99 fixed in Blender. Example: do not export camera/lights. Others me being wrong... but .babylon exporter pretty solid. Clapping... JCP. JCPalmer 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 5, 2018 Share Posted January 5, 2018 See Blender 5.5 exporter announcement. Quote Link to comment Share on other sites More sharing options...
Sailarg Posted February 20, 2018 Author Share Posted February 20, 2018 I'm sorry to answer after so long, but I was very busy with my work. many times this helped me Quote A little busy, but looking at your log file, I see no skeletons exported & a number of actions (animations) exported against 4 different Node objects. You are sure there is an armature in the .blend? Something with a bone icon in the outliner window. Since you have multiple objects with blender actions (animations), the names have to be in the format of object-action. This is the exception I mentioned in my above post. Your names are close 'capa 1 abajo|Take 001|BaseLayer' would need to become 'capa 1-abajo|Take 001|BaseLayer'. While this is trivial, Blender has a very big UI. Blender is not a tool meant to be an: install it import something export it in something else barely knowing anything about Blender Since you have Unity, why not just figure out how to use the .babylon exporter from there? Or use three.JS for this? and this too On 5/1/2018 at 12:32 PM, JCPalmer said: See Blender 5.5 exporter announcement. GameMonetize and JCPalmer 2 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.