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

Remove WebIO and build directly on Mux.jl and HTTP.jl #141

Merged
merged 8 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.ipynb_checkpoints
deps/build.log
Manifest.toml

12 changes: 3 additions & 9 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
name = "MeshCat"
uuid = "283c5d60-a78f-5afe-a0af-af636b173e11"
authors = ["Robin Deits <[email protected]>"]
version = "0.9.1"
version = "0.10.0"

[deps]
AssetRegistry = "bf4720bc-e11a-5d0c-854e-bdca1663c893"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
BinDeps = "9e28174c-4ba2-5203-b857-d8d62c4213ee"
Blink = "ad839575-38b3-5650-b840-f874b8c74a25"
Cassette = "7057c7e9-c182-5462-911a-8362d720325c"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
JSExpr = "97c1335a-c9c5-57fe-bc5d-ec35cebe8660"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
MsgPack = "99f44e22-a591-53d1-9472-aa23ef4bd671"
Mux = "a975b10e-0019-58db-a62f-e48ff68538c9"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Expand All @@ -24,26 +22,22 @@ Rotations = "6038ab10-8711-5258-84ad-4b1120ba62dc"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29"
WebSockets = "104b5d7c-a370-577a-8038-80a2059c5097"

[compat]
AssetRegistry = "0.1"
BinDeps = "1"
Blink = "0.12"
Cassette = "0.2.5"
Colors = "0.9, 0.10, 0.11"
CoordinateTransformations = "0.5"
DocStringExtensions = "0.5, 0.6, 0.7, 0.8"
FFMPEG = "0.2"
GeometryTypes = "0.6, 0.7"
JSExpr = "0.3, 0.5"
MsgPack = "1"
Mux = "0.7"
Parameters = "0.10, 0.11, 0.12"
Requires = "0.5, 1"
Rotations = "0.8, 0.9, 0.10, 0.11, 0.13"
StaticArrays = "0.10, 0.11, 0.12"
WebIO = "0.8.11"
julia = "0.7, 1"

[extras]
Expand Down
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ The MeshCat viewer runs entirely in the browser, with no external dependencies.
* Inside a Jupyter Notebook with [IJulia.jl](https://github.com/JuliaLang/IJulia.jl)
* In a standalone window with [Blink.jl](https://github.com/JunoLab/Blink.jl)
* Inside the [Juno IDE](http://junolab.org/)
* Inside the VSCode editor with the [julia-vscode](https://www.julia-vscode.org/) extension.

As much as possible, MeshCat.jl tries to use existing implementations of its fundamental types. In particular, we use:

Expand Down
15 changes: 4 additions & 11 deletions notebooks/animation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"# open(vis)\n",
"\n",
"## To open the visualizer inside this jupyter notebook, do: \n",
"# IJuliaCell(vis)\n",
"# render(vis)\n",
"\n",
"## To open this visualizer in a standalone window, do:\n",
"# using Blink\n",
Expand Down Expand Up @@ -219,13 +219,6 @@
"source": [
"# MeshCat.convert_frames_to_video(\"/home/rdeits/Downloads/meshcat_1528401494656.tar\", overwrite=true)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -234,15 +227,15 @@
"lastKernelId": null
},
"kernelspec": {
"display_name": "Julia 1.1.0",
"display_name": "Julia 1.3.1",
"language": "julia",
"name": "julia-1.1"
"name": "julia-1.3"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.1.0"
"version": "1.3.1"
}
},
"nbformat": 4,
Expand Down
21 changes: 13 additions & 8 deletions notebooks/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@
"metadata": {},
"outputs": [],
"source": [
"IJuliaCell(vis)"
"# The `render(vis)` function will try to render a MeshCat\n",
"# visualizer inline. In Jupyter, it will cause the visualizer\n",
"# to be displayed in the output of the current Jupyter cell. \n",
"# In Juno/VSCode, it will cause the visualizer to be displayed in\n",
"# the plot pane.\n",
"render(vis)"
]
},
{
Expand Down Expand Up @@ -92,7 +97,7 @@
"### Embed the visualizer inside this notebook\n",
"\n",
"```julia\n",
"IJuliaCell(vis)\n",
"render(vis)\n",
"```"
]
},
Expand Down Expand Up @@ -436,7 +441,7 @@
"outputs": [],
"source": [
"using GeometryTypes: Point3f0\n",
"points = rand(Point3f0, 100000)\n",
"points = rand(Point3f0, 1000000)\n",
"setobject!(vis[:pointcloud], PointCloud(points))"
]
},
Expand Down Expand Up @@ -531,19 +536,19 @@
],
"metadata": {
"@webio": {
"lastCommId": "057909cff550485386c7979bb5f0930e",
"lastKernelId": "81aa3ac9-8239-4690-9c92-5615ab42195e"
"lastCommId": null,
"lastKernelId": null
},
"kernelspec": {
"display_name": "Julia 1.1.0",
"display_name": "Julia 1.3.1",
"language": "julia",
"name": "julia-1.1"
"name": "julia-1.3"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.1.0"
"version": "1.3.1"
}
},
"nbformat": 4,
Expand Down
56 changes: 13 additions & 43 deletions src/MeshCat.jl
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
__precompile__()

module MeshCat

using WebIO
import Mux
import AssetRegistry
import Cassette
import FFMPEG
using GeometryTypes, CoordinateTransformations
using Rotations: rotation_between, Rotation, Quat
using Colors: Color, Colorant, RGB, RGBA, alpha, hex
using StaticArrays: StaticVector, SVector, SDiagonal, SMatrix
using GeometryTypes: raw
using Parameters: @with_kw
using DocStringExtensions: SIGNATURES
using JSExpr: @js, @new, @var
using Requires: @require
using Base.Filesystem: rm
using BinDeps: download_cmd, unpack_cmd
Expand All @@ -23,12 +15,18 @@ using LinearAlgebra: UniformScaling, Diagonal, norm
using Sockets: listen, @ip_str, IPAddr, IPv4, IPv6
using Base64: base64encode
using MsgPack: MsgPack, pack
import Mux
import Logging
import Mux.WebSockets
import Cassette
import FFMPEG


import Base: delete!

export Visualizer,
ViewerWindow,
IJuliaCell
IJuliaCell,
render

export setobject!,
settransform!,
Expand Down Expand Up @@ -87,50 +85,22 @@ include("msgpack.jl")
include("visualizer.jl")
include("atframe.jl")
include("arrow_visualizer.jl")
include("render.jl")
include("servers.jl")
include("assets.jl")
include("integrations.jl")

const VIEWER_ROOT = joinpath(@__DIR__, "..", "assets", "meshcat", "dist")

function develop_meshcat_assets(skip_confirmation=false)
meshcat_dir = abspath(joinpath(@__DIR__, "..", "assets", "meshcat"))
if !skip_confirmation
println("CAUTION: This will delete all downloaded meshcat assets and replace them with a git clone.")
println("The following path will be overwritten:")
println(meshcat_dir)
println("To undo this operation, you will need to manually remove that directory and then run `Pkg.build(\"MeshCat\")`")
print("Proceed? (y/n) ")
choice = chomp(readline())
if isempty(choice) || lowercase(choice[1]) != 'y'
println("Canceled.")
return
end
end
println("Removing $meshcat_dir")
rm(meshcat_dir, force=true, recursive=true)
run(`git clone https://github.com/rdeits/meshcat $meshcat_dir`)
rm(joinpath(meshcat_dir, "..", "meshcat.stamp"))
end

const ASSET_KEYS = String[]

function __init__()
main_js = abspath(joinpath(VIEWER_ROOT, "main.min.js"))
if !isfile(main_js)
error("""
main.min.js not found at $main_js.
Please build MeshCat using `import Pkg; Pkg.build("MeshCat")`""")
end
push!(ASSET_KEYS, AssetRegistry.register(main_js))

@require Blink="ad839575-38b3-5650-b840-f874b8c74a25" begin
function Base.open(core::CoreVisualizer, w::Blink.AtomShell.Window)
# Ensure the window is ready
Blink.js(w, "ok")
# Set its contents
Blink.body!(w, core.scope)
w
end
end
setup_integrations()
end


end
19 changes: 19 additions & 0 deletions src/assets.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function develop_meshcat_assets(skip_confirmation=false)
meshcat_dir = abspath(joinpath(@__DIR__, "..", "assets", "meshcat"))
if !skip_confirmation
println("CAUTION: This will delete all downloaded meshcat assets and replace them with a git clone.")
println("The following path will be overwritten:")
println(meshcat_dir)
println("To undo this operation, you will need to manually remove that directory and then run `Pkg.build(\"MeshCat\")`")
print("Proceed? (y/n) ")
choice = chomp(readline())
if isempty(choice) || lowercase(choice[1]) != 'y'
println("Canceled.")
return
end
end
println("Removing $meshcat_dir")
rm(meshcat_dir, force=true, recursive=true)
run(`git clone https://github.com/rdeits/meshcat $meshcat_dir`)
rm(joinpath(meshcat_dir, "..", "meshcat.stamp"))
end
19 changes: 0 additions & 19 deletions src/commands.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@ struct SetProperty{T} <: AbstractCommand
value::T
end

abstract type AbstractControl end

struct Button <: AbstractControl
observer::Observable
name::String
end

struct NumericControl{T} <: AbstractControl
observer::Observable
name::String
value::T
min::T
max::T
end

struct SetControl <: AbstractCommand
control::AbstractControl
end

struct SetAnimation{A <: Animation} <: AbstractCommand
animation::A
play::Bool
Expand Down
17 changes: 17 additions & 0 deletions src/integrations.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
function setup_integrations()
@require Blink="ad839575-38b3-5650-b840-f874b8c74a25" begin
function Base.open(core::CoreVisualizer, w::Blink.AtomShell.Window)
# Ensure the window is ready
Blink.js(w, "ok")
# Set its contents
Blink.loadurl(w, url(core))
w
end
end

@require WebIO="0f1e0344-ec1d-5b48-a673-e5cf874b6c29" begin
WebIO.render(vis::Visualizer) = WebIO.render(vis.core)

WebIO.render(core::CoreVisualizer) = WebIO.render(MeshCat.render(core))
end
end
25 changes: 0 additions & 25 deletions src/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,31 +293,6 @@ function lower(cmd::SetProperty)
)
end

function lower(b::Button)
Dict{String, Any}(
"name" => b.name,
"callback" => string(@js((value) -> $(b.observer)[] = [$(b.name), Date.now()])),
)
end

function lower(n::NumericControl)
Dict{String, Any}(
"name" => n.name,
"callback" => string(@js((val) -> $(n.observer)[] = [$(n.name), val])),
"value" => n.value,
"min" => n.min,
"max" => n.max
)
end

function lower(cmd::SetControl)
d = Dict{String, Any}(
"type" => "set_control",
)
merge!(d, lower(cmd.control))
d
end

function lower(track::AnimationTrack)
Dict{String, Any}(
"name" => string(".", track.name),
Expand Down
Loading