• Content Count

  • Joined

  • Last visited

About sable

  • Rank
    Advanced Member

Profile Information

  • Location
    New Zealand

Recent Profile Visitors

1,149 profile views
  1. sable

    MeshBuilder createPlane from sourcePlane

    Cool, done. Thanks @Gijs for that pg, made it easy to test.
  2. sable

    Google Earth shift drag controls

    I removed the offsetX check as I was finding it jarring for the camera to pan a little sometimes while rotating if the x offset happened to be zero (while the y offset was not). Where's the screenCoordinatesToWorldCoordinates function from? It sounds like the start of firing a ray from the camera and then using it to pick a point. ´╗┐Regarding picking a pivot point, if you're just dealing with a flat 2d plane, then doing an intersection test against that (BABYLON.Plane) will be a bit cheaper than doing one against a mesh (especially if you're wanting to test on mouse move when dragging to maintain position under the cursor). Edit: Just stumbled across which you might also find of use
  3. sable

    Google Earth shift drag controls 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.
  4. I was looking at the pg in the above post, and noticed that the near plane is positioned incorrectly. It seems that passing in a source plane to meshBuilder's createPlane function translates the plane in the wrong direction, and also rotates it so that it is facing the wrong way. For a plane with normal (0,0,1), and a point on the plane (0,0,10), meshBuilder will position the plane at (0,0,-10) and face it looking along the -ve Z axis. Example pg, with what I believe are fixes here.
  5. sable

    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.
  6. sable

    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.
  7. sable

    Texture hasAlpha performance issue

    If you're meaning it won't build (i.e. you're using typescript) you can cast to any to get around that (the only downside being if the variable name or behaviour changes in a future version of babylonjs).
  8. sable

    Texture hasAlpha performance issue 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.
  9. 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.
  10. sable

    Texture updateSamplingMode issue

    Yeah my use case is loading a model (.babylon format), and then applying a customMaterial to it (so I can modify the shaders). I was trying to just attach the texture from the original material to this new material and just update the sampling mode when I ran across the issue (after discovering that setting the sampling mode in the .babylon file was also didn't work). My workaround was to just extract the url and make a new texture, which I'll continue to do for now, as even waiting for the texture to load doesn't seem to always work. Thanks for looking into this.
  11. sable

    Texture updateSamplingMode issue

    It seems like texture.updateSamplingMode() doesn't actually work (though looking through the code, it looks like it should, as it's making the right gl calls). I noticed this as loading a .babylon file with sampling mode set wasn't working (though the samplingMode property on the texture would be correct, it was not rendering in that mode). (And assuming that it should work, should probably be updated to include the samplingMode property)
  12. sable

    BabylonJS render slower thanThreeJS?

    It seems odd that there is not much of a performance boost when setting all meshes to alwaysSelectAsActiveMesh = true, but a big boost from freezing active meshes. Intuitively I'd think they'd have similar results.
  13. sable

    BabylonJS render slower thanThreeJS?

    I agree that evaluate active meshes seems unreasonably slow, especially in the case where all the meshes in the scene are marked as always active. The difference between having all the meshes marked as always active, and freezing the active meshes array is 30 -> 45 fps for me.
  14. sable

    BabylonJS render slower thanThreeJS?

    You can make up most of the performance difference just by freezing the material. Though the techniques above (instancing or sps) perform far better for scenes like this. It's certainly worth investigating these sorts of things though.
  15. sable

    Coloring backface

    If you're ok using BABYLON.CustomMaterial, you can do this like so: It's probably a bit faster doing the dot product in the vertex shader though: You would probably want to pass in the desired color as a uniform instead of hard coding it.