Jump to content


  • Content Count

  • Joined

  • Last visited

Everything posted by sable

  1. 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.
  2. 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
  3. Using facet normals: https://www.babylonjs-playground.com/#95PXRY#32 https://doc.babylonjs.com/how_to/how_to_use_facetdata Though I think @Wingnut is right in that a decal may fit your needs better, especially for footsteps.
  4. Something like this: https://www.babylonjs-playground.com/#95PXRY#29 Would need to be changed slightly if you wanted facet normal instead.
  5. 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).
  6. Cool, done. https://github.com/BabylonJS/Babylon.js/pull/5500 Thanks @Gijs for that pg, made it easy to test.
  7. 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
  8. 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.
  9. 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.
  10. 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.
  11. 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
  12. 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).
  13. 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. htt
  14. 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
  15. 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.
  16. 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). http://www.babylonjs-playground.com/#Q9RDM0 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, https://doc.babylonjs.com/resources/file_format_map_(.babylon)#textures should probably be updated to include the samplingMode property)
  17. 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. http://www.babylonjs-playground.com/debug.html#QRIX4R#2 Intuitively I'd think they'd have similar results.
  18. 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. https://jsfiddle.net/6ng7usmj/65/
  19. You can make up most of the performance difference just by freezing the material. https://jsfiddle.net/6ng7usmj/52/ Though the techniques above (instancing or sps) perform far better for scenes like this. It's certainly worth investigating these sorts of things though.
  20. 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.
  21. 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,.
  22. Actually pretty sure it's your sort function, needs to return a -ve number, +ve number, or 0, not true or false. https://www.babylonjs-playground.com/#BTU1J7#5 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.
  23. 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. https://www.babylonjs-playground.com/#BTU1J7#3
  24. 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 https://blender.stackexchange.com/questions/46990/how-to-completely-remove-all-loaded-data-from-blender?noredirect=1&lq=1 # 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_lis
  25. The model might be right handed. You could try: scene.useRightHandedSystem = true;
  • Create New...