[x3d-public] What to do with ViewpointNode and NavigationInfoNode in prototype expander

John Carlson yottzumm at gmail.com
Thu Jun 30 18:17:35 PDT 2016


examples/X3dForWebAuthors/Chapter14-Prototypes/ViewFrustumExample.json

I am prototype expanding this file from x3d resources examples.

I expand into this snippet (don’t ask how I got here, I’m trying to actually figure out what I should do?), which is not passing JSON Schema:

          "-ViewpointNode": {
              "#comment": "prefer empty description to prevent entry in player's ViewpointList"
            },
            "-NavigationInfoNode": {
              "NavigationInfo": {
                "@visibilityLimit": 15
              }
            },

I believe the leading – is coming from the -children.  However, it’s likely those objects shouldn’t even be there.  Obviously, I should be seeing that it’s an SFNode and returning the first child.  Arranging that may be more difficult. On the other hand, this is in a script node, and the prototype expander is obviously trying to set a default value or some such for the Script field…which the prototype expander likely shouldn’t be doing IDK.  I should probably leave the field as is and set a default value of the SFNode information.  Apparently, I am doing something horrible with script fields, likely if they are SFNode type.  Code is at https://github.com/coderextreme/PrototypeExpander.js  What should I do with script fields that have a default value assigned from the prototype, especially if they are SFNodes?

Complete expanded JSON follows:

{
  "X3D": {
    "encoding": "UTF-8",
    "@profile": "Immersive",
    "@version": "3.3",
    "@xsd:noNamespaceSchemaLocation": "http://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema": "http://www.web3d.org/specifications/x3d-3.3-JSONSchema.json",
    "head": {
      "meta": [
        {
          "@name": "title",
          "@content": "ViewFrustumExample.x3d"
        },
        {
          "@name": "description",
          "@content": "Display view frustum associated with a given pair of Viewpoint and NavigationInfo nodes"
        },
        {
          "@name": "creator",
          "@content": "Don Brutzman"
        },
        {
          "@name": "translated",
          "@content": "16 August 2008"
        },
        {
          "@name": "modified",
          "@content": "23 December 2010"
        },
        {
          "@name": "reference",
          "@content": "ViewFrustumPrototype.x3d"
        },
        {
          "@name": "drawing",
          "@content": "ViewFrustumComputation.png"
        },
        {
          "@name": "Image",
          "@content": "ViewFrustumOverheadView.png"
        },
        {
          "@name": "Image",
          "@content": "ViewFrustumObliqueView.png"
        },
        {
          "@name": "Image",
          "@content": "ViewpointCalculator.png"
        },
        {
          "@name": "subject",
          "@content": "view culling frustum"
        },
        {
          "@name": "identifier",
          "@content": "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14-Prototypes/ViewFrustumExample.x3d"
        },
        {
          "@name": "generator",
          "@content": "X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
        },
        {
          "@name": "license",
          "@content": "../license.html"
        },
        {
          "@name": "translated",
          "@content": "27 March 2016"
        },
        {
          "@name": "generator",
          "@content": "X3dToJson.xslt, http://www.web3d.org/x3d/stylesheets/X3dToJson.html"
        },
        {
          "@name": "warning",
          "@content": "An experimental version of X3D JSON encoding is used for this scene.  Status online at http://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
        }
      ]
    },
    "Scene": {
      "-children": [
        {
          "Viewpoint": {
            "@description": "ViewFrustum from above, looking down",
            "@orientation": [
              1,
              0,
              0,
              -1.57
            ],
            "@position": [
              0,
              40,
              0
            ]
          }
        },
        {
          "Viewpoint": {
            "@description": "ViewFrustum from point of view"
          }
        },
        {
          "Viewpoint": {
            "@description": "ViewFrustum behind point of view",
            "@position": [
              0,
              0,
              15
            ]
          }
        },
        {
          "Viewpoint": {
            "@description": "ViewFrustum oblique side view",
            "@orientation": [
              0.8005,
              0.5926,
              0.0898,
              -0.3743
            ],
            "@position": [
              -5,
              5,
              20
            ]
          }
        },
        {
          "NavigationInfo": {
            "@type": [
              "EXAMINE",
              "FLY",
              "ANY"
            ]
          }
        },
        {},
        {
          "#comment": "Example use"
        },
        {
          "Switch": {
            "@DEF": "DECLViewFrustum_INSTANCE_VisibilitySwitch",
            "@whichChoice": -1,
            "-children": [
              {
                "Transform": {
                  "@DEF": "DECLViewFrustum_INSTANCE_PositionTransform",
                  "@rotation": [
                    0,
                    1,
                    0,
                    3.14159
                  ],
                  "-children": [
                    {
                      "Transform": {
                        "@DEF": "DECLViewFrustum_INSTANCE_OrientationTransform",
                        "-children": [
                          {
                            "Shape": {
                              "-geometry": {
                                "IndexedLineSet": {
                                  "@DEF": "DECLViewFrustum_INSTANCE_FrustumLines",
                                  "@coordIndex": [
                                    0,
                                    1,
                                    2,
                                    3,
                                    0,
                                    -1,
                                    4,
                                    5,
                                    6,
                                    7,
                                    4,
                                    -1,
                                    0,
                                    4,
                                    -1,
                                    1,
                                    5,
                                    -1,
                                    2,
                                    6,
                                    -1,
                                    3,
                                    7,
                                    -1
                                  ],
                                  "-coord": {
                                    "Coordinate": {
                                      "@DEF": "DECLViewFrustum_INSTANCE_FrustumCoordinate",
                                      "@point": [
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0,
                                        0
                                      ]
                                    }
                                  }
                                }
                              },
                              "-appearance": {
                                "Appearance": {
                                  "-material": {
                                    "Material": {
                                      "@emissiveColor": [
                                        0.9,
                                        0.9,
                                        0.9
                                      ]
                                    }
                                  }
                                }
                              }
                            }
                          },
                          {
                            "Shape": {
                              "-geometry": {
                                "Extrusion": {
                                  "@DEF": "DECLViewFrustum_INSTANCE_FrustumExtrusion"
                                }
                              },
                              "-appearance": {
                                "Appearance": {
                                  "@DEF": "DECLViewFrustum_INSTANCE_FrustumAppearance",
                                  "-material": {
                                    "Material": {
                                      "@diffuseColor": [
                                        0.8,
                                        0.8,
                                        0.8
                                      ],
                                      "@transparency": 0.75
                                    }
                                  }
                                }
                              }
                            }
                          },
                          {
                            "Shape": {
                              "-geometry": {
                                "Sphere": {
                                  "@radius": 0.08
                                }
                              },
                              "-appearance": {
                                "Appearance": {
                                  "@USE": "DECLViewFrustum_INSTANCE_FrustumAppearance"
                                }
                              }
                            }
                          }
                        ]
                      }
                    }
                  ]
                }
              }
            ]
          }
        },
        {
          "Script": {
            "@DEF": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@directOutput": true,
            "@url": [
              "examples/X3dForWebAuthors/Chapter14-Prototypes/ViewFrustumPrototypeScript.js",
              "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter14-Prototypes/ViewFrustumPrototypeScript.js"
            ],
            "field": [
              {
                "@name": "visible",
                "@accessType": "inputOutput",
                "@appinfo": "Whether or not frustum geometry is rendered",
                "@type": "SFBool",
                "@value": true
              },
              {
                "@name": "visibilitySwitchSelection",
                "@accessType": "outputOnly",
                "@appinfo": "Adjust Switch selection to make geometry visible or not",
                "@type": "SFInt32"
              },
              {
                "@name": "ViewpointNode",
                "@accessType": "initializeOnly",
                "@type": "SFNode",
                "-children": {
                  "#comment": "NULL node, ProtoInstance must provide"
                }
              },
              {
                "@name": "NavigationInfoNode",
                "@accessType": "initializeOnly",
                "@type": "SFNode",
                "-children": {
                  "#comment": "NULL node, ProtoInstance must provide"
                }
              },
              {
                "@name": "FrustumCoordinate",
                "@accessType": "initializeOnly",
                "@type": "SFNode",
                "-children": [
                  {
                    "Coordinate": {
                      "@USE": "DECLViewFrustum_INSTANCE_FrustumCoordinate"
                    }
                  }
                ]
              },
              {
                "@name": "FrustumExtrusion",
                "@accessType": "initializeOnly",
                "@type": "SFNode",
                "-children": [
                  {
                    "Extrusion": {
                      "@USE": "DECLViewFrustum_INSTANCE_FrustumExtrusion"
                    }
                  }
                ]
              },
              {
                "@name": "recompute",
                "@accessType": "inputOnly",
                "@type": "SFBool"
              },
              {
                "@name": "aspectRatio",
                "@accessType": "inputOutput",
                "@appinfo": "assumed ratio height/width",
                "@type": "SFFloat",
                "@value": 0.75
              },
              {
                "@name": "position_changed",
                "@accessType": "outputOnly",
                "@type": "SFVec3f"
              },
              {
                "@name": "orientation_changed",
                "@accessType": "outputOnly",
                "@type": "SFRotation"
              },
              {
                "@name": "spine_changed",
                "@accessType": "outputOnly",
                "@type": "MFVec3f"
              },
              {
                "@name": "scale_changed",
                "@accessType": "outputOnly",
                "@type": "MFVec2f"
              },
              {
                "@name": "point_changed",
                "@accessType": "outputOnly",
                "@type": "MFVec3f"
              },
              {
                "@name": "trace",
                "@accessType": "initializeOnly",
                "@type": "SFBool",
                "@value": false
              }
            ],
            "@visible": true,
            "-ViewpointNode": {
              "#comment": "prefer empty description to prevent entry in player's ViewpointList"
            },
            "-NavigationInfoNode": {
              "NavigationInfo": {
                "@visibilityLimit": 15
              }
            },
            "@aspectRatio": 0.75,
            "@trace": true
          }
        },
        {
          "ROUTE": {
            "@fromNode": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@fromField": "visibilitySwitchSelection",
            "@toNode": "DECLViewFrustum_INSTANCE_VisibilitySwitch",
            "@toField": "whichChoice"
          }
        },
        {
          "ROUTE": {
            "@fromNode": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@fromField": "position_changed",
            "@toNode": "DECLViewFrustum_INSTANCE_PositionTransform",
            "@toField": "translation"
          }
        },
        {
          "ROUTE": {
            "@fromNode": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@fromField": "orientation_changed",
            "@toNode": "DECLViewFrustum_INSTANCE_OrientationTransform",
            "@toField": "rotation"
          }
        },
        {
          "ROUTE": {
            "@fromNode": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@fromField": "spine_changed",
            "@toNode": "DECLViewFrustum_INSTANCE_FrustumExtrusion",
            "@toField": "set_spine"
          }
        },
        {
          "ROUTE": {
            "@fromNode": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@fromField": "scale_changed",
            "@toNode": "DECLViewFrustum_INSTANCE_FrustumExtrusion",
            "@toField": "set_scale"
          }
        },
        {
          "ROUTE": {
            "@fromNode": "DECLViewFrustum_INSTANCE_GeometryComputationScript",
            "@fromField": "point_changed",
            "@toNode": "DECLViewFrustum_INSTANCE_FrustumCoordinate",
            "@toField": "point"
          }
        },
        {
          "#comment": "Visualization assists"
        },
        {
          "Inline": {
            "@DEF": "GridXZ",
            "@url": [
              "../../Savage/Tools/Authoring/GridXZ_20x20Fixed.x3d",
              "https://savage.nps.edu/Savage/Tools/Authoring/GridXZ_20x20Fixed.x3d"
            ]
          }
        },
        {
          "Transform": {
            "@scale": [
              5,
              5,
              5
            ],
            "-children": [
              {
                "Inline": {
                  "@DEF": "CoordinateAxes",
                  "@url": [
                    "../Chapter03-Grouping/CoordinateAxes.x3d",
                    "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter03-Grouping/CoordinateAxes.x3d"
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20160630/86cf19b8/attachment-0001.html>


More information about the x3d-public mailing list