Search the Community

Showing results for tags 'solved'.

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

  1. Hey guys, Has anyone had any luck packaging up a Babylon scene inside a Cordova app? The problem I'm having is apparently path related: I get the error message "Error status: 0 - Unable to load..". Everything works fine on the webserver though.
  2. In my tsconfig.json I have "strictNullChecks": true That won't let me have something like: function unsetParent(mesh: AbstractMash) { mesh.setParent(null); } Error TS2345 (TS) Argument of type 'null' is not assignable to parameter of type 'AbstractMesh'. I didn't see a tsconfig in BabylonJS project. Seems like it should be setParent(mesh: AbstractMesh | null){...}? Or is it just not support to have strictNullChecks.
  3. Hi Almighty Babylon Community, I am new to Babylon (and JavaScript in general), and am working on rendering huge tiled maps. The tiled map consists of many square cells are each cell is a 2048 x 2048 pngs (served by HTTP from the server as static files). At each moment we only need to render ~ 12 cells covering an area centered at the main entity. As the main entity moves, it might need to render another set of cells, although the new set of cells shares most part with the old set. My current approach is to render the set of cells with a TiledGround. The TiledGround has MultiMaterial attached to it, and each material in the MultiMaterial has a texture with the corresponding png. Each time when the main entity moves to the point that we need to update the TiledGround, the original TiledGround is disposed and a new TiledGround is created. The problem is that, I can feel the lagging at the moment when the disposing/recreation happens. I am wondering: Since the new set of cells and the old set of cells share most of cells, is there a way to incrementally update the TiledGround so that the lagging can go away? I am setting `.isblocking = false` for all the textures hoping that this can help with the lagging (it is okay to display a black cell first and have texture filled in later when it is loaded). Is this the right way to achieve the goal? Would using multiple Grounds instead TiledGround help? I am worrying that this might not the direction to go. Thanks a lot. Below is the code I have for this task, where `syncState` is called every time when an update on the tile map happens. I would like to do this on the PG but I am not sure how I can have it interact with the cell images, sorry! Thanks a lot for your time and patience import * as BABYLON from "babylonjs"; import { onSnapshot } from "mobx-state-tree"; import STORE from "store"; /** Maintains the 3D entity in BABYLON for tile maps. **/ export default class TileMap { constructor(scene) { this.scene = scene; // Under the hood, the tile map is represented as a tiled ground, // with a multi material. this.tiledGround = null; this.multiMaterial = null; // Create the pure black material for tiles without an image. this.pureBlack = new BABYLON.StandardMaterial("PureBlack", this.scene); this.pureBlack.diffuseColor = new BABYLON.Color3.Black(); // Connects the global state so that this becomes a view of the // the tileMap state. onSnapshot(STORE.tileMap, state => { if (!state.pending) { this.syncState(STORE.tileMap); } }); } /** * Updates the geometric properties of the mesh to make it in sync with the * given state. */ syncState(state) { if (this.tiledGround) { this.tiledGround.dispose(); } // 1. Prepare the multi material for the updated tiled ground. this.multiMaterial = new BABYLON.MultiMaterial( "TileMapMaterial", this.scene); for (let v = 0; v < state.rows; ++v) { for (let u = 0; u < state.cols; ++u) { const i = (state.rows - v - 1) * state.cols + u; if (state.tile[i]) { const image = new BABYLON.StandardMaterial(state.tile[i], this.scene); image.emissiveTexture = new BABYLON.Texture(state.tile[i], this.scene); image.emissiveTexture.uscale = 1; // Invert the v (Y) axis because the tile map has inverted Y. image.emissiveTexture.vscale = -1; // Asnchronously load the image texture. image.emissiveTexture.isBlocking = false; this.multiMaterial.subMaterials.push(image); } else { this.multiMaterial.subMaterials.push(this.pureBlack); } } } // 2. Create the tiled ground. this.tiledGround = new BABYLON.Mesh.CreateTiledGround( "TileMap", state.origin.x, -(state.origin.y + state.height), state.origin.x + state.width, -state.origin.y, { h: state.rows, w: state.cols }, // Number of tiles along x and z (Y). { h: 2, w: 2 }, // Precisions for each tile. this.scene); // 3. Apply the multi material to the tiled ground. this.tiledGround.material = this.multiMaterial; const numTiles = state.rows * state.cols; const verticesCount = this.tiledGround.getTotalVertices(); const tileIndicesLength = this.tiledGround.getIndices().length / numTiles; // Distribute the multi material into sub meshes. this.tiledGround.subMeshes = []; for (let i = 0; i < numTiles; ++i) { this.tiledGround.subMeshes.push(new BABYLON.SubMesh( i, 0, verticesCount, tileIndicesLength * i, tileIndicesLength, this.tiledGround)); } } }
  4. So I'm kinda stumped as to how to troubleshoot this. I just kind of tossed this together and its really badly formatted but I will clean it up later when I have time. First problem is it seems like my shader is off somehow, no matter how i sample the "tiles" texture it seems to not output what I expect. I have a sneaking suspicion its an error in the shader... Anyone have any idea why I cant get the atlas to display correctly? *EDIT* : Ok I am way closer now, just got to get the tile scaling to work correctly and then get rid of the repeating of it then extend some of the functions... but basically got it figured out now. **EDIT** Ok I got it for the most part now, just need to finish up some other things on it and I will start using it in a demo. Might have to refresh a couple of times until the graphics all load.
  5. Hi everybody: We're trying to use the BJS Editor in order to have PBR materials, as the Exporter (from Blender) doesn´t let use them. Our problem is that the resulting .babylon file generated by BJS Editor seems to include the textures as embedded ("base64String" property), resulting so in a huge .babylon file. In parallel, a clever reusing of textures (as .dds) is not possible, as they are all embedded time after time, with each scene. Is there any alternative to this workflow? Thanks for your time. Best regards. Addendum (real .babylon file excerpt): . . . { "tags": "added", "directIntensity": 1, "emissiveIntensity": 1, "environmentIntensity": 1, "specularIntensity": 1, "disableBumpMap": false, "albedoTexture": { "tags": null, "url": "tubo_basecolor.png", "uOffset": 0, "vOffset": 0, "uScale": 1, "vScale": 1, "uAng": 0, "vAng": 0, "wAng": 0, "isBlocking": true, "name": "tubo_basecolor.png", "hasAlpha": false, "getAlphaFromRGB": false, "level": 1, "coordinatesIndex": 0, "coordinatesMode": 0, "wrapU": 1, "wrapV": 1, "anisotropicFilteringLevel": 4, "isCube": false, "gammaSpace": true, "invertZ": false, "lodLevelInAlpha": false, "lodGenerationOffset": 0, "lodGenerationScale": 0.8, "isRenderTarget": false, "animations": [], "base64String": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAEAAAABAACAIAAAB9wbNAAAAACXBIWXMAAAsTAAALEwEAmpwYAAAgAElEQVR4nOzbQQ0AIRDAwCM5/5YXCTyhyYyCGuiamQ8AA . . ." }, . . .
  6. hi, I have a physic body which should be static on the ground, but I log it's position, and it actually keep changing slightly, why?
  7. Hi. How to properly update text when I'm using texture with transparent background. Because drawText doesn't clear the previous text and just paints the new text on top. Here is the code:
  8. I've used camera.getTarget() to advance a character forward, as described here: It's worked well with a FreeCamera, but I can't get it to work with the WebVR camera. camera.getTarget().subtract(camera.position) always returns the same vector regardless of what I'm looking at through the VR headset. It was a bit tricky to demonstrate in the playground, but I managed: That demo starts with a FreeCamera attached to the canvas. Open up the JavaScript console, and you'll see that it's logging the camera.getTarget().subtract(camera.position) vector every second. If you move the camera looking direction with your mouse, you'll see that the "looking vector" changes in the console. Now the same code, but with a WebVR camera (HTC Vive): In the console, the "looking vector" is always the same, regardless of what I'm seeing in the HTC Vive headset. As always, thanks for your help!
  9. Hello Experts I need your Best Guidline I need to know Is it possible to take 3d Model Canvas Screenshot ? And How Its Work can u show me demo ?
  10. Are there any way to enable touch panning for ArcRotateCamera? now we have 1 finger rotate,2 finger zoom,maybe 3 finger for panning?
  11. Hi, We have a few questions concerning the cameraExposure and cameraContrast properties on PBRMaterial. Have these properties been lost during the update to 3.1 ? It would be something like this : Here, the spheres have the same contrast and exposure. I think it was not the case before. Also, we love the new workflow for PBR (specular glossy and metallic roughness), but it does not expose this property at all. Is there a way to achieve this kind of result with the new workflow ? note : we kinda did it through material["_imageProcessingConfiguration"].contrast = v; But it tends to cause WebGL warnings (INVALID_VALUE: uniformBlockBinding: invalid uniform block index) and randomly overexpose our scene. Thanks a lot for your help ! We'd take any info you have about this properties, Best regards,
  12. Hi All, I'm facing some issue in iphone 5c, both safari and iphone, the mesh is horribly jagged, and the transparent side of the mesh have some black pixels in it. 2017-10-13 18.33.58.png?dl=0 FxaaPostProcess make the scene look jagged+ blurry in iphone. In android is a bit jagged too but FxaaPostProcess does make the situation slightly better. Anyone know how to make it look better? Thanks
  13. Hi all, in order to improve the performance of a scene built dinamically, I'm facing this problem: is it possible to have one material, to which is applied one texture, using different uScale e vScale depending on the mesh to which that material is applied? I need this because I have a 3d model of a city with many street segments, each segment having quite different length from each others. Now, those segments are textured: if I use the same uScale for them all, the road texture would appear "stretched" or "shrinked" depending on the length of the segment on which the material is applied, while I want it to appear uniform. I can bypass this problem assigning one different material for every street segment and setting uScale according to its length, but in the end the amount of materials and textures grows dramatically and scene performance falls down at 3 - 4 fps. Any ideas of how reducing the number of materials? Those are the actual stats for a mid-sized city: Total meshes 7309 - Total vertices 170688 - Total materials 7309 - Total textures 3834 Any ideas on how to solve this? Thanks in advance, cheers
  14. GUI in PG

    I think GUI is not working in PG right now. Uncaught Error: Check dependency list! Synchronous require cannot resolve module 'babylonjs'. This is the first mention of this module! From babylon.gui.min.js.
  15. I'm new to babylonJS, so please forgive if this question is stupid. I'd like to use the playground and import an OBJ from my computer into the scene. I've looked at the documentation, but it seems to indicate I need a special loader. The sample of which does not work on my computer/Chrome or IE browser (i.e. And the other way seems to be to just use playground and use Assetsmanager. But the forums seem to indicate that Assetsmanager is for loading scenes or .babylon file and/or you "simply cant' do that, the OBJ must be on the web") I'm a little unclear on this. It seems a simple request, to be able to load an OBJ into playground and then save it off again as a zip (babylon scene, I assume, or perhaps just a zip of html code). I even saw someone try using loader.addMeshTask("A2", "", "http://localhost:8080/A2/", "a2.obj"); Which apparently works for them, but again, not me (though perhaps one must somehow set up one's computer to act like a localhost? ) Also, the docs seem limited on this...if I'm missing something (other than the Assetsmanager tutorial and page, obj loader page, and link already provided) could someone point me at the docs I need? Much appreciated,
  16. Hello guys, So I have two meshes with physicsImpostor, I want them to ignore each other(no collision, just go through), but still behave normally with other physic objects. How can I do that?
  17. Hey guys, Is it possible to drag-drop sprites? The scene.pickSprite doesn't return a pickedPoint.
  18. Hi guys, I'm having a spot of trouble with my latest practice project - my class 150 DMU simulator. I've got the throttle and brake levers working perfectly, but the horn lever refuses to work at all, despite the code being almost completely identical. Tried everything from resizing to complete code rewriting, even adjusting the order of the code but caught no joy. I also find that when moving the throttle (right) lever, it will often move the horn's "imposter" (hornImp mesh), which is also weird as to my knowledge there should be absolutely no connection between them. I've set up a playground sample which functions the same as it does on my tablet (save for sounds, local textures etc) so if anyone has any ideas on what's going on. The horn lever should remain upright but have two tones when pushed or pulled (currently simulated with the console log). I apologise if the code seems "messy". I'm in the process of changing a lot of the code to simplify it all.....especially making use of the (awesome!!!!!) new Polygon Mesh (whichever legend is responsible for this, I owe you a pint!!!). Darn beginner blues strike again. Cheers chaps.
  19. Hello everyone, After mesh.clone(), cloned mesh mirroring pivot point??? PG After click on each mesh, info in console. Any ideas what I'm doing wrong?
  20. Hello, I noticed some jagged edges on the diagonal lines. Is there any way to get rid of them? I have tried using the ffxa post processing, but it still does not remove them completely. Why do they even occur? It's just a straight line. Sorry if I can't give any more input in this issue, but my knowledge of graphics is limited. Here's a babylonjs playground example. Attached is a screenshot of how it looks in the scene of my project. The diagonal lines don't look very appealing for a production ready project.
  21. Hello, I have a mesh that is clickable and i would like to prevent it being clicked if there is a GUI element in front of it. Playground: In this example i made the GUI clickable as well, but i would like the GUI to stop mesh from being clicked even if there wasn't click function assigned to it. Is this possible? I can almost do this with my own input handler, but it only works like 90% of the time. And it's a bit funky involving global cooldown on clicks. It also requires me assigning an empty click function to the GUI.
  22. hi, The error message does not print on console page if it is triggered right after an asset is loaded, has anyone met the same issue? If I give it a little delay then it shows normally. This also happens when I use assetsManager.addMeshTask.
  23. Hello, With C2D i've used action managers left pick trigger for drag / click stuff and right pick trigger to make context menus, is there a way to enable right click on Babylon GUI elements? I can only find the pointer down / up events. Thanky hanky.
  24. I recently got my hands on an HTC Vive, and I can't even express how excited I am about this technology! Babylon.js works well with the device too. I'm just thrilled! I have run into what I think might be a bug, though. When I load a .babylon file that I exported from Blender and try to hook in a WebVR camera, the controllers don't show up. I can't figure out how to open up an external .babylon file in the Playground, unfortunately, but here's my code: function makeWebVRCamera(scene, position) { var metrics = BABYLON.VRCameraMetrics.GetDefault(); var camera = new BABYLON.WebVRFreeCamera( "deviceOrientationCamera", position, scene, false, // compensate distortion metrics ); window.scrollTo(0, 1); // supposed to autohide scroll bar. return camera; } function startLoop(engine, scene) { engine.runRenderLoop(function(){ scene.render(); }); } function addLight(scene) { var light = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(0, 1, 0), scene); light.intensity = .5; } function createSceneFromBabylonFile(canvas, engine) { BABYLON.SceneLoader.Load("", "babylon.babylon", engine, (newScene) => { var webVRCamera = makeWebVRCamera(newScene, newScene.activeCamera.position); // Wait for textures and shaders to be ready newScene.executeWhenReady(() => { jQuery("#renderCanvas").click(() => { // Now remove the original camera newScene.activeCamera.detachControl(canvas); if (newScene.activeCamera.dispose) { newScene.activeCamera.dispose(); } // Set the new (VR) camera to be active newScene.activeCamera = webVRCamera; // Attach that camera to the canvas. newScene.activeCamera.attachControl(canvas); // This won't work if desktop-based vr like htc vive. So this command also run on play-button click. }); addLight(newScene); startLoop(engine, newScene); }); }); } function createSceneFromScratch(canvas, engine) { window.scrollTo(0, 1); // supposed to autohide scroll bar. var scene = new BABYLON.Scene(engine); var webVRCamera = makeWebVRCamera(scene, new BABYLON.Vector3(1.8756, 3.4648, 8.517)); jQuery("#renderCanvas").click(() => { // Set the new (VR) camera to be active scene.activeCamera = webVRCamera; // Attach that camera to the canvas. scene.activeCamera.attachControl(canvas); // This won't work if desktop-based vr like htc vive. So this command also run on play-button click. }); addLight(scene); var box = BABYLON.Mesh.CreateBox("Box", 4.0, scene); startLoop(engine, scene); } jQuery(document).ready(() => { var canvas = document.getElementById('renderCanvas'); var engine = new BABYLON.Engine(canvas, true); // createSceneFromBabylonFile(canvas, engine); createSceneFromScratch(canvas, engine); }); There are two functions for creating a scene: "createSceneFromBabylonFile" and "createSceneFromScratch". createSceneFromScratch (not commented out in the code above) works great. I can see my scene in the HTC Vive, and the Vive's controllers are also visible. createSceneFromBabylonFile (commented out in the code above) also works well. The 3D scene appears in the Vive correctly. But there are no controllers visible in the scene, even when I'm holding them in my hands. I haven't for the life of me been able to figure out how to make those controllers appear when I load an external .babylon file. (Note: putting newScene.activeCamera.initControllers() after the camera is attached to the canvas was not effective.) Thanks for your help!
  25. I have a texture that's part of the .babylon file which loads and is displayed without any problem. However, when I dynamically change texture, including to the initial one, I get this strange swirly effect on the texture. I've attached an image to show the difference. You can also try it out here Select the "Gilbert" shirt and you'll see the difference. Does anyone know how to stop this effect? (I tried to attach an image but I keep getting "There was a problem processing the uploaded file" so if you want to see the problem you'll have to go to the URL above.)