Skip to content

Commit

Permalink
Adds planes.
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitvarkey committed Sep 17, 2015
1 parent 5e09bb3 commit 351f494
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/render.jl
Expand Up @@ -3,7 +3,7 @@ using Colors
export mesh, box, sphere, pyramid, cylinder, torus, parametric, meshlines,
material, camera, pointlight, spotlight, ambientlight, vertex, line,
linematerial, geometry, face, dodecahedron, icosahedron, octahedron,
tetrahedron
tetrahedron, plane

"""
Creates a Three-js mesh at position (`x`,`y`,`z`).
Expand Down Expand Up @@ -119,6 +119,18 @@ function tetrahedron(radius::Float64)
)
end

"""
Creates a plane in the XY plane with specified width and height centered
around the origin.
Should be put in a `mesh` along with another material Elem to render.
"""
function plane(width::Float64, height::Float64)
Elem(
:"three-js-plane",
attributes = @compat Dict(:w => width, :h => height)
)
end

"""
Creates a geometry.
This should be a child of a `mesh`.
Expand Down
3 changes: 2 additions & 1 deletion test/runtests.jl
Expand Up @@ -72,7 +72,8 @@ facts("Testing Render Elem Outputs") do
)
@fact torus(12.0, 2.0) -->
Elem(:"three-js-torus", attributes = @compat Dict(:r => 12.0, :tube => 2.0))

@fact plane(12.0, 2.0) -->
Elem(:"three-js-plane", attributes = @compat Dict(:w => 12.0, :h => 2.0))
#colormap = Colors.colormap("RdBu")
#zs = [0.0, 1.0, 2.0, 1.0, 2.0, 3.0, 2.0, 3.0, 4.0, 3.0, 4.0, 5.0]
#colors = map(z -> "#"*hex(colormap[ceil(Int,(5-z)/5 * (100-1)+1)]), zs)
Expand Down

0 comments on commit 351f494

Please sign in to comment.