{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.1",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.1.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"CreateNodesFromPrototypeECMAScript.x3d"
          },
          {
            "@name":"description",
            "@content":"This example shows creation of nodes from a prototype"
          },
          {
            "@name":"creator",
            "@content":"X3D Specification"
          },
          {
            "@name":"translated",
            "@content":"23 February 2005"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"subject",
            "@content":"X3D ECMAScript Script Authoring Interface (SAI)"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/CreateNodesFromPrototypeECMAScript.x3d"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/specifications/ISO-IEC-19777-1-X3DLanguageBindings-ECMAScript/Part1/examples.html#CreateNodesFromAPrototype"
          },
          {
            "@name":"generator",
            "@content":"Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"02 September 2025"
          },
          {
            "@name":"generator",
            "@content":"X3dToJson.xslt, https://www.web3d.org/x3d/stylesheets/X3dToJson.html"
          },
          {
            "@name":"reference",
            "@content":"X3D JSON encoding: https://www.web3d.org/wiki/index.php/X3D_JSON_Encoding"
          }
        ]
    },
    "Scene": {
        "-children":[
          { "WorldInfo":
            {
              "@title":"CreateNodesFromPrototypeECMAScript.x3d"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"ColoredSphere",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"color",
                      "@accessType":"initializeOnly",
                      "@type":"SFColor",
                      "@value":[0.0,0.0,0.0]
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Shape":
                      {
                        "-appearance":
                          { "Appearance":
                            {
                              "-material":
                                { "Material":
                                  {
                                    "IS": {
                                        "connect": [
                                          {
                                            "@nodeField":"diffuseColor",
                                            "@protoField":"color"
                                          }
                                        ]
                                    }
                                  }
                                }
                            }
                          },
                        "-geometry":
                          { "Sphere":
                            {
                            }
                          }
                      }
                    }
                  ]
              }
            }
          },
          { "Script":
            {
              "@DEF":"SC",
              "#sourceCode":[
"",
"",
"ecmascript:",
"",
"// Create nodes directly in the parent scene",
"",
"function initialize()",
"{",
"    scene = Browser.currentScene;",
"",
"    // Look through proto declarations for ColoredSphere",
"    protoDecls = scene.protoDeclarations;",
"",
"    var protoDecl;",
"",
"    for(i=0; i < protoDecls.length; i++) {",
"        if (protoDecls[i].name == 'ColoredSphere')",
"            protoDecl = protoDecls[i];",
"    }",
"",
"    // Create an instance of RedSphere",
"    instance = protoDecl.newInstance();",
"",
"    // Set the color field to Red",
"    instance.color = new SFColor(1,0,0);",
"",
"    // Add the created proto to the scene",
"    scene.rootNodes[0] = instance;",
"}",
"",
""
]
            }
          }
        ]
    }
  }
}