[x3d-public] X3DOM X3DScript examples.
John Carlson
yottzumm at gmail.com
Fri Jul 3 16:21:51 PDT 2020
I awoke this morning with a plan in mind to convert X3DScripts to script
code, using new Function. So far, I have just the first few steps. A big
next step is parsing function names. Comments are welcome. So are
contributions to https://github.com/coderextreme/x3domx3dscripting.
=======================================================
// Copyright 2020 John W Carlson. Licensing at link above.
let scripts = [];
scripts[0] = new Function (
// CDATA text follows
`ecmascript:
function initialize() {
console.log("initialize");
}
function shutdown() {
console.log("shutdown");
}
// add the following after the CDATA text
initialize();
// I need to generate this assignment for all the functions in the
script. I don't have a good way to parse the function names yet.
this.shutdown = shutdown;
return this;`)();
scripts[0].shutdown();
===============================================================
On Tue, Jun 30, 2020 at 9:32 PM John Carlson <yottzumm at gmail.com> wrote:
> I am currently thinking about how to handle things like "initialize()". I
> know I need at most one for each X3DScript element. I do not currently
> have a good way to put these in a separate scope so they don't overwrite
> each other. I can create an object to put the script functions in. I do
> not know if something like new Function() could help with this. I feel
> like I'm stumbling in the dark even though I already did this in
> node/Script.js. If I could look at the code for ProtoDeclare (where is
> it?), perhaps it would help?
>
> What I'd like to do is enable ROUTEing to/from scripts by using the X3DOM
> infrastructure. I do not know how to do this yet, or if it's automatically
> done for me.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20200703/60005e37/attachment.html>
More information about the x3d-public
mailing list