[x3d-public] JSON Script encoding [was announce: updated encoding, X3D to JSON Stylesheet Converter: string arrays, whitespace, UTF-8, Script #source]

Don Brutzman brutzman at nps.edu
Mon Nov 23 11:07:14 PST 2015


thanks for the steady progress, apologies for delayed reply.

As described on the html page, #sourceText is intended only for the 3 nodes which can contain scripting code:  Script, ShaderPart and ShaderProgram nodes.

Only one CDATA text block is allowed for each of these nodes in the XML encoding.  This option was provided so that source text didn't have to get smashed into the url attribute, which would clobber line spacing when canonicalized.  anywhere else is invalid X3D.

Since only one #sourceText can appear in each of these three nodes, and nowhere else, it is completely encapsulated and external scope is a non-issue.


On 11/21/2015 1:01 AM, John Carlson wrote:
> For example:
>
> www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/TimeOfDay.json <http://www.web3d.org/x3d/content/examples/Savage/Environment/TimeOfDay/TimeOfDay.json>

actual links at
https://savage.nps.edu/Savage/Environment/TimeOfDay/

that one is pretty old, i will look at cleaning it up.

am hoping we can do some simple examples first, walking before running with Scripts and Protos and fields oh my.

got Hello World?

> has 3 set_boolean functions and in 3 different scripts.  It would seem like I should treat these differently.  I was thinking about adding a numbered object around the functions to create some scope for the function, but I think I’ll have to deal with fields, and routes to those fields etc. etc. If cobweb can handle multiple functions with the same name (can it?), can we use it?  I’m pretty sure ordinary JavaScript will overwrite the function declaration if it sees another one.
>
> I will try a basic load for right now.  I think we’ll need something more complex.
>
> John
>> On Nov 20, 2015, at 10:35 AM, John Carlson <yottzumm at gmail.com <mailto:yottzumm at gmail.com>> wrote:
>>
>> Which is why I brought up name scopes.  Should we try a JSON -> Cobweb loader instead of a JSON -> X3DOM loader?
>>
>> On Nov 20, 2015 9:07 AM, "Leonard Daly" <web3d at realism.com <mailto:web3d at realism.com>> wrote:
>>
>>     I think trying to figure out the encoding of a Script node is getting a little ahead of things.
>>
>>     JSON code is typically executed to create the data structure(s). In this case it appears that the result will be to put the script code into a variable that needs to be executed again. Unless JSON is to be used as another encoding for storage and transport, I think the use within HTML needs to be settled first.
>>
>>
>>     Leonard Daly
>>
>>
>>>     The 3-way option for Script #source is now deployed in the examples, described on the X3dToJson stylesheet page, and implemented in X3D-Edit to facilitate testing.  Conversion parameters panel screenshot attached.
>>>
>>>     http://www.web3d.org/x3d/stylesheets/X3dToJson.html#Options
>>>     https://savage.nps.edu/X3D-Edit/#new
>>>     https://savage.nps.edu/X3D-Edit/images/X3dToJsonConversionPanel.png
>>>
>>>     On 11/18/2015 4:43 PM, Don Brutzman wrote:
>>>>     OK and now for the next level for Script source code in JSON form...
>>>>
>>>>          "When you come to a fork in the road, take it." Yogi Berra
>>>>
>>>>     John:  let's make the #source content a string array, and then authors/tools/files can use any of the three forms equivalently.  first 2 out of 3 pass jslint, likely 3 out of 3 just plain work.
>>>>
>>>>     as before, but in consistent ["string-array"] form:
>>>>
>>>>     - array of one plaintext block string.
>>>>     - array of one single-line string with all linefeeds and tabs escaped as \n and \t.
>>>>     - array of multiple one-line strings as shown below.
>>>>
>>>>     A commonly acceptable solution for each of the alternatives takes all the sting out of any choice, we don't have to worry about tradeoff advantages/disadvantages.
>>>>
>>>>     Pretty exciting that a no-lose approach might exist to cope with this situation!  8)
>>>>
>>>>     So I will change stylesheet support for the three alternatives to all be string _array_ and rebuild the examples.
>>>>[...]


all the best, Don
-- 
Don Brutzman  Naval Postgraduate School, Code USW/Br       brutzman at nps.edu
Watkins 270,  MOVES Institute, Monterey CA 93943-5000 USA   +1.831.656.2149
X3D graphics, virtual worlds, navy robotics http://faculty.nps.edu/brutzman



More information about the x3d-public mailing list