018 Posted December 16, 2016 Share Posted December 16, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 16, 2016 Share Posted December 16, 2016 you are correct. This ( <BABYLON.InstancedMesh> mesh2.createInstance('instance1'); ) is the right way to do it Quote Link to comment Share on other sites More sharing options...
018 Posted December 17, 2016 Author Share Posted December 17, 2016 Awesome - 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.