<?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='Cut.x3d'/>
<meta name='descriptioncontent='Cutting plane parts: this file contains two prototype declarations used in creating a cutting plane. The example scene TexturePlane uses these for external prototype instances and creates a plane with one of a set of textures mapped to it. The texture choice is controlled by a fraction eventIn. SlidingPlane creates a texture plane that slides back and forth along the X axis, changing the texture based upon the X position.'/>
<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='CutPlane.x3d'/>
<meta name='referencecontent='TexturePlane.x3d'/>
<meta name='referencecontent='originals/cut.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/mt0497.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/Cut.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 ProtoDeclare definitions : SlidingPlane, TexturePlane

Index for DEF nodes : App, Label, Plane, PlanePosition, Selector, Slider, Translator
-->
<Scene>
<WorldInfo info='"Copyright (c) 1997, David R. Nadeau"title='Cutting Plane parts'/>
<ProtoDeclare name='TexturePlane'>
<ProtoInterface>
<field name='texturestype='MFNodeaccessType='initializeOnly'>
<!-- initialized with ImageTexture nodes upon use -->
</field>
<field name='set_fractiontype='SFFloataccessType='inputOnly'/>
</ProtoInterface>
<ProtoBody>
<Group>
<Shape>
<!-- ROUTE information for App node:  [from Selector.texture_changed to set_texture ] -->
<Appearance DEF='App'/>
<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='-1.0 -1.0 0.0 1.0 -1.0 0.0 1.0 1.0 0.0 -1.0 1.0 0.0'/>
</IndexedFaceSet>
</Shape>
<Shape>
<Appearance/>
<IndexedLineSet coordIndex='0 1 2 3 0'>
<Coordinate point='-1.0 -1.0 0.0 1.0 -1.0 0.0 1.0 1.0 0.0 -1.0 1.0 0.0'/>
</IndexedLineSet>
</Shape>
</Group>
<!-- ROUTE information for Selector node:  [from texture_changed to App.set_texture ] -->
<Script DEF='SelectordirectOutput='true'>
<field name='texturestype='MFNodeaccessType='initializeOnly'/>
<field name='texture_changedtype='SFNodeaccessType='outputOnly'/>
<field name='set_fractiontype='SFFloataccessType='inputOnly'/>
<IS>
<connect nodeField='texturesprotoField='textures'/>
<connect nodeField='set_fractionprotoField='set_fraction'/>
</IS>
<![CDATA[
          
ecmascript:
    function initialize( ) {
        texture_changed = textures[0];
        Browser.println ('[Cut Selector] initialize(): textures.length=' + textures.length); // debug
    }
    function set_fraction( f, tm ) {
        i = Math.floor(f * 10);
        if ( i == 10 ) { i = 9; }
        Browser.println ('[Cut Selector] set_fraction(): i=' + i); // debug
        texture_changed = textures[i];
    }

        
]]>
</Script>
<ROUTE fromNode='SelectorfromField='texture_changedtoNode='ApptoField='set_texture'/>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='SlidingPlane'>
<ProtoInterface>
<field name='texturestype='MFNodeaccessType='initializeOnly'>
<!-- initialized with ImageTexture nodes upon use -->
</field>
<field name='minMaxXtype='SFVec2fvalue='0.0 1.0accessType='initializeOnly'/>
<field name='initialXtype='SFFloatvalue='0.0accessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<Transform rotation='0.0 1.0 0.0 1.571'>
<!-- ROUTE information for Slider node:  [from Translator.minPosition_changed to set_minPosition ] [from Translator.maxPosition_changed to set_maxPosition ] [from Translator.offset_changed to set_offset ] [from translation_changed to PlanePosition.set_translation ] [from translation_changed to Translator.set_translation ] -->
<PlaneSensor DEF='Sliderdescription='drag to see cross-section slices'/>
<!-- ROUTE information for PlanePosition node:  [from Slider.translation_changed to set_translation ] [from Translator.offset_changed to set_translation ] -->
<Transform DEF='PlanePositionrotation='0.0 1.0 0.0 -1.571'>
<!-- ROUTE information for Plane node:  [from Translator.fraction_changed to set_fraction ] -->
<ProtoInstance name='TexturePlaneDEF='Plane'>
<IS>
<connect nodeField='texturesprotoField='textures'/>
</IS>
</ProtoInstance>
<Transform rotation='0.0 1.0 0.0 1.571translation='1.05 -1.2 0.0'>
<Shape>
<Appearance/>
<!-- ROUTE information for Label node:  [from Translator.label_changed to set_string ] -->
<Text DEF='Labelstring='""'>
<FontStyle justify='"MIDDLE" "MIDDLE"size='0.3style='BOLD'/>
</Text>
</Shape>
</Transform>
</Transform>
</Transform>
<!-- ROUTE information for Translator node:  [from Slider.translation_changed to set_translation ] [from fraction_changed to Plane.set_fraction ] [from label_changed to Label.set_string ] [from minPosition_changed to Slider.set_minPosition ] [from maxPosition_changed to Slider.set_maxPosition ] [from offset_changed to Slider.set_offset ] [from offset_changed to PlanePosition.set_translation ] -->
<Script DEF='Translator'>
<field name='set_translationtype='SFVec3faccessType='inputOnly'/>
<field name='minMaxXtype='SFVec2faccessType='initializeOnly'/>
<field name='minPosition_changedtype='SFVec2faccessType='outputOnly'/>
<field name='fraction_changedtype='SFFloataccessType='outputOnly'/>
<field name='initialXtype='SFFloataccessType='initializeOnly'/>
<field name='offset_changedtype='SFVec3faccessType='outputOnly'/>
<field name='maxPosition_changedtype='SFVec2faccessType='outputOnly'/>
<field name='label_changedtype='MFStringaccessType='outputOnly'/>
<IS>
<connect nodeField='minMaxXprotoField='minMaxX'/>
<connect nodeField='initialXprotoField='initialX'/>
</IS>
<![CDATA[
          
ecmascript:
        function translate( x ) {
        // compute the fraction using the given X position
            f = (x-minMaxX[0]) / (minMaxX[1] - minMaxX[0]);
        // send a fraction event
            fraction_changed = f;
        // send a new label string with 1 digit after decimal
            label_changed[0] = Math.floor(f*10.0)/10.0;
        }

        function initialize( ) {
        // set the plane sensor bounds
            minPosition_changed[0] = minMaxX[0];
            minPosition_changed[1] = 0.0;
            maxPosition_changed[0] = minMaxX[1];
            maxPosition_changed[1] = 0.0;
        // set the plane sensor initial position
            offset_changed[0] = initialX;
            offset_changed[1] = 0.0;
            offset_changed[2] = 0.0;
        // compute the initial values
            translate( initialX );
        }

        function set_translation( t, tm ) {
        // compute the new values
            translate( t[0] );
        }

        
]]>
</Script>
<ROUTE fromNode='SliderfromField='translation_changedtoNode='PlanePositiontoField='set_translation'/>
<ROUTE fromNode='SliderfromField='translation_changedtoNode='TranslatortoField='set_translation'/>
<ROUTE fromNode='TranslatorfromField='fraction_changedtoNode='PlanetoField='set_fraction'/>
<ROUTE fromNode='TranslatorfromField='label_changedtoNode='LabeltoField='set_string'/>
<ROUTE fromNode='TranslatorfromField='minPosition_changedtoNode='SlidertoField='set_minPosition'/>
<ROUTE fromNode='TranslatorfromField='maxPosition_changedtoNode='SlidertoField='set_maxPosition'/>
<ROUTE fromNode='TranslatorfromField='offset_changedtoNode='SlidertoField='set_offset'/>
<ROUTE fromNode='TranslatorfromField='offset_changedtoNode='PlanePositiontoField='set_translation'/>
</ProtoBody>
</ProtoDeclare>
<!-- Display scene instructions for viewing an example scene with a corresponding prototype instance -->
<Background skyColor='0 0.333333 0.66667'/>
<Transform translation='0 2.5 0'>
<Anchor description='select text to view parent scene'
  url=' "CutPlane.x3d" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/CutPlane.x3d" "CutPlane.wrl" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/CutPlane.wrl" '>
<Shape>
<Text string='"The Cut.x3d scene holds" "prototype declarations" "Select this text to view example usage" "in CutPlane.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>
</Transform>
<Transform translation='0 -2.5 0'>
<Anchor description='select text to view parent scene'
  url=' "TexturePlane.x3d" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/TexturePlane.x3d" "TexturePlane.wrl" "https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/TexturePlane.wrl" '>
<Shape>
<Text string='"or select this text to view example usage" "in TexturePlane.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>
</Transform>
</Scene>
</X3D>
<!--

Index for ProtoDeclare definitions : SlidingPlane, TexturePlane

Index for DEF nodes : App, Label, Plane, PlanePosition, Selector, Slider, Translator
-->

<!-- 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)
    <Prototype name='ProtoName'> <field name='fieldName'/> </Prototype> -->

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