<div dir="ltr"><div>And here is a version which mixes x3d and html scripting:</div><div><br></div><div><a href="https://x3d-v4-mixed-scripting.glitch.me/" target="_blank">https://x3d-v4-mixed-<wbr>scripting.glitch.me/</a><br></div><div>forkable source:</div><a href="https://glitch.com/edit/#!/x3d-v4-mixed-scripting?path=index.html:69:4" target="_blank">https://glitch.com/edit/#!/<wbr>x3d-v4-mixed-scripting?path=<wbr>index.html:69:4</a><br><div><br></div><div>The idea to use a redefinable global function in a x3d field function worked fine.</div><div><br></div><div>Above now uses regular x3d animation via timesensor and routes. The x3d script acts as an interpolator accepting set_fraction input. It does end up not using the fraction since the original animation was defined in terms of clock time. So the script also uses timestamps and the original changeY and linearX global html script functions. The redefinition of changeY via button names is unchanged.</div><div><br></div><div>It would be nicer to define the interpolators in terms of a fraction but that is secondary.</div><div><br></div><div>The x3dom approach would be to use its onOutputChange event:</div><div> <a href="https://doc.x3dom.org/tutorials/animationInteraction/onoutputchange/index.html">https://doc.x3dom.org/tutorials/animationInteraction/onoutputchange/index.html</a></div><div><br></div><div>for defining a custom interpolator.</div><div><br></div><div>-Andreas</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 12, 2017 at 10:40 AM, Andreas Plesch <span dir="ltr"><<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi Leonard,<div><br></div><div>here is a version of the example which uses cobweb with cobweb-dom for DOM API use.</div><div><br></div><div><a href="https://x3d-v4-scripting-cobweb.glitch.me/" target="_blank">https://x3d-v4-scripting-cobwe<wbr>b.glitch.me/</a><br></div><div>and</div><div><a href="https://glitch.com/edit/#!/x3d-v4-scripting-cobweb?path=index.html:63:1" target="_blank">https://glitch.com/edit/#!/x3d<wbr>-v4-scripting-cobweb?path=inde<wbr>x.html:63:1</a><br></div><div><br></div><div>The necessary changes were minor:</div><div>- The display area div needed to be replaced with a x3d canvas</div><div>- The ball div needed to become a sphere shape transform</div><div>- The ball position is set via the translation attribute rather than position style properties.</div><div><br></div><div>The viewpoint is at a distance such that 1px in the original div rectangle corresponds to about 1m in the x3d scene when viewed from the viewpoint.</div><div><br></div><div>Otherwise no changes are needed since full control via the DOM API is possible.</div><div><br></div><div>I also found that I need to update cobweb-dom to work with the latest cobweb since there were some changes in the cobweb parser. The current cobweb-dom only works with cobweb < 3.0.</div><div><br></div><div>I suppose the next question is if one can use x3d scripts instead of the html scripts or somehow mix and match. What functionality should be provided in an x3d script ? The tricky thing to try maybe to do the animation inside x3d but replace the x3d interpolator with a custom interpolator from an html script ? Maybe I can think of something.</div><div><br></div><div>-Andreas</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Aug 12, 2017 at 1:13 AM, Andreas Plesch <span dir="ltr"><<a href="mailto:andreasplesch@gmail.com" target="_blank">andreasplesch@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto"><div>I went back to the cobweb repo to very carefully read through the rather mind bending script node code in </div><div dir="auto"><br></div><div dir="auto"><a href="https://github.com/create3000/cobweb/blob/master/cobweb.js/cobweb/Components/Scripting/Script.js" target="_blank">https://github.com/create3000/<wbr>cobweb/blob/master/cobweb.js/c<wbr>obweb/Components/Scripting/Scr<wbr>ipt.js</a></div><div dir="auto"><br></div><div dir="auto">and came to the conclusion that the x3d scripts are only evaled once during initialization, contrary to what I had thought. The script text is cleverly appended with an array of all defined named functions which then becomes the return value of the eval call. These functions are then stored in a local scope this.context object, essentially as methods. Then, whenever a lifecycle function or a field function needs to be executed, the context method is called.</div><div dir="auto"><br></div><div dir="auto">One could probably expose this context object and then redefine its methods from Dom scripts. However, one would lose the cobweb constructed "with" "global" object which allows easy and standard access to x3d functions and user defined fields. It could be probably reconstructed if needed.</div><div dir="auto"><br></div><div dir="auto">I may try to convert the example to cobweb dom.</div><div dir="auto"><br></div><div dir="auto">Andreas</div><div dir="auto"><br></div><div dir="auto">-The formatting survived the direct mail but not the route through the list probably because I receive digests.</div><div dir="auto"><br><div class="gmail_extra" dir="auto"><br><div class="gmail_quote">On Aug 11, 2017 9:03 PM, "Leonard Daly" <<a href="mailto:Leonard.Daly@realism.com" target="_blank">Leonard.Daly@realism.com</a>> wrote:<br type="attribution"><blockquote class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF">
<div class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261moz-cite-prefix">I was asked by John to construct an
example illustrating the items listed below. I also have replies
to Andreas' comments. The original message is at the bottom (for
reference). I've copied the relevant questions/statements to the
top to make reading easier.<br>
<br>
First to the example. It is located at
<a class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261moz-txt-link-freetext" href="http://tools.realism.com/development/WG-Support/2017-08-09/ScriptIllustration.html" target="_blank">http://tools.realism.com/devel<wbr>opment/WG-Support/2017-08-09/S<wbr>criptIllustration.html</a><br>
It does not use Cobweb since I can't begin to figure out how to do
this in Cobweb. OTOH, if X3D is DOM integrated, then the it
shouldn't matter where various functions and methods are located.<br>
<br>
The example is strictly 2D, but I think it clearly illustrates the
goal. The default Y interpolator is nothing (no change). Selecting
different buttons change the interpolator in real-time. Each
interpolator is defined as a function. The variable 'changeY'
holds the current interpolator. When a button is pressed, the
value of 'changeY' is set to the selected interpolator. There is
no 'case' statement the uses the correct interpolator on each pass
through the animation loop.<br>
<br>
John if this doesn't illustrate the concept, please explain what
you need to see.<br>
<br>
Andreas, you have done and continue to do a lot in support of web
3D, especially wrt to X3DOM. I continue to be impressed with your
solutions to problems presented to that list. [I'll have one soon,
with a potential solution.]<br>
<br>
<br>
<div><font color="#3333ff">AP: Mixing DOM and x3d scripts is
inherently problematic since x3d scripts expect their own
environment (scope). But let's see.</font></div>
<div><font color="#3333ff"> </font></div>
<font color="#3333ff">AP: Not sure if x3d scripts should be
available globally, eg. as window.foo which means foo is global.
This would mean that any other script or framework needs to be
careful not to use the same function names.<br>
<br>
AP: window.x3d should be nicer, as a dedicated namespace. x3dom
uses the x3dom namespace.</font><br>
<br>
If X3D and HTML are fully integrated then they will be mixed. It
is now common practice to put library methods into their own
namescope. This namescope is not limited, but is prefixed by a
known library label (e.g., x3dom, THREE, etc.). Mandating that X3D
in HTML use the 'x3d' namescope would cause problems if someone
wanted to run two different libraries from the same HTML context.
iframe can fix that, but it seems overly restrictive.<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<font color="#009900">function bar(event, time) {<br>
window.foo = bar; // I would (perhaps) settle
for window.x3d.foo = bar;<br>
}<br>
</font><br>
</blockquote>
<div><br>
</div>
<font color="#3333ff">AP: This currently does not work since
cobweb goes back to the original function source each time the
script is run. But the x3d script could probably use internally
a global HTML script function which can be redefined at will, to
enable a hook into an x3d script.</font><br>
<br>
[<font color="#009900">1] <br>
</font>
<blockquote><font color="#009900"><Script ...> <!--
X3D Script node --><br>
function foo (event, time) {<br>
window.bar = foo;<br>
}<br>
</script></font><br>
</blockquote>
<br>
<font color="#3333ff">AP: This probably already works since cobweb
evals the function text almost as is.</font>
<div><font color="#3333ff"><br>
</font></div>
<div><font color="#3333ff">Is this the same as</font></div>
<div><br>
<font color="#009900">[2]<br>
</font></div>
<blockquote>
<div><font color="#009900">var foo = function (event, time)
{do_work;};</font></div>
<div><font color="#009900">window.bar = foo;</font></div>
</blockquote>
<div><font color="#3333ff"> ?</font></div>
<br>
It seems to me that eval the script text each time, especially in
an animation loop, is needlessly expensive. <br>
The two examples (indented if that works in your mail reader) are
not the same. The first example sets window.bar to be 'foo' each
time it runs. The second example only sets window.bar to be 'foo'
after the definition is processed. If there is something else
setting window.bar after the 'foo' function definition is
processed, then that definition to 'foo' is never used.<br>
<br>
<br>
<font color="#3333ff">AP: What does the SAI say about manipulating
or calling x3d script functions from the outside ? You may only
be able to remove and add complete script nodes but not work
with the script functions ?</font>
<div><font color="#3333ff"><br>
</font></div>
<font color="#3333ff">AP: Proposed text would be great. For now,
it may be productive to settle for slightly less integration by
keeping x3d scripts pretty much internal to the x3d context but
allow x3d scene control via the DOM, eg. make x3d nodes similar
to svg/html elements.</font><br>
<br>
<br>
This is my main point. DOM is an API. If X3D chooses to define an
API in HTML, then it must be done so as not to interfere with the
DOM API. Developers will use the DOM API to do things anyway. X3D
should only expand on that, not restrict that. Anything less would
not be full integration. There is no such thing as an SVG Script
tag. It is located in the same space all all HTML scripts.<br>
<br>
<br>
Leonard Daly<br>
<br>
P.S. I hope all of the formatting and styling worked.<br>
<br>
<br>
<br>
<br>
<br>
<br>
On 8/11/2017 7:33 AM, Andreas Plesch wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Date: Thu, 10 Aug 2017
18:31:25 -0700<br>
From: Leonard Daly <<a href="mailto:Leonard.Daly@realism.com" target="_blank">Leonard.Daly@realism.com</a>><br>
To: John Carlson <<a href="mailto:yottzumm@gmail.com" target="_blank">yottzumm@gmail.com</a>>, X3D
Graphics public mailing<br>
list <<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a>>,
Web3D Consortium <<a href="mailto:consortium@web3d.org" target="_blank">consortium@web3d.org</a>><br>
Cc: X3D Graphics Working Group <<a href="mailto:x3d@web3d.org" target="_blank">x3d@web3d.org</a>><br>
Subject: Re: [x3d-public] [x3d] X3D Specification
Relationships<br>
diagram<br>
</blockquote>
<div><br>
</div>
<div>Leonard, thanks for raising this, and I appreciate your
attempt to rally broader support around v4 and web
compatibility. I continue to do what I can which is not
too much these days.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On 8/10/2017 5:17 PM, John Carlson wrote:<br>
><br>
> Leonard wrote:<br>
><br>
> >and node name collisions (i.e., Script).<br>
><br>
> There has been quite a bit of progress with this and
X3DJSONLD and<br>
> X3DOM. It?s been under the covers because I have not
advertised it<br>
> much. I have several scripts running, but not the
full complement of<br>
> my examples. It does not run the X3D event model
yet, except for<br>
> initialize().<br>
><br>
> Cobweb of course, already handles this, so quit
bellyaching.<br>
><br>
<br>
Cobweb even with Andreas' DOM interface extensions does
not integrate<br>
with the DOM regarding Scripts. A full integration would
allow the<br>
following:<br>
<br>
</blockquote>
<div><br>
</div>
<div>Mixing DOM and x3d scripts is inherently problematic
since x3d scripts expect their own environment (scope).
But let's see.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
X3D Script function called 'foo'<br>
HTML script function called 'bar'<br>
<br>
In the body of bar, I should be able to redefine 'foo'. It
is (in a<br>
fully integrated system) available as window.foo.
Similarly for inside<br>
of 'foo' to change 'bar'.<br>
<br>
</blockquote>
<div><br>
</div>
<div>Not sure if x3d scripts should be available globally,
eg. as window.foo which means foo is global. This would
mean that any other script or framework needs to be
careful not to use the same function names.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
function bar(event, time) {<br>
window.foo = bar; // I would (perhaps)
settle for<br>
window.x3d.foo = bar;<br>
}<br>
<br>
</blockquote>
<div><br>
</div>
<div>window.x3d should be nicer, as a dedicated namespace.
x3dom uses the x3dom namespace.</div>
<div><br>
</div>
<div>This currently does not work since cobweb goes back to
the original function source each time the script is run.
But the x3d script could probably use internally a global
HTML script function which can be redefined at will, to
enable a hook into an x3d script.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
and<br>
<br>
<Script ...> <!-- X3D Script node --><br>
function foo (event, time) {<br>
window.bar = foo;<br>
}<br>
</script><br>
<br>
</blockquote>
<div><br>
</div>
<div>This probably already works since cobweb evals the
function text almost as is.</div>
<div><br>
</div>
<div>Is this the same as</div>
<div><br>
</div>
<div>var foo = function (event, time) {do_work;};</div>
<div>window.bar = foo;</div>
<div> ?</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I should be able to construct an object with 'foo' as a
method. E.g.,<br>
<br>
var globalVar = {};<br>
globalVar.x3d = foo;<br>
<br>
// should call the X3D script passing it a reference to
the current<br>
value of 'event' and 'time'.<br>
globalVar.x3d(event, time);<br>
<br>
</blockquote>
<div><br>
</div>
<div>It may be possible to 'export' named x3d script
functions to window.x3d, so they can be called. cobweb
would currently redefine a named function each time an x3d
script is executed.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Inside 'foo' I should be able to access any DOM element to
get it's<br>
current state or even establish an event listener.<br>
</blockquote>
<div><br>
</div>
<div>You should be able to do that in cobweb now although it
would be strange to find DOM code in an X3D script.
Perhaps for HUD of GUI purposes it could be useful,
actually.</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
I know there are some things that Cobweb can do, but there
has been no<br>
discussions in the WG for the language that would be
necessary to ensure<br>
HTML/DOM/X3D interaction like I described above.<br>
</blockquote>
<div><br>
</div>
<div>What does the SAI say about manipulating or calling x3d
script functions from the outside ? You may only be able
to remove and add complete script nodes but not work with
the script functions ?</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Unrolling scripts on the server (or at least not in the
runtime of the<br>
browser) is all fine and good, but again there has been no
discussion in<br>
the WG as to how to even approach writing that up.<br>
<br>
I will be happy to be (relatively) quiet on these points
if someone can<br>
show me working examples and proposed text to make this
work.<br>
</blockquote>
<div><br>
</div>
<div>Proposed text would be great. For now, it may be
productive to settle for slightly less integration by
keeping x3d scripts pretty much internal to the x3d
context but allow x3d scene control via the DOM, eg. make
x3d nodes similar to svg/html elements.</div>
<div><br>
</div>
<div>-Andreas</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
--<br>
*Leonard Daly*<br>
3D Systems & Cloud Consultant<br>
LA ACM SIGGRAPH Chair<br>
President, Daly Realism - /Creating the Future/<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170810/93cc05ca/attachment.html" rel="noreferrer" target="_blank">http://web3d.org/pipermail/x3<wbr>d-public_web3d.org/attachments<wbr>/20170810/93cc05ca/attachment.<wbr>html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
______________________________<wbr>_________________<br>
x3d-public mailing list<br>
<a href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a><br>
<a href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" rel="noreferrer" target="_blank">http://web3d.org/mailman/listi<wbr>nfo/x3d-public_web3d.org</a><br>
<br>
<br>
------------------------------<br>
<br>
End of x3d-public Digest, Vol 101, Issue 9<br>
******************************<wbr>************</blockquote>
</div>
<div><br><span class="gmail-m_3040691064007112017m_4854531439596135322HOEnZb"><font color="#888888"><font color="#888888">
</font></font></span></div><span class="gmail-m_3040691064007112017m_4854531439596135322HOEnZb"><font color="#888888"><font color="#888888">
-- <br>
<div class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261gmail_signature">Andreas Plesch<br>
39 Barbara Rd.<br>
Waltham, MA 02453</div>
</font></font></span></div><span class="gmail-m_3040691064007112017m_4854531439596135322HOEnZb"><font color="#888888"><font color="#888888">
</font></font></span></div><span class="gmail-m_3040691064007112017m_4854531439596135322HOEnZb"><font color="#888888"><font color="#888888">
<br>
<fieldset class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261mimeAttachmentHeader"></fieldset>
<br>
<pre>______________________________<wbr>_________________
x3d-public mailing list
<a class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261moz-txt-link-abbreviated" href="mailto:x3d-public@web3d.org" target="_blank">x3d-public@web3d.org</a>
<a class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261moz-txt-link-freetext" href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org" target="_blank">http://web3d.org/mailman/listi<wbr>nfo/x3d-public_web3d.org</a>
</pre>
</font></font></span></blockquote><span class="gmail-m_3040691064007112017m_4854531439596135322HOEnZb"><font color="#888888"><font color="#888888">
<p><br><span class="gmail-m_3040691064007112017HOEnZb"><font color="#888888">
</font></span></p><span class="gmail-m_3040691064007112017HOEnZb"><font color="#888888">
<div class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261moz-signature">-- <br>
<font class="gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261tahoma,arial,helvetica gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261san gmail-m_3040691064007112017m_4854531439596135322m_-7705566929662997561m_-2111562572881299261serif" color="#333366">
<font size="+1"><b>Leonard Daly</b></font><br>
3D Systems & Cloud Consultant<br>
LA ACM SIGGRAPH Chair<br>
President, Daly Realism - <i>Creating the Future</i></font></div></font></span></font></font></span></div></blockquote></div></div></div></div><span class="gmail-m_3040691064007112017HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="gmail-m_3040691064007112017HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_3040691064007112017m_4854531439596135322gmail_signature">Andreas Plesch<br>39 Barbara Rd.<br>Waltham, MA 02453</div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail-m_3040691064007112017gmail_signature">Andreas Plesch<br>39 Barbara Rd.<br>Waltham, MA 02453</div>
</div></div>