Leaderboard


Popular Content

Showing content with the highest reputation since 12/03/2018 in all areas

  1. 8 points
    trevordev

    AmmoJS support

    Hey, AmmoJS physics plugin has been added to Babylon preview. It should work well with composite meshes which we've had trouble with in the past with other engines. Let me know if you find any issues or have any feedback. Note: Support for motors, soft bodies, other ammo specific features are not yet supported so yell if you need anything specific for your project. vid.mp4 Examples: Basic impostors: https://playground.babylonjs.com/#7149G4#31 Loading mesh and colliders from file: https://playground.babylonjs.com/#66PS52 Loading and adding colliders manually in Babylon: https://playground.babylonjs.com/#FD65RR Loading and adding collider with joints and pointer interactions: https://playground.babylonjs.com/#DGEP8N WebVR grabbing and throwing: https://playground.babylonjs.com/#ZNX043#1 Docs: https://doc.babylonjs.com/how_to/using_the_physics_engine
  2. 5 points
    NasimiAsl

    Shared transparency

    hi https://www.babylonjs-playground.com/#1TYWYB#188 you can use 2 renderTarget for make that 1. for render transparent area inside of black Area https://www.babylonjs-playground.com/#1TYWYB#186 2. render nan transparent meshes https://www.babylonjs-playground.com/#1TYWYB#187 then mix that with postprocess
  3. 4 points
    Deltakosh

    Scissor Rects

    Here we are: https://playground.babylonjs.com/#JJYFI8#1
  4. 3 points
    Wingnut

    Please Help with this...

    Hi @i_tejas19, welcome to the forum. Congrats on successful BJS scene/animations! Pop-up mouse-over labels, eh? Here, check this out... https://www.babylonjs-playground.com/#XCPP9Y#447 That playground teaches BabylonJS GUI labels... AND BJS ActionManager onPointerOverTrigger. Keep in mind that an entire PANEL of information... can pop-up, with clickable stuff on that panel. WOW! I found that playground... using a playground search. I happen to know that MOST GUI demos have the term "advancedTexture" in them... from experience. I often re-name my GUI demo vars to 'adt' - short for advancedDynamicTexture. AdvancedDynamicTexture is a basis for BabylonJS GUI "stuff"... sort of like a sheet of glass that can be put atop a mesh, or across entire screen. Then we paint GUI "controls" onto that glass. That playground will get you started. Both BJS GUI and BJS ActionManagers... are very powerful and versatile. Take the time to read/experiment. Look at the demos/playgrounds in the docs... they inspire more ideas. Soon you will be expert. Ask more, if needed. Make a playground to show us stuff, if you wish. We'll be here. If solved, mark this thread solved, please.
  5. 3 points
    timetocode

    Degrading sound

    Now that I have this reproduced, I think I'm realizing that this idea was never going to work due to the number of sounds. I did a little bit more testing with a 500 KB wav file vs a 15 KB mp3, and the degradation seems more related to the number of sounds than their size. In my game each weapon has like 5-20 sounds, and a player can hold a few weapons. The walk/run cycle has like 16 sounds per material (concrete, wood, grass, etc). It can add up to about ~100 possible sounds per player, though 99% of them aren't playing at any given point. BJS seems totally fine with that many sounds, but it looks like attachToMesh is not designed for this. I read the source code, and it looks like it *might* be viable if it would check if the sound is playing before rebuilding the matrices. Currently it does some fairly expensive work, even for non-playing sounds (setPosition and computeWorldMatrix fill the profiler when stress tested with cloned sounds on moving meshes). I'm going to test positioning the sounds manually at the time that they are played, and not having them move along with the mesh. If that doesn't work I guess I'll pool them in addition. Edit: definitely need a pool Edit#2 at 21 players firing the same automatic rifle, the pool brought the active number of sound instances from 210 down to 59 Here's an ultra simple auto-expanding pool if anyone wants. Usage is just to use 'get' for short-lived sounds and it will handle allocation and releasing on its own. It never deallocs. class SoundPool { constructor() { this.scene = null this.sounds = {} } init(scene) { this.scene = scene } allocate(name) { const sound = BABYLON.Sound.FromAtlas(name, name, this.scene) sound.onEndedObservable.add(() => { this.release(sound) }) this.sounds[name].push(sound) } get(name) { if (!this.sounds[name]) { this.sounds[name] = [] } if (this.sounds[name].length === 0) { this.allocate(name) } return this.sounds[name].pop() } release(obj) { this.sounds[obj.name].push(obj) } } const singleton = new SoundPool() module.exports = singleton BABYLON.Sound.FromAtlas is a little wrapper that clones sounds without making additional xhrs (e.g. 'sounds/foo.mp3', clones it and applies new options)
  6. 3 points
    JohnK

    Wikipedia

    Back up and running again. Hope everything legit this time!
  7. 2 points
    You need to add a reference to the material library: https://github.com/BabylonJS/Babylon.js/tree/master/materialsLibrary
  8. 2 points
    samme

    Cant get group to work

    You have to avoid the Phaser 2 examples, they won't work and will confuse you. https://medium.com/@michaelwesthadley/modular-game-worlds-in-phaser-3-tilemaps-1-958fc7e6bbd6 etc. will be better help. var monsters = this.physics.add.group(); monsters.addMultiple(map.createFromObjects( 'Monsters', 'blob', { key: 'monster' }, )); monsters.getChildren().forEach(function (enemy) { // You need to use the `body` methods because these are Sprites (not ArcadeSprites) enemy.body.setBounceX(1); enemy.body.setCollideWorldBounds(true); enemy.body.velocity.x = 40; }, this);
  9. 2 points
    I've just finished the morphing demo that I've been working on. Thanks everyone for your input! (especially @NasimiAsl who is the grandmaster of shaders) What I'm trying to demonstrate here is morphing not just vertices, but textures as well. I got this idea from Wrap3 which has this feature. This is important with faces because redness and wrinkles will sometimes appear when you tense your face. Unfortunately there is no built-in feature to do this but we were able to pull it off with some extra shader code. I would've loved to add some specularity to the skin but I couldn't figure out how to do that with the custom material. I know this is extreme detail but its a good test. If the player is in the distance then it wouldn't be necessary. I added a "Powered by Babylon.js" sticker so everyone knows that Babylon.js can do cooler stuff than Three.js hehe Feel free to use the source code. http://punkoffice.com/facial
  10. 2 points
    I think this is an awesome question, and it the sort of thing everybody runs in to: "How to structure your application to make coding up your logic as easy as possible.". First up, there is 0 wrong with what you're doing. You've already split your code base up in to logical chunks: something handles bullets, something else handles collisions etc etc. That's great. Think how you could further split things up so that, ideally, you make changes in a minimum amount of places. Actually, with just a couple of places to change how different types of bullets (and any modifiers applied to them) are handled, you're doing pretty well already. There are many many different ways you could attempt to solve this problem. Personally, I reckon I'd start thinking more about the data structures I'm passing around and what each different aspect of my system needs to run. You could start structuring your data to be more descriptive about the types of things. Maybe a bullet entity could contain all the variables that your bullet handling and collision code needs to work such as the texture that should be set and the colour or type of any particle emitter that gets generated? Maybe there should be a variable that declares the speed? This way you just pass this structured object into your functions and they don't care on the specifics of what type they are, they infer what to do based on the properties of that object i.e. rather than those functions knowing that a 'flame bullet' travels at 120 and a 'exploding bullet' travels at 100, it just takes a bullet object that has a speed and uses that to set velocity. Then, when you apply a 'power-up', whatever function that applies the power-up could either add the modifiers or manually change the bullet properties. i.e. var flameBullet = { speed: 120 } var speedPowerUp = { modifier: 20 } function applyPowerUp (bullet, powerup) { return { ...bullet, speed: bullet.speed + powerup.modifier } } I've used object-spread there, that's fairly new to JS, all it does it create a copy of `bullet` but then applies a new `speed` property, which takes precedence over what was previously defined in the bullet passed in. There is no need to do it like this, maybe you just store the modifier and calculate the speed later. There's no one single right answer. Evaluate which method best suits your needs, both of your system and you (or the team) as a programmer. There's also no need to use a separate function like this, maybe you like classical coding (using classes, careful with these in JS) and you want that function to live on the powerup or bullet objects, that's absolutely fine as a solution. It sounds like you have divided and structured your code and logic, it also sounds like maybe you just need to do this for the data that logic operates on and you'll be most of the way there to a solution that fits you.
  11. 2 points
    B3L7

    Cant get group to work

    First, that amphibian tutorial is great but it's for Phaser 2 not 3 so it may be causing some issues there. Second, we will need some more info. When you say fail do you mean you get an error, or does nothing happen? Do you see the monster sprites on the screen? Right off the bat it looks like the parameters in your createFromObjects call may be wrong. I think you are using the Phaser 2 example which won't work. See the Phaser 3 examples and docs: https://labs.phaser.io/edit.html?src=src\game objects\tilemap\static\create from objects.js https://photonstorm.github.io/phaser3-docs/Phaser.Tilemaps.Tilemap.html#createFromObjects__anchor Also, it doesn't look like your repo is public.
  12. 2 points
    Limes2018

    How to save & import project?

    @Luaacro Thanks! I added another blog post about BJS editor. BJS itself is not so popular in Japan. I'll share the good points step by step. I'll waiting for your updated documentation! https://www.crossroad-tech.com/entry/Babylonjs_Editor_ParticleSystems
  13. 2 points
    Telinc1

    Tilemap objects

    Object layers simply hold geometric data which Phaser rarely uses directly. It's up to you how you treat that data - if you loop through the object layer, you can choose how to interpret each shape and whether you want to use its size at all. Unless you're setting a Sprite's size to the size of the tilemap object, it doesn't really matter how big it is. Anyhow, you can definitely resize objects in Tiled. Click on the object and you should get control points around it which you can use to resize it. Alternatively, you can directly enter a size in the object's properties. To answer your other question, moving the enemies wouldn't be a problem at all. Use the object data from the tilemap to add them as Sprites and you will be able to move them like any other Sprite.
  14. 2 points
    prob

    Scratching Effect(mask)

    This may be a better way, if it's what you're looking for:
  15. 2 points
    Zuzuk

    Count LOD distance from camera target

    Thanks a lot! Everything works perfect
  16. 2 points
    Hi, Wingnut! So nice of you! Your PG inspired me. You use animation to your box in PG. So i think it will be possible to use animation in my camera. I find a topic about ArcRotateCamera animation, it's very useful. As to the problem of smallest angle to rotate, we can determine whether the rotation angle larger that PI(L105-125). Then i use the function in ExecuteCodeAction and it works. Here is my new Playground. may be it will help somebody. And I think that camera.lockedTarget act incorrectly. It acts like camera.setTarget but not "locked to" mesh.
  17. 2 points
    When you're more comfortable with Phaser, you can also consider moving your panels to a separate Scene. That would allow you to keep the UI's display list and logic separate from your gameplay, which may end up being easier to work with. For now, however, I'd go with Olf's solution of using `setScrollFactor`.
  18. 2 points
    Based on the `physics.world.enableBody` in the code, it looks like you're using Arcade Physics. If that's the case, keep in mind that Arcade Physics only support collision between axis-aligned bounding boxes (AABBs) and circles, i.e. you can't rotate bodies. If you need rotation, look into a more complicated physics engine such as Matter.js (it's available out-of-the-box). Phaser also supports Impact Physics, but I've never used them and I don't know if they support rotation. You could also combine a library like SAT.js with Arcade's collision handlers to pull this off, but it's likely a lot more complicated than switching physics engines, especially if you're early in development.
  19. 2 points
    Wingnut

    3D Text library

    And maybe, check out the demo-filled forum thread about meshWriter, too. http://www.html5gamedevs.com/topic/37487-text-as-polygon-mesh/ Actually, stay on PAGES 3/4 of that forum thread. Less broken playgrounds. (usually broken due-to stale URL to meshWriter lib) I like this one. https://www.babylonjs-playground.com/#XWVXN9#63 ...and this physics-ish one... https://playground.babylonjs.com/#1KPF49#54 (might need extra click on RUN) (also, joint between "o" and "n" not working) [Wingnut gives a little wink to @The Leftover, a swell guy and the author of meshWriter]
  20. 2 points
    Deltakosh

    Deltakosh out for 2 weeks

    I'm back
  21. 2 points
    Game Objects can be fixed to a camera with ".setScrollFactor(0)" : Phaser 3 example
  22. 2 points
    sable

    Custom zooming

    The reason it was quite slow is that spheres have a lot of faces, and the pick function has to iterate over each one to find the picked point. The fastPick version doesn't behave in the same way as the original, as it generally is just stopping at the ground/wall intersection, so is not putting the mouse sphere on the SPS. You can implement your own picking for the sps, and do ray sphere tests, https://www.babylonjs-playground.com/debug.html#8PY6X5#18, which is much, much, faster. If the particles aren't spheres, then you could do the above using spheres as bounding spheres, and then get the actual picked point from an intersection test with just the closest particle. I'm not sure the zooming in is quite working as intended, as if you move the mouse once already zoomed in, and then zoom out or in, the sps jumps to a new position. Probably need to do some sort of correction given the current pivot point.
  23. 2 points
    Hello everyone, BlockTanks is a simple and explosive multiplayer tank game. Join other players in a fast-paced and destructive team deathmatch. Collect weapons and defeat the enemy team using strategy, cooperation, or good old-fashioned brute force. Play the game at blocktanks.net Features: Lobby with multiple maps and matches. Power ups like rockets, bombs, and flashbangs. An account system so you can track your stats and level up. Unlockable items such as stickers and decals. Made with Phaser and NodeJS, and hosted on AWS Lightsail.
  24. 2 points
    freeeve

    Problems with Keyboard events.

    I figured it out. It was the evernote web clipper chrome plugin messing with keyboard input. I realized it might be a chrome issue when I tested in firefox and it worked fine. (someone else posted a similar issue here)...
  25. 1 point
    Hi! always nice to have fresh users on their quest for the next webgl game :-) There are two ways to use collisions and physics in babylon. It has a native collision system, that supports gravity on free cameras only. It also supports mesh-to-mesh collision when you wish to avoid meshes "merging" into one another. As Temechon said, the moveWithCollisions function of any mesh will move it in a specific direction until it collides with a different mesh. you can see a gravity simulation in this playground - http://playground.babylonjs.com/#NVWUF . What I am doing is simply applying the scene'S gravity constantly to the box on each frame. But this is not the way the collision detection system was meant to be used. It is actually more for the camera and less for meshes. To prevent from going through walls and such. To allow meshes physically colliding with one another using mass and friction and other fun things, you will need one of the two physics engines Babylon supports. Here is almost the same playground with Oimo physics turned on - http://playground.babylonjs.com/#NVWUF#1 Try understanding what'S happening here. I think I will soon write an updated tutorial about the collisions system and physics On a side note - I am not sure why we can't add the gravity support to the meshes, let me have a look :-). Maybe 2.2 will include moving meshes with gravity as well.