• Content count

  • Joined

  • Last visited

About xtreemze

  • Rank

Contact Methods

  • Twitter

Profile Information

  • Gender
  • Location

Recent Profile Visitors

242 profile views
  1. xtreemze


    This is playable now with proper win and loss states. Enjoy! Play here: https://xtreemze.github.io/defend
  2. Thanks Davrous for taking such a deep look into this. Since it's not feasible I'll mark this as solved as I just wanted to see if it was easily done with the current APIs.
  3. Interesting that there are other possibilities to pass into the BABYLON.Sound constructor. But in this case, if I'm not mistaken, the buffer would not be real-time sound, as it would somehow be buffered/pre-rendered. My intention is to use variables that constantly change per frame to affect specific parameters of the synthesizers so recorded sound would not be an ideal solution. Nonetheless, there would be about 20ms of delay to play with so the sound might still be perceived as immediate. Thanks Davrous! I appreciate you taking the time to have a look.
  4. xtreemze


    Thanks, I solved it by delaying the firing of the projectile to give the lookAt function some time to complete. Don't think it's anything wrong with the engine, just too many position queries on the meshes on every frame to measure distances and acquire the nearest target. The delay is not noticeable. Updated: now with generated sound thanks to the WASFX library by @fenomas
  5. xtreemze

    How to dispose a Ray

    Once a ray is created, is it possible to dispose/delete the Ray so it can be cleared by JavaScript garbage collection? For instance, what happens to the Rays that are using a disposed mesh as an origin?
  6. My question is in reference to audio tied to a mesh, so volume and panning are handled by the BABYLON engine. This works great for wav and mp3 audio files but lately I've wanted to use generators like tone.js to generate tones with javascript. It seems that BABYLON audio requires a URL to insert audio into the audio chain but is there any way to use the audio engine in BABYLON with tones generated with tone.js and the web audio API without rendering them to wav or mp3?
  7. xtreemze


    Hi everyone, Been away for a while but I've kept practicing with Babylon. This is at a prototype phase with no 3d/sound/artwork. Just pure javascript code for now. Trying to get the mechanics working properly first. One question I have is how the projectile rotationQuaternion is cloned. It seems to follow the lookAt() quaternion from the origin tower even after the quaternion is cloned. How can I ensure that the rotationQuaternion is not linked to the original quaternion it is taken from? This causes problems when a tower shoots a projectile and then rotates to target another enemy. The previously mentioned projectile rotates in midair still copying the rotation of the tower. Here's the relevant code taken from line 53 of https://github.com/xtreemze/defend/blob/master/src/js/main/projectiles.ts const clonedRotation = originMesh.rotationQuaternion.clone(); clonedRotation.normalize(); projectile.rotationQuaternion.copyFrom(clonedRotation); Comments, questions are welcome! The project is hosted here with open source: https://github.com/xtreemze/defend View the project here: https://xtreemze.github.io/defend
  8. xtreemze

    setLinearVelocity on LOCAL Space?

    I updated the game and used this code in case anyone is wondering how the code turned out. window.up = 130; window.forward = 93; const moveCube = function moveCube() { redMesh.lookAt(camera.position); const direction = camera.position.subtract(redMesh.position); direction.normalize(); // Speed control const result = direction.scale(window.forward); // Jump result.y = window.up; const bottomForce = redMesh.position.subtract(new BABYLON .Vector3(0, 2, 0)); redCube.applyImpulse(result, bottomForce); }; window.setInterval(moveCube, 2000);
  9. xtreemze

    setLinearVelocity on LOCAL Space?

    Thanks for checking out my game/prototype @Wingnut! I didn't realize it but those cubes do seem like frogs jumping That's a yuge PG you got there! Quaternions are next on my ToDo list so this should be useful for some future projects I'd like to work on once I get the hang of the basics. Thanks for sharing! By the way, I also made a taxi game as one of my first javascript/HTML5 endeavours https://xtreemze.github.io/TAXi/
  10. xtreemze

    setLinearVelocity on LOCAL Space?

    Thanks @Deltakosh Had to play around with it a bit but I think this is what you were suggesting and it works!: https://www.babylonjs-playground.com/indexstable#UXU2E9 I'm just now learning to calculate two vectors together... I'll apply it to the game soon once I get the force to hit the cube a bit lower than the central position so the cube doesn't fall on it's forward face when it jumps.
  11. xtreemze

    setLinearVelocity on LOCAL Space?

    Thanks for the quick reply @Deltakosh! I really like the Babylonjs engine you've helped to make and I'm using this little game as a prototype to learn more about it. I will try to use impulse instead but I'm confused with what vectors to use as arguments because the forward face of the camera is irrelevant in this case because the red cube (redMesh) should approach the camera at all times even if the camera is looking away. The game already does this, but I'd like to use physics instead of using locallyTranslate(). It would be more helpful to acquire the forward facing vector of the "enemy" red cube and then apply the force onto that cube so the position of the cube approaches the camera with each jump. getForwardRay() is useful for shooting the projectiles, however. But it seems I can't use it for the enemy cube because getForwardRay() seems available to the camera and not the abstract mesh. To rephrase my question and follow your suggestion to use impulse: How can I pass the local forward facing vector of the redMesh cube to an impulse that would apply a force of 2 along the axis facing the camera global position?
  12. xtreemze

    setLinearVelocity on LOCAL Space?

    I added this line to illustrate what I want to do, but I would like to use physics instead of position translations. redMesh.locallyTranslate(new BABYLON.Vector3(0, 0, -4));
  13. Hello Everyone, I've been trying to go at this on my own but I've been stuck for days trying to add some basic AI to a cube. Play the FPS style game here on desktop or mobile: https://xtreemze.github.io/Ballistic you can find the full JavaScript here: https://github.com/xtreemze/Ballistic/blob/master/js/master.js Controls: touch the cube button on the bottom to shoot ice cubes and use standard universal camera controls to move and look around. Here's where I'm stuck: I got window.cube to jump and look at the camera but now I need a force to push the window.cube to move towards window.camera. I just can't figure out how to setLinearVelocity in the local forward direction of window.cube. redMesh is the Mesh of window.cube and redCube is the impostor of redMesh. (Also would be nice if the lookAt() rotation was eased or slowed down so it wouldn't seem so sudden but that's a lower priority.) Here's the part of the code that controls the cube AI and thanks in advance for taking a shot at this! // Global Scope Declarations for Console Tests window.button = button; window.cube = redCube; window.cubeMesh = redMesh; window.camera = camera; // Red Cube turns to look at camera const rotateCube = function rotateCube() { redMesh.lookAt(camera.position); }; // Cube Movement towards Camera ??? const jump = new BABYLON.Vector3(0, 5, 0); const front = new BABYLON.Vector3(0, -10, 0); const goForward = redMesh.getDirection(front); const moveCube = function moveCube() { redCube.setLinearVelocity(jump); rotateCube(); // redCube.setLinearVelocity(goForward); }; window.setInterval(moveCube, 2000);
  14. Had this exact same issue but simply added the dash character as @gryff suggested. My action name went from SuzanneAction to Suzanne-Action and then it worked as expected! Thanks @gryff! Previously I would have to go in and check the exported babylon file and see exactly what keyframes were used. The exporter aparently adds extra frames to the end of the current timeline. In this example I used the default 120 frames in blender. If I did not do this, then both meshes would use the entire combined timeline for the actions. With @gryff's suggestion, I can easily delete these lines from my code and just check the Auto Launch Animations inside Babylon Exporter options within Blender. const suzanne = scene.getMeshByID('Suzanne'); scene.beginAnimation(suzanne, 131, 250, true); const iceberg = scene.getMeshByID('iceberg'); scene.beginAnimation(iceberg, 1, 120, true);