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 56 results

  1. 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... ?
  2. 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
  3. hy everyone, can i use sceneLoader.load for obj.ext files to load a scene?
  4. 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!
  5. 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!
  6. 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.
  7. 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
  8. 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.
  9. 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?
  10. 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.
  11. Hi! We just released a new Phaser Editor version (1.3.0) Updated to the latest Eclipse version (Neon.1): Performance improvements and much more. Eclipse Marketplace Client: to install third party plugins, like EGit. We are evaluating the typescript plugins developed by the Eclipse community. Automatic Updates: all components of the editor will be updated automatically, including the latest Phaser official version (no Phaser CE support for now) Improved JS Editor: small changes in the JS type inference engine that results in a much better content assist (yet not *perfect*) Bug fixing, performance improvements and *minor* features in the scene editor, asset pack, local HTTP server, project templates and chains. New learning content: we wrote a tutorial in the GameDevAcademy blog, about how to make a platformer game with the visual scene editor. Read more in the release notes For the next release we plan to focus on: Do a research of the available Typescript plugins and write a tutorial about how to install them. Start with the implementation of the P2 Physics tools for the visual level editor. Support Phaser v3 if it is released in the next 3 months. See you soon! Arian (Scene editor: Added two new parameters to the Animations editor) (Scene editor: recovery from missing assets) (Check for Updates) (Eclipse Marketplace)
  12. Hello, Currently I'm working on my game environment. So I found and bought low poly but quite large forest scene. Almost everything works fine except that when moving camera around some trees are rendered in wrong order. I actually don't have a clue what could be wrong. Is it a model? or maybe some properties of the mesh or whole scene is set wrong? Adding a screenshot of the scene and the bug.
  13. I am building a game using babylon.js and I just ran into a problem. The game is about a chicken that has to find its way back to the henhouse, and on the way there are several tractors driving around that can run over the chicken. The scene loads allright, but when I add animation so that the tractors can move, the scene doesn't load when I start it and I have to refresh it a few times. Does anyone know what could be the problem and how to solve it so that the scene will load when you start the game? here is my main code: var engine; var scene; var canvas; var chicken; var henhouse; var tractor; var tractor2; var tractor3; document.addEventListener("DOMContentLoaded", function () { onload(); }, false); window.addEventListener("resize", function () { if (engine) { engine.resize(); } },false); var onload = function () { canvas = document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, true); initScene(); engine.runRenderLoop(function () { scene.render(); }); }; var createSkybox = function() { var skybox = BABYLON.Mesh.CreateSphere("skyBox", 100, 1000, scene); BABYLON.Engine.ShadersRepository = "shaders/"; var shader = new BABYLON.ShaderMaterial("gradient", scene, "gradient", {}); shader.setFloat("offset", 10); shader.setColor3("topColor", BABYLON.Color3.FromInts(0,119,255)); shader.setColor3("bottomColor", BABYLON.Color3.FromInts(240,240, 255)); shader.backFaceCulling = false; skybox.material = shader; }; var initScene = function() { scene = new BABYLON.Scene(engine); scene.clearColor=new BABYLON.Color3(0.8,0.8,0.8); // Camera attached to the canvas -> chicken doesnt move //var camera = new BABYLON.ArcRotateCamera("Camera", 0.67, 1.2, 150, BABYLON.Vector3.Zero(), scene); //camera.attachControl(canvas); //Create the camera -> chicken is moving camera = new BABYLON.FreeCamera("camera", new BABYLON.Vector3(200, 6,-300), scene); camera.setTarget(new BABYLON.Vector3(0,0,0)); var h = new BABYLON.HemisphericLight("hemi", new BABYLON.Vector3(0, 1, -1), scene); h.intensity = 0.85; var d = new BABYLON.DirectionalLight("dir", new BABYLON.Vector3(1, -1, -2), scene); d.position = new BABYLON.Vector3(-300,300,600); var shadowGenerator = new BABYLON.ShadowGenerator(2048, d); createSkybox(); var ground = BABYLON.Mesh.CreateGround("ground", 1000, 2000, 2, scene); ground.material = new BABYLON.StandardMaterial("ground", scene); ground.material.diffuseColor = BABYLON.Color3.FromInts(193, 181, 151); ground.material.specularColor = BABYLON.Color3.Black(); ground.receiveShadows = true; scene.gravity = new BABYLON.Vector3(0, -0.9, 0); var tg = new TreeGenerator(scene, shadowGenerator); // Number of lanes var LANE_NUMBER = 4; var LANE_INTERVAL = 160; // distance between lanes var LANES_POSITIONS = []; // Function to create lanes var createLane = function (id, position) { var lane = BABYLON.Mesh.CreateBox("lane"+id, 1, scene); lane.scaling.y = 0.1; lane.scaling.x = 15; lane.scaling.z = 1100; lane.position.x = position; lane.position.z = lane.scaling.z/2-600; lane.rotation.y = 180; }; var currentLanePosition = LANE_INTERVAL * -1 * (LANE_NUMBER/2); for (var i = 0; i<LANE_NUMBER; i++){ LANES_POSITIONS[i] = currentLanePosition; createLane(i, currentLanePosition); currentLanePosition += LANE_INTERVAL; } // MESH IMPORTS BABYLON.SceneLoader.ImportMesh("", "assets/", "chicken.babylon", scene, function (newMeshes) { chicken = newMeshes[0]; chicken.position.y = 1; chicken.position.x = 180; chicken.position.z = -280; = chicken; chicken.rotation.y = -1; }); BABYLON.SceneLoader.ImportMesh("", "assets/", "henhouse.babylon", scene, function (newMeshes) { henhouse = newMeshes[0]; henhouse.scaling.x = 4; henhouse.scaling.y = 4; henhouse.scaling.z = 4; henhouse.position.z = 350 ;//+ 50; henhouse.position.x = -200; henhouse.rotation.y += -0.5; }); BABYLON.SceneLoader.ImportMesh("", "", "assets/tractor.babylon", scene, function (newMeshes) { tractor = newMeshes[0]; tractor.scaling.x = 4; tractor.scaling.y = 4; tractor.scaling.z = 4; tractor.position.y = 3.6; tractor.position.x = -72; tractor.rotation.z = 0.04; tractor.rotation.y = -0.6; }); BABYLON.SceneLoader.ImportMesh("", "", "assets/tractor.babylon", scene, function (newMeshes) { tractor2 = newMeshes[0]; tractor2.scaling.x = 4; tractor2.scaling.y = 4; tractor2.scaling.z = 4; tractor2.position.y = 3.6; tractor2.position.x = 95; tractor2.position.z = -20; tractor2.rotation.z = 0.04; tractor2.rotation.y = -3.5; }); BABYLON.SceneLoader.ImportMesh("", "", "assets/tractor.babylon", scene, function (newMeshes) { tractor3 = newMeshes[0]; tractor3.scaling.x = 4; tractor3.scaling.y = 4; tractor3.scaling.z = 4; tractor3.position.y = 3.6; tractor3.position.x = -15; tractor3.position.z = -190; tractor3.rotation.z = 0.04; tractor3.rotation.y = -0.6; }); //tractor animation scene.registerBeforeRender(function() { tractor.position.x += 0.6; if(tractor.position.x >=90){ tractor.position.x = -72; } tractor2.position.x -= 0.6; if(tractor2.position.x <=-80){ tractor2.position.x = 95; } tractor3.position.x += 0.6; if(tractor3.position.x >=170){ tractor3.position.x = -15; } }); }; //moving the chicken window.addEventListener("keydown", function (event) { switch(event.keyCode) { /*case 76: chicken.position.z += 1; chicken.rotation.x += 0.5; camera.position.z += 1; break;*/ case 37: //right chicken.position.x += -1; chicken.rotation.y += -0.001; camera.position.x += -1; //camera.rotation.y += -0.01; break; case 39: //left chicken.rotation.y += 0.001; chicken.position.x += 1; camera.position.x += 1; //camera.rotation.y += 0.005; break; case 40: //backwards chicken.position.z += -1; camera.position.z += -1; break; case 38: //forward chicken.position.z += 1; camera.position.z += 1; break; case 32: //jumping chicken.position.y += 2; camera.position.z += 1; chicken.position.z += 1; //pause //yield to.sleep(.500); setTimeout(function(){ chicken.position.y -= 2; },150); break; } }, true);
  14. Hi, How do you unload a scene? There's a BABYLON.SceneLoader.Load, but no Unload? How do I remove a scene completely? Here's my dilemma: I've got a game with 3 levels. I'm not loading assets through the assets manager as all three scenes are Blender exports (with lights and cameras set up). At the end of each level I want to unload the previous scene (instances, clones, sounds, etc) and load a new one. Surely there must be a way, but I just cant find it... Thanks!
  15. This request is more for the BabylonJS maintainers like David. I talked you guys into letting me add node.metadata which is WORKING GREAT... SO GREAT that i really need (and hope you can see the same value as well) of having the same serializable metadata at the scene level. So i am asking SOMEONE to please: @serialize() public metadata:any = null; to babylon.scene.ts so it can be used exactly like node.metedata. Right now if i want to store SCENE level metadata i gotta put a DUMMY mesh (or node) into the scene and search the all the scene.meshes to find some node.metadata that has been aliased to be used as scene level data. That kinda sucks (Note: I DONT MEAN BABYLONJS sucks in any way... remember... I luv you guys and the very concept of babylonjs ). Just not a clean way to store and retrieve any scene level metadata. Adding scene.metadata would give that same 'automatic de-serialization' of the built in babylon parsing framework. We will end up with a real javascript object scene.metadata JUST LIKE node.metadata Please REALLY think about it... I would luv to clean up some of my BabylonJS loader code and having to look thru the scene nodes to grab a dummy node with my scene level metadata, really bugs my OCD Thanks again for even thinking about it
  16. Hi everybody, I am very new to both Blender and Babylon. Basically I am trying to load a scene exported from Blender and create a skybox afterward, the scene is nothing more than a default blender scene(the one consists of a box, camera and light, I load this scene just to make sure I hadn't added or modified anything in the scene that may leads to other issues once I export the scene into babylon file). I try to create a skybox after loading the scene, using code below: =============================================== var canvas; var engine; var scene; function initScene() { canvas = document.getElementById("renderCanvas"); engine = new BABYLON.Engine(canvas, true); scene = new BABYLON.Scene(engine); BABYLON.SceneLoader.Load("babylon/","testScene.babylon",engine,function(newScene){ newScene.executeWhenReady(function(){ newScene.activeCamera.attachControl(canvas,false); var ground = BABYLON.Mesh.CreateGround("ground", 10, 10, 2, newScene); var skybox = BABYLON.Mesh.CreateBox("skyBox",1000.0,newScene); var skyboxMaterial = new BABYLON.StandardMaterial("skyBox",newScene); skyboxMaterial.backFaceCulling = false; skybox.infiniteDistance = true; skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("images/skybox/cloudSkyBox/DaySkybox", newScene); skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE; skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0); skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0); skyboxMaterial.disableLighting = true; skybox.material = skyboxMaterial; engine.runRenderLoop(function(){ newScene.render(); }); }); },function(progress){}); } function initBB(){ if (BABYLON.Engine.isSupported()){ initScene(); }else{ console.log("not support BB"); } } document.addEventListener("DOMContentLoaded",initBB,false); document.addEventListener("resize",function(){ engine.resize(); }); =============================================== The blender scene "newScene" is loaded(I can see the box, a directional light of the blender default scene, I can use the free camera preset in blender scene), the ground mesh added into the newScene can be seen as well, but the skybox is not shown! There is no error message shown on the browser console, I had tried to google for similar problem but couldn't find the solution... I am not sure if I set up the blender scene wrongly before I export or there is other factor that cause this issue. Any help would be greatly appreciated!
  17. Hi, I hava a question/suggestion re BJS Cameras/Scenes. 1) In THREE.js a Camera inherits all 3d properties from a Node, including Scale, which is VERY handy: by changing the scale of camera, you're changing the World's scale. 2) Same applies to a Scene: you can simply state myScene.scale.x = 2 and it works beautifully! Now, maybe I'm missing something in BJS, but what do I do if I need to scale an imported Scene? Iterating through meshes seems like an awkward way of doing things - same as creating an empty parent for all objects in the scene. Is there a simple solution? 3) Are there any helper objects in BJS, e.g. light cones, floor grids etc? Thanks.
  18. 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.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.
  19. I am using Cocos2D for Android: I have two scenes `MainScene` and `LogoScene`. I want to show a Splash screen on `LogoScene` then, I want to transition to `MainScene`. I am wondering how I can go from `LogoScene` to `MainScene` using: CCDirector.sharedDirector().replaceScene(MainScene.scene()); What is an example of Scene Transition from a splash screen to the main scene?
  20. How do I create Start, Stop and Restart buttons? I'm learning babylonjs to teaching it for my physics stutents. My plan is to teaching to create physics simulations like phet colorado sims but in 3d. First, I need a standard GUI with Play, Stop and Restart buttons that works with physics engines. I made a playground for sample it: click two time run for wok after castor error. I want to stop the sphere free fall and restart the scene. Which functions or commands do I need to use for it? Thanks, Rafael J.
  21. Updated August 31, 2016 A new version of Phaser Editor is available! Take a look! --- Hi, I invite you to check this PREVIEW video about Canvas, the Phaser Editor scene builder that is in development. In the video we show how you can create the scene objects by dragging the assets shown in the Assets explorer, the texture atlas previews and the sprite-sheet previews (it was funny to discover that a texture atlas could be a nice "sprite palette"). We think this is a natural behavior that will increase your productivity since it uses the same elements you are familiar with. We want to build an editor from the bottom to the top: We implemented a powerful asset manager, based on the Phaser Asset Pack format. Asset packers like the texture atlas and the audio sprites generators. A Preview window that is able to visualize those assets in a way that helps the user to get a quick feedback of the kind of objects she is using in her game. A JavaScript editor that understands the assets of your game, and helps the user to write the asset keys and provides popup windows with useful information and visual (and echoing) feedback. And now an scene builder that takes advantage of the asset pack and the Preview windows. When the scene builder gets ready and stable, then we will focus on the objects of the scene, and provide more specialized editors for aspects like tweens, sprite-sheet animations, physics and emitters, to mention some of them. Our gold rule: stick to vanilla Phaser concepts, models and formats, we do not want the user to learn new stuff, we want to reuse what he already knows about Phaser, the same names, the same structures, and we want he to learn something that applies even outside our editor, because it is just Phaser after all. Well.. it was a long talk :-) I let you with the video. Any idea about the scene builder or whatever other thing, is more than welcome. Updated June 25, 2016 Video updated with the last version of the scene editor.
  22. Hi, I am pleased to announce a new Phaser Editor release. Finally the game level visual editor is available for you to play with it and create some games. It is a preview version but yet powerful enough to make the scenes of many games. In addition we introduced a new method to update the editor with the last Phaser build. It means, each time Phaser is released you will be able to easy update the components of the editor that are linked to the Phaser source and metadata. Just take a look to the release notes!
  23. Is there some plugin or some tool inside Phaser that can help me draw a table of data. I have this image: As you can see I have two arrays of data and they are drawn in Phaser text field as string, but since the numbers inside are of different string length points array is longer than errors array and therefore cut if over the screen boundaires. How can I draw a table with this data, 3 rows by 15 columns? Also could I possibly create such plugin for Phaser?
  24. Hi, I don't know if you could really call this a bug or maybe it's working as intended and I'm doing it wrong... (sorry) If you get sufficiently close and intimate with a mesh you can't pick it. Here's a playground: The important parameter to look at is the Z coordinate of the camera. If I set it to -1.06 then I can successfully pick the front face of the box and distance to the box is 0.01. (I'm printing pickResult in the console) If I set it to -1.04 then I can only pick the back face of the box yet I can still see the front face. If I set it to more than -1 then I can't see the box so I can't pick it, that's normal. It's as If the ray's origin wasn't exacly in the camera's viewframe but 1 unit length in front of it.
  25. Hello, Using a playground taken from this thread as reference In this playground if you click on a cube it will switch camera. I have noticed that if you drag the scene around then change camera by clicking on a cube the last movement done on the previous camera will be executed on the new camera too. Is there a way to prevent this? This also happen if you change scene: - You are on scene 1 - go on scene 2 - drag the camera - go back to scene 1 scene 1's camera will move too as soon as you go back to that scene It doesn't happen if you move the camera using the keyboard, though