K3D-tools / K3D-jupyter

K3D lets you create 3D plots backed by WebGL with high-level API (surfaces, isosurfaces, voxels, mesh, cloud points, vtk objects, volume renderer, colormaps, etc). The primary aim of K3D-jupyter is to be easy for use as stand alone package like matplotlib, but also to allow interoperation with existing libraries as VTK.
MIT License
953 stars 121 forks source link

Supporting user generated normals for Standard Mesh object #415

Closed kishoreVen closed 1 year ago

kishoreVen commented 1 year ago

Supporting Normals input for Mesh

Problem

Users might some times want to use custom normals with their 3d Mesh as opposed to the ones computed by the provider (in this case three.js). This is currently not supported in k3d.

Solution

Introduce a new parameter to the Mesh object and support custom normals in MeshStandard.js.

Proof of Life

Before: Screenshot from 2023-03-08 21-50-46

Notice that flat_shading is False, meaning computeNormals is used.

After: Screenshot from 2023-03-08 21-50-22

Notice that user generated normals are passed to the mesh factory.

Questions

At it's current state this is a relatively safe change to merge. That said here are some pending questions

  1. Do we need a test case for this? It's not a drastic change, so I'm not sure if a test is needed. But community can vote on this.
  2. It is unclear if MeshVolume should also be getting this normals update. Thoughts?
  3. How to update the document to indicate this new change?
artur-trzesiok commented 1 year ago

Hi @kishoreVen !

Thanks for such nice improvement!