Jump to content


  • Posts

  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Snouto's Achievements


Newbie (1/14)



  1. Ding ding ding ding we have a winner! That fixed the problem immediately. That's both super satisfying and incredible perplexing and frustrating at the same time. Just when you think you're getting a handle on BJS something like this occupies half your day! Well I appreciate your help there @brianzinn you managed to solve two big issues for me and now the animation works as planned. Cheers!
  2. Thanks dude, that easing code is exactly what I was looking for. And now that I've seen it I realise I've used it before in one of my other hundred test scripts ? Following on from my test code I've been searching around more and found an article on pivot points. My code now looks like this: var onMeshPicked = function(bjsEvent) { myPickedMesh = bjsEvent.source; if(!myPickedMesh.isPickable) return; var frames = 90; // number of points if( parent===null ){ parent = myPickedMesh.parent; var CoR_At = new BABYLON.Vector3(0, parent.position.y, 0); var axis = BABYLON.Vector3.Up(); var pilotStart = new BABYLON.Vector3(parent.position.x,parent.position.y,parent.position.z); pivot = new BABYLON.TransformNode("root"); pivot.position = CoR_At; parent.parent = pivot; parent.position.y = 1.7657999992370605; var angle = 0.01; parent.yRot = new BABYLON.Animation("yRot", "rotation.y", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); var keyFramesR = []; keyFramesR.push({ frame: 0, value: 0 }); keyFramesR.push({ frame: 2 * frames, value: 2 * Math.PI }); parent.yRot.setKeys(keyFramesR); var easingFunction = new BABYLON.QuarticEase(); easingFunction.setEasingMode(BABYLON.EasingFunction.EASINGMODE_EASEINOUT); parent.yRot.setEasingFunction(easingFunction); } scene.beginDirectAnimation(pivot, [parent.yRot], 0, 2*frames, false); } That line: parent.position.y = 1.7657999992370605; is my wacky attempt to adjust the position of the mesh once it is parented to the pivot, because as soon as that happens the mesh position changes. It may well be due to the parent mesh being over sized in the blender model due to wanting to avoid recalculating the baked animation (which was done before being parented), but I've struggled to figure out what that Y figure should be since there doesn't appear to be an obvious correlation to the new position that I can see.
  3. Alright errybody This is a question more about maths than anything else, and i'm terrible at maths so I'm hoping someone (maybe @Wingnut) can help me here. My scene is loaded from a blender export, which in itself is partially an imported FBX from C4D (still waiting on that C4D exporter boys!). I have a mesh within the scene that has a set position, and I want to allow it to orbit in a circle when clicked or tapped by the user. Fundamentally this is fine and I have most of the logic in place, but I'm struggling to figure out how to make it animate from it's initial position. All of the example code I've seen make the object jump to a calculated first position and then animate, which is not what I want. Has anyone got some sweet ninja code that I can borrow steal that will do what I need? Additionally is there a convenient technique or built in method to add easing to the beginAnimation call, or to the calculated keyframes? Cheers! Here's my current code: var onMeshPicked = function(bjsEvent) { myPickedMesh = bjsEvent.source; var frames = 90; // number of points var parent = myPickedMesh.parent; parent.indexPoint = 0; var p=0; var points = []; var radius = 2; for (var i = 0; i < frames; i++) { // calculate the keyframes points.push( new BABYLON.Vector3((radius + Math.sin(i*Math.PI/frames))* Math.cos(2*i*Math.PI/frames), parent.position.y, ( radius + Math.sin(i*Math.PI/frames)) * Math.sin(2*i*Math.PI/frames))); } parent.points=points; var path3d = new BABYLON.Path3D(points); var tangents = path3d.getTangents(); //array of tangents to the curve var normals = path3d.getNormals(); //array of normals to the curve var binormals = path3d.getBinormals(); //array of binormals to curve parent.animationPosition = new BABYLON.Animation("animPos", "position", 30, BABYLON.Animation.ANIMATIONTYPE_VECTOR3, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); parent.animationRotation = new BABYLON.Animation("animRot", "rotationQuaternion", 30, BABYLON.Animation.ANIMATIONTYPE_QUATERNION, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); var keysPosition = []; var keysRotation = []; for(i = 0,p=frames; i < p; i++) { keysPosition.push({ frame: i, value: parent.points[i] }); keysRotation.push({ frame: i, value: BABYLON.Quaternion.RotationQuaternionFromAxis(normals[i], binormals[i], tangents[i]) }); } parent.animationPosition.setKeys(keysPosition); parent.animationRotation.setKeys(keysRotation); scene.beginDirectAnimation(parent, [parent.animationPosition,parent.animationRotation], 0, frames, false, 0.25,null); };
  4. Thanks for the information chaps, very helpful ??
  5. Sigh....I hate myself sometimes. Tried a bunch of angles except god-damn 0. Okay so that works on a couple of the meshes in my scene that need it. Here's the thing though, whereas before it was super convenient to be able to apply the flat mesh across the whole scene it seems now I have to choose individual meshes and set the EdgeSplit manually. If i was only doing this one time that would probably be fine but in my case I am receiving regular updates to the FBX model I'm importing and so every time I import a new FBX I'm going to have to manually go through every mesh and set the EdgeSplit again. This is less than optimal, plus I'm really lazy. Since there is also the script option I mentioned earlier, if I were to simply use Mesh.convertToFlatShadedMesh only and skip setting EdgeSplits across dozens of meshes in Blender, am I going to experience a significant performance or quality drop/difference in the browser? I can accept a bit of a performance drop right at the start as my code iterates each mesh and fires that JS command, but is there any knock-on effect to my scene after that process completes? Just asking so I understand my options. Cheers JCP. [edit] Another option springs to mind, and that is to use a simple python script within Blender to auto add an EdgeSplit modifier to all meshes: import bpy for obj in bpy.data.objects: if obj.type == "MESH": edgeSplit = obj.modifiers.new("EdgeSplit", type = "EDGE_SPLIT") edgeSplit.split_angle = 0 bpy.context.scene.update() I'd still like to reduce the amount of steps I need to take every time an FBX is imported so would appreciate some further information as asked above. Cheers
  6. Yo 3D dudes and dudettes I've just updated the Blender exporter and BJS to the latest versions as I was using some fairly old code. One of the first things I noticed was that my .babylon file has gone from 2.1mb down to 600kb, which is awesome, so bravo to you guys for that excellent piece of optimisation. I also noticed through first observing and then from looking about the internets that the export option to make everything Flat has vanished. I confirmed this from a post by @JCPalmer here For my project I still wish to maintain that flat look, so I understand one way to do this is via BJS code using Mesh.convertToFlatShadedMesh() I just wanted to ask if this is indeed the correct approach to reproduce the flat shading appearance from Blender? It does work for me (albeit I have to ensure the meshes I'm iterating through after load support mesh.subMeshes, otherwise a JS error is thrown) but I'm not sure this is the most optimal way. I did try adjusting the angle of the split edged modifier in Blender but that didn't appear to make the slightest bit of difference once I exported to BJS. If I stick with convertToFlatShadedMesh() when loading my scenes and objects am I incurring an additional performance hit over the old exporter approach of "Flat shade entire scene", or are these two things essentially the same outcome just with the processing occurring in different places? If the latter, how might I take care of that processing at the model level rather than the client browser? Cheers and keep up the excellent work!
  7. Okay, never mind, regarding the previous post it was being caused by the animation export options not being checked. I found this post by @JCPalmer which led me to try checking those new animation options, and wouldn't you just know it it worked instantly after that. JCP - you're alright with me. Good lad. ? So for the time being, at least I know I can do the C4D -> BJS route with animations kept intact. Yet even when setting the camera export options as I've just described in my original Helicopter scene, it still doesn't work properly. I must be doing something wrong in Blender, so I'll put this issue on hold until I'm working with a proper scene and if the problem arises again I'll necro the thread. Thanks again everyone.
  8. Okay so this is slightly off the original topic, but here's a very simple animation test. It was created in C4D, exported to FBX, imported in to Blender, then exported to BJS. In blender the animation appeared fine, but once in BJS it went sideways. Here's the video of the scene in blender - you can see visually how the animation should behave. It's just two objects, each with a baked animation. blender.mov Here's a PG using the exported BJS file. Notice how it just aint right, yo. https://www.babylonjs-playground.com/#02YH29 It appears as though the keyframe animation of the cube trumps that of the sphere, to the extent that even if you comment out the animation of the cube in the PG code, the movement of the sphere mimics that of the cube's animation, which is clearly wrong. I get the feeling this either isn't possible, or I'm doing something wildly incorrect here. Happy to hear your thoughts! Cheers test.blend
  9. Thanks for the replies chaps, I'll have a look at your suggestions and come back with any further questions. @JCPalmer thanks for the tip, seems a bit... steampunk.... but I'll defo take a look at that
  10. Yo party dudes Here I am, still at this damn project, still struggling with everyday issues (yo). Latest in a long list of probably-easy-but-hard-for-me questions is regarding animation. To set the scene (arf!), lets assume I have a Blender file with an empty parent object. Inside are two child objects; helicopter_body, and helicopter_props. What I'd like to do is, in Blender, animate the _props object so it looks like the chopper blades are spinning. Then in BJS animate the parent and children. Okay so once I have a simple prop rotation animation set in the dope sheet, if I export the scene and load in to BJS, what I see is that the position of the props is all kinds of wrong and the animation itself isn't working like I can see in Blender. Q1: Is this possible? Can I have a parent object animated with BJS with one of the children running a Blender animation independently? If so, what could be going wrong? I tried applying position and rotation/scale but that didn't change much. Q2: Also are there any obvious issues if I were to create a scene in C4D with animations (how's that exporter going btw?), export to FBX including animations, load the fbx in to blender then export to BJS? I can see in this page http://doc.babylonjs.com/resources/blender#animation that you're saying every single animated object should be produced as a seperate babylon file. Q3: why is that? Q4: And would that mean I have to use several sceneloader.append calls to bring all the different models in to the base scene? Cheers! blend_anim.mov
  11. No worries @davrous I'll work with what I've got and if the "powers that be" (i.e. the client) decide the effect needs work I'll come back to you with a PG. Cheers!
  12. 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 https://github.com/BabylonJS/Babylon.js/issues/4001). 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
  13. Any chance of a follow up on this stuff @davrous? Cheers
  14. 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
  15. 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?
  • Create New...