Search the Community

Showing results for tags 'dispose'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 31 results

  1. 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.
  2. 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?
  3. Bug in GUI causes crash

    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
  4. 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?
  5. 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!
  6. 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
  7. Slow FPS remains even after prim.dispose()

    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
  8. 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!
  9. How to dispose a material on run time and dynamically create again. I want when my sphere material collide with floor material my sphere material should dispose completely and I want to create a new sphere material again. @Deltakosh @Wingnut @Dad72
  10. 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!
  11. 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 :
  12. 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 <david.catuhe@live.fr> 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
  13. Rectangle2D.dispose() creates a WebGL error

    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 !
  14. Reverse dispose

    hello, is it possible to bring back a mesh after it's disposed?
  15. 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...
  16. Hey Delta... Did you get a chance to put the missing light.onDispose and camera.onDispose just like the mesh.onDispose has???
  17. dispose in 2.5 alpha nightly

    Hi the following code gives a webGL error: INVALID_OPERATION: drawElement: no buffer is bound to enabled attribute If you remove the diffuseTexture it works, and I tried calling material.dispose and diffuseTexture.dispose to no avail, I've reverted to 2.4 and this does not occur. Thank you for the amazing work! var material = new BABYLON.StandardMaterial('texture', scene); material.diffuseTexture = Util.texture('assets/height.jpg', scene); material.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5); var mesh = BABYLON.MeshBuilder.CreateIcoSphere('Ball', { radius:64, subdivisions:4 }, scene); mesh.position.x = 64; mesh.position.z = 256; mesh.position.y = 32; mesh.material = material; setTimeout(() => { console.log(mesh); console.log(scene.meshes.length); setTimeout(() => { mesh.visibility = false; mesh.dispose(); console.log(scene.meshes.length); }, 1000); }, 2000);
  18. Hello, is it the correct behaviour that instances that are being disposed doesn't get removed from ShadowGenerator.getShadowMap().renderList ? I have the refreshrate set to 0 and only render with shadow on demand. if (_renderShadow && this._manuallyShadowRender) { this._shadowGenerator.getShadowMap().refreshRate = 1; this._scene.render(); this._shadowGenerator.getShadowMap().refreshRate = 0; } else { this._scene.render(); } Is this a problem i this case? I just want to know (maybe it's a bug). Shouldn't ShadowGenerator check the Mesh.isDisposed attribute? Have a nice day Kevin
  19. Hey there! I'm making a game based on Megamania (Atari 2600) for my end of graduation work and i'm having problems with the Dispose function. When i click the mouse, the ship shot a bullet, then it "intersectsmesh" with a box, the box and the bullet are disposed, but "something" invisible stays in the place, if i shoot at that place again the bullet is destroyed even if technically nothing is there. this is the function: window.addEventListener("click", function(e) { console.log(score); scene.registerBeforeRender(function() { bullet.position.y = bullet.position.y + 10; }) var bullet = BABYLON.Mesh.CreateCylinder("bullet", 5, 1, 1, 6, 1, scene); var BstartPos = ship.position; var posVec = new BABYLON.Vector3(BstartPos.x, BstartPos.y + 17, BstartPos.z); bullet.position = posVec; scene.registerBeforeRender(function shot() { for(var i1 = 0; i1 < enemy1.length; i1++) { if(enemy1[i1].intersectsMesh(bullet, true)) { bullet.dispose(); enemy1[i1].dispose(); score = score + 1; scene.unregisterBeforeRender(shot); } } for(var i2 = 0; i1 < enemy2.length; i2++) { if(enemy2[i2].intersectsMesh(bullet, true)) { bullet.dispose(); enemy2[i2].dispose(); scene.unregisterBeforeRender(shot); score = score + 1; } } for(var i3 = 0; i3 < enemy3.length; i3++) { if(enemy3[i3].intersectsMesh(bullet, true)) { bullet.dispose(); enemy3[i3].dispose(); scene.unregisterBeforeRender(shot); score = score + 1; } } if(bullet.position.y < -250 || bullet.position.y > 250) { bullet.dispose(); scene.unregisterBeforeRender(shot); } }); }); i've tried "enemy3[i3].intersectsMesh(bullet, true)" and "bullet.intersectsMesh(enemy3[i3], true)", the results are the same. if you check the score in the console, you'll see that the numbers doesn't makes sense too, they grow exponentially... here's the code: http://techslave.com.br/games/dispose/js/core.js and here's the game: http://techslave.com.br/games/dispose/ not in the playground because there's a lot of files can someone help me?
  20. Hi! First time posting. I ran in to an issue I've battled with for a several days. When calling the canvas2d.dispose the error: "Uncaught TypeError: Cannot read property 'modelKey' of null" sometimes occur. I did a fair bit of research but I don't see that I am calling anything incorrecly. While posting I realised that I can probably circumvent the problem by creating a "RepositionGUI" function but I would like to understand the problem. In the example the error occurs in chrome after the button is pressed. <html> <head> <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/> <title>Babylon - Getting Started</title> <!--- link to the last version of babylon ---> <script src="babylon.2.5-alpha.js"></script> <style> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; } #renderCanvas { width : 100%; height : 100%; touch-action: none; } </style> </head> <body> <canvas id="renderCanvas"></canvas> <script> window.addEventListener('DOMContentLoaded', function() { // get the canvas DOM element var canvas = document.getElementById('renderCanvas'); // load the 3D engine var engine = new BABYLON.Engine(canvas, true); var scene; var canvas2d; var createScene = function() { scene = new BABYLON.Scene(engine); var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene); var cam = new BABYLON.ArcRotateCamera("ArcRotateCamera", Math.PI / 3, Math.PI / 3, 200, new BABYLON.Vector3(-10, 30, 10), scene); cam.attachControl(canvas); scene.executeWhenReady(createGUI); return scene; }; var createGUI = function() { canvas2d = new BABYLON.ScreenSpaceCanvas2D(scene, { id: "ScreenCanvas", enableInteraction: true }); //buttons var button1 = new BABYLON.Rectangle2D({ parent: canvas2d, id: "button1", x: canvas.width /2 - 150, y: canvas.height / 2 , width: 300, height: 80, fill: "#ffffffff", border: "#DADDDEFF", borderThickness: 8, children: [new BABYLON.Text2D("Button 1", { fontName: "32pt Arial", defaultFontColor: new BABYLON.Color4(0.2, 0.2, 0.2, 2), marginAlignment: "h: center, v: center", fontSuperSample: true })] }); var text1 = new BABYLON.Rectangle2D({ parent: canvas2d, id: "text1", x: canvas.width /2 - 125, y: canvas.height / 2 - 300, width: 250, height: 80, fill: "#e4e4e4ff", border: "#DADDDEFF", borderThickness: 8, children: [ new BABYLON.Text2D("Text 1", { fontName: "24pt Arial", defaultFontColor: new BABYLON.Color4(0.2, 0.2, 0.2, 2), marginAlignment: "h: center, v: center", fontSuperSample: true }) ] }); var text2 = new BABYLON.Rectangle2D({ parent: canvas2d, id: "text2", isVisible: false, x: canvas.width /2 - 125, y: canvas.height / 2 - 300, width: 250, height: 80, fill: "#e4e4e4ff", border: "#DADDDEFF", borderThickness: 8, children: [ new BABYLON.Text2D("TempText2", { fontName: "24pt Arial", defaultFontColor: new BABYLON.Color4(0.2, 0.2, 0.2, 2), marginAlignment: "h: center, v: center", fontSuperSample: true }) ] }); /*specific button function*/ button1.actionManager.registerAction(new BABYLON.SetValueAction(BABYLON.ActionManager.OnPickTrigger, text1, "levelVisible", false)); button1.actionManager.registerAction(new BABYLON.SetValueAction(BABYLON.ActionManager.OnPickTrigger, text2, "levelVisible", true)); }; // call the createScene function scene = createScene(); // run the render loop engine.runRenderLoop(function() { scene.render(); }); // the canvas/window resize event handler window.addEventListener('resize', function() { engine.resize(); canvas2d.dispose();//this is not working, some of the canvas is not disposed, textfield disapears bottommenu does not createGUI(); }); }); </script> </body> </html>
  21. 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.
  22. Hello, I have a scene which contains a GUI and other functions to log into and set up settings for a second scene to be loaded from a seperate script. This would be similar to loading one environment from on script for a game and ipon completion of the first level - disposing of the first scene and loading a second scene (level) from a seperate script. I don't want to have every level (scene) in a single script, as the functions in each of the scripts are far too different from one another and would be very large and inefficient to contain in a single script. So I have been able to dispose of my first scene, however I have a function in my second script which is set to run when the first script disposes and sends a global variable to the second script which conditionally should cause the function in the second script to initialize a new and different environment, scene, and functions. The global variable is being passed to the function in the second script, yet the scene in the second script is not initializing. I hope someone has an example online of this or a similar process where they are callig new scenes in seperate scripts successfully; as I cannot get a second script to initialize the function loading the second scene. Any examples would be very much appriciated. Thank you, DB
  23. I try to use dispose function to remove the 2d line when click the canvas, but seems not work. http://babylonjs-playground.com/#15C96V#2
  24. Disabling SSAO

    Hi, Not able to dispose SSAO render pipeline, using dispose method. The renderer stops and the screen goes blank, with an error at setTexturesFromPostProcess. I am using preview release.
  25. Hi guys! I have this scene where I import different meshes with lots of polygons, like here: http://babylonjs-playground.com/#1OI6LZ#11 You'll see that I'm importing the same mesh repeated times instead of using instances on purpose. So at some moment, I'd like to remove some of these meshes. In the example above, when you click on the skulls, the mesh.dispose() is called. When I track the memory with the Chrome JS Heap timeline tool I can't really see the memory released though when the dispose() function is called. Here the four skulls were loaded and then I clicked on every one of them, so shouldn't there be some drops visible?: Is there something I'm missing?