Skip to content

Support arbitrary kwargs for materials (fixes #75) - #274

Open
rainerrodrigues wants to merge 1 commit into
rdeits:masterfrom
rainerrodrigues:feature-material-kwargs
Open

Support arbitrary kwargs for materials (fixes #75)#274
rainerrodrigues wants to merge 1 commit into
rdeits:masterfrom
rainerrodrigues:feature-material-kwargs

Conversation

@rainerrodrigues

Copy link
Copy Markdown

Description

This PR addresses issue #75 by providing a "fallback" dictionary for Material types, allowing users to pass arbitrary, unsupported Three.js properties directly to the browser.

Changes Made

  • Added a kwargs::Dict{String, Any} = Dict{String, Any}() property to Texture, GenericMaterial, PointsMaterial, and FatLineMaterial in src/objects.jl.
  • Updated the lower methods in src/lowering.jl to merge! the user's kwargs directly into the outgoing JSON dictionary right before it is returned.

Example Usage:
Users can now pass things like wireframe or wireframeLinewidth seamlessly:

using Colors, GeometryBasics
mat = MeshPhongMaterial(
    color=RGB(0., 0.5, 1.), 
    kwargs=Dict{String, Any}("wireframe" => true, "wireframeLinewidth" => 5)
)

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

Successfully merging this pull request may close these issues.

1 participant