inteja Posted April 1, 2018 Share Posted April 1, 2018 If I have a TS class called say MyThing that creates various Meshes, LineMeshes and Textures and adds to the scene, what (if anything) do I need to do to dispose of all the resources these MyThing objects use? If the MyThing class extends BABYLON.Mesh, calling myThing.dispose() does nothing. If I write a method MyThing.dispose() I am able to dispose of individual Meshes which are each associated with a member, but I'm running into problems pushing LineMeshes onto an array so that I can dispose of those within a loop in my dispose() method. Hope this makes sense. Quote Link to comment Share on other sites More sharing options...
inteja Posted April 1, 2018 Author Share Posted April 1, 2018 Found a solution, not sure if it's best practice though. Basically I extended TransformNode, created and parented meshes to it, then dispose() just works. class MyThing extends BABYLON.TransformNode { // ... constructor(name, scene) { // ... let mesh1 = new BABYLON.Mesh('mesh1', scene); mesh1.parent = this; let mesh2 = new BABYLON.Mesh('mesh2', scene); mesh2.parent = this; let lines1 = BABYLON.Mesh.CreateLines("lines1", points, scene); lines1.parent = this; } } Quote Link to comment Share on other sites More sharing options...
Guest Posted April 2, 2018 Share Posted April 2, 2018 looks good to me 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.