Ok, this is probably good enough:  https://tinyurl.com/rotatingF

It's tempting to embellish or modify it somewhat. For example, maybe
instead of a time uniform using a mouse position uniform so that the
orientation of the F can be dragged.

Or, maybe I should document its mechanisms ro some such...

But what I really wanted was a callback into the J session and I don't
quite have that yet. Instead, in the playground, javascript is the
host and here J is just a tool for delivering javascript.

Conceptually, also, I should be able to generate textures using webgl
and if I could export them back into javascript (not sure I can, but
it seems like that ought to be supported), I could then turn around
and export a result back into J as an array.

Anyways.. It does at least work now, when I run it a second or third time.

Thanks,

-- 
Raul

On Sun, Jan 15, 2023 at 5:54 PM Joe Bogner <[email protected]> wrote:
>
> It was kind of tricky/slightly hacky but here is a demo with a console.log
> when the dialog is closed:
> https://jsoftware.github.io/j-playground/bin/html2/#url=https://gist.githubusercontent.com/joebo/6002c573f08b57c279c1203d7f5c4328/raw/f7035715b33ec37e09c01fe02e18e4b6bb45b9a9/jplayground%2520webgl
>
> The relevant part is here:
>
> //event to catch popup visibility change
> const resizewatcher=new ResizeObserver(entries => {
>   for (const entry of entries){
>   const visible = !(entry.contentRect.width == 0)
>     console.log('popup visibility is: ' + visible);
>   }
> })
>
> var popupid = getid("popup")
> //prevent adding the event multiple times if the script is run multiple
> times
> if (popupid.dataset.has_close_watcher == undefined) {
>   resizewatcher.observe(popupid)
>   popupid.dataset.has_close_watcher = true;
> }
>
> I thought about changing the popup code to emit an event when visibility
> changed in start.js
> https://github.com/jsoftware/j-playground/blob/9da3ae0509580f282cb09b93aa5817a2ac1d3152/bin/html2/start.js#L62
> but instead just added a MutationObserver to watch the visibility change
>
> idea from:
> https://stackoverflow.com/a/70019354
>
> On Sun, Jan 15, 2023 at 8:19 AM Raul Miller <[email protected]> wrote:
>
> > After thinking about this a bit: probably when running webgl code
> > under the playground, I should be hooking into the close event for the
> > "popup" containing the canvas and dispose of my webgl constructs.
> >
> > Conceptually speaking, maybe the browser could do this automatically,
> > but even if that doesn't run afoul of some webgl or ecmascript or dom
> > standards that sort of thing might be years in the future.
> >
> > What would a close event handler look like, here? (I just need a
> > proof-of-concept with a console.log -- not something which does a
> > complete cleanup...) Maybe I can figure this out on my own, but if you
> > have a concrete idea of how to implement that abstraction, that would
> > be great.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> > On Sun, Jan 15, 2023 at 7:52 AM Raul Miller <[email protected]> wrote:
> > >
> > > Hmm....
> > >
> > > I tried the webgl implementation from
> > > https://rosettacode.org/wiki/WebGL_rotating_F#J and I got it to work,
> > > once.
> > >
> > > But, closing the webgl subwindow and then trying to run it again did
> > > not work (instead, it eventually crashed my browser).
> > >
> > > I don't know if that's a problem specific to my machine, or if it's a
> > > playground issue or a browser issue or whatever else.
> > >
> > > --
> > > Raul
> > >
> > > On Sun, Jan 15, 2023 at 7:01 AM Joe Bogner <[email protected]> wrote:
> > > >
> > > > >
> > > > >
> > > > > One alternative here might be to create a webserver in J which
> > webview
> > > > > interacts with (perhaps a jhs variant, though possibly being run from
> > > > > within jqt). This would involve significant overhead but it might
> > > > > work...
> > > >
> > > >
> > > > How about the J Playground? I took your code and it was copy/paste to
> > make
> > > > it run in the J Playground.
> > > >
> > > >
> > > >
> > https://jsoftware.github.io/j-playground/bin/html2/#url=https://gist.githubusercontent.com/joebo/6002c573f08b57c279c1203d7f5c4328/raw/038f37e626813cca56c15c8376edc705a9a3c8d1/jplayground%2520webgl
> > > >
> > > >
> > > > It shows the console.log too
> > > >
> > > > You should be able to use the jdo1() from javascript to interact with J
> > > > and (2!:0) from J to interact with javascript. See UI example in the
> > > > playground
> > > >
> > > > If you go this route I'd like to add it back in as a J Playground
> > example.
> > > > I'm not familiar enough with webgl to make something interesting
> > > > ----------------------------------------------------------------------
> > > > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to