Jump to content

Can you create an InstancedMesh from an AbstractMesh in Typescript?


018
 Share

Recommended Posts

In the Instances demo:

http://www.babylonjs.com/Demos/Instances/instances.js

 // Trees
        BABYLON.SceneLoader.ImportMesh("", "../../assets/Tree/", "tree.babylon", scene, function (newMeshes) {
            newMeshes[0].material.opacityTexture = null;
            newMeshes[0].material.backFaceCulling = false;
            newMeshes[0].isVisible = false;
            newMeshes[0].position.y = ground.getHeightAtCoordinates(0, 0); // Getting height from ground object

            shadowGenerator.getShadowMap().renderList.push(newMeshes[0]);
            var range = 60;
            var count = 100;
            for (var index = 0; index < count; index++) {
                var newInstance = newMeshes[0].createInstance("i" + index);

ImportMesh returns an AbstractMesh array which is then accessed by index and then .createInstance() is called on it.  There's no method for that in typescript as far as I can see in 2.4 and 2.5.

How can you create an InstancedMesh in Typescript properly?

This seems to work by bypassing types.

        let mesh2 : any = mesh;
        let instance : BABYLON.InstancedMesh = <BABYLON.InstancedMesh> mesh2.createInstance('instance1');

Thanks.

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