{ "X3D": {
    "encoding":"UTF-8",
    "@profile":"Immersive",
    "@version":"3.3",
    "@xsd:noNamespaceSchemaLocation":"https://www.web3d.org/specifications/x3d-3.3.xsd",
    "JSON schema":"https://www.web3d.org/specifications/x3d-4.0-JSONSchema.autogenerated.json",
    "head": {
        "meta": [
          {
            "@name":"title",
            "@content":"Flames.x3d"
          },
          {
            "@name":"description",
            "@content":"Flickering flames: this prototype declaration illustrates the use of a script to cycle between textures, and then encapsulation of the script, a clock, and a polygon, all within a new Flames prototype node that makes flickering flames. See the Match.x3d scene for an example."
          },
          {
            "@name":"creator",
            "@content":"David R. Nadeau"
          },
          {
            "@name":"translator",
            "@content":"Don Brutzman"
          },
          {
            "@name":"created",
            "@content":"1 July 1998"
          },
          {
            "@name":"translated",
            "@content":"2 February 2014"
          },
          {
            "@name":"modified",
            "@content":"20 October 2019"
          },
          {
            "@name":"reference",
            "@content":"Match.x3d"
          },
          {
            "@name":"reference",
            "@content":"originals/flames.wrl"
          },
          {
            "@name":"reference",
            "@content":"http://www.siggraph.org/s98"
          },
          {
            "@name":"reference",
            "@content":"http://www.siggraph.org/s98/conference/courses/18.html"
          },
          {
            "@name":"reference",
            "@content":"http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0499.htm"
          },
          {
            "@name":"reference",
            "@content":"http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm"
          },
          {
            "@name":"reference",
            "@content":"https://www.web3d.org/x3d/content/examples/X3dResources.html"
          },
          {
            "@name":"identifier",
            "@content":"https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Flames.x3d"
          },
          {
            "@name":"generator",
            "@content":"Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html"
          },
          {
            "@name":"generator",
            "@content":"X3D-Edit, https://www.web3d.org/x3d/tools/X3D-Edit"
          },
          {
            "@name":"license",
            "@content":"../license.html"
          },
          {
            "@name":"translated",
            "@content":"17 April 2026"
          },
          {
            "@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":[
          {
            "#comment":"Three flame textures are used: flames1.png flames2.png flames3.png"
          },
          {
            "#comment":"All three textures have a transparency channel (alpha channel) so that areas outside of the flame are transparent."
          },
          {
            "#comment":"flame1.png was hand-drawn in PhotoShop. The other two flames were created by applying the PhotoShop 'Twirl' filter to several parts of the original flame. This creates a curling effect that looks vaugely flame-like. For a better effect, use more flame images and more care in applying the Twirl filter... or hand draw them all."
          },
          { "WorldInfo":
            {
              "@info":["Copyright (c) 1997, David R. Nadeau"],
              "@title":"Flickering Flames"
            }
          },
          { "ProtoDeclare":
            {
              "@name":"Flames",
              "ProtoInterface": {
                  "field": [
                    {
                      "@name":"startTime",
                      "@accessType":"initializeOnly",
                      "@type":"SFTime",
                      "@value":0.0
                    },
                    {
                      "@name":"cycleInterval",
                      "@accessType":"initializeOnly",
                      "@type":"SFTime",
                      "@value":1.0
                    }
                  ]
              },
              "ProtoBody": {
                  "-children":[
                    { "Shape":
                      {
                        "-appearance":
                          { "Appearance":
                            {
                              "@DEF":"FlameAppearance"
                            }
                          },
                        "-geometry":
                          { "IndexedFaceSet":
                            {
                              "@coordIndex":[0,1,2,3],
                              "@solid":false,
                              "@texCoordIndex":[0,1,2,3],
                              "-texCoord":
                                { "TextureCoordinate":
                                  {
                                    "@point":[0.0,0.0,1.0,0.0,1.0,1.0,0.0,1.0]
                                  }
                                },
                              "-coord":
                                { "Coordinate":
                                  {
                                    "@point":[-0.5,0.0,0.0,0.5,0.0,0.0,0.5,1.8,0.0,-0.5,1.8,0.0]
                                  }
                                }
                            }
                          }
                      }
                    },
                    { "TimeSensor":
                      {
                        "@DEF":"Clock",
                        "@loop":true,
                        "IS": {
                            "connect": [
                              {
                                "@nodeField":"startTime",
                                "@protoField":"startTime"
                              },
                              {
                                "@nodeField":"cycleInterval",
                                "@protoField":"cycleInterval"
                              }
                            ]
                        }
                      }
                    },
                    { "Script":
                      {
                        "@DEF":"FlameSelector",
                        "@directOutput":true,
                        "field": [
                          {
                            "@name":"flameTextures",
                            "@accessType":"initializeOnly",
                            "@type":"MFNode",
                            "-children":[
                              { "ImageTexture":
                                {
                                  "@DEF":"Flame1",
                                  "@repeatS":false,
                                  "@repeatT":false,
                                  "@url":["flames1.png","https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames1.png"]
                                }
                              },
                              { "ImageTexture":
                                {
                                  "@repeatS":false,
                                  "@repeatT":false,
                                  "@url":["flames2.png","https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames2.png"]
                                }
                              },
                              { "ImageTexture":
                                {
                                  "@USE":"Flame1"
                                }
                              },
                              { "ImageTexture":
                                {
                                  "@repeatS":false,
                                  "@repeatT":false,
                                  "@url":["flames3.png","https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames3.png"]
                                }
                              }
                            ]
                          },
                          {
                            "@name":"texture_changed",
                            "@accessType":"outputOnly",
                            "@type":"SFNode"
                          },
                          {
                            "@name":"set_fraction",
                            "@accessType":"inputOnly",
                            "@type":"SFFloat"
                          }
                        ],
                        "#sourceCode":[
"",
"",
"ecmascript:",
"    function set_fraction( f, tm ) {",
"            if ( f < 0.25 )",
"                    texture_changed = flameTextures[0];",
"            else if ( f < 0.50 )",
"                    texture_changed = flameTextures[1];",
"            else if ( f < 0.75 )",
"                    texture_changed = flameTextures[2];",
"            else",
"                    texture_changed = flameTextures[3];",
"    }",
"",
""
]
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"fraction_changed",
                        "@fromNode":"Clock",
                        "@toField":"set_fraction",
                        "@toNode":"FlameSelector"
                      }
                    },
                    { "ROUTE":
                      {
                        "@fromField":"texture_changed",
                        "@fromNode":"FlameSelector",
                        "@toField":"set_texture",
                        "@toNode":"FlameAppearance"
                      }
                    }
                  ]
              }
            }
          },
          {
            "#comment":"Display scene instructions for viewing an example scene with a corresponding prototype instance"
          },
          { "Background":
            {
              "@skyColor":[0,0.333333,0.66667]
            }
          },
          { "Anchor":
            {
              "@description":"select text to view parent scene",
              "@url":["Match.x3d","https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Match.x3d","Match.wrl","https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Match.wrl"],
              "-children":[
                { "Shape":
                  {
                    "-geometry":
                      { "Text":
                        {
                          "@string":["The Flames.x3d scene holds","a prototype declaration","Select this text to view example usage","in Match.x3d scene"],
                          "-fontStyle":
                            { "FontStyle":
                              {
                                "@justify":["MIDDLE","MIDDLE"],
                                "@style":"BOLD"
                              }
                            }
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@diffuseColor":[1,0.9,0.4]
                              }
                            }
                        }
                      }
                  }
                },
                {
                  "#comment":"Invisible box behind text makes selection easier"
                },
                { "Shape":
                  {
                    "-geometry":
                      { "Box":
                        {
                          "@size":[12,5,0.1]
                        }
                      },
                    "-appearance":
                      { "Appearance":
                        {
                          "-material":
                            { "Material":
                              {
                                "@transparency":1
                              }
                            }
                        }
                      }
                  }
                }
              ]
            }
          }
        ]
    }
  }
}