<?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='Bounce2.x3d'/>
<meta name='descriptioncontent='Bouncing beachball (Java version): this world illustrates the use of a Script node to create a computed animation path. In particular, the Script node uses a Java program script to compute translation values for a vertically bouncing beach ball.'/>
<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='3 November 2019'/>
<meta name='referencecontent='originals/bounce2.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/mt0457.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/Bounce2.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>
<!--

Index for DEF nodes : Ball, Bouncer, Clock, Palm

Index for Viewpoint image : Viewpoint_1
-->
<Scene>
<!-- http://www.sdsc.edu/~moreland/courses/Siggraph98/vrml97/slides/bounce2.htm -->
<!-- The bounce path is based upon the projectile motion equation of physics, constrained to create a cyclic bouncing path with a user-selected maximum bounce height. Also, there is no friction, drag, or damping. For an explanation of the script, see 'bounce1.wrl'. -->
<!-- Things to experiment with -->
<!-- Encapsulate the ball, script, timer, and sensors within a PROTO for a new node named "BouncingBall". Then use that new BouncingBall node multiple times to create multiple bouncing balls. Your PROTO interface might look like this: -->
<!-- PROTO BouncingBall [ field SFFloat bounceHeight 2.0 field SFTime cycleInterval 2.0 ] { . . . } -->
<!-- See 'bounce3.wrl', which implements such a PROTO. -->
<!-- - Add a shadow under the bouncing ball. To do this, add a circular, semi-transparent, black shape that doesn't bounce. To make the shadow more realistic, scale the shadow in the X and Z directions, shrinking it as the ball goes up, and increasing it as the ball comes down. You'll need to add another eventOut for the Script node and send an XYZ scaling factor triple out that eventOut. Try the following values for the XYZ scale values: -->
<!-- xzscale = 1.0 - 0.5 * y / bounceHeight; -->
<!-- shadowScale_changed[0] = xzscale; -->
<!-- shadowScale_changed[1] = 1.0; -->
<!-- shadowScale_changed[2] = xzscale; -->
<!-- See 'bounce4.wrl', which implements shadows using the above -->
<!-- - Add a sound to the PROTO so that each time the ball touches the ground, it makes a 'boing' sound. -->
<!-- - When the ball hits the ground, scale the ball slightly so that it appears to squish. -->
<WorldInfo info='"Copyright (c) 1997, David R. Nadeau"title='Bouncing beachball (Java)'/>
<Viewpoint description='Bouncing beachball, Java versionorientation='1.0 0.0 0.0 0.1position='0.0 0.6 8.0'/>
<NavigationInfo headlight='falsespeed='2.0'/>
<DirectionalLight ambientIntensity='0.5direction='0.0 -1.0 -0.5'/>
<Background skyAngle='1.371 1.571skyColor='0.0 0.0 1.0 0.0 0.5 1.0 0.7 0.7 1.0'/>
<Shape>
<Appearance>
<TextureTransform scale='10.0 10.0'/>
<Material/>
<ImageTexture
  url=' "sand.jpg" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/sand.jpg" '/>
</Appearance>
<IndexedFaceSet solid='falsecoordIndex='0 1 2 3'>
<Coordinate point='-50.0 -1.0 50.0 50.0 -1.0 50.0 50.0 -1.0 -50.0 -50.0 -1.0 -50.0'/>
</IndexedFaceSet>
</Shape>
<Transform translation='-3.0 -1.0 -10.0'>
<Group DEF='Palm'>
<Billboard>
<Shape>
<Appearance> </Appearance>
<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='-2.5 0.0 0.0 2.5 0.0 0.0 2.5 11.25 0.0 -2.5 11.25 0.0'/>
</IndexedFaceSet>
</Shape>
</Billboard>
<Shape>
<Appearance>
<Material diffuseColor='0.0 0.0 0.0transparency='0.5'/>
<ImageTexture
  url=' "palmsh.png" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/palmsh.png" '/>
</Appearance>
<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='-2.5 0.05 2.5 2.5 0.05 2.5 2.5 0.05 -2.5 -2.5 0.05 -2.5'/>
</IndexedFaceSet>
</Shape>
</Group>
</Transform>
<Transform scale='0.6 0.6 0.6translation='-5.0 -1.0 -6.0'>
<Group USE='Palm'/>
</Transform>
<Transform translation='5.0 -1.0 -9.0'>
<Group USE='Palm'/>
</Transform>
<Transform translation='10.0 -1.0 -15.0'>
<Group USE='Palm'/>
</Transform>
<!-- ROUTE information for Ball node:  [from Bouncer.value_changed to set_translation ] -->
<Transform DEF='Ball'>
<Shape>
<Appearance>
<TextureTransform scale='2.0 1.0'/>
<Material ambientIntensity='0.5diffuseColor='1.0 1.0 1.0shininess='0.4specularColor='0.7 0.7 0.7'/>
<ImageTexture
  url=' "beach.jpg" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/beach.jpg" '/>
</Appearance>
<Sphere/>
</Shape>
</Transform>
<!-- ROUTE information for Clock node:  [from fraction_changed to Bouncer.set_fraction ] -->
<TimeSensor DEF='ClockcycleInterval='2.0loop='truestartTime='1.0'/>
<!-- ROUTE information for Bouncer node:  [from Clock.fraction_changed to set_fraction ] [from value_changed to Ball.set_translation ] -->
<Script DEF='Bouncer'
  url=' "Bounce2Script.class" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Bounce2Script.class" '>
<field name='value_changedtype='SFVec3faccessType='outputOnly'/>
<field name='bounceHeighttype='SFFloatvalue='3.0accessType='initializeOnly'/>
<field name='set_fractiontype='SFFloataccessType='inputOnly'/>
</Script>
<ROUTE fromNode='ClockfromField='fraction_changedtoNode='BouncertoField='set_fraction'/>
<ROUTE fromNode='BouncerfromField='value_changedtoNode='BalltoField='set_translation'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : Ball, Bouncer, Clock, Palm

Index for Viewpoint image : Viewpoint_1
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->

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