Search the Community

Showing results for tags 'scene'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


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

Found 71 results

  1. Is there a way to clone an imported mesh to use it in a different scene? I try to change the _scene parameter of the mesh like that : this.mesh._scene = newscene; but I got an error. It seems like I must import all my meshes twice in both of my scenes. Unfortunetly it will increase the loading time. Looking for suggestions! Thanks
  2. Hi community, I want to propose you some addition to assetManager and sceneOptimizer. If the solution already exist, said me assetManager : 1. Get loading percent, not on x file loaded but on stream data loaded when it's possible. > for more precision and to show state if you load some big files. 2. Add "abort" function and "onAbort" callback to cancel running tasks and loading files. > Currently "clean" function delete tasks in assetManager but not abort current loads. That mean if you have a big file in loading, it don't stop. sceneOptimizer : 1. Add a starter level to try optimizing render : > I tested the current sceneOptimizer and the problem is it try the best render first. If you have an older device, the website crash and the browser reload page before that sceneOptimizer can downgrade the render. So, it's a loop without ending. 2. Create two steps to optimize render : > First : upgrading. The sceneOptimizer try to reach "x" FPS with the starter level. If it's ok, it upgrade render again until when it can't reach "x" FPS. > Second : dowgrading. If the last try (or the first try with the starter level ) not reach FPS, the sceneOptimizer downgrade until when it can reach FPS. If the sceneOptimizer reach "x" FPS, it stop. > Of course, we keep "trackerDuration" : time in milliseconds between passes. > You will can restart the sceneOptimizer when you add or change something like the current version What do you think about this ? Have a nice day !
  3. Hello. Is there a way to interrupt/stop BABYLON.SceneLoader.load ?
  4. Hi, Need some help with scene, skybox and camera adjustments. Scene not covering skybox. My working area 10000,10000,10000. Just rotate scene and you will see what I mean. Any help will be appreciated.
  5. Hello good day / night guys, I am new on the comunity of babylonjs , really happy to have found a great tool to make some games , i have a concern about if there is a way that according to the camera.position.y it can change the scene's properties , for example like the fog if i am underwater and change it back to less fog if i am outside the water ? i've tried this : "scene.getCameraByName("FreeCamera").position.y<=0" and "scene.getCameraByName("FreeCamera").position.y>0" , but not sure if it is okey to set it inside the : scene.registerBeforeRender ? like this : scene.registerBeforeRender(function() { if(scene.getCameraByName("FreeCamera").position.y<=0){ // properties for camera when is inside water } if(scene.getCameraByName("FreeCamera").position.y>0){ // properties for camera when is outside water } }); will this affect performance? , or there is another way to detect camera positions to change properties according to the high level ? , thanks in advance
  6. Wow... I never saw this project... when did this get here, was this always here??? Does this mean we can convert the json .babylon text file to a Binary Format ??? Is this real binary data (maybe dumb question) but it look like regular json text being written using stream writer... Does that make it binary?? I would think there would some kind of 'Byte Encoding' going on to make it binary... Dunno... What that is all about.... But looks like a VERY KOOL option to add to the toolkit... Save your scene files as binary rather than text... If thats the case... would is be possible to save Directly From Babylon Entities to this binary format instead of saving to .babylon text file then going back and converting the text file to this Babylon binary format... I can't believe I NEVER saw this project before... Must have over looked this guy Anyways... What are the advantages of this binary format vs me just pre-compressing to a .gz file ???
  7. Hello, I am new to Phaser. What is the best way to create scene (menu, top, settings, game itself) for puzzle game? Should I create scene manually (code) or should I use some GUI and export results as JSON file which later I can use in Phaser? Thanks in advance and I hope my question was not answered hundreds times
  8. Camera and Sprite

    I have been working tirelessly with this and really struggling to get anywhere, if anyone can offer some form of assistance I would be greatly appreciative. I have essentially set up a reel of characters (staff) as sprites organised by co'ords in three circles, 12 characters per circle, around the camera set at (0,0,0), (Radius of circles are 1.5/1.45/1.4 I have a scene built currently which is super buggy in movement as well. I need it to when the mouse hovers on the left or right side of the screen to rotate the camera continuously scrolling through the images on loop (Cant get working past following the mouse - no loop - no smooth movement as mouse movement on y axis also rotates the camera. This is my mouse movement code: var mouse = {x:0,y:0}; var cameraMoves = {x:0,y:0,z:-0.1,move:false,speed:0.03}; function mouseMove(e){ mouse.x = e.clientX; mouse.y = e.clientY; camera.rotation.x += Math.max(Math.min((e.clientX - mouse.x) * 0.01, cameraMoves.speed), -cameraMoves.speed); camera.rotation.y += Math.max(Math.min((e.clientY - mouse.x) * 0.01, cameraMoves.speed), -cameraMoves.speed); The second main issue i'm having is that the sprites keep disappearing when rotating the camera, I'm trying to create a constant panable image reel from inside to view members of staff, there is an example i'm trying to follow and recreate found here: If anyone could tell me how to solve me mouse hover to move issue (with infinite looping) or a fix for the rendering of sprites issue it would be great! If anyone thinks they can help and needs any more code of any kinds just let me know and i''ll sort it! Thanks!
  9. Code: So if you try to load a scene asynchronously, do something else, start the engine using that scene, The scene will just show an empty space. However, if you take a look at the code above, go to async function createScene(config) { const { textureModifier } = config; const { height, width, color } = config; const scene = new Scene(config.engine); await importScene(config.mesh, scene); And comment 'importScene' line, the go to async function run() { // await importScene(config.mesh, scene.internal); engine.runRenderLoop(() => scene.render()); // engine.runRenderLoop(() => console.log('test')); } And uncomment 'importScene' here, it works fine. I've included a .babylon file below. foot.babylon
  10. Hi, I'm working on a medical application where anatomical 3d Models are shown in the Browser. At the moment I am working with Threejs, but I am looking for alternatives and Babylon.js looks very good, especially from a documentation perspective. But I cant find much information about loading Scenes/STLs using XHR Requests. In most tutorials they are loaded as assets directly from the webserver the app is hosted on. So my Questions are: Is it possible to load a scene from an application server which is not the webserver using http GET, including an x-auth-token in the header ? Is it possible to load the file as a binary stream, or in a small format? (Because the models often have a high poly-count) Thanks in advance :-)
  11. Hot reloading engine

    // @flow // $FlowIgnore import * as BABYLON from 'babylonjs'; import shortid from 'shortid'; type Color = { r: number, b: number, g: number, }; export default class Scene { _scene: BABYLON.Scene; _camera: BABYLON.ArcRotateCamera; _light: BABYLON.HemisphericLight; constructor(engine: BABYLON.Engine, canvas: HTMLElement) { const scene = new BABYLON.Scene(engine); scene.clearColor = new BABYLON.Color4(0.5, 0.8, 0.6, 0.8); const camera = new BABYLON.ArcRotateCamera('Camera', 1.5 * Math.PI, Math.PI / 8, 50, BABYLON.Vector3.Zero(), scene); camera.setTarget(BABYLON.Vector3.Zero()); camera.attachControl(canvas, false); const light = new BABYLON.HemisphericLight('light1', new BABYLON.Vector3(1, 1, 1), scene); light.intensity = 0.5; const sphereMaterial = new BABYLON.StandardMaterial('texture1', scene); sphereMaterial.alpha = 1; // sphereMaterial.diffuseColor = new BABYLON.Color3(0.5, 0.5, 0.5); sphereMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0.5); const boxCfg = { size: 5, updatable: true, }; const sphere = BABYLON.MeshBuilder.CreateBox('sphere1', boxCfg, scene); sphere.material = sphereMaterial; sphere.position.y = 5; this._scene = scene; this._camera = camera; this._light = light; } render = () => { this._scene.render(); } dispose = () => { this._scene.dispose(); } } import { Engine } from 'babylonjs'; import Scene from './Scene'; export default class RenderEngine { constructor(container) { this._container = container; } animate() { this._engine.runRenderLoop(this._scene.render); window.addEventListener('resize', this._engine.resize); } createScene() { this._scene = new Scene(this._engine, this._canvas); } render = () => { this._canvas = document.createElement('canvas'); this._container.appendChild(this._canvas); this._engine = new Engine(this._canvas, false); this.createScene(); this.animate(); } reRender = () => { this._engine.dispose(); this._container.removeChild(this._canvas); this.render(); } } const root = document.getElementById('root'); const engine = new RenderEngine(root); engine.render(); if ( {'./RenderEngine', () => { engine.reRender(); }); } I am currently learning babylon.js and with my set up I have hot reloading, so when any files are changed, engine.reRender() will be called. To test it out I change up color of sphereMaterial. It creates new canvas, but for some reason it still shows the old colors... Is there any way to clear out the scene and engine to load the webgl with new configuration? Thank you.
  12. I am working on a project that switches between a handful of scenes. To do this I load all of my scenes at the start so you can switch between them quickly. You start out in an overall view of the area and you can click markers to go into rooms. In the rooms are more makers that are hooked up to click events. However If one of the markers in the scene is in the bottom left of the screen per say and I move to a different scene, If I would click in the bottom left of the screen the click event of the previous room triggers. How do I make sure that click events are only active for the currently active scene?
  13. Hi, Got strange situation, one mesh, that was exported from 3d max , is not appearing in `scene.mesh` list, but it works with `scene.getMeshByName("meshName");` var mesh; mesh = scene.getMeshByName("meshName"); // Works scene.meshes.forEach((m) => { console.log(; // Doesn't appear here if( === "meshName") { mesh = m; // Never happens } }
  14. Hi guys! I have small problem, If I dispose WorldSpaceCanvas2D, material from canvas stay on the scene Example, you need look in console, you can see after disposing canvas the material on scene "myCanvas_Material" How I can dispose this material? Thanks!
  15. Pick mesh in the Scene

    I've exported my scene from 3Dsmax. Now I want to get individual meshes and want to do something with them. How can I select a mesh in the scene? with its name or ID... ?
  16. Hi guys! Found very usefull feature in three.js like ability to set texture as scene backgorund ( Is there something like that in Babylon? Ofcourse we can use two scenes, put texture to plane, setup orthogonal camera... but it's very uncomfortable
  17. Obj file

    hy everyone, can i use sceneLoader.load for obj.ext files to load a scene?
  18. Does anyone have any evidence (anecdotal even) on which method would be quickest? Scenario A: Dispose of 200 static meshes and create 12 new ones. Scenario B: Dispose of the whole scene and create a new scene with 13 static meshes. Scenario C: Not sure this is possible, but can you make babylon.js not render meshes? I could "turn off" the 200 static meshes so they do not interact with lights and player input. This would be the preferred method, I think, since it would minimize object creation, which in C is an expensive process. I can test it, of course, but was wondering if anyone had any best practices on how to make that as seamless as possible. Thanks for any input. EDIT: Looks like setEnabled() may make Scenario C possible! I will test it!
  19. Maximum Scene Polycount

    Hello, I'm trying to export a model which is about 400,000 Polys. I know the maximum export is somewhere around 60, 000 for any one mesh. I am thinking about breaking and exporting the mesh in different parts. Will this lead to issues in the scene? Also, what is the best polygon count for a babylon scene for efficiency in web and mobile? Finaly, what is the maximum polygon count for a babylon scene before it crashes? Thank you in advance!
  20. I have an existing scene made in Babylon.js (scene1) I have a `.babylon` file (scene2) I want to append to scene1. Before appending scene2 to scene1 I want to do some operations on the meshes of scene2. `BABYLON.SceneLoader.Append` just immediately dumps everything from scene2 into the scope of scene1. This is not helpful. I have a lot of meshes in scene2 and scene1 with dynamic names so it's a lot of work to manually go through the merged array and look for the meshes that were in scene2. I was hoping I could use `BABYLON.SceneLoader.Load` for this. Load scene2, iterate over the scene2 meshes, then manually add them to scene1. Maybe I've missed something but, it doesn't like there is straightforward support for this. Seems like `BABYLON.SceneLoader.Load` is designed to load an initial scene only.
  21. I am clearing my scene entirely, where I use completely new sounds and new plans/textures. What is the proper way to do this? I'm first going through each of my planes and removing the plane and animations for each of them: item.plane.dispose(); item.animateR.reset(); item.animateX.reset(); item.animateY.reset(); and do the same for the sounds. Then I go to the scene and do the following: scene.dispose(); scene.disposeSounds(); The problem is I still see a lot of memory being used up, even after I do this and have an empty canvas on the screen. Am I missing a step or going about this wrong? Thanks, Jeff
  22. Interaction with objects

    Hi, my project with BabylonJS is growing day to day. Now, I am going to introduce interaction to my scene. I dont know how can I get this. I would like click to some object and see on screen show information of it. To do this I need to know differents way to interact with objects of scene. Also using a gui, I am interested to hide or show differents elements of my world. Could you show me similar examples? Thanks.
  23. var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var initBallSpeed = 0.05; var ballSpeed = initBallSpeed; var xDirection = 1; var yDirection = 1; var boardX = -3.0; var boardY = 3.0; var keyState = {}; var MainScene = function () { // This creates a basic Babylon Scene object (non-mesh) var scene = new BABYLON.Scene(engine); // This creates and positions a free camera (non-mesh) var camera = new BABYLON.FreeCamera("camera1", new BABYLON.Vector3(0, 0, -20), scene); //camera.attachControl(canvas, true); var light = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, 0), scene); //Setup the bat for the scene. Dont know what else to call it. var bat = BABYLON.Mesh.CreateBox("bat", 0.5, scene); bat.scaling.x = 5.0; bat.position.y = -5.0; //Setup the ball var ball = BABYLON.Mesh.CreateSphere("ball", 5, 0.5,scene); ball.position.y = bat.position.y + 1; ball.position.x = bat.position.x; //Register keypress actions with the ball scene.actionManager = new BABYLON.ActionManager(scene); window.addEventListener('keydown',function(e){ keyState[e.keyCode || e.which] = true; },true); window.addEventListener('keyup',function(e){ keyState[e.keyCode || e.which] = false; },true); // scene.actionManager.registerAction(new BABYLON.ExecuteCodeAction( // BABYLON.ActionManager.OnEveryFrameTrigger, // function (evt) { // })); //Setup the walls // Top Wall var topWall = BABYLON.Mesh.CreateBox("topWall", 0.5, scene); topWall.position.y = 6.0; topWall.scaling.x = 25.0; // Left Wall var leftWall = BABYLON.Mesh.CreateBox("leftWall", 0.5, scene); leftWall.position.x = -6.0; leftWall.position.y = 1.0; leftWall.scaling.y = 25.0; // Right Wall var rightWall = BABYLON.Mesh.CreateBox("rightWall", 0.5, scene); rightWall.position.x = 6.0; rightWall.position.y = 1.0; rightWall.scaling.y = 25.0; var enemy = BABYLON.Mesh.CreateBox("enemy1", 1.0, scene); enemy.position.x = boardX; enemy.position.y = boardY; var matBB = new BABYLON.StandardMaterial("matBB", scene); matBB.emissiveColor = new BABYLON.Color3(1, 1, 1); enemy.material = matBB; scene.registerBeforeRender(function(){ ball.position.x += ballSpeed * xDirection; ball.position.y += ballSpeed * yDirection; if(ball.position.y < -7){ ball.position.y = bat.position.y + 1; ball.position.x = bat.position.x; ballSpeed = initBallSpeed; xDirection = yDirection = 1; } if(ball.intersectsMesh(rightWall, true)){ xDirection = -1; } if(ball.intersectsMesh(leftWall, true)){ xDirection = 1; } if(ball.intersectsMesh(topWall, true)){ yDirection = -1; } if(ball.intersectsMesh(bat, true)){ yDirection = 1; if(ballSpeed <= 0.25) ballSpeed+=0.01; } if(ball.intersectsMesh(enemy, true)) { xDirection = -1; yDirection = -1; enemy.material.emissiveColor = new BABYLON.Color3(1, 0, 0); } if (keyState[37] || keyState[65]){ bat.position.x-=ballSpeed*2; } if (keyState[39] || keyState[68]){ bat.position.x+=ballSpeed*2; } }); return scene; }; var scene = MainScene(); engine.runRenderLoop(function () { scene.render(); }); // Resize window.addEventListener("resize", function () { engine.resize(); }); Either I am really high or the enemy block is turning red before my ball can even collide with the block. Any ideas?
  24. Importing OBJ file

    Hi, i would like to import an OBJ file into my scene and I have got it. However, I don't get change the position and scale of the mesh. ┬┐How could I do it? This is my code: var loader = new BABYLON.AssetsManager(scene); var edificioB4 = loader.addMeshTask("A2", "", "http://localhost:8080/modelos/A2/", "A2.obj"); BABYLON.OBJFileLoader.OPTIMIZE_WITH_UV = true; loader.load(); Thanks, JuanMa J.R.