Jump to content

How to correctly make multiple objects with the same imported mesh


Satiana
 Share

Recommended Posts

Hey!

I will just link the relevant code and then ask the question (ignore the material parameter, is from an older build still have to get rid of it):

function GenerateRandomObject(scene, material){
    var nekej = BABYLON.Mesh.CreateBox("box1", 1, scene);
    nekej.position = new BABYLON.Vector3(getRandom(8, 90, true), 0.5, 90);
    nekej.rotation.y = getRandom(0, 360, true);
    nekej.isVisible = false;
    BABYLON.SceneLoader.ImportMesh("", "_resources/", "Drevo2.babylon", scene, function (newMeshes, particleSystems) {
        newMeshes[0].parent = nekej;
    });
    return nekej;
}

So this is the way I create every new instance of a background object. This happens about 0.5 - 2 times every second for this type of object. More with others that I create with similar functions just different imported meshes.

So my question is if there is a better way to import/use an imported mesh so i would not need to import the same mesh over and over again every single time i create a new object with that mesh.

Thank you very much for any answers you might provide,

with best regards, Satiana

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...