Zimbofly Posted July 26, 2014 Share Posted July 26, 2014 Hi all - I've done as much searching as possible and tried so many different things - STILL, I'm struggling to position or resize any files from Blender exporter.THis is driving me nuts!!!! The model will display, but refuses to change position and size. here are a few codes I've tried.....var LoadChairs = function () {BABYLON.SceneLoader.ImportMesh("", "GalleryAssets/", "office_chair2.babylon", scene, function (newMeshes, particleSystems) { var benchCenter1 = newMeshes; benchCenter1.scaling = new BABYLON.Vector3(0.4, 0.3, 0.4); benchCenter1.rotation.y = Math.PI / 1; benchCenter1.position = new BABYLON.Vector3(8, 0.1, 0); shadowGenerator.getShadowMap().renderList.push(benchCenter1); });}This brings the chair in - BUT no scaling/position responsevar LoadChairs = function () {BABYLON.SceneLoader.ImportMesh("", "GalleryAssets/", "office_chair2.babylon", scene, function (newMeshes, particleSystems) { var benchCenter1 = newMeshes[0]; benchCenter1.scaling = new BABYLON.Vector3(0.4, 0.3, 0.4); benchCenter1.rotation.y = Math.PI / 1; benchCenter1.position = new BABYLON.Vector3(8, 0.1, 0); shadowGenerator.getShadowMap().renderList.push(benchCenter1); });}This brings the chair in and the first mesh - here the first mesh responds to position and resizing - you can see it to the right in the image below.BABYLON.SceneLoader.ImportMesh("", "GalleryAssets/", "office_chair2.babylon", scene, function (newMeshes, particleSystems) { newMeshes[0].position = new Babylon.vector3(10, 1, 10); newMeshes[0].scaling = new Babylon.vector3(0.5, 0.5, 0.5); });chair comes in - no scaling/position response a) is this something I'm doing wrong in calling my routine, or I've left out lack of understanding of meshesc) problem with the way I'm exporting these files from Blender - I have tried quite a few and all giving the same issue. - I've attached a zip of office_chair2.babylon fileIs there something I should be doing in blender b4 exporting???? another related problem is that if try load more than one mesh, then the second one gives console error - Cannot set property 'y' of undefined..... Can anyone help please this has and has been going on for days -I realize it's most likely my lack of understanding of meshes etc -but it's driving me nuts!!!!! office_chair2.zip Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 26, 2014 Share Posted July 26, 2014 Your object must be a single mesh and not several. Welding objects to make than a single mesh or manipulate each object newMeshes [0], newMeshes [1]... Zimbofly 1 Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 26, 2014 Share Posted July 26, 2014 Forgive me, I did not watch the first instalment (hopefully this is not a trilogy ). These properties you are changing are copied and cached. Presumably the cached versions exist for a reason. After changing the objects, you could call a method which re-copies to the cached versions: newMeshes[0].computeWorldMatrix(true); There is a _isSynchronized(), which detects if something has been changed, but maybe it has already been called & found no changes, then you changed it. Actively, forcing a copy to cache, would at least rule that out. Zimbofly 1 Quote Link to comment Share on other sites More sharing options...
Zimbofly Posted July 27, 2014 Author Share Posted July 27, 2014 Hi dad72 - welding objects to a single mesh sounds exactly what i need - must it be done in blender b4 export or Babylon? Good comment JCPalmer - hope it's not a trilogy either - I will play with the cache idea - thanks any other ideas out there? Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 27, 2014 Share Posted July 27, 2014 Well, what you could do in Blender is, parent all of the meshes to a single parent. If you then explicitly import that mesh, FileLoader will also import child meshes. Once in the callback, find the mesh object, & do your thing:BABYLON.SceneLoader.ImportMesh("bigDaddy", "GalleryAssets/", "office_chair2.babylon", scene, function (newMeshes, particleSystems) { var bigDaddy = scene.getMeshByID("bigDaddy"); bigDaddy.position = new Babylon.vector3(10, 1, 10); bigDaddy.scaling = new Babylon.vector3(0.5, 0.5, 0.5); });That is not to say that there may be performance improvements to making a single mesh. I would do it on the Babylon side, to keep your editing options cleaner in Blender. This doc talks about it in Step 5: http://blogs.msdn.com/b/davrous/archive/2014/02/19/coding4fun-tutorial-creating-a-3d-webgl-procedural-qrcode-maze-with-babylon-js.aspx Finally, you might want to do both. It might be easier in Blender to work with the meshes if they were parented. For Blender info on parenting see: http://wiki.blender.org/index.php/Doc:2.6/Manual/Modeling/Objects/Groups_and_Parenting Quote Link to comment Share on other sites More sharing options...
Zimbofly Posted July 29, 2014 Author Share Posted July 29, 2014 THANKYOU JC - finaly got it all working - I owe you a beer! since making the all the meshes to a single parent, and using this code from temechon - http://www.html5gamedevs.com/topic/1896-problem-with-babylonsceneloaderimportmesh/ (I think very similar to yours)BABYLON.SceneLoader.ImportMesh("", "GalleryAssets/room/", "furniture.babylon", scene, function (newMeshes) { setup(newMeshes[0]); function setup(mesh) { mesh.position.x = 0; mesh.position.z = 24; mesh.scaling = new BABYLON.Vector3(50, 40, 40); mesh.material.emissiveColor = new BABYLON.Color3(0.4, 0, 0); mesh.material.diffuse = new BABYLON.Color3(0.1, 0.1, 0.1); shadowGenerator.getShadowMap().renderList.push(mesh); //mesh.receiveShadows = true; }working good - (except I'm getting some strange results when parenting all in blender - so I need to learn a bit more about blender ) thanks!!! GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
gadget Posted October 28, 2014 Share Posted October 28, 2014 hi, Zimbofly there is a } missing in your codes, I do not know where to put it in. please put in all the codes that works. thanks 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.