hen Posted December 21, 2015 Share Posted December 21, 2015 It seems there is some problem with the gltf model axis conversion. I did a test with a few collada files exported either with y or z axis up and converted them in to the gltf format.The converter always adds a dummy node to the models root ("Y_UP_Transform") wich has some matrix applied that solves the rotation but does no real axis conversion. Big problem is that the model and dummy node imported to babylon still have the wrong axis up wich affects all pos/rot settings, breaks physics and flips the normals. The code below shows how i loaded the test models and the errors with physics.Maybe this could be solved at loader level?BABYLON.SceneLoader.ImportMesh(null, assethost, source, scene, function (meshes, particleSystems, skeletons) { for (var i = 0; i < meshes.length; i++){ var mesh = meshes[i]; // we want to import meshes only, so just dispose everything else than the transform node. if (!mesh.geometry && mesh.name != "Y_UP_Transform") { mesh.dispose(true) } else if (mesh.name == "Y_UP_Transform") { // set the position of the root/transform node mesh.position = new BABYLON.Vector3(0,5,0); // up axis is flipped here (z was changed) } else { mesh.material = _materialLoader.get(scene, material); mesh.renderingGroupId = 1; mesh.receiveShadows = true; shadowGenerator.getShadowMap().renderList.push(mesh); // enable physics // returns errors: .faceNormals[38] = Vec3(0.16052952624529215,0.8138526506383952,-0.5584569224679018) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule. mesh.setPhysicsState(BABYLON.PhysicsEngine.MeshImpostor, { mass: 1, friction: .1, restitution: .01 }); mesh.checkCollisions = true; } } for (var j = 0; j < skeletons.length; j++){ var skeleton = skeletons[j]; // do something with skeletons }}); Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 21, 2015 Share Posted December 21, 2015 I just commited a new MeshImpostor implementation, using a different shape type. This should fix those errors. I haven't updated the preview build yet, will do it in a sec - you can then try with it and see how it works.A small note - it can only collide with spheres and planes. So setting mass: 0 might be better, otherwise it will fall forever. (or put a plane underneath :-) ) Quote Link to comment Share on other sites More sharing options...
hen Posted December 22, 2015 Author Share Posted December 22, 2015 Thanks. I just tried your update, but it is not solving my problem. The axis on gltf meshes is wrong, so when i apply some mass the mesh is moving in to -x direction. Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 23, 2015 Share Posted December 23, 2015 The importer must take care of that. This shouldn't happen. STL, for example, has y and a switch. The importer is taking care of that, otherwise the object is not displayed correctly.Could you show a live demo? Quote Link to comment Share on other sites More sharing options...
hen Posted December 23, 2015 Author Share Posted December 23, 2015 Is it possible to load an asset from source in playground?Ive tried to prepare something but it looks always at the localhost. 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.