[x3d-public] [x3d] V4.0 Open discussion/workshop on X3D HTMLintegration > brainstorming > protos

John Carlson yottzumm at gmail.com
Fri Jun 10 09:00:20 PDT 2016


>If so, how do they do it, without confusing the scripts?

Here’s one way to introduce stuff into the JavaScript without having a name space except for the global one:


(function() {
	// stuff here
})();

It’s called an IIFE

Other ways are to introduce objects or arrays to store your instances.

Attached is the JavaScript code (as xxx.txt) to move two nodes, nodeA and nodeB and a cylinder between them.  The original code only had one script for nodeA and nodeB as proto instances.  It is attached as for.json.  The prototype expanded code is attached as forppp.json.  I can provide XML as desired.  Ultimately, the JSON is moved into DOM and is addressed with Jquery in the “routes”.

This code doesn’t actually work yet, but it’s meant as an example as to what we might do.  As you can see, DEFing scripts with instance names might actually work okay (but I am still working on it).

This obviously is my brainchild, but it does show what you can do with JavaScript.

John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160610/bbd7902a/attachment-0001.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: xxx.txt
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160610/bbd7902a/attachment-0001.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: for.json
Type: application/json
Size: 13604 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160610/bbd7902a/attachment-0002.json>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: forppp.json
Type: application/json
Size: 18581 bytes
Desc: not available
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160610/bbd7902a/attachment-0003.json>


More information about the x3d-public mailing list