[x3d-public] Script Illustrative Example [was: X3D Specification Relationshipsdiagram]
John Carlson
yottzumm at gmail.com
Fri Aug 11 19:07:30 PDT 2017
Sent from Mail for Windows 10
From: Leonard Daly
Sent: Friday, August 11, 2017 9:03 PM
To: X3D Graphics public mailing list
Cc: Andreas Plesch; John Carlson
Subject: Script Illustrative Example [was: X3D Specification Relationshipsdiagram]
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.
First to the example. It is located at http://tools.realism.com/development/WG-Support/2017-08-09/ScriptIllustration.html
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.
Let’s see if I can extract the salient points of the link, so we know what to show in Cobweb:
1. getElementById
2. window.requestAnimationFrame/event loop
3. setAttribute of style to set position
4. Functions with time and more than 2 parameters
5. Use of a field or attribute to set a function, and using window to find the function.
6. Easy access to a position array.
Is that all the salient points we need to show in Cobweb? I will likely implement the whole thing anyway, and I have the feeling that it can be done, perhaps with or without the window object.
It seems to me that eval the script text each time, especially in an animation loop, is needlessly expensive.
What I currently eval each loop in X3DJSONLD are the events that need to fire for the Script to interact with ROUTEs, and probably a subset of those (TimeSensor comes to mind). The rest of the script can be eval’ed once. I have 3 evals, one for the script and setup, one for initializeOnly routes, and one for the main event loop. The loop itself is not eval’ed and kept external. Conceivably, I could put the loop in the eval block and have it only eval once (but then it would be hard to set and clear breakpoints possibly). Each time a new X3D JSON file is loaded, the contents of the eval’s may be wiped out (they are no longer referenced, but may stick around in memory, I am not sure). In any case, putting the event loop in the eval is a performance enhancement, and I’m not into performance at this point, debugging is more important. I am sorry if you are criticizing my implementation, but no harm taken (thanks for the advice in fact). A simple fix is all that is required, and has been done before.
I actually eval everything twice in X3DJSONLD, I believe, once per X3DOM canvas.
John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20170811/e153e7b3/attachment.html>
More information about the x3d-public
mailing list