sable

Members
  • Content Count

    88
  • Joined

  • Last visited


Reputation Activity

  1. Thanks
    sable got a reaction from eeskikoy@gmail.com in ArcRotateCamera zoom to mouse position   
    https://www.babylonjs-playground.com/#DD2IDJ
    The above pg implements controls that are similar to most mapping solutions (panning keeps mouse in same position, as does zooming), and is basically a stripped down version of the control system I used here (though there the camera was also heavily modified so as to allow both rotation around the globe and about the surface target. The 2d mode available through the tools menu could have been done using the control scene from the pg and the standard camera however. Touch controls are also implemented there but not in the above pg). There may be a more idiomatic way of implementing custom controls though.
    I'm not sure if this is entirely what you're looking for (2d plane navigation), though I think it could be extended to work in 3d zooming in to a plane parallel to the viewport. Let me know if anything in there is unclear.
  2. Like
    sable got a reaction from Tibotiber in Controlling the render loop   
    The inputs to arc rotate camera don't modify the alpha/beta/radius directly, but rather modifies inertialAlphaOffset, inertialBetaOffset and inertialRadiusOffset, which in turn sets the alpha, beta and radius of the camera (adds the offset, then multiplies the offset by inertia, repeat until the offset is ~0, see here).
    If you just want to make sure movement hasn't been buffered while the render is stopped, you can just set these offset to 0 before the render.
    https://www.babylonjs-playground.com/#AFPV4K#2
    If you just want to allow rendering while the camera is moving, you can however just use a render loop that checks if these values are not 0.
    https://www.babylonjs-playground.com/#AFPV4K#5
    @Deltakosh When inertia is set to 0 in the above pg, the movement seems to be a frame behind (if zoom in then out, the first frame after the zoom out scroll wheel tick will zoom in). Something to do with render order? Also if you zoom, then just click move to rotate normally, it will do the final zoom on that render.
  3. Like
    sable got a reaction from Elijah in Propagating mousewheel event to parent?   
    Hi there. Just did a similar test to Wingy, and looks like babylon doesn't block the events, http://www.babylonjs-playground.com/#C3ZPAS.
    Looking at your page source, I think the issue is that the scene is embedded in an iframe. You should be able to send the event (or a message) from the iframe to the parent either via window.parent or window.Postmessage
  4. Like
    sable got a reaction from trevordev in Custom zooming   
    Was mainly just copied from a project I've been working on which faced similar performance issues with picking sphere particles from a sps, with corrections for the pivot point changing.
    I''ll try and take a look at sorting out the jumping in the next few days, but post back if you get it sorted before then.
  5. Like
    sable reacted to RyanONeill1970 in Custom zooming   
    I just noticed all the extra work you did in the playground @sable, did that come out of your head? That's very impressive, would take me quite some time to figure out what is going on there.
    Thanks again
  6. Like
    sable got a reaction from RyanONeill1970 in 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.
     
     
  7. Like
    sable got a reaction from Deltakosh in 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.
     
     
  8. Like
    sable got a reaction from meteoritool in How to change the orientation a plane according to ground orientation   
    Something like this:
    https://www.babylonjs-playground.com/#95PXRY#29
    Would need to be changed slightly if you wanted facet normal instead.
  9. Like
    sable got a reaction from NRA in (SOLVED) SpriteSheet size limit?   
    https://webglstats.com/webgl/parameter/MAX_TEXTURE_SIZE
    Which would concur with Sebavan's 4k recommendation (and 2k if you really need to support old mobile devices).
  10. Thanks
    sable got a reaction from bghgary in MeshBuilder createPlane from sourcePlane   
    Cool, done.
    https://github.com/BabylonJS/Babylon.js/pull/5500
     
    Thanks @Gijs for that pg, made it easy to test. 
  11. Thanks
    sable got a reaction from brean in ArcRotateCamera zoom to mouse position   
    https://www.babylonjs-playground.com/#DD2IDJ
    The above pg implements controls that are similar to most mapping solutions (panning keeps mouse in same position, as does zooming), and is basically a stripped down version of the control system I used here (though there the camera was also heavily modified so as to allow both rotation around the globe and about the surface target. The 2d mode available through the tools menu could have been done using the control scene from the pg and the standard camera however. Touch controls are also implemented there but not in the above pg). There may be a more idiomatic way of implementing custom controls though.
    I'm not sure if this is entirely what you're looking for (2d plane navigation), though I think it could be extended to work in 3d zooming in to a plane parallel to the viewport. Let me know if anything in there is unclear.
  12. Like
    sable got a reaction from Gijs in MeshBuilder createPlane from sourcePlane   
    Cool, done.
    https://github.com/BabylonJS/Babylon.js/pull/5500
     
    Thanks @Gijs for that pg, made it easy to test. 
  13. Like
    sable reacted to Gijs in MeshBuilder createPlane from sourcePlane   
    No fix, but here's the playground with just the wrong plane and the original CreatePlane function in the top. May be helpful.
    https://www.babylonjs-playground.com/#E29R4J#7
  14. Thanks
    sable got a reaction from chicagobob123 in Google Earth shift drag controls   
    https://www.babylonjs-playground.com/#NU4F6Y#91
    Was just a minor error, assigning the dragPoint.y the pickpoint.y instead of z on line 47.
    I added a //change comment to each line I modified from the original pg.
    Made this pg from scratch while checking, but prob not too much use to you.
  15. Like
    sable got a reaction from Sebavan in Google Earth shift drag controls   
    I implemented google map style controls in a pg linked above, and also provided a link to where this (something similar anyway) was used in production (which will give you a better idea as to whether this is the sort control style you're wanting to do).
    I modified the ArcRotate camera though, not the Free Camera.
  16. Like
    sable got a reaction from NasimiAsl in Google Earth shift drag controls   
    I implemented google map style controls in a pg linked above, and also provided a link to where this (something similar anyway) was used in production (which will give you a better idea as to whether this is the sort control style you're wanting to do).
    I modified the ArcRotate camera though, not the Free Camera.
  17. Like
    sable got a reaction from Lary in Camera Inertia Angle   
    If all you're wanting is the additional angle that the camera will rotate due to inertia after the pointerup event, you can calculate it in radians as:
    const additionalAngle = camera.inertialAlphaOffset / (1 - camera.inertia); which follows from the implementation posted by Sebavan above.
    http://playground.babylonjs.com/#PCMNE0#1
  18. Like
    sable got a reaction from Sebavan in Camera Inertia Angle   
    If all you're wanting is the additional angle that the camera will rotate due to inertia after the pointerup event, you can calculate it in radians as:
    const additionalAngle = camera.inertialAlphaOffset / (1 - camera.inertia); which follows from the implementation posted by Sebavan above.
    http://playground.babylonjs.com/#PCMNE0#1
  19. Thanks
    sable got a reaction from Dreik in Texture hasAlpha performance issue   
    https://github.com/BabylonJS/Babylon.js/blob/4b63e18d3dbd31d400fff1cba68de2981f8ba2ee/src/Materials/Textures/babylon.baseTexture.ts#L16 https://github.com/BabylonJS/Babylon.js/blob/4b63e18d3dbd31d400fff1cba68de2981f8ba2ee/src/babylon.scene.ts#L6001
    Setting has alpha seems to mark all materials in the scene as dirty. So in this case it's calling markAllMaterialsAsDirty a thousand times, each time with a larger materials array to loop over.
    You could get a compromise of behaviour by just setting the private _hasAlpha and then calling markAllMaterialsAsDirty after the loop.
    http://www.babylonjs-playground.com/#R8QY81#1
  20. Thanks
    sable got a reaction from Dreik in ArcRotateCamera zoom to mouse position   
    https://www.babylonjs-playground.com/#DD2IDJ
    The above pg implements controls that are similar to most mapping solutions (panning keeps mouse in same position, as does zooming), and is basically a stripped down version of the control system I used here (though there the camera was also heavily modified so as to allow both rotation around the globe and about the surface target. The 2d mode available through the tools menu could have been done using the control scene from the pg and the standard camera however. Touch controls are also implemented there but not in the above pg). There may be a more idiomatic way of implementing custom controls though.
    I'm not sure if this is entirely what you're looking for (2d plane navigation), though I think it could be extended to work in 3d zooming in to a plane parallel to the viewport. Let me know if anything in there is unclear.
  21. Thanks
    sable reacted to Sebavan in Texture updateSamplingMode issue   
    Good Catch, it comes from the fact that the texture has not been loaded yet whilst you are trying to change the mode:
    http://www.babylonjs-playground.com/#Q9RDM0#2
    I will modify the code to ensure it works even before waiting for the end of the loading.
    Thanks
  22. Like
    sable reacted to yokewang in BabylonJS render slower thanThreeJS?   
    The frame rate improved by some optimizations from https://doc.babylonjs.com/how_to/optimizing_your_scene.
    https://jsfiddle.net/6ng7usmj/57/  optimized version. But still slower than ThreeJS version.
    https://jsfiddle.net/6ng7usmj original version.
    BTW: We should not compare an ONE DRAWCALL instance version with a 8000 DRAWCALL version.  And ThreeJS supports instanced draw too.
    It's seems BabylonJs spends more time than ThreeJS to evaluate active meshes. I will try octree to see if it will help.
    Any help would be greatly appreciated.
  23. Like
    sable got a reaction from Hartha in Coloring backface   
    If you're ok using BABYLON.CustomMaterial, you can do this like so:
    http://www.babylonjs-playground.com/#PMVQPJ#3
    It's probably a bit faster doing the dot product in the vertex shader though:
    http://www.babylonjs-playground.com/#PMVQPJ#4
    You would probably want to pass in the desired color as a uniform instead of hard coding it.
  24. Like
    sable got a reaction from brianzinn in Coloring backface   
    If you're ok using BABYLON.CustomMaterial, you can do this like so:
    http://www.babylonjs-playground.com/#PMVQPJ#3
    It's probably a bit faster doing the dot product in the vertex shader though:
    http://www.babylonjs-playground.com/#PMVQPJ#4
    You would probably want to pass in the desired color as a uniform instead of hard coding it.
  25. Like
    sable reacted to brianzinn in TYPESCRIPT in Playground   
    I have been coding nearly 3 years almost entirely in TypeScript, so am biased.  Once a project reaches a certain size, I feel that JS slows me down a lot.
    I do agree that there is perhaps not a lot gained in TS playgrounds as they are essentially snippets and I feel that TS doesn't really shine until a project is medium sized.  At the same time I feel this is a REALLY great addition, so thank-you @NasimiAsl - I would really like at some point to post my BabylonJS TypeScript code that does not compile without some trickery (ie: try converting http://www.babylonjs-playground.com/#1K0NSN#1) - and now we finally have a way to share!!  This was not possible before in a PG, so there is something tangible gained by TS playgrounds.

    Why not let people choose making playgrounds where they are comfortable and happy --- providing the opportunity for both seems like the right thing.  I have a feeling anybody hanging out in the forum will learn TypeScript by osmosis, so that's a good thing too!!
    Also, the TypeScript playground is missing examples, so maybe that's a good teaching tool as well to see the same examples side-by-side.
    I hope not a disaster!  You will find that it's really trivial to convert from TS to JS - just remove some syntactic sugar from variable/function/argument declarations.  TS is just a superset of JS with optional typings