From 286dededf9f8e4ec85ef33844a97387fc39edee4 Mon Sep 17 00:00:00 2001 From: Robert Ramirez Date: Mon, 12 Apr 2021 21:57:45 -0400 Subject: [PATCH 1/2] show how to get root render-ctx via implicit-listener and new JS enabled jit.proxy object the current version posts an error to the console when it tests the root context for a drawto attribute. this will be fixed in a future version --- meshwarp/meshwarp.js | 42 +++++++++++++++++++-------- meshwarp/meshwarp.maxpat | 62 ++++++++++++---------------------------- 2 files changed, 48 insertions(+), 56 deletions(-) diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js index 0f89358..73982f7 100644 --- a/meshwarp/meshwarp.js +++ b/meshwarp/meshwarp.js @@ -6,31 +6,46 @@ function postln(arg) { } postln.local = 1; +var impdrawto = "" var drawto = "" var swaplisten = null +const is820 = (max.version >= 820); +var proxy = null; +if(is820) { + proxy = new JitterObject("jit.proxy"); +} -function setdrawto(arg) { - if(arg === drawto || !arg) { +function setdrawto(newdrawto) { + if(newdrawto == drawto || !newdrawto) { // bounce return; } - postln("setdrawto " + arg); - drawto=arg; + if(proxy) { + proxy.name = newdrawto; + //proxyattrs = proxy.send("getattributes"); + proxydrawto = proxy.send("getdrawto"); + if(proxydrawto !== null && proxydrawto !== undefined) { + // important! drawto is an array so get first element + return setdrawto(proxydrawto[0]); + } + } + + postln("setdrawto " + newdrawto); + drawto = newdrawto; if(swaplisten) swaplisten.subjectname = ""; - swaplisten = new JitterListener(drawto,swapcallback); + swaplisten = new JitterListener(newdrawto, swapcallback); } function swapcallback(event){ - post("callback: " + event.subjectname + " sent "+ event.eventname + " with (" + event.args + ")\n"); - + post("callback: " + event.subjectname + " sent "+ event.eventname + " with (" + event.args + ")\n"); // if context is root we use swap, if jit.gl.node use draw if ((event.eventname=="swap" || event.eventname=="draw")) { - //drawmovies(); + } } swapcallback.local = 1 @@ -39,9 +54,12 @@ var implicit_tracker = new JitterObject("jit_gl_implicit"); var implicit_lstnr = new JitterListener(implicit_tracker.name, implicit_callback); function implicit_callback(event) { - if(drawto !== implicit_tracker.drawto) { - setdrawto(implicit_tracker.drawto); - //outlet(0, "drawto", (cur_drawto.length > 0 ? cur_drawto : vg.curctx)); + //postln("implicit event " + implicit_tracker.drawto + " " + event.eventname); + + // important! drawto is an array so get first element + if(impdrawto != implicit_tracker.drawto[0]) { + impdrawto = implicit_tracker.drawto[0]; + setdrawto(impdrawto); } } -implicit_callback.local = 1; \ No newline at end of file +implicit_callback.local = 1; diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat index 79ffabe..fe4e8e1 100644 --- a/meshwarp/meshwarp.maxpat +++ b/meshwarp/meshwarp.maxpat @@ -10,7 +10,7 @@ } , "classnamespace" : "box", - "rect" : [ 390.0, 79.0, 961.0, 661.0 ], + "rect" : [ 390.0, 79.0, 648.0, 370.0 ], "bglocked" : 0, "openinpresentation" : 0, "default_fontsize" : 12.0, @@ -40,49 +40,37 @@ "assistshowspatchername" : 0, "boxes" : [ { "box" : { - "id" : "obj-9", - "maxclass" : "toggle", + "attr" : "name", + "id" : "obj-8", + "maxclass" : "attrui", "numinlets" : 1, "numoutlets" : 1, - "outlettype" : [ "int" ], - "parameter_enable" : 0, - "patching_rect" : [ 38.690475821495056, 125.595236897468567, 24.0, 24.0 ] - } - - } -, { - "box" : { - "id" : "obj-7", - "maxclass" : "newobj", - "numinlets" : 2, - "numoutlets" : 2, - "outlettype" : [ "", "" ], - "patching_rect" : [ 245.833330988883972, 232.738093018531799, 155.0, 22.0 ], - "text" : "substitute drawto setdrawto" + "outlettype" : [ "" ], + "patching_rect" : [ 305.0, 125.595236897468567, 217.0, 22.0 ] } } , { "box" : { - "id" : "obj-6", - "maxclass" : "message", - "numinlets" : 2, + "attr" : "drawto", + "id" : "obj-5", + "maxclass" : "attrui", + "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "" ], - "patching_rect" : [ 249.404759526252747, 65.476189851760864, 61.0, 22.0 ], - "text" : "getdrawto" + "patching_rect" : [ 305.0, 100.0, 217.0, 22.0 ] } } , { "box" : { - "id" : "obj-4", + "id" : "obj-9", "maxclass" : "toggle", "numinlets" : 1, "numoutlets" : 1, "outlettype" : [ "int" ], "parameter_enable" : 0, - "patching_rect" : [ 87.642860054969788, 23.119050145149231, 24.0, 24.0 ] + "patching_rect" : [ 48.690475821495056, 100.0, 24.0, 24.0 ] } } @@ -206,7 +194,7 @@ "maxclass" : "inlet", "numinlets" : 0, "numoutlets" : 1, - "outlettype" : [ "int" ], + "outlettype" : [ "" ], "patching_rect" : [ 107.0, 64.0, 30.0, 30.0 ] } @@ -252,7 +240,7 @@ ] } , - "patching_rect" : [ 108.642860054969788, 129.119050145149231, 93.0, 22.0 ], + "patching_rect" : [ 108.642860054969788, 100.0, 93.0, 22.0 ], "saved_object_attributes" : { "description" : "", "digest" : "", @@ -271,32 +259,18 @@ "source" : [ "obj-1", 0 ] } - } -, { - "patchline" : { - "destination" : [ "obj-7", 0 ], - "source" : [ "obj-2", 2 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-4", 0 ] - } - } , { "patchline" : { "destination" : [ "obj-2", 0 ], - "source" : [ "obj-6", 0 ] + "source" : [ "obj-5", 0 ] } } , { "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-7", 0 ] + "destination" : [ "obj-2", 0 ], + "source" : [ "obj-8", 0 ] } } From ce03e6c1edf6b9692013bd5456988de6ad67f128 Mon Sep 17 00:00:00 2001 From: Robert Ramirez Date: Wed, 21 Apr 2021 13:28:03 -0400 Subject: [PATCH 2/2] remove unused files --- meshwarp/meshwarp.js | 65 --------- meshwarp/meshwarp.maxpat | 296 --------------------------------------- 2 files changed, 361 deletions(-) delete mode 100644 meshwarp/meshwarp.js delete mode 100644 meshwarp/meshwarp.maxpat diff --git a/meshwarp/meshwarp.js b/meshwarp/meshwarp.js deleted file mode 100644 index 73982f7..0000000 --- a/meshwarp/meshwarp.js +++ /dev/null @@ -1,65 +0,0 @@ -autowatch = 1; - -function postln(arg) { - //if(verbose) - post(arg+"\n"); -} -postln.local = 1; - -var impdrawto = "" -var drawto = "" -var swaplisten = null - -const is820 = (max.version >= 820); -var proxy = null; -if(is820) { - proxy = new JitterObject("jit.proxy"); -} - -function setdrawto(newdrawto) { - if(newdrawto == drawto || !newdrawto) { - // bounce - return; - } - - if(proxy) { - proxy.name = newdrawto; - //proxyattrs = proxy.send("getattributes"); - proxydrawto = proxy.send("getdrawto"); - if(proxydrawto !== null && proxydrawto !== undefined) { - // important! drawto is an array so get first element - return setdrawto(proxydrawto[0]); - } - } - - postln("setdrawto " + newdrawto); - drawto = newdrawto; - - if(swaplisten) - swaplisten.subjectname = ""; - swaplisten = new JitterListener(newdrawto, swapcallback); -} - - -function swapcallback(event){ - post("callback: " + event.subjectname + " sent "+ event.eventname + " with (" + event.args + ")\n"); - // if context is root we use swap, if jit.gl.node use draw - if ((event.eventname=="swap" || event.eventname=="draw")) { - - } -} -swapcallback.local = 1 - -var implicit_tracker = new JitterObject("jit_gl_implicit"); -var implicit_lstnr = new JitterListener(implicit_tracker.name, implicit_callback); - -function implicit_callback(event) { - //postln("implicit event " + implicit_tracker.drawto + " " + event.eventname); - - // important! drawto is an array so get first element - if(impdrawto != implicit_tracker.drawto[0]) { - impdrawto = implicit_tracker.drawto[0]; - setdrawto(impdrawto); - } -} -implicit_callback.local = 1; diff --git a/meshwarp/meshwarp.maxpat b/meshwarp/meshwarp.maxpat deleted file mode 100644 index fe4e8e1..0000000 --- a/meshwarp/meshwarp.maxpat +++ /dev/null @@ -1,296 +0,0 @@ -{ - "patcher" : { - "fileversion" : 1, - "appversion" : { - "major" : 8, - "minor" : 2, - "revision" : 0, - "architecture" : "x64", - "modernui" : 1 - } -, - "classnamespace" : "box", - "rect" : [ 390.0, 79.0, 648.0, 370.0 ], - "bglocked" : 0, - "openinpresentation" : 0, - "default_fontsize" : 12.0, - "default_fontface" : 0, - "default_fontname" : "Arial", - "gridonopen" : 1, - "gridsize" : [ 15.0, 15.0 ], - "gridsnaponopen" : 1, - "objectsnaponopen" : 1, - "statusbarvisible" : 2, - "toolbarvisible" : 1, - "lefttoolbarpinned" : 0, - "toptoolbarpinned" : 0, - "righttoolbarpinned" : 0, - "bottomtoolbarpinned" : 0, - "toolbars_unpinned_last_save" : 0, - "tallnewobj" : 0, - "boxanimatetime" : 200, - "enablehscroll" : 1, - "enablevscroll" : 1, - "devicewidth" : 0.0, - "description" : "", - "digest" : "", - "tags" : "", - "style" : "", - "subpatcher_template" : "", - "assistshowspatchername" : 0, - "boxes" : [ { - "box" : { - "attr" : "name", - "id" : "obj-8", - "maxclass" : "attrui", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 305.0, 125.595236897468567, 217.0, 22.0 ] - } - - } -, { - "box" : { - "attr" : "drawto", - "id" : "obj-5", - "maxclass" : "attrui", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 305.0, 100.0, 217.0, 22.0 ] - } - - } -, { - "box" : { - "id" : "obj-9", - "maxclass" : "toggle", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "int" ], - "parameter_enable" : 0, - "patching_rect" : [ 48.690475821495056, 100.0, 24.0, 24.0 ] - } - - } -, { - "box" : { - "id" : "obj-2", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 3, - "outlettype" : [ "jit_matrix", "bang", "" ], - "patching_rect" : [ 108.642860054969788, 171.119050145149231, 205.0, 22.0 ], - "text" : "jit.world" - } - - } -, { - "box" : { - "id" : "obj-1", - "maxclass" : "newobj", - "numinlets" : 3, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patcher" : { - "fileversion" : 1, - "appversion" : { - "major" : 8, - "minor" : 2, - "revision" : 0, - "architecture" : "x64", - "modernui" : 1 - } -, - "classnamespace" : "box", - "rect" : [ 182.0, 178.0, 640.0, 480.0 ], - "bglocked" : 0, - "openinpresentation" : 0, - "default_fontsize" : 12.0, - "default_fontface" : 0, - "default_fontname" : "Arial", - "gridonopen" : 1, - "gridsize" : [ 15.0, 15.0 ], - "gridsnaponopen" : 1, - "objectsnaponopen" : 1, - "statusbarvisible" : 2, - "toolbarvisible" : 1, - "lefttoolbarpinned" : 0, - "toptoolbarpinned" : 0, - "righttoolbarpinned" : 0, - "bottomtoolbarpinned" : 0, - "toolbars_unpinned_last_save" : 0, - "tallnewobj" : 0, - "boxanimatetime" : 200, - "enablehscroll" : 1, - "enablevscroll" : 1, - "devicewidth" : 0.0, - "description" : "", - "digest" : "", - "tags" : "", - "style" : "", - "subpatcher_template" : "", - "assistshowspatchername" : 0, - "boxes" : [ { - "box" : { - "id" : "obj-8", - "maxclass" : "newobj", - "numinlets" : 1, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 119.0, 202.0, 88.0, 22.0 ], - "saved_object_attributes" : { - "filename" : "meshwarp.js", - "parameter_enable" : 0 - } -, - "text" : "js meshwarp.js" - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-7", - "index" : 2, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 201.0, 64.0, 30.0, 30.0 ] - } - - } -, { - "box" : { - "id" : "obj-6", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 334.0, 64.0, 150.0, 20.0 ], - "text" : "from jit.world" - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-5", - "index" : 3, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 299.0, 64.0, 30.0, 30.0 ] - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-4", - "index" : 1, - "maxclass" : "inlet", - "numinlets" : 0, - "numoutlets" : 1, - "outlettype" : [ "" ], - "patching_rect" : [ 107.0, 64.0, 30.0, 30.0 ] - } - - } -, { - "box" : { - "id" : "obj-3", - "maxclass" : "comment", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 141.0, 333.0, 150.0, 20.0 ], - "text" : "connect to jit.world" - } - - } -, { - "box" : { - "comment" : "", - "id" : "obj-1", - "index" : 1, - "maxclass" : "outlet", - "numinlets" : 1, - "numoutlets" : 0, - "patching_rect" : [ 102.0, 326.0, 30.0, 30.0 ] - } - - } - ], - "lines" : [ { - "patchline" : { - "destination" : [ "obj-8", 0 ], - "source" : [ "obj-4", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-1", 0 ], - "source" : [ "obj-8", 0 ] - } - - } - ] - } -, - "patching_rect" : [ 108.642860054969788, 100.0, 93.0, 22.0 ], - "saved_object_attributes" : { - "description" : "", - "digest" : "", - "globalpatchername" : "", - "tags" : "" - } -, - "text" : "p mesher" - } - - } - ], - "lines" : [ { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-1", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-5", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-8", 0 ] - } - - } -, { - "patchline" : { - "destination" : [ "obj-2", 0 ], - "source" : [ "obj-9", 0 ] - } - - } - ], - "dependency_cache" : [ { - "name" : "meshwarp.js", - "bootpath" : "~/Desktop/meshwarp", - "patcherrelativepath" : ".", - "type" : "TEXT", - "implicit" : 1 - } - ], - "autosave" : 0 - } - -}