I am pretty new to three.js and extremely new to OpenGL. In the past few days, I have been trying to develop an online web-hosted solution which can be used to show real-time 3D reconstruction from Implicit 3D voxel-grid. My problem at the moment is that I am using BufferGeometry with PointsMaterial to show the points and they look very ugly at sparse regions (See
I am trying to replace these points to some planar or circular geometry where I can manipulate properties (such as width, height and orientation) to piece together a relatively better looking meshes. I have already tried to add bunch of planes from PlaneBufferGeometry and replaced them with Points but the system is terribly inefficient and gives ~5fps with 20000 planes.
I am aware that in traditional OpenGL, a handmade shader can be used to achieve these results but my lack of knowledge and experience (and internet resources) have restricted me to implement such in three.js.
Question: Is there an efficient way already implemented in three.js in which I can draw planes (with height,width and orientation) instead of points?
The performance of your app is probably degraded by the amount of draw calls. Hence, consider to use instanced rendering. An easy way to do this (without modifying shaders) is the usage of THREE.InstancedMesh. Check out the documentation page and the respective examples in order to get familiar with this class.
Dear @Mugen87,
Thank you for your reply, at the moment I am experimenting with THREE.InstacedMesh and it seems that at-least adding 20000 planar object is not a problem. However is there any way I can change the color of each mesh at run-time? because even if I initiate sufficient meshes in advance, I cannot know the color of each vertex.
Thanks again for quick reply. I am already trying to get myself familiarize with the referenced example, however those colors are still at the time of creation and not “run-time”. I am afraid that I may have to re-create InstancedMesh with each update.
Thank you, that helped a lot. just one last question. It is working nicely but since I am using THREE.MeshMatcapMaterial it does not goes well with lighting with it. Is there any way to add light as everything seems very dim. (Screenshot of sub-sampled mesh)