Adem Posted December 19, 2016 Share Posted December 19, 2016 Hy guys, i used instances for my mesh, but it's really laggy Here's the code: var house; BABYLON.SceneLoader.ImportMesh("Cottage_House", "cottage/", "cottage.babylon", scene, function (newMeshes, particleSystems, skeletons) { house = newMeshes[0]; house.scaling = new BABYLON.Vector3(0.09, 0.09, 0.09); house.position = new BABYLON.Vector3(-6, 0, 0); house.checkCollisions = true; var instances = new Array(); for (var i = 0; i < 10; i++) { instances = house.clone('Instance' + i); instances.position.z = 4; instances.position.x = 3; } var houses = BABYLON.Mesh.MergeMeshes(instances); Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted December 19, 2016 Share Posted December 19, 2016 Try instead of mesh clone do new Mesh.createInsance() I think it is to make an instance instead of a clone to save the draw calls. Adem 1 Quote Link to comment Share on other sites More sharing options...
Convergence Posted December 19, 2016 Share Posted December 19, 2016 1 hour ago, Pryme8 said: Try instead of mesh clone do new Mesh.createInsance() I think it is to make an instance instead of a clone to save the draw calls. If he was merging the meshes, which seems to be the case, it should be reduced to one draw call (assuming one house was one draw call). Try to look at the browsers' profiler to see which functions are the slowest. Adem 1 Quote Link to comment Share on other sites More sharing options...
Adem Posted December 19, 2016 Author Share Posted December 19, 2016 thanks , it's just working fine Quote Link to comment Share on other sites More sharing options...
Adem Posted December 19, 2016 Author Share Posted December 19, 2016 @Pryme8Is this code correct? var instances = new Array(); for (var i = 0; i < 8; i++) { instances = house.createInstance('Instance' + i); instances.position.z = 4; instances.position.x = 3; } var houses = BABYLON.Mesh.MergeMeshes(instances); Quote Link to comment Share on other sites More sharing options...
adam Posted December 19, 2016 Share Posted December 19, 2016 InstancedMeshes shouldn't be merged. Adem 1 Quote Link to comment Share on other sites More sharing options...
Adem Posted December 19, 2016 Author Share Posted December 19, 2016 oh i corrected that, 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.