<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Immersive' version='3.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<meta name='titlecontent='ViewpointGroupPrototype.x3d'/>
<meta name='descriptioncontent='ViewpointGroup contains Viewpoint and ViewpointGroup nodes, allowing nested lists and viewpoint scoping in viewpoint lists. This is a developmental example for potential specification improvement. It is needed because (a) currently specified rules for X3D/VRML node binding state that behavior of child Viewpoints beneath Switch/LOD/etc. is undefined, and (b) browser viewpoint list display behavior is undefined.'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='29 October 2003'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name=' warning content=' this prototype is for development purposes only, do not override native player support for ViewpointGroup '/>
<meta name='referencecontent='ViewpointListViewpointGroupProse.html'/>
<meta name='referencecontent='ViewpointGroupExample.x3d'/>
<meta name='referencecontent=' https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/navigation.html#Viewpoint '/>
<meta name='referencecontent=' https://www.web3d.org/technicalinfo/specifications/vrml97/part1/nodesRef.html#Viewpoint '/>
<meta name='subjectcontent='ViewpointGroup Viewpoint'/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupPrototype.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

Index for ProtoDeclare definition : ViewpointGroup

Index for DEF nodes : DescriptionHolder, DisplayedHolder, HoldExposedFields, ProximityZone, UnbindingControlScript, ViewpointsSwitch

Index for Viewpoint images : Viewpoint_1, Viewpoint_2
-->
<Scene>
<WorldInfo title='ViewpointGroupPrototype.x3d'/>
<ProtoDeclare name='ViewpointGroupappinfo='warning: developmental prototype for X3D v3.2 node do not override native support!'>
<ProtoInterface>
<field name='childrentype='MFNodeaccessType='inputOutput'
 appinfo='[Viewpoint | ViewpointGroup] only'>
<!-- initialized at runtime, default is empty array of Viewpoint/ViewpointGroup nodes. -->
</field>
<field name='descriptiontype='SFStringaccessType='inputOutput'
 appinfo='Text description or navigation hint to be displayed for this ViewpointGroup.'/>

<field name='displayedtype='SFBoolvalue='trueaccessType='inputOutput'
 appinfo='Whether this ViewpointGroup description is displayed in current viewpoint list.'/>

<field name='centertype='SFVec3fvalue='0 0 0accessType='inputOutput'
 appinfo='Position offset from origin of local coordinate system.'/>

<field name='radiustype='SFFloatvalue='10accessType='initializeOnly'
 appinfo='[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.'/>

<field name='set_radiustype='SFFloataccessType='inputOnly'
 appinfo='[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.'/>

<field name='retainUserOffsetstype='SFBoolvalue='trueaccessType='inputOutput'
 appinfo='Whether viewpoint needs to retain (true) or rezero (false) any prior user navigation offsets from defined viewpoint position orientation.'/>
</ProtoInterface>
<ProtoBody>
<Group>
<!-- ROUTE information for ProximityZone node:  [from isActive to UnbindingControlScript.isActive ] -->
<ProximitySensor DEF='ProximityZonesize='20 20 20'>
<IS>
<connect nodeField='centerprotoField='center'/>
</IS>
</ProximitySensor>
<Switch DEF='ViewpointsSwitchwhichChoice='0'>
<Group>
<IS>
<connect nodeField='childrenprotoField='children'/>
</IS>
</Group>
</Switch>
<Switch DEF='HoldExposedFieldswhichChoice='-1'>
<!-- WorldInfo not used because title field is accessType initializeOnly -->
<Anchor DEF='DescriptionHolder'>
<IS>
<connect nodeField='descriptionprotoField='description'/>
</IS>
</Anchor>
<ProximitySensor DEF='DisplayedHolder'>
<IS>
<connect nodeField='enabledprotoField='displayed'/>
</IS>
</ProximitySensor>
</Switch>
<!-- ROUTE information for UnbindingControlScript node:  [from ProximityZone.isActive to isActive ] -->
<Script DEF='UnbindingControlScriptdirectOutput='true'>
<field name='isActivetype='SFBoolaccessType='inputOnly'/>
<field name='ProximityZonetype='SFNodeaccessType='initializeOnly'>
<ProximitySensor USE='ProximityZone'/>
</field>
<field name='radiustype='SFFloataccessType='initializeOnly'
 appinfo='[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.'/>

<field name='set_radiustype='SFFloataccessType='inputOnly'
 appinfo='[0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.'/>

<field name='viewpointsSwitchtype='SFNodeaccessType='initializeOnly'>
<Switch USE='ViewpointsSwitchwhichChoice='-1'/>
</field>
<!-- use node holders to work around VRML 97 Script exposedField restriction -->
<field name='descriptionHoldertype='SFNodeaccessType='initializeOnly'>
<Anchor USE='DescriptionHolder'/>
</field>
<field name='displayedHoldertype='SFNodeaccessType='initializeOnly'>
<ProximitySensor USE='DisplayedHolder'/>
</field>
<field name='descriptiontype='SFStringaccessType='initializeOnly'/>
<field name='displayedtype='SFBoolvalue='trueaccessType='initializeOnly'/>
<field name='traceEnabledtype='SFBoolvalue='falseaccessType='initializeOnly'/>
<IS>
<connect nodeField='radiusprotoField='radius'/>
<connect nodeField='set_radiusprotoField='set_radius'/>
</IS>
<![CDATA[
            
ecmascript:

function initialize ()
{
	// since Viewpoints remain on binding stack as before,
	// no initialization action is necessary when implemented natively.
	description = descriptionHolder.description;
	displayed = displayedHolder.enabled;
	tracePrint ('displayed=' + displayed);
	if (!displayed) viewpointsSwitch.whichChoice = -1;
	set_radius (radius);

	// typecheck valid children nodes:
	tracePrint ('viewpointsSwitch.choice.length=' + viewpointsSwitch.choice.length);
	if (viewpointsSwitch.choice.length >= 1)
		for (i=0; i >= viewpointsSwitch.choice.length; i)
		{
			// how to check type?
			// if (viewpointsSwitch.choice[i].____ etc.)
			// once type checked, warn if Viewpoint position outside proximity box size
		}
	tracePrint ('... initialize() complete');
}
function isActive (activeValue)
{
	// Most likely, viewpoint list actions will be controlled by browser.

	// If viewpoint list is exposed via SAI, could do things here
	// such as setting ViewpointGroup.description as browser label.

	// Current action:  switch child Viewpoints in/out of scope.
	tracePrint ('activeValue=' + activeValue);

	tracePrint ('displayed=' + displayed);
	if (!displayed) return;

	if (activeValue) viewpointsSwitch.whichChoice =  0;
	else             viewpointsSwitch.whichChoice = -1;

	tracePrint ('viewpointsSwitch.whichChoice=' + viewpointsSwitch.whichChoice);
}
function set_radius (value, timestamp)
{
	radius = value;
	ProximityZone.size.x = 2 * radius;
	ProximityZone.size.y = 2 * radius;
	ProximityZone.size.z = 2 * radius;
	tracePrint ('set_radius (' + value + '), radius=' + radius + ', ProximityZone.size=' + ProximityZone.size);
}

function tracePrint(outputString)
{
	if (traceEnabled) Browser.print ('[ViewpointGroup' + description + ']' + outputString);
}
function alwaysPrint(outputString)
{
	Browser.print ('[ViewpointGroup' + description + ']' + outputString);
}

          
]]>
</Script>
<ROUTE fromNode='ProximityZonefromField='isActivetoNode='UnbindingControlScripttoField='isActive'/>
</Group>
</ProtoBody>
</ProtoDeclare>
<!-- ===============Example============== -->
<NavigationInfo type='"FLY" "ANY"'/>
<Anchor description='ViewpointGroupExampleparameter='"target=_blank"'
  url=' "ViewpointGroupExample.x3d" "https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupExample.x3d" "ViewpointGroupExample.wrl" "https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupExample.wrl" '>
<Shape>
<Text string='"ViewpointGroupPrototype" "defines a prototype" "" "Click on this text to see" "ViewpointGroupExample scene"'>
<FontStyle justify='"MIDDLE" "MIDDLE"size='0.5'/>
</Text>
<Appearance>
<Material diffuseColor='1 1 0.2'/>
</Appearance>
</Shape>
</Anchor>
<Viewpoint description='inside scope: ViewpointGroupposition='0 0 5'/>
<Viewpoint description='outside scope: ViewpointGroupposition='0 0 12'/>
</Scene>
</X3D>
<!--

Index for ProtoDeclare definition : ViewpointGroup

Index for DEF nodes : DescriptionHolder, DisplayedHolder, HoldExposedFields, ProximityZone, UnbindingControlScript, ViewpointsSwitch

Index for Viewpoint images : Viewpoint_1, Viewpoint_2
-->

<!-- 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> -->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->