<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Immersive'  version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' https://www.web3d.org/specifications/x3d-3.3.xsd ' >
<head>
<meta name='titlecontent='Flames.x3d'/>
<meta name='descriptioncontent='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.'/>
<meta name='creatorcontent='David R. Nadeau'/>
<meta name='translatorcontent='Don Brutzman'/>
<meta name='createdcontent='1 July 1998'/>
<meta name='translatedcontent='2 February 2014'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name='referencecontent='Match.x3d'/>
<meta name='referencecontent='originals/flames.wrl'/>
<meta name='referencecontent=' http://www.siggraph.org/s98 '/>
<meta name='referencecontent=' http://www.siggraph.org/s98/conference/courses/18.html '/>
<meta name='referencecontent=' http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0499.htm '/>
<meta name='referencecontent=' http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm '/>
<meta name='referencecontent=' https://www.web3d.org/x3d/content/examples/X3dResources.html '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Flames.x3d '/>
<meta name='generatorcontent='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/>
<meta name='generatorcontent='X3D-Edit, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: Clock, Flame1, FlameAppearance, FlameSelector

Index for ProtoDeclare definition: Flames
-->
<Scene>
<!-- Three flame textures are used: flames1.png flames2.png flames3.png -->
<!-- All three textures have a transparency channel (alpha channel) so that areas outside of the flame are transparent. -->
<!-- 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='startTimetype='SFTimevalue='0.0accessType='initializeOnly'/>
<field name='cycleIntervaltype='SFTimevalue='1.0accessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<Shape>
<!-- ROUTE information for FlameAppearance node:  [from FlameSelector.texture_changed to set_texture ] -->
<Appearance DEF='FlameAppearance'/>

<IndexedFaceSet solid='falsecoordIndex='0 1 2 3texCoordIndex='0 1 2 3'>
<TextureCoordinate point='0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0'/>
<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'/>
</IndexedFaceSet>
</Shape>
<!-- ROUTE information for Clock node:  [from fraction_changed to FlameSelector.set_fraction ] -->
<TimeSensor DEF='Clockloop='true'>
<IS>
<connect nodeField='startTimeprotoField='startTime'/>
<connect nodeField='cycleIntervalprotoField='cycleInterval'/>
</IS>
</TimeSensor>
<!-- ROUTE information for FlameSelector node:  [from Clock.fraction_changed to set_fraction ] [from texture_changed to FlameAppearance.set_texture ] -->
<Script DEF='FlameSelectordirectOutput='true'>
<field name='flameTexturestype='MFNodeaccessType='initializeOnly'>
<ImageTexture DEF='Flame1repeatS='falserepeatT='false'
  url=' "flames1.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames1.png " ' />

<ImageTexture repeatS='falserepeatT='false'
  url=' "flames2.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames2.png " ' />

<ImageTexture USE=' Flame1'/>
<ImageTexture repeatS='falserepeatT='false'
  url=' "flames3.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames3.png " ' />
</field>
<field name='texture_changedtype='SFNodeaccessType='outputOnly'/>
<field name='set_fractiontype='SFFloataccessType='inputOnly'/>
<![CDATA[
          
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];
    }

        
]]>
</Script>
< ROUTE  fromNode=' Clock' fromField='fraction_changed' toNode=' FlameSelector' toField='set_fraction'/>
< ROUTE  fromNode=' FlameSelector' fromField='texture_changed' toNode=' FlameAppearance' toField='set_texture'/>
</ProtoBody>
</ProtoDeclare>
<!-- 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" ' >
<Shape>
<Text string='"The Flames.x3d scene holds" "a prototype declaration" "" "Select this text to view example usage" "in Match.x3d scene"'>
<FontStyle justify='"MIDDLE" "MIDDLE"style='BOLD'/>
</Text>
<Appearance>
<Material diffuseColor='1 0.9 0.4'/>
</Appearance>
</Shape>
<!-- Invisible box behind text makes selection easier -->
<Shape>
<Box size='12 5 0.1'/>
<Appearance>
<Material transparency='1'/>
</Appearance>
</Shape>
</Anchor>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: Clock, Flame1, FlameAppearance, FlameSelector

Index for ProtoDeclare definition: Flames
-->

Event Graph ROUTE Table entries with 2 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

Clock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
FlameSelector
Script
set_fraction
SFFloat

 
 
then
FlameSelector
Script
texture_changed
SFNode

ROUTE
event to
(2)
FlameAppearance
Appearance
set_texture
SFNode



-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/FlamesIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Flames.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
    <ProtoDeclare name='ProtoName'> <field name='fieldName'/> </ProtoDeclare> -->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->