rdeits / MeshCat.jl

WebGL-based 3D visualizer in Julia
MIT License
233 stars 43 forks source link

Support vertexColors for meshes via GeometryBasics.meta #183

Closed rdeits closed 3 years ago

rdeits commented 4 years ago

Example:

# Create a simple mesh with a single triangle
geometry = GeometryBasics.Mesh(
    [Point(0., 0, 0), Point(1., 0, 0), Point(1., 1, 0)],
    [NgonFace(1, 2, 3)])
# Wrap that mesh with metadata encoding the vertex colors
mesh_meta = meta(geometry, vertexColors=[RGB(1, 0, 0), RGB(0, 1, 0), RGB(0, 0, 1)])
# Create a Gouraud-shaded material with vertex coloring enabled
material = MeshLambertMaterial(vertexColors=true)
# Add it to the scene
setobject!(v[:vertex_color_mesh], mesh_meta, material)
settransform!(v[:vertex_color_mesh], Translation(1, -1.5, 0))

Result:

Screenshot from 2020-09-22 23-33-06

codecov-commenter commented 4 years ago

Codecov Report

Merging #183 into master will increase coverage by 0.21%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #183      +/-   ##
==========================================
+ Coverage   78.41%   78.62%   +0.21%     
==========================================
  Files          18       18              
  Lines         505      510       +5     
==========================================
+ Hits          396      401       +5     
  Misses        109      109              
Impacted Files Coverage Δ
src/MeshCat.jl 80.00% <ø> (ø)
src/lowering.jl 96.05% <100.00%> (+0.27%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 59e4d2c...36a1c47. Read the comment docs.