#VRML V2.0 utf8
# X3D-to-VRML-97 XSL translation autogenerated by X3dToVrml97.xslt
# https://www.web3d.org/x3d/content/X3dToVrml97.xslt
# Generated using XSLT processor: Saxonica
# [X3D] VRML V3.0 utf8
# PROFILE Immersive
# [X3D] version=3.0
# [X3D] noNamespaceSchemaLocation=https://www.web3d.org/specifications/x3d-3.0.xsd
# [head]
# META "title" "ViewpointGroupPrototype.x3d"
# META "description" "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 "creator" "Don Brutzman"
# META "created" "29 October 2003"
# META "modified" "20 October 2019"
# META "warning" "this prototype is for development purposes only, do not override native player support for ViewpointGroup"
# META "reference" "ViewpointListViewpointGroupProse.html"
# META "reference" "ViewpointGroupExample.x3d"
# META "reference" "https://www.web3d.org/specifications/X3Dv4Draft/ISO-IEC19775-1v4-IS.proof/Part01/components/navigation.html#Viewpoint"
# META "reference" "https://www.web3d.org/technicalinfo/specifications/vrml97/part1/nodesRef.html#Viewpoint"
# META "subject" "ViewpointGroup Viewpoint"
# META "identifier" "https://www.web3d.org/x3d/content/examples/Basic/development/ViewpointGroupPrototype.x3d"
# META "generator" "X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit"
# META "license" "../license.html"
# [Scene] ========== ========== ==========
WorldInfo {
title "ViewpointGroupPrototype.x3d"
}
PROTO ViewpointGroup [
# [appinfo] warning: developmental prototype for X3D v3.2 node do not override native support!
exposedField MFNode children [ ] # [appinfo] [Viewpoint | ViewpointGroup] only
# initialized at runtime, default is empty array of Viewpoint/ViewpointGroup nodes.
exposedField SFString description "" # [appinfo] Text description or navigation hint to be displayed for this ViewpointGroup.
exposedField SFBool displayed TRUE # [appinfo] Whether this ViewpointGroup description is displayed in current viewpoint list.
exposedField SFVec3f center 0 0 0 # [appinfo] Position offset from origin of local coordinate system.
field SFFloat radius 10 # [appinfo] [0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.
eventIn SFFloat set_radius # [appinfo] [0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.
### Warning: ProtoInterface is unreferenced in ProtoBody with no corresponding IS/connect/@protoField
exposedField SFBool retainUserOffsets TRUE # [appinfo] Whether viewpoint needs to retain (true) or rezero (false) any prior user navigation offsets from defined viewpoint position orientation.
] {
Group {
children [
DEF ProximityZone ProximitySensor {
size 20 20 20
center IS center
}
DEF ViewpointsSwitch Switch {
whichChoice 0
choice [
Group {
children IS children
}
]
}
DEF HoldExposedFields Switch {
whichChoice -1
choice [
# WorldInfo not used because title field is accessType initializeOnly
DEF DescriptionHolder Anchor {
description IS description
}
DEF DisplayedHolder ProximitySensor {
enabled IS displayed
}
]
}
DEF UnbindingControlScript Script {
eventIn SFBool isActive
field SFNode ProximityZone USE ProximityZone
field SFFloat radius IS radius # [appinfo] [0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.
eventIn SFFloat set_radius IS set_radius # [appinfo] [0..infinity) Radius in meters of Proximity box within which the ViewpointGroup is usable and displayed on the viewpoint list.
field SFNode viewpointsSwitch USE ViewpointsSwitch
### Error: No additional/overriding attribute values (whichChoice='-1') allowed with USE node
# use node holders to work around VRML 97 Script exposedField restriction
field SFNode descriptionHolder USE DescriptionHolder
field SFNode displayedHolder USE DisplayedHolder
field SFString description ""
field SFBool displayed TRUE
field SFBool traceEnabled FALSE
directOutput TRUE
# use node holders to work around VRML 97 Script exposedField restriction
# use node holders to work around VRML 97 Script exposedField restriction
url [ "javascript: // ### X3D Browser.print() not supported by all VRML97 viewers, instead simply using print()
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) printingln ('[ViewpointGroup' + description + ']' + outputString);
}
function alwaysPrint(outputString)
{
printingln ('[ViewpointGroup' + description + ']' + outputString);
}
" ]
}
]
ROUTE ProximityZone.isActive TO UnbindingControlScript.isActive
}
}
# ===============Example==============
NavigationInfo {
type [ "FLY" "ANY" ]
}
Anchor {
description "ViewpointGroupExample"
parameter [ "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" ]
children [
Shape {
geometry Text {
string [ "ViewpointGroupPrototype" "defines a prototype" "" "Click on this text to see" "ViewpointGroupExample scene" ]
fontStyle FontStyle {
justify [ "MIDDLE" "MIDDLE" ]
size 0.5
}
}
appearance Appearance {
material Material {
diffuseColor 1 1 0.2
}
}
}
]
}
Viewpoint {
description "inside scope: ViewpointGroup"
position 0 0 5
}
Viewpoint {
description "outside scope: ViewpointGroup"
position 0 0 12
}