<?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='16 December 2023'/>
<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>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: App, Label, Plane, PlanePosition, Selector, Slider, Translator

Index for ProtoDeclare definitions: SlidingPlane, TexturePlane
-->
<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>
<!-- ProtoBody child following first child will not be rendered, since the first child determines node type of this prototype. -->
<!-- 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=' Selector' fromField='texture_changed' toNode=' App' toField='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 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>
<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=' Slider' fromField='translation_changed' toNode=' PlanePosition' toField='set_translation'/>
< ROUTE  fromNode=' Slider' fromField='translation_changed' toNode=' Translator' toField='set_translation'/>
< ROUTE  fromNode=' Translator' fromField='fraction_changed' toNode=' Plane' toField='set_fraction'/>
< ROUTE  fromNode=' Translator' fromField='label_changed' toNode=' Label' toField='set_string'/>
< ROUTE  fromNode=' Translator' fromField='minPosition_changed' toNode=' Slider' toField='set_minPosition'/>
< ROUTE  fromNode=' Translator' fromField='maxPosition_changed' toNode=' Slider' toField='set_maxPosition'/>
< ROUTE  fromNode=' Translator' fromField='offset_changed' toNode=' Slider' toField='set_offset'/>
< ROUTE  fromNode=' Translator' fromField='offset_changed' toNode=' PlanePosition' toField='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>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: App, Label, Plane, PlanePosition, Selector, Slider, Translator

Index for ProtoDeclare definitions: SlidingPlane, TexturePlane
-->

Event Graph ROUTE Table entries with 9 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.

Selector
Script
texture_changed
SFNode

ROUTE
event to
(1)
App
Appearance
set_texture
SFNode


      Plane
ProtoInstance
TexturePlane
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 



-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/CutIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Siggraph98Course/Cut.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)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

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