Export Interactive Standalone HTML from WGLMakie

Hi :slight_smile:

I want to use WGLMakie to extract static HTML, but my code does not work with the method described here.
I think I wrote a bad code. Is there anyone who can suggest how to do this?

The following worked on Pluto or GLMakie.
WGLMakie v0.3.9
JSServe v1.2.2

using WGLMakie, JSServe
Page()
begin
	x = range(100,900;length=10)
	y = x
	R(x)=[cos(x) -sin(x); sin(x) cos(x)]
	tmp=[[x1,y1] for x1 = x,y1=y]	|>x-> reshape(x,100) .|> Point2f0
	fig= Figure(resolution=(1000,1000))
	axis = fig[1, 1] = Axis(fig;panbutton=0,
		ygridvisible=false,
		xgridvisible=false,
		xticklabelsvisible=false,
		yticklabelsvisible=false,
		xticksvisible=false,
		yticksvisible=false,
		xpanlock=true,
		ypanlock=true,
		xzoomlock=true,
		yzoomlock=true,
		xrectzoom=false,
		yrectzoom=false
		)
	
	mousemarker = Observable(Point2f0([0,0]))
	on(events(axis.scene).mouseposition) do mp
		area = pixelarea(axis.scene)[]
		mp = Point2f0(mp) .- minimum(area)
	    r = Point2f0(to_world(axis.scene, mp))
		mousemarker[] = r
		return false
	end
	
	xlims!(axis,0,1000)
	ylims!(axis,0,1000)
	
	arrows!(tmp,lift(x->(fill(R(1)x,100)-@.(R(1)*tmp))/5,mousemarker),arrowsize=15,linewidth=5)
	scatter!(axis, mousemarker; markersize=30,color="black")
	
	fig
end

Here’s the code I did.

function arrowstest()
         x = range(100,900;length=10)
## ~~above codes~~
	fig
end
page = Page(offline=true, exportable=true);
page_html = sprint() do io
    show(io, MIME"text/html"(), page)
    show(io, MIME"text/html"(), arrowstest())
    show(io, MIME"text/html"(), volume(rand(4, 4, 4)))
end
write("test.html", page_html)

You forgot to describe what it is that doesn’t work?

I mean when I made the above code into an HTML file, it was not able to detect that the mouse was inside the canvas.
I don’t know much about it, but I think Observable is not translating well.

Most mouse interactions need a running Julia process…
Page(offline=true) means “don’t talk to Julia ever again”.
Have a look at Home · WGLMakie.jl to get some expectations about what should and should not work with offline export.

Thank you for your advice. I’m rooting for the development of this package.