1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
|
3 | <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'> |
4 | <head> |
5 | <meta name='title' content='Flames.x3d'/> |
6 | <meta 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.'/> |
7 | <meta name='creator' content='David R. Nadeau'/> |
8 | <meta name='translator' content='Don Brutzman'/> |
9 | <meta name='created' content='1 July 1998'/> |
10 | <meta name='translated' content='2 February 2014'/> |
11 | <meta name='modified' content='20 October 2019'/> |
12 | <meta name='reference' content='Match.x3d'/> |
13 | <meta name='reference' content='originals/flames.wrl'/> |
14 | <meta name='reference' content='http://www.siggraph.org/s98'/> |
15 | <meta name='reference' content='http://www.siggraph.org/s98/conference/courses/18.html'/> |
16 | <meta name='reference' content='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/mt0499.htm'/> |
17 | <meta name='reference' content='http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/vrml97.htm'/> |
18 | <meta name='reference' content='https://www.web3d.org/x3d/content/examples/X3dResources.html'/> |
19 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Flames.x3d'/> |
20 | <meta name='generator' content='Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html'/> |
21 | <meta name='generator' content='X3D-Edit, https://savage.nps.edu/X3D-Edit'/> |
22 | <meta name='license' content='../license.html'/> |
23 | </head> |
24 | <Scene> |
25 | <!-- Three flame textures are used: flames1.png flames2.png flames3.png --> |
26 | <!-- All three textures have a transparency channel (alpha channel) so that areas outside of the flame are transparent. --> |
27 | <!-- 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. --> |
28 | <WorldInfo info='"Copyright (c) 1997, David R. Nadeau"' title='Flickering Flames'/> |
29 | <ProtoDeclare name='Flames'> |
30 | <ProtoInterface> |
31 | <field name='startTime' type='SFTime' value='0.0' accessType='initializeOnly'/> |
32 | <field name='cycleInterval' type='SFTime' value='1.0' accessType='initializeOnly'/> |
33 | </ProtoInterface> |
34 | <ProtoBody> |
35 | <Shape> |
36 |
<!-- ROUTE information for FlameAppearance node:
[from FlameSelector.texture_changed to set_texture
]
-->
<Appearance DEF='FlameAppearance'/> |
37 | <IndexedFaceSet solid='false' coordIndex='0 1 2 3' texCoordIndex='0 1 2 3'> |
38 | <TextureCoordinate point='0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0'/> |
39 | <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'/> |
40 | </IndexedFaceSet> |
41 | </Shape> |
42 |
<!-- ROUTE information for Clock node:
[from fraction_changed to FlameSelector.set_fraction
]
-->
<TimeSensor DEF='Clock' loop='true'> |
43 | <IS> |
44 | <connect nodeField='startTime' protoField='startTime'/> |
45 | <connect nodeField='cycleInterval' protoField='cycleInterval'/> |
46 | </IS> |
47 | </TimeSensor> |
48 |
<!-- ROUTE information for FlameSelector node:
[from Clock.fraction_changed to set_fraction
]
[from texture_changed to FlameAppearance.set_texture
]
-->
<Script DEF='FlameSelector' directOutput='true'> |
49 | <field name='flameTextures' type='MFNode' accessType='initializeOnly'> |
50 |
<!-- ImageTexture
Flame1 is a DEF node that has 1 USE node: USE_1 --> <ImageTexture DEF='Flame1' repeatS='false' repeatT='false' url=' "flames1.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames1.png " '/> |
51 | <ImageTexture repeatS='false' repeatT='false' url=' "flames2.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames2.png " '/> |
52 | <ImageTexture USE='Flame1'/> |
53 | <ImageTexture repeatS='false' repeatT='false' url=' "flames3.png " "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/flames3.png " '/> |
54 | </field> |
55 | <field name='texture_changed' type='SFNode' accessType='outputOnly'/> |
56 | <field name='set_fraction' type='SFFloat' accessType='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]; }
]]>
|
|
58 | </Script> |
59 | < ROUTE fromNode='Clock' fromField='fraction_changed' toNode='FlameSelector' toField='set_fraction'/> |
60 | < ROUTE fromNode='FlameSelector' fromField='texture_changed' toNode='FlameAppearance' toField='set_texture'/> |
61 | </ProtoBody> |
62 | </ProtoDeclare> |
63 | <!-- Display scene instructions for viewing an example scene with a corresponding prototype instance --> |
64 | <Background skyColor='0 0.333333 0.66667'/> |
65 | <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" '> |
66 | <Shape> |
67 | <Text string='"The Flames.x3d scene holds" "a prototype declaration" "" "Select this text to view example usage" "in Match.x3d scene"'> |
68 | <FontStyle justify='"MIDDLE" "MIDDLE"' style='BOLD'/> |
69 | </Text> |
70 | <Appearance> |
71 | <Material diffuseColor='1 0.9 0.4'/> |
72 | </Appearance> |
73 | </Shape> |
74 | <!-- Invisible box behind text makes selection easier --> |
75 | <Shape> |
76 | <Box size='12 5 0.1'/> |
77 | <Appearance> |
78 | <Material transparency='1'/> |
79 | </Appearance> |
80 | </Shape> |
81 | </Anchor> |
82 | </Scene> |
83 | </X3D> |
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 |
FlameSelector
Script set_fraction SFFloat |
then
|
FlameSelector
Script texture_changed SFNode |
FlameAppearance
Appearance set_texture SFNode |
Anchor |
description='select text to view parent scene' User-interaction hint for this node. |
<!--
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>
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->