<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-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="moz-txt-link-freetext" href="http://tools.realism.com/development/WG-Support/2017-08-09/ScriptIllustration.html">http://tools.realism.com/development/WG-Support/2017-08-09/ScriptIllustration.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"
cite="mid:CAKdk67v=p4F+ev30DOkEsmxm5RdMba-bY0zu9mrsn77qaBFx=A@mail.gmail.com">
<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"
moz-do-not-send="true">Leonard.Daly@realism.com</a>><br>
To: John Carlson <<a href="mailto:yottzumm@gmail.com"
moz-do-not-send="true">yottzumm@gmail.com</a>>, X3D
Graphics public mailing<br>
list <<a href="mailto:x3d-public@web3d.org"
moz-do-not-send="true">x3d-public@web3d.org</a>>,
Web3D Consortium <<a href="mailto:consortium@web3d.org"
moz-do-not-send="true">consortium@web3d.org</a>><br>
Cc: X3D Graphics Working Group <<a
href="mailto:x3d@web3d.org" moz-do-not-send="true">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" moz-do-not-send="true">http://web3d.org/pipermail/<wbr>x3d-public_web3d.org/<wbr>attachments/20170810/93cc05ca/<wbr>attachment.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"
moz-do-not-send="true">x3d-public@web3d.org</a><br>
<a
href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://web3d.org/mailman/<wbr>listinfo/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>
</div>
-- <br>
<div class="gmail_signature">Andreas Plesch<br>
39 Barbara Rd.<br>
Waltham, MA 02453</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
x3d-public mailing list
<a class="moz-txt-link-abbreviated" href="mailto:x3d-public@web3d.org">x3d-public@web3d.org</a>
<a class="moz-txt-link-freetext" href="http://web3d.org/mailman/listinfo/x3d-public_web3d.org">http://web3d.org/mailman/listinfo/x3d-public_web3d.org</a>
</pre>
</blockquote>
<p><br>
</p>
<div class="moz-signature">-- <br>
<font class="tahoma,arial,helvetica san serif" 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>
</body>
</html>