• Content count

  • Joined

  • Last visited

About sable

  • Rank
    Advanced Member

Profile Information

  • Location
    New Zealand

Recent Profile Visitors

1,088 profile views
  1. 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.
  2. 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).
  3. 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.
  4. 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.
  5. 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.
  6. 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)
  7. 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.
  8. 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.
  9. 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.
  10. 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.
  11. sable

    Babylon shows a different result

    Would you be able to make a pg showing that behaviour? It might though be easier to just export the model as left handed as per @brianzinn above,.
  12. sable

    alphaIndex occurs depth problem.

    Actually pretty sure it's your sort function, needs to return a -ve number, +ve number, or 0, not true or false. If you log out the position.z of each mesh after sorting the way it was you'll see that they're not in the correct order. It would be less work just using the pos.z - campos directly as the alpha index though, unless there is some other reason you need to sort them.
  13. sable

    alphaIndex occurs depth problem.

    Thought I'd just chime in here to confirm that I get the same effect as @klaude, blinking and wrong order. Interestingly it works fine though if I use the distance to the camera as the z-index.
  14. I've just done something similar for 3ds files, which while not removing a dependency on blender, makes it really easy to batch convert models using the babylonjs blender exporter. I'm sure other formats could be converted using a similar method. import os import bpy import sys # see # make sure scene is empty bpy.ops.wm.read_homefile(use_empty=True) path_to_3ds = sys.argv[5] file_list = sorted(os.listdir(path_to_3ds)) autodesk_list = [item for item in file_list if item.endswith('.3ds')] for item in autodesk_list: bpy.ops.wm.addon_enable(module="babylon-js") path_to_files = os.path.join(path_to_3ds, item) bpy.ops.import_scene.autodesk_3ds(filepath = path_to_files) bpy.ops.bjs.main(filepath= os.path.join(path_to_3ds, item.replace("3ds", "babylon"))) # bpy.ops.export_scene.obj(filepath= os.path.join(path_to_3ds, item.replace("3ds", "obj"))) bpy.ops.wm.read_homefile(use_empty=True) And then call this using: "$BLENDER_LOCATION" --background --python ./ -- "$PATH_TO_MODELS" Some fixing up afterwards (due to 3ds models not having a diffuse colour, and a few other things) is done using sed on the .babylon files after this, but what (if anything) needs fixing would depend on the input format. For the models I've been converting, it's been taking less than a second for each one.
  15. sable

    Babylon shows a different result

    The model might be right handed. You could try: scene.useRightHandedSystem = true;