• Content count

  • Joined

  • Last visited

  1. Animation and Spatial Audio

    Thanks for the information @davrous - my reasons for needing such behaviour are quite specific to my project and probably not likely to be needed elsewhere, but to answer your question I wanted to have a visual representation in my scene of audio playing at a particular location. To do this I'm simply updating the Y scale of a mesh in time to one of the frequency channels, but since the analyser only works when the audio can be heard this means that from afar my mesh does nothing and the effect is lost. It's not vitally important though. I'm still interested in understanding what updates to the Arc camera you were planning on making to the spatial audio set up (added to the roadmap here I feel like I might be missing out on an important update for the spatial audio to work exactly as intended with my use case, but it's equally possible you had some other updates to make that won't make a huge difference to me. If they are significant and important updates would it be possible to expedite and release the work quickly? Cheers
  2. Animation and Spatial Audio

    Any chance of a follow up on this stuff @davrous? Cheers
  3. Someone can probably confirm this but as I understand it, you can check the imported mesh's animations array property. If it's null or length==0, you don't have an animation. Something like: if( MESH_NAME.animations && MESH_NAME.animations.length > 0 ) // you've got an animation
  4. Animation and Spatial Audio

    On a seperate note but still related to spatial audio, i've just noticed that using the audio analyser with spatial audio only works if the audio can be heard. So for example if the spatial audio is at a distance that means audio can not be heard, then the soundtrack to which the sound is attached will not create any data for the analyser to use. Is there something going on under the hood with spatial audio whereby maybe audio.pause is being called when out of range, to save on resources perhaps?
  5. Animation and Spatial Audio

    Indeed you are correct that does work well, but if you recall the original purpose of this thread was to discuss spatial audio in the context of an arc camera attached to a mesh and the mesh then animated. You seemed to acknowledge that using spatial audio in this way would require changes to the arc camera and added it to your 3.3 milestone. I then made a change in the code at my side, but I'm not sure whether this is the change you have added to your 3.3 milestone or if you intended to do something more, and that's really what I'm following up here. With regards to my observations of my scene it could simply be my crappy ears not hearing things properly, but I just wanted to be sure the custom implementation I have now is in fact what you intend to add later (i.e. I'm not missing something).
  6. Animation and Spatial Audio

    Is there any way I can get the arc camera spatial audio update added sooner rather than later? Just noticed the 3.3 timeline is up until september 2018, which is well beyond my needs. @Deltakosh when you said earlier that support for the arc rotate camera was needed, what exactly is it missing at the moment? Like I mentioned in a subsequent comment I can hear the audio kicking in while using my arc camera. I have reservations about whether the audio is playing correctly, in the sense that it starts when it should and increases in volume as it approaches the source, and that the range of the audio is accurate. I'm sure I've heard other audio playing at the same time that shouldn't be within earshot, and i'm not at all convinced the sound starts, stops and the volume adjusts as it should. Are these the issues you're thinking of? Cheers
  7. Animation and Spatial Audio

    So by your example, max distance would equal the radius of the spheres in your scene I.e. half the sphere diameter? If I had a cube of height,width,depth = 5 each would max distance then be 2.5 if we assume the sound is attached to the mesh (does attaching to a mesh centre the sound in the mesh?)
  8. Animation and Spatial Audio

    An additional question: When we create spatial audio we define as such: new BABYLON.Sound("Music", "sounds/sound.wav", scene, null, { loop: true, autoplay: true, spatialSound:true, maxDistance:1.5, volume:0.3 }); The docs say the value of maxDistance - 1.5 here - is also in units. How does this distance value relate to e.g. diameter of a sphere of 5, what would the maxDistance value need to be to ensure the audio starts to play the moment the edge of the sphere is encountered?
  9. Animation and Spatial Audio

    By the way, maybe I'm missing something here but as I mentioned in my first post spatial audio appeared to work fine (at least, with my limited tests) using the ArcRotateCamera so long as one moves the camera manually. It's only when the camera is parented and then the parent animated that the spatial audio has issues. If the issue is that this setup would work fine with any other camera then fine, I just wanted to be absolutely clear here. p.s. do you need my home address for the contributor patches @Wingnutmentioned?
  10. Animation and Spatial Audio

    Thanks guys. So I've made the following change in my Babylon.max.js code (from line 4066 in your source code linked above): var matrix = listeningCamera.getWorldMatrix(); var world_position = BABYLON.Vector3.TransformCoordinates(listeningCamera.position, matrix); audioEngine.audioContext.listener.setPosition(world_position.x, world_position.y, world_position.z); and it seems to work fine, but can you see any issues with this patch? I'm wondering what the cost of calculating the world matrix and then transforming the camera's position using this matrix will be on the rendering pipeline. I need my scene to run smooth on all devices including mobile so if this is likely to cause a performance hit I'll have to think of a different approach.
  11. Custom controls based on grid

    For the first link I was referring to the specific comment I've linked to, where DK says "However for future reference, as DK mentioned - I always use a parent node to provide the coordinate system by which objects are animated.". I throwing ideas at you hoping something will stick As for the second post, I don't know, but you could try and let us know the results.
  12. Does anyone know if there's a reason why spatial audio doesn't work when animating a camera towards a mesh that has an audio source either attached or placed in the same position? My project has an Arc Camera parented to a mesh, which is then animated around a scene. I've set up end points where the camera parent will animate to, with the idea being as soon as it approaches the centre of the target position the spatial audio will kick in. However, in practice this doesn't appear to ever happen and in fact the only way I seem able to get it to work at all is if I manually zoom or move the arc camera past these audio zones. Any thoughts anyone?
  13. Custom controls based on grid

    Oh you wanted locale movement? Sorry, I didn't read the full thread closely enough. Maybe this will help ? p.s. check this out if you need to convert from world to local
  14. Custom controls based on grid

    For simple movement try adding this code: BABYLON.AbstractMesh.prototype.moveTo = function (targetPos, fps, frames, done) { var ease = new BABYLON.QuadraticEase(); ease.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT); this.activeAnimation = BABYLON.Animation.CreateAndStartAnimation('at5', this, 'position', fps, frames, this.position, targetPos, 0, ease, done); }; This will attach a moveTo method to every mesh in your scene, and then you can simply call the function like so: myMesh.moveTo(new BABYLON.Vector3(x,y,z),24,96,function(){ console.log("Movement complete!"); }); You can extend the function to accept the easing type in the method call if you intend to have different ease effects according to situation. For rotation you may wish to look in to Quaternions, as they in general provide much smoother and more reliable results. The following is an example implementation for slerping between two quaternions, however there are probably other methods you can use for this. // set up the initial Quaternion on your mesh, as they are not created automatically myMesh.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll( myMesh.rotation.y, myMesh.rotation.x, myMesh.rotation.z ); // add an "indicator" mesh to your main mesh. This will be used to look at the target location, and the different between its quaternion and your mesh's quaternion then slerped to match var indicatorMesh=BABYLON.Mesh.CreateBox("meshIndicator", 0.1, scene); // add quaternion for this new mesh too indicatorMesh.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll( indicatorMesh.rotation.y, indicatorMesh.rotation.x, indicatorMesh.rotation.z ); // parent the indicator mesh to your main mesh indicatorMesh.parent = myMesh; // now, in a registerAfterRender function (called automatically), adjust the two quaternions. change the world/local space to suit. targetPosition it the Vector3 you want to look at scene.registerAfterRender(function () { if(myMesh.isRotating=true){ // make the indicator mesh look to the target position. This will update its quaternion. indicatorMesh.lookAt(targetPosition,0,0,0,BABYLON.Space.WORLD); // now get an integer value representing the difference between the main mesh quaternion value and the indicator mesh's quaternion value. var diff = myMesh.rotationQuaternion.subtract(indicatorMesh.rotationQuaternion).length(); // registerAfterRender fires after ever frame render, so here we can check the difference between the two quaternions and decide to do something once we meet a certain threshold. if(diff > 0.05){ // if we are still above the threshold, adjust the mesh quaternion a little. You can adjust the amount to suit. The higher the number the quicker the rotation and the faster the rotation will pass the threshold. We use Slerp here because this will spherically interpolate a value in directional vectors myMesh.rotationQuaternion = BABYLON.Quaternion.Slerp( myMesh.rotationQuaternion, indicatorMesh.rotationQuaternion, 0.035 ); else { // set the rotating flag to false to stop this loop for firing again myMesh.isRotating=false; // optionally call a function to continue processing done && done(); } } }); // somewhere in your code, start the process away targetObject=new BABYLON.Vector3(x,y,z); myMesh.isRotating=true; var done = function(){ console.log("done rotating"); };
  15. Chrome iOS

    Absolutely, in fact one of the reasons I chose Babylon for this client project over say Threes or PlayCanvas was the existence of this extremely valuable forum. As a seasoned developer I put a very high value on publicly available resources to turn to when the going gets tough, and even after developing for about 20 years I can comfortably say the coin gets tough in nearly ever project I'm involved with (that probably says a lot more about me than I intended!). Thanks again, I'll be sure to update this thread further if all this back-patting turns out to be premature heh!