Jump to content

Instances performance


Adem
 Share

Recommended Posts

:)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);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@Pryme8:huh:Is 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);

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...