<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>What happens when you make it an array instead of an array of arrays?</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Sent from <a href="http://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;border:none;padding:0in'><br><b>From: </b><a href="mailto:clement@igonet.fr">Clement IGONET</a><br><b>Sent: </b>Sunday, December 20, 2015 4:49 PM<br><b>To: </b><a href="mailto:yottzumm@gmail.com">John Carlson</a><br><b>Cc: </b><a href="mailto:x3d-public@web3d.org">X3D Graphics public mailing list</a>; <a href="mailto:x3dom-users@lists.sourceforge.net">x3dom mlist</a><br><b>Subject: </b>Re: [x3d-public] More on X3D script to X3DOM scripting...conversionprogram beginning. Help is welcome.</p></div><p class=MsoNormal><span style='font-size:12.0pt;font-family:"Times New Roman",serif'><o:p> </o:p></span></p><p class=MsoNormal>geometry crossSection is missing testing with X3Djson of my own:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>{</p><p class=MsoNormal> "X3D": {</p><p class=MsoNormal> "@profile": "Immersive",</p><p class=MsoNormal> "@version": 3.3,</p><p class=MsoNormal> "@xsd:noNamespaceSchemaLocation":</p><p class=MsoNormal>"http://www.web3d.org/specifications/x3d-3.3.xsd",</p><p class=MsoNormal> "Scene": {</p><p class=MsoNormal> "-children": [{</p><p class=MsoNormal> "Transform": {</p><p class=MsoNormal> "@translation": [0, 20, 0],</p><p class=MsoNormal> "-children": [{</p><p class=MsoNormal> "Group": {</p><p class=MsoNormal> "@class": "buildingPart",</p><p class=MsoNormal> "-children": [{</p><p class=MsoNormal> "Shape": {</p><p class=MsoNormal> "-appearance": [{</p><p class=MsoNormal> "Appearance": {</p><p class=MsoNormal> "-material": [{</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>"Material": {</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> "@diffuseColor": [null, null, null],</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal> "@transparency": 0.6</p><p class=MsoNormal> }</p><p class=MsoNormal> }]</p><p class=MsoNormal> }</p><p class=MsoNormal> }],</p><p class=MsoNormal> "-geometry": [{</p><p class=MsoNormal> "Extrusion": {</p><p class=MsoNormal> "@convex": false,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>"@creaseAngle": 0.785,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>"@crossSection": [[-39.94663841462567, -39.472313797352705],</p><p class=MsoNormal>[-26.98130996805282, -33.99040391371091], [-24.13471984587026,</p><p class=MsoNormal>-37.8377483755381], [0.5505538701044541, -27.385425271266268],</p><p class=MsoNormal>[-2.2960362520781055, -23.538080809439077], [3.5528168882482545,</p><p class=MsoNormal>-21.058433944731174], [24.424104619198804, -12.21843727668515],</p><p class=MsoNormal>[30.10616537155961, -9.816626861538039], [33.00835295692408,</p><p class=MsoNormal>-13.752927264140247], [57.671387687309995, -3.3117236526628173],</p><p class=MsoNormal>[54.791439085954146, 0.6023377651406799], [68.37945912269265,</p><p class=MsoNormal>6.351115472687708], [41.848349624970105, 42.33379373503747],</p><p class=MsoNormal>[28.28256857382039, 36.59613552028483], [25.22470809249468,</p><p class=MsoNormal>40.74370628361037], [0.561673362108766, 30.30250267213294],</p><p class=MsoNormal>[3.58617536742154, 26.199409879194917], [-2.2293192968918842,</p><p class=MsoNormal>23.73088250728141], [-23.078368042253633, 14.913124824824184],</p><p class=MsoNormal>[-28.81602625779635, 12.477955931293877], [-31.907245218295344,</p><p class=MsoNormal>16.67000466579701], [-56.614757918278684, 6.206562067940691],</p><p class=MsoNormal>[-53.501299972190886, 1.992274348638849], [-66.47774791234822,</p><p class=MsoNormal>-3.500755027797344], [-39.94663841462567, -39.472313797352705]],</p><p class=MsoNormal> "@solid": false,</p><p class=MsoNormal> "@endCap": false,</p><p class=MsoNormal> "@spine":</p><p class=MsoNormal>[0, 0, 0, 0, 55, 0]</p><p class=MsoNormal> }</p><p class=MsoNormal> }]</p><p class=MsoNormal> }</p><p class=MsoNormal>(...)</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>And after converting to xml X3D with X3DJSONLD:</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN"</p><p class=MsoNormal>"http://www.web3d.org/specifications/x3d-3.3.dtd"><X3D><Scene></p><p class=MsoNormal> <X3D profile='Immersive' version='3.3'</p><p class=MsoNormal>xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.3.xsd'></p><p class=MsoNormal> <Scene></p><p class=MsoNormal> <Transform translation='0 20 0'></p><p class=MsoNormal> <Group class='buildingPart'></p><p class=MsoNormal> <Shape></p><p class=MsoNormal> <Appearance></p><p class=MsoNormal> <Material diffuseColor='' transparency='0.6'></p><p class=MsoNormal> </Material></p><p class=MsoNormal> </Appearance></p><p class=MsoNormal> <Extrusion convex='false' creaseAngle='0.785'</p><p class=MsoNormal>crossSection='' solid='false' endCap='false' spine='0 0 0 0 55 0'></p><p class=MsoNormal> </Extrusion></p><p class=MsoNormal> </Shape></p><p class=MsoNormal>(...)</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On Sat, Dec 19, 2015 at 6:26 AM, John Carlson <yottzumm@gmail.com> wrote:</p><p class=MsoNormal>> Start of a Script Expander for X3D JSON — X3D -> X3DOM scripting. I have no</p><p class=MsoNormal>> clue how initialization, shutdown or event processing will work.</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> This code is currently a MESS. This is not an example of how I like to</p><p class=MsoNormal>> present myself and I present it here in order to stimulate someone else to</p><p class=MsoNormal>> help with X3D bits I have little knowledge of. I will continue working on</p><p class=MsoNormal>> this, but some guidance would be welcome.</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> John</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> https://github.com/coderextreme/X3DJSONLD/blob/master/Script.js</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> // X3D JSON Script Expander</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> var content = '';</p><p class=MsoNormal>> // read content into buffer</p><p class=MsoNormal>> process.stdin.resume();</p><p class=MsoNormal>> process.stdin.on('data', function(buf) { content += buf.toString(); });</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> function Package(package, name) {</p><p class=MsoNormal>> this.initializers = [];</p><p class=MsoNormal>> this.getters = {};</p><p class=MsoNormal>> this.setters = {};</p><p class=MsoNormal>> this.values = {};</p><p class=MsoNormal>> this.types = {};</p><p class=MsoNormal>> this.packages = {};</p><p class=MsoNormal>> if (typeof package === 'undefined' || package.name === "") {</p><p class=MsoNormal>> if (typeof name === 'undefined') {</p><p class=MsoNormal>> this.name = "";</p><p class=MsoNormal>> } else {</p><p class=MsoNormal>> this.name = name;</p><p class=MsoNormal>> }</p><p class=MsoNormal>> } else {</p><p class=MsoNormal>> if (typeof name === 'undefined') {</p><p class=MsoNormal>> this.name = package.name;</p><p class=MsoNormal>> } else {</p><p class=MsoNormal>> this.name = package.name+'.'+name;</p><p class=MsoNormal>> }</p><p class=MsoNormal>> package.packages[name] = this;</p><p class=MsoNormal>> }</p><p class=MsoNormal>> // initialize children packages</p><p class=MsoNormal>> // add package to parent so you can find the package without full path</p><p class=MsoNormal>> }</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> Package.prototype.find = function (name) {</p><p class=MsoNormal>> if (typeof this.packages[name] === 'undefined') {</p><p class=MsoNormal>> // there is no package, so global package</p><p class=MsoNormal>> return new Package(undefined, name);</p><p class=MsoNormal>> } else {</p><p class=MsoNormal>> return this.packages[name];</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> function processPrototypes(object, clazz, package) {</p><p class=MsoNormal>> var p;</p><p class=MsoNormal>> if (typeof object === "object") {</p><p class=MsoNormal>> for (p in object) {</p><p class=MsoNormal>> var name = object[p]["@name"];</p><p class=MsoNormal>> if (typeof name === 'undefined') {</p><p class=MsoNormal>> name = object[p]["@DEF"];</p><p class=MsoNormal>> }</p><p class=MsoNormal>> if (p.toLowerCase() === 'script') {</p><p class=MsoNormal>> var script = new Package(package, name);</p><p class=MsoNormal>> processPrototypes(object[p], clazz, script);</p><p class=MsoNormal>> } else if (p.toLowerCase() === 'route') {</p><p class=MsoNormal>> processRoutes(object[p], clazz, package);</p><p class=MsoNormal>> } else if (p.toLowerCase() === 'field' && object['@language'] !== 'GLSL') {</p><p class=MsoNormal>> processFields(object[p], package);</p><p class=MsoNormal>> clazz.push('var ' + package.name + ' = function(' +</p><p class=MsoNormal>> package.initializers.join(', ') + ') {');</p><p class=MsoNormal>> clazz.push('var that = this;');</p><p class=MsoNormal>> clazz.push('this.setters = {};');</p><p class=MsoNormal>> clazz.push('this.getters = {};');</p><p class=MsoNormal>> for (var v in package.values) {</p><p class=MsoNormal>> if (package.types[v].indexOf("MF") === 0) {</p><p class=MsoNormal>> clazz.push('var that.' + v + ' = ['+ package.values[v] + '];');</p><p class=MsoNormal>> } else {</p><p class=MsoNormal>> clazz.push('var that.' + v + ' = '+ package.values[v] + ';');</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>> for (var v in package.getters) {</p><p class=MsoNormal>> clazz.push('this.getters.' + v + ' = function () { return that.' + v + ';</p><p class=MsoNormal>> };');</p><p class=MsoNormal>> }</p><p class=MsoNormal>> processSource(object['#sourceText'], clazz, package);</p><p class=MsoNormal>> clazz.push('}');</p><p class=MsoNormal>> processPrototypes(object[p], clazz, package);</p><p class=MsoNormal>> } else if (p.toLowerCase() === '@use') {</p><p class=MsoNormal>> var name = object["@USE"];</p><p class=MsoNormal>> object["@USE"] = name;</p><p class=MsoNormal>> // object[p] is not an object</p><p class=MsoNormal>> } else if (p.toLowerCase() === '@def') {</p><p class=MsoNormal>> var name = object["@DEF"];</p><p class=MsoNormal>> object["@DEF"] = name;</p><p class=MsoNormal>> // object[p] is not an object</p><p class=MsoNormal>> } else {</p><p class=MsoNormal>> processPrototypes(object[p], clazz, package);</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> function processRoutes(routes, clazz, package) {</p><p class=MsoNormal>> clazz.push("this.runRoute = function() {");</p><p class=MsoNormal>> var r;</p><p class=MsoNormal>> for (r in routes) {</p><p class=MsoNormal>> var route = routes[r];</p><p class=MsoNormal>> var fromNode = route["@fromNode"];</p><p class=MsoNormal>> var fromField = route["@fromField"];</p><p class=MsoNormal>> var toNode = route["@toNode"];</p><p class=MsoNormal>> var toField = route["@toField"];</p><p class=MsoNormal>> clazz.push(package.name+'.this.'+toNode+'.setters.'+toField+'('+package.name+'.this.'+fromNode+'.getters.'+fromField+'());');</p><p class=MsoNormal>> }</p><p class=MsoNormal>> clazz.push("};");</p><p class=MsoNormal>> }</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> function processFields(fields, package) {</p><p class=MsoNormal>> var f;</p><p class=MsoNormal>> for (f in fields) {</p><p class=MsoNormal>> var object = fields[f];</p><p class=MsoNormal>> var name = object["@name"];</p><p class=MsoNormal>> package.types[name] = object["@type"];</p><p class=MsoNormal>> switch(object['@accessType']) {</p><p class=MsoNormal>> case 'initializeOnly':</p><p class=MsoNormal>> // these should be in order, so it's an array</p><p class=MsoNormal>> package.initializers.push(name);</p><p class=MsoNormal>> package.values[name] = object["@value"];</p><p class=MsoNormal>> break;</p><p class=MsoNormal>> case 'inputOutput':</p><p class=MsoNormal>> // setters should be looked up by name</p><p class=MsoNormal>> package.setters[name] = object;</p><p class=MsoNormal>> package.getters[name] = object;</p><p class=MsoNormal>> package.values[name] = object["@value"];</p><p class=MsoNormal>> break;</p><p class=MsoNormal>> case 'inputOnly':</p><p class=MsoNormal>> // setters should be looked up by name</p><p class=MsoNormal>> package.setters[name] = object;</p><p class=MsoNormal>> package.values[name] = object["@value"];</p><p class=MsoNormal>> break;</p><p class=MsoNormal>> case 'outputOnly':</p><p class=MsoNormal>> break;</p><p class=MsoNormal>> package.getters[name] = object;</p><p class=MsoNormal>> default:</p><p class=MsoNormal>> break;</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> function processSource(lines, clazz, package) {</p><p class=MsoNormal>> if (typeof lines !== 'undefined') {</p><p class=MsoNormal>> var functions = lines.join("\n").split("function");</p><p class=MsoNormal>> var f;</p><p class=MsoNormal>> for (var f = 1; f < functions.length; f++) { // skip ecmascript:</p><p class=MsoNormal>> var func = functions[f];</p><p class=MsoNormal>> var sp = func.indexOf('(');</p><p class=MsoNormal>> var name = func.substr(0, sp).trim();</p><p class=MsoNormal>> var funcvar = 'this.' + name; // a non setter function</p><p class=MsoNormal>> if (typeof package.setters[name] !== 'undefined') {</p><p class=MsoNormal>> funcvar = 'this.setters.' + name; // a setter function</p><p class=MsoNormal>> }</p><p class=MsoNormal>> clazz.push(funcvar + ' = function ' + func.substr(sp));</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>> }</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> process.stdin.on('end', function() {</p><p class=MsoNormal>> var object = JSON.parse(content);</p><p class=MsoNormal>> var clazz = [];</p><p class=MsoNormal>> processPrototypes(object, clazz, new Package());</p><p class=MsoNormal>> console.log(clazz.join('\n'));</p><p class=MsoNormal>> //console.log(JSON.stringify(object, null, 2));</p><p class=MsoNormal>> });</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>> _______________________________________________</p><p class=MsoNormal>> x3d-public mailing list</p><p class=MsoNormal>> x3d-public@web3d.org</p><p class=MsoNormal>> http://web3d.org/mailman/listinfo/x3d-public_web3d.org</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>