Search the Community
Showing results for tags 'dispose'.
-
I've been working on an open world project that involves a lot of loading and unloading of assets. (A virtual museum of Earth history.) SceneLoader.LoadAssetContainerAsync() seems to be the only means of tracking which and when new assets have been loaded, as SceneLoader.LoadAsync() returns only the current scene. Where I'm running into trouble is the end of the life cycle. AssetContainer does not have a dispose() method. My attempts to manually create one have thus far ended in halt & catching fire. The removeAllFromScene() method will dispose of the assets* but I'm still left with an AssetContainer object from every SceneLoader call. If I clear the assets in a different way, the assets won't garbage collect, because the AssetContainer itself still references them. Has anyone worked on a similar scenario? How did you manage large volumes of load -> use -> forget? *AssetContainer.removeAllFromScene() seems to have a problem removing instanced objects, but I've been too lazy to create a proper bug report. I promise I will!
- 2 replies
-
- open world
- dispose
-
(and 2 more)
Tagged with:
-
Erm, again not sure what this is, I tried to create some gui elements and then immediately after use executeOnAllControls to dispose: https://www.babylonjs-playground.com/#XCPP9Y#583 You can see in the console that the textblocks created and those disposed are different. Is this due to registerBeforeRender ? Should I be using some other command ?
-
http://www.babylonjs-playground.com/#PFCYT#1 This playground makes 9 meshes and tries to delete them all at once in a loop. It does not work. Am I missing something? I defeated the problem via this unholy function ... function deleteAllMeshes(scene){ var countMesh = 0; scene.meshes.forEach(function(m) { countMesh++; console.log(m.name); m.dispose(); }); console.log(countMesh + " meshes deleted"); var x = countMeshes(scene); if(x > 0) { deleteAllMeshes(scene); } } Here is the output of the unholy function proving only half of the meshes are deleted per function call.
-
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.
-
erm, ok...I haven't been following the latest announcements so pls bear with me if someone has spotted this alr. Working on a long ass project which was working fine until today, got an error in my console ' setting getter-only property "skeleton" '. Traced my codes down to the error popping up in disposing of instanced meshes and managed to get the repro in PG: http://www.babylonjs-playground.com/index.html#0URP8I Is this a bug or just me ?
-
Hello, I'm importing a new OBJ file with the MTL and texture into my scene every 30 seconds. When I import, I dispose of an existing OBJ and MTL, and declare their variable (array) as null. But my frame rate continues to drop as I add and dispose of objects - even though there is only 20 heads at a time in the scene - never more. But my fps drops from over 40fps to under 20fps once I add less than 10 new heads and dispose of an equal amount. I've even forced dispose, but fps still drops. Thanks, DB
-
Hi! Have some problem, I create many particles systems in my game and very often delete them after first playing, but if I using the same texture in particle systems, then after first disposing of particle system the texture disposing too. And I should to cloning each one new texture, but it is bad for performance. How I can to create a particles systems with same texture but after disposing particles system do not dispose texture? Thanks!
-
Hi, On a Stackoverflow found an advice to set the mesh variable to null after the dispose call (to tell the GC he can collect). Something like: ball.dispose(); ball = null; ... is this needed nowadays or is already implemented in BJS ?
-
Hello, I load a Glft model with a loader https://bin.fuelphp.com/snippet/view/OI and later with a HTML button I change the model in the same scene with a dispose (to remove it) and reload the new. The issue is that it seem memory is not released from the previous model, on iPad tablet for exemple, the scene become very slow. After several disposes and loads safari crash out of memory. Maybe Am I wrong with the mesh capture : loader.onMeshLoaded = function (mesh) { actualMesh = mesh; }; any idea ?
-
Hello, I have a script due tomorrow morning, and have asked a question on a seperate post which is the ideal solution. The only other solution I could show have for tomorrow is to start the renderloop, load an OBJ, and then dispose of the scene - but then the scene needs to begin loading new meshes after it detects a new path and mesh in an array, and render without any client interaction. I can't figure out how to load several scenes - lets say 5 scenes - and load scene 1 for 30 seconds, destroy scene one, on destroy scene two loads on it's own, and this process continues until scene 5 is loaded and then disposed.
-
When i recreate texture or material, clone/dispose created more one texture (clone logic incorrect material.texture.clone() and material._texture.clone()) example https://www.babylonjs-playground.com/indexstable#Y48SUQ this is very important for dynamic scene, please fix source ** I tryed run in this latest version and saw what recreate correctry, but i not undersend how... and other -- i see what canvas2D will be not suported in future? I see GUI, this is very cool feature, but GIU can't do many tasks... Tell me whether it is possible to work with canvas2d in babylon.js 3.0, or will the support be returned in the future?
- 6 replies
-
- recreate texture
- material
-
(and 4 more)
Tagged with:
-
Hi, I run into trouble when trying to clear a scene. The scene contains objects which have Babylon.GUI labels linked on them. Something is not getting updated properly? I can make it work using a timer delay between consecutive mesh.dispose() commands, but running them in a loop crashes the program. Here is the same problem in a PG. You can dispose one or the other mesh, but not both -- without a delay. http://www.babylonjs-playground.com/#5ZHBR8
-
Hello, this is my first post, but visit the forum for a while and am thrilled. :-) I'm currently working on a Babylon project and I'm using a CustomShader (ShaderMaterial) for the Meshes. Now I wanted to use mesh.dispose(); and mesh.material.dispose(); to remove the textures, but it does not work. Whenever I check the size with scene.textures.length, it becomes more and more. What helps?
-
Hi, So... my problem is a bit specific. I will try to reproduce it in the playgroud but I am not sure I will be able to. So I have a Rectangle2d that holds 4 rectangle2d children, the green background is the parent square and the children square are the 4 grey rectangles. I am using the centering and margin system: I used to dispose of those rectangle children and recreate them at certain points in time, storing the newly created children in the same array replacing the hold ones. The problem is that when I resize the window there is a call to Prim2DBase._updatePositioning that returns (NaN, NaN) as the _actualPosition (in the if (hasMargin) ... which they do). And it cause the parent and all its children to disappear from the screen. That's why i though it was linked to the bug @Wingnut mentionned yesterday. There are several variables that are NaN, one of them is Prim2d._size3... but i do not know why, nor do I see where it is define (I only see one definition that sets it to zero... I will look tonight into the typescript source to see if it is there...). This does not happen if I do not dispose of the children prim2d... I had problems with Prim2d.dispose() before, and looking at it, I do not see where the prim2d is actually set to null. Maybe that is the problem? Some kind of persistant reference that interferes with the computation of the rectangles. I will look more into it, but if it is something people have encountered I am interested to know their thoughts. @Nockawa <3 For now I am not disposing of the prims anymore
- 1 reply
-
- prim2dbase
- canvas2d
- (and 4 more)
-
Hi guys! I have small problem, If I dispose WorldSpaceCanvas2D, material from canvas stay on the scene Example http://www.babylonjs-playground.com/#JG2PA5, you need look in console, you can see after disposing canvas the material on scene "myCanvas_Material" How I can dispose this material? Thanks!
- 1 reply
-
- worldspacecanvas
- material
-
(and 2 more)
Tagged with:
-
Hi, Just to report that on the example given in the documentation: http://www.babylonjs-playground.com/#OWCCR#8 Increasing the number of primitive slows down the fps, but when reducing that number fps stays low even after dispose(). I don't know it if was reported before, and I did not remember this behavior last time I checked this example... @Nockawa
-
Hello! I'm importing an obj model, and I want to tweak the visibility of it, or just dispose it when I click a button... var loader = new BABYLON.AssetsManager(scene); var leg = loader.addMeshTask("leg", "", "", "leg.obj"); BABYLON.SceneLoader.ImportMesh("", "", "leg.obj", scene, function (newMesh) { BABYLON.SceneLoader.Load("", "leg.obj", engine, function (newScene) { }); }); $('#quadril_bt').click(function () { //........ something to dispose the mesh, or make it invisible }); Can't seem to find a way to do it!
- 4 replies
-
- dispose
- visibility
-
(and 3 more)
Tagged with:
-
Hello world, this is my first post (and first weekend using babylon) so please be kind First I'd like to say that BJS is amazing, and I can't believe I've gotten this far as someone with little programming background. Here is a playground that shows the issue I'm having: http://www.babylonjs-playground.com/#DR6N9#15 The player (box) is able to throw fireballs, via spacebar. Movement is WASD. The code is supposed to detect collision of the fireball instance with the ground, dispose the fireball instance, and create a new different instance of the fireball being lodged in the ground. And then dispose that. This does happen occasionally, but only when the player is facing x or z directions. (On my localhost I dont have the direction issue?) The rest of the time the fireball keeps bouncing along. In both my localhost and the playground, the lodged fireball instance often appears mysteriously floating in the air instead of in the ground. I can't figure out if this is a physics engine issue or an issue with my code (most likely ). Any insight would be greatly appreciated. Thanks!
- 3 replies
-
- registeronphysicscollide
- dispose
-
(and 1 more)
Tagged with:
-
Hello all! I'm currently working on a website that has a Babylon.js scene as it's background, and also includes a game created with Babylon.js. I'm trying to keep the scene as simple as possible - I'm only using planes and their clones - and I'm testing on a 2013 ASUS laptop where I'm getting constant 60FPS. But of course, there are users out there with lower graphics performance, and I'm trying to find a way to test and handle that. In my current setup, I monitor the FPS in the first ten seconds, and if it averages under 45FPS, I call scene.dispose(); and set a cookie so the scene won't be loaded next time. Is there a better way to do this? Thanks in advance! BTW, here a video of the submarine-themed game in progress :
-
Hi, I have 4 sprite2D buttons in an array. They are the only visible sprites on a canvas, but not the only one (several with opacity 0). If I dispose of 3 among the 4 everything is fine. elements2D.levelButtons[0].dispose(); elements2D.levelButtons[1].dispose(); // elements2D.levelButtons[2].dispose(); elements2D.levelButtons[3].dispose(); But if I dispose of all of them webGL throws a warning on a couple of render() - i'd say around 100 engine.render(). During those render any call to add primitives is not taken into account, resulting in a slight delay. Then, without any reason the warnings stop and calls to render and modify sprite are taking into account and rendered. babylon.2.5.max.js:7685 WebGL: INVALID_OPERATION: drawElements: no buffer is bound to enabled attribute Engine.draw @ babylon.2.5.max.js:7685 Rectangle2DRenderCache.render @ babylon.2.5.canvas2d.max.js:8864 Group2D._renderTransparentData @ babylon.2.5.canvas2d.max.js:8415 Group2D._groupRender @ babylon.2.5.canvas2d.max.js:8287 Canvas2D._render @ babylon.2.5.canvas2d.max.js:13009 (anonymous) @ babylon.2.5.canvas2d.max.js:11954 Observable.notifyObservers @ babylon.2.5.max.js:3605 Scene.render @ babylon.2.5.max.js:18697 (anonymous) @ catch-the-wolf-mri.js:653 Engine._renderLoop @ babylon.2.5.max.js:7166 requestAnimationFrame (async) Tools.QueueNewFrame @ babylon.2.5.max.js:4878 Engine._renderLoop @ babylon.2.5.max.js:7173 requestAnimationFrame (async) Tools.QueueNewFrame @ babylon.2.5.max.js:4878 Engine._renderLoop @ babylon.2.5.max.js:7173 requestAnimationFrame (async) Tools.QueueNewFrame @ babylon.2.5.max.js:4878 Engine._renderLoop @ babylon.2.5.max.js:7173 requestAnimationFrame (async) Tools.QueueNewFrame @ babylon.2.5.max.js:4878 Engine._renderLoop @ babylon.2.5.max.js:7173 I have no idea where it is coming from. It is not due to the fact that they are in an array, if I add another unrelated button to the scene I can dispose of the four rect without warning. This is my function creating the button, but I am not sure it is coming from that, I sometime had the same behavior when using dispose() in other contexts. var addButton = function (stateManager = mandatory(), options = null) { return new Promise(function (resolve, reject) { if (typeof stateManager._parent.parentTaskObject === "undefined") { throw new Error("stateManager.addButton: stateManager._parent.parentTaskObject is undefined"); } var baseOptions = { id: "button" + stateManager.timeInMs, text: "text", x: 50, y: 50, width: 100, height: 50, fill: BABYLON.Canvas2D.GetSolidColorBrush(new BABYLON.Color4(0.8, 0.8, 0.8, 1)), clickEventData: null, fontName: "30pt Arial", baseOpacity: 0.8, hoverOpacity: 1 }; options = _.extend(baseOptions, options); var elements2D = stateManager.getGlobal("elements2D"); var canvas = elements2D.canvas; // create button and add to canvas var buttonRect = new BABYLON.Rectangle2D({ parent: canvas, id: options.id, x: options.x, y: options.y, width: options.width, height: options.height, fill: options.fill, roundRadius: 0, children: [ new BABYLON.Text2D(options.text, { fontName: options.fontName, marginVAlignment: "v: center", marginHAlignment: 3 }) ] }); buttonRect.opacity = options.baseOpacity; // Add an observable for hovering buttonRect.pointerEventObservable.add(function (d, s) { buttonRect.opacity = options.hoverOpacity; }, BABYLON.PrimitivePointerInfo.PointerOver); buttonRect.pointerEventObservable.add(function (d, s) { buttonRect.opacity = options.baseOpacity; }, BABYLON.PrimitivePointerInfo.PointerOut); // Add an observable for clicking if ((options.clickEventData !== null) && (options.clickEventData.constructor === EventData)) { buttonRect.pointerEventObservable.add(function (d, s) { options.clickEventData.happenedAt = stateManager.timeInMs; options.clickEventData.data.button = buttonRect; stateManager.addEvent(options.clickEventData); }, BABYLON.PrimitivePointerInfo.PointerUp); } resolve(buttonRect); }); }; Did that happen to someone else ? Any clue ? To circumvent the problem I create a 1*1 pixel button with opacity 0 at position 0,0 and that allows me to dispose() all the real buttons without error. Thanks !
-
Hi there, I have a minimap implemented by having a secondary camera in a RenderTargetTexture applied on a plane. In the 2.6 preview version since a change committed on Dec 21st 2016, something has been broken. So when I dispose an object in my scene, the entire plane which holds the minimap (the RenderTargetTexture of a camera) disappears too. This is obviously not the expected behaviour. I traced the problematic commits and they happened to be these: commit 49e419016287753a9720a46114bbc605df69db79 Merge: 55f1083 d0fbbc9 Author: David Catuhe <[email protected]> Date: Wed Dec 21 12:23:33 2016 -0800 Merge pull request #1622 from haxiomic/UseOpenGLProjectionMatricies Use OpenGL projection matricies over Direct3D for better depth precision To reproduce the problem, please download the attached zip and run index.html. The code has setTimeout that will dispose the sphere. You will see that the minimap disappears too. Then when you modify index.html to reference good-babylon.js instead of bad-babylon.js you will see that when the sphere disappears, the minimap will not disappear. bad-babylon.js is the current preview version built from master, whereas good-babylon.js is from a version before the problematic commit. I hope someone knowledgeable of the changed area of code fix the issue for us. bug.zip
- 4 replies
-
- rendertargettexture
- disappear
-
(and 3 more)
Tagged with:
-
hello, is it possible to bring back a mesh after it's disposed?
-
I'm working on a project where a large number of objects get created, then are destroyed (with .dispose()), on an ongoing basis. Using latest code from the version builder having learned my lesson :-) I see the number of materials (in scene.materials) gradually get larger and larger. And the browser using more and more memory.... So it looks like the materials are not being dispose()'ed of when the mesh that uses them is disposed. I'm using the construct from the examples, i.e. var mesh = new BABYLON.Mesh.CreateXXX(...) mesh.material = new BABYLON.StandardMaterial(...) EDIT: It does NOT always seem to help to explicitly dispose of the material before the mesh, e.g. mesh.material.dispose(); mesh.dispose(); ..and it has some side-effects if a material is used by another mesh. But should that be necessary? Also, can it help to store a single material that can be used by a number of meshes? Or does the material data get duplicated when assigned to a mesh in any case? Cheers...