Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback for other JSON Material attributes #75

Open
goretkin opened this issue Nov 30, 2018 · 0 comments
Open

fallback for other JSON Material attributes #75

goretkin opened this issue Nov 30, 2018 · 0 comments

Comments

@goretkin
Copy link

Not exactly an issue, but I needed to visualize some wireframes, and I wanted to try using MeshCat.jl. Here's the hack I was able to do:

import MeshCat
const mc = MeshCat

"""low-level access to three js JSON interface
See https://github.com/mrdoob/three.js/blob/master/src/loaders/MaterialLoader.js"""
mutable struct OverlayMaterial{T<:mc.AbstractMaterial, OVT} <: mc.AbstractMaterial
  underlying::T
  overlay::Dict{String, OVT}
end

function mc.lower(material::OverlayMaterial)
  merge(mc.lower(material.underlying), material.overlay)
end

wireframe_material = OverlayMaterial(
    mc.MeshPhongMaterial(color=mc.RGBA{Float32}(0.8, 0.8, 0.8, 1)),
    Dict{String, Any}("wireframe"=>true))

That might be a good escape hatch to support any possible feature of the three js loaders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant