en fr

Calerga VR Implementation

Calerga VR is an experimental implementation of the VRML and X3D standards developed by Calerga. VRML is a markup language for the description of 3D scenes in virtual reality, developed in the 1990. X3D is its successor, with better extensibility and multiple encodings, including one based on XML. Calerga implementation relies on modern web technologies such as JavaScript and WebGL. If WebGL is not available, a wireframe representation is displayed in a 2d canvas.

This document is a complement to VRML and X3D standards; neither a user manual or tutorial, nor even a self-contained description of Calerga VR.

Files

Default encoding is VRML 97. The parser recognizes as X3D the files starting with the header comment #X3D V3.? utf8. In X3D, the following features of the Classic VRML encoding are supported:

  • X3D keywords
  • X3D field types
  • Block comments

Support for the XML encoding is still basic, with incomplete field types. Support for the JSON encoding (not a standard yet) is also partial.

Nodes

For the VRML standard, see web3D standards, VRML 97 (ISO/IEC 14772-1).

For the X3D standard, see web3D standards, X3D Architecture and base components V3 (ISO/IEC IS 19775-1:2013) and X3D Classic VRML encoding (ISO/IEC 19776-2 IS).

This sections gives the implementation status of nodes and fields. The tables contain the following columns:

  • field access ([] or [in,out] for stored values, [in] or [out] for events; noted respectively initializeOnly, inputOutput, inputOnly and outputOnly in X3D, or field, exposedField, eventIn and eventOut in VRML)
  • field type
  • field name
  • "b" if valid in both VRML and X3D, "v" if only in VRML, empty if only in X3D

The implementation status of each field is shown by its color. The table below gives the number of fields in each class; but it isn't an accurate statement of completion, because X3D nodes which don't exist in VRML are omitted.

supported?
ignored?
not implemented?
custom?

The container field is the name of the default field of the parent the node is attached to. It is used in XML encoding (default value of the attribute containerField) or, as a non-standard extension, in the Classic VRML encoding when the field name is missing (see section Default field names).

Anchor

Container field: children

[in] MFNode addChildren b
[] SFVec3f bboxCenter b
[] SFVec3f bboxSize b
[in,out] MFNode children b
[in,out] SFString description b
[in,out] SFNode metadata  
[in,out] MFString parameter b
[in] MFNode removeChildren b
[in,out] MFString url b

Appearance

Container field: appearance

[in,out] SFNode material b
[in,out] SFNode metadata  
[in,out] SFNode texture b
[in,out] SFNode textureTransform b

AudioClip

Container field: source

[in,out] SFString description b
[out] SFTime duration_changed b
[out] SFBool isActive b
[in,out] SFBool loop b
[in,out] SFNode metadata  
[in,out] SFTime pauseTime
[in,out] SFFloat pitch b
[in,out] SFTime resumeTime
[in,out] SFTime startTime b
[in,out] SFTime stopTime b
[in,out] MFString url b

Background

Container field: children

[in,out] MFString backUrl b
[in,out] MFString bottomUrl b
[in,out] MFString fronUrl b
[in,out] MFFloat groundAngle b
[in,out] MFColor groundColor b
[out] SFBool isBound b
[in,out] MFString leftUrl b
[in,out] SFNode metadata  
[in,out] MFString rightUrl b
[in] SFBool set_bind b
[in,out] MFFloat skyAngle b
[in,out] MFColor skyColor b
[in,out] MFString topUrl b

Billboard

Container field: children

[in] MFNode addChildren b
[in,out] SFVec3f axisOfRotation b
[] SFVec3f bboxCenter b
[] SFVec3f bboxSize b
[in,out] MFNode children b
[in,out] SFNode metadata  
[in] MFNode removeChildren b

BooleanFilter

Container field: children

[out] SFBool inputFalse  
[out] SFBool inputNegate  
[out] SFBool inputTrue  
[in,out] SFNode metadata  
[in] SFBool set_boolean  

BooleanSequencer

Container field: children

[in,out] MFFloat key  
[in,out] MFBool keyValue  
[in,out] SFNode metadata  
[in] SFBool next  
[in] SFBool previous  
[in] SFFloat set_fraction  
[out] SFBool value_changed  

BooleanToggle

Container field: children

[in,out] SFNode metadata  
[in] SFBool set_boolean  
[in,out] SFBool toggle  

BooleanTrigger

Container field: children

[in,out] SFNode metadata  
[in] SFTime set_triggerTime  
[out] SFBool triggerTrue  

Box

Container field: geometry

[] SFFloat bevel  
[in,out] SFNode metadata  
[] SFVec3f size b
[] SFBool solid  

The new field bevel (default: 0) is the size of a bevel along the 12 edges of the box.

Collision

Container field: children

[in] MFNode addChildren b
[] SFVec3f bboxCenter b
[] SFVec3f bboxSize b
[in,out] MFNode children b
[in,out] SFBool collide b
[out] SFTime collideTime b
[in,out] SFNode metadata  
[] SFNode proxy b
[in] MFNode removeChildren b

Color

Container field: color

[in,out] MFColor color b
[in,out] SFNode metadata  

ColorInterpolator

Container field: children

[in,out] MFFloat key b
[in,out] MFColor keyValue b
[in,out] SFNode metadata  
[in] SFFloat set_fraction b
[in,out] SFColor value_changed b

Cone

Container field: geometry

[] SFBool bottom b
[] SFFloat bottomRadius b
[] SFFloat height b
[in,out] SFNode metadata  
[] SFBool side b
[] SFBool solid  

Coordinate

Container field: coord

[in,out] SFNode metadata  
[in,out] MFVec3f point b

CoordinateInterpolator

Container field: children

[in,out] MFFloat key b
[in,out] MFVec3f keyValue b
[in,out] SFNode metadata  
[in] SFFloat set_fraction b
[in,out] MFVec3f value_changed b

Cylinder

Container field: geometry

[] SFFloat bevel  
[] SFBool bottom b
[] SFFloat height b
[] SFFloat innerRadius  
[in,out] SFNode metadata  
[] SFFloat radius b
[] SFBool side b
[] SFBool solid  
[] SFBool top b

The new field bevel (default: 0) is the size of a bevel along the base and top of the cylinder.

The new field innerRadius (default: 0) is the radius of a cylindric hole, concentric with the external cylinder. 0 means none.

CylinderSensor

Container field: children

[out] SFFloat angle_changed  
[in,out] SFNode autoOffset b
[in,out] SFString description  
[in,out] SFFloat diskAngle b
[in,out] SFBool enabled b
[out] SFBool isActive b
[in,out] SFFloat maxAngle b
[in,out] SFNode metadata  
[in,out] SFFloat minAngle b
[in,out] SFFloat offset b
[out] SFRotation rotation_changed b
[out] SFVec3f trackPoint_changed b

The new output event angle_changed gives the 4th element of the rotation rotation_changed, which can simplify routing in some cases.

DirectionalLight

Container field: children

[in,out] SFFloat ambientIntensity b
[in,out] SFColor color b
[in,out] SFVec3f direction b
[in,out] SFFloat intensity b
[in,out] SFNode metadata  
[in,out] SFBool on b

DistanceSensor

Container field: children

[in,out] SFBool enabled  
[in,out] SFNode metadata  
[in,out] SFFloat value  

Node DistanceSensor is a sensor node which gives the distance to the nearest shape from its position along the positive x axis in local coordinates. If no shape intersects the positive x axis, the value which is output is infinity. This node type can be used to simulate proximity sensors in robotics.

ElevationGrid

Container field: geometry

[] SFBool ccw b
[in,out] SFNode color b
[] SFBool colorPerVertex b
[] SFFloat creaseAngle b
[] MFFloat height b
[in,out] SFNode metadata  
[in,out] SFNode normal b
[] SFBool normalPerVertex b
[in] MFFloat set_height b
[] SFBool solid b
[in,out] SFNode texCoord b
[] SFInt32 xDimension b
[] SFFloat xSpacing b
[] SFInt32 zDimension b
[] SFFloat zSpacing b

Extrusion

Container field: geometry

[] SFBool beginCap b
[] SFBool ccw b
[] SFBool convex b
[] SFFloat creaseAngle b
[] MFVec2f crossSection b
[] SFBool endCap b
[in,out] SFNode metadata  
[] MFRotation orientation b
[] MFVec2f scale b
[in] MFVec2f set_crossSection b
[in] MFRotation set_orientation b
[in] MFVec2f set_scale b
[in] MFVec3f set_spine b
[] SFBool solid b
[] MFVec3f spine b

Fog

Container field: children

[in,out] SFColor color b
[in,out] SFString fogType b
[out] SFBool isBound b
[in,out] SFNode metadata  
[in] SFBool set_bind b
[in,out] SFFloat visibilityRange b

FontStyle

Container field: fontStyle

[] SFString family b
[] SFBool horizontal b
[] MFString justify b
[] SFString language b
[] SFBool leftToRight b
[in,out] SFNode metadata  
[] SFFloat size b
[] SFFloat spacing b
[] SFString style b
[] SFBool topToBottom b

Group

Container field: children

[in] MFNode addChildren b
[] SFVec3f bboxCenter b
[] SFVec3f bboxSize b
[in,out] MFNode children b
[in,out] SFNode metadata  
[in] MFNode removeChildren b

ImageTexture

Container field: texture

[in,out] SFNode metadata  
[] SFBool repeatS b
[] SFBool repeatT b
[] SFNode textureProperties
[in,out] MFString url b

IndexedFaceSet

Container field: geometry

[] SFBool ccw b
[in,out] SFNode color b
[] MFInt32 colorIndex b
[] SFBool colorPerVertex b
[] SFBool convex b
[in,out] SFNode coord b
[] MFInt32 coordIndex b
[] SFFloat creaseAngle b
[in,out] SFNode metadata  
[in,out] SFNode normal b
[] MFInt32 normalIndex b
[] SFBool normalPerVertex b
[in] MFInt32 set_colorIndex b
[in] MFInt32 set_coordIndex b
[in] MFInt32 set_normalIndex b
[in] MFInt32 set_texCoordIndex b
[] SFBool solid b
[in,out] SFNode texCoord b
[] MFInt32 texCoordIndex b

IndexedLineSet

Container field: geometry

[in,out] SFNode color b
[] MFInt32 colorIndex b
[] SFBool colorPerVertex b
[in,out] SFNode coord b
[] MFInt32 coordIndex b
[in,out] SFNode metadata  
[in] MFInt32 set_colorIndex b
[in] MFInt32 set_coordIndex b

Inline

Container field: children

[] SFVec3f bboxCenter b
[] SFVec3f bboxSize b
[in,out] SFNode metadata  
[in,out] MFString url b

IntegerSequencer

Container field: children

[in,out] MFFloat key  
[in,out] MFInt32 keyValue  
[in,out] SFNode metadata  
[in] SFBool next  
[in] SFBool previous  
[in] SFFloat set_fraction  
[out] SFInt32 value_changed  

IntegerTrigger

Container field: children

[in,out] SFInt32 integerKey  
[in,out] SFNode metadata  
[in] SFBool set_boolean  
[out] SFInt32 triggerValue  

LOD

Container field: children

[in] MFNode addChildren  
[] SFVec3f bboxCenter  
[] SFVec3f bboxSize  
[] SFVec3f center b
[in,out] MFNode children  
[] SFBool forceTransitions  
[in,out] MFNode level v
[out] SFInt32 level_changed  
[in,out] SFNode metadata  
[] MFFloat range b
[in] MFNode removeChildren  

Material

Container field: material

[in,out] SFFloat ambientIntensity b
[in,out] SFColor diffuseColor b
[in,out] SFColor emissiveColor b
[in,out] SFNode metadata  
[in,out] SFFloat shininess b
[in,out] SFColor specularColor b
[in,out] SFFloat transparency b

MetadataBoolean

Container field: metadata

[in,out] SFNode metadata  
[in,out] SFString name  
[in,out] SFString reference  
[in,out] MFBool value  
 

MetadataDouble

Container field: metadata

[in,out] SFNode metadata  
[in,out] SFString name  
[in,out] SFString reference  
[in,out] MFDouble value  
 

MetadataFloat

Container field: metadata

[in,out] SFNode metadata  
[in,out] SFString name  
[in,out] SFString reference  
[in,out] MFFloat value  
 

MetadataInteger

Container field: metadata

[in,out] SFNode metadata  
[in,out] SFString name  
[in,out] SFString reference  
[in,out] MFInt32 value  
 

MetadataSet

Container field: metadata

[in,out] SFNode metadata  
[in,out] SFString name  
[in,out] SFString reference  
[in,out] MFNode value  
 

MetadataString

Container field: metadata

[in,out] SFNode metadata  
[in,out] SFString name  
[in,out] SFString reference  
[in,out] MFString value  
 

MovieTexture

Container field: texture

[in,out] SFString description
[out] SFFloat duration_changed b
[out] SFTime elapsedTime
[out] SFBool isActive b
[out] SFBool isPaused
[in,out] SFBool loop b
[in,out] SFNode metadata  
[in,out] SFTime pauseTime
[] SFBool repeatS b
[] SFBool repeatT b
[in,out] SFTime resumeTime
[in,out] SFFloat speed b
[in,out] SFTime startTime b
[in,out] SFTime stopTime b
[] SFNode textureProperties
[in,out] MFString url b

NavigationInfo

Container field: children

[in,out] MFFloat avatarSize b
[in,out] SFBool headlight b
[out] SFBool isBound b
[in,out] SFNode metadata  
[in] SFBool setBind b
[in,out] SFFloat speed b
[in,out] MFString type b
[] SFFloat visibilityLimit b

Normal

Container field: normal

[in,out] SFNode metadata  
[in,out] MFVec3f vector b

NormalInterpolator

Container field: children

[in,out] MFFloat key b
[in,out] MFVec3f keyValue b
[in,out] SFNode metadata  
[in] SFFloat set_fraction b
[in,out] MFVec3f value_changed b

NumberInput

Container field: geometry

[in,out] SFBool enabled  
[in,out] SFNode fontStyle  
[in,out] SFFloat maxValue  
[in,out] SFNode metadata  
[in,out] SFFloat minValue  
[in,out] SFString prefix  
[in,out] SFFloat step  
[in,out] SFString suffix  
[in,out] SFFloat value  
[in,out] SFBool wrap  

Node NumberInput is a geometry which displays a number like the text node, with optional prefix and suffix strings. It lets the user change the value of the number by clicking arrows at the right of the string.

OrientationInterpolator

Container field: children

[in,out] MFFloat key b
[in,out] MFRotation keyValue b
[in,out] SFNode metadata  
[in] SFFloat set_fraction b
[in,out] SFRotation value_changed b

OrthoViewpoint

Container field: children

[out] SFTime bindTime  
[in,out] SFVec3f centerOfRotation  
[in,out] SFString description  
[in,out] MFFloat fieldOfView  
[out] SFBool isBound  
[in,out] SFBool jump  
[in,out] SFNode metadata  
[in,out] SFRotation orientation  
[in,out] SFVec3f position  
[in,out] SFBoolean retainUserOffsets  
[in] SFBool set_bind  

PixelTexture

Container field: texture

[in,out] SFImage image b
[in,out] SFNode metadata  
[] SFBool repeatS b
[] SFBool repeatT b
[] SFNode textureProperties

PlaneSensor

Container field: children

[in,out] SFBool autoOffset b
[in,out] SFString description  
[in,out] SFBool enabled b
[out] SFBool isActive b
[in,out] SFVec2f maxPosition b
[in,out] SFNode metadata  
[in,out] SFVec2f minPosition b
[in,out] SFVec3f offset b
[out] SFVec3f trackPoint_changed b
[out] SFVec3f translation_changed b
[out] SFFloat x_changed  
[out] SFFloat y_changed  

The new output events x_changed and y_changed give the 1st and 2nd elements of the translation vector translation_changed, respectively, which can simplify routing in some cases.

PointLight

Container field: children

[in,out] SFFloat ambientIntensity b
[in,out] SFVec3f attenuation b
[in,out] SFColor color b
[in,out] SFFloat intensity b
[in,out] SFVec3f location b
[in,out] SFNode metadata  
[in,out] SFBool on b
[in,out] SFFloat radius b

PointSet

Container field: geometry

[in,out] SFNode color b
[in,out] SFNode coord b
[in,out] SFNode metadata  

Polyline2D

Container field: geometry

[in,out] MFVec2f lineSegments  
[in,out] SFNode metadata  

Polypoint2D

Container field: geometry

[in,out] SFNode metadata  
[in,out] MFVec2f point  

PositionInterpolator

Container field: children

[in,out] MFFloat key b
[in,out] MFVec3f keyValue b
[in,out] SFNode metadata  
[in] SFFloat set_fraction b
[in,out] SFVec3f value_changed b

ProximitySensor

Container field: children

[in,out] SFVec3f center b
[in,out] SFBool enabled b
[in,out] SFTime enterTime b
[in,out] SFTime exitTime b
[in,out] SFBool isActive b
[in,out] SFNode metadata  
[in,out] SFRotation orientation_changed b
[in,out] SFVec3f position_changed b
[in,out] SFVec3f size b

Rectangle2D

Container field: geometry

[in,out] SFNode metadata  
[] SFVec2f size  
[] SFBoolean solid  

ScalarBundle

Container field: children

[in,out] MFNode children  
[in,out] SFNode metadata  
[out] MFFloat value_changed  

Node ScalarBundle bundles multiple nodes which have an SFFloat field "value". When at least one of them changes, it sends an event with all the values as an MFFloat.

ScalarInterpolator

Container field: children

[in,out] MFFloat key b
[in,out] MFFloat keyValue b
[in,out] SFNode metadata  
[in] SFFloat set_fraction b
[in,out] SFFloat value_changed b

Scope

Container field: children

[in] MFFloat addVector  
[in] SFBool clear  
[in,out] SFNode metadata  
[in,out] SFVec2f size  
[in,out] SFFloat timeWindow  
[in,out] MFNode traceMaterial  
[in,out] MFFloat vectorMax  
[in,out] MFFloat vectorMin  

Node Scope is a geometry which displays one or several traces, scrolling continuously to the left. New data are appended to the right with input event addVector. The Scope geometry is a rectangle centered at 0 in the z=0 plane whose size is given by field size. Like Text nodes, no background is displayed. The value range and the material (color) of each trace are given by the corresponding elements of fields vectorMin, vectorMax and traceMaterial.

Script

Container field: children

[] SFBool directOutput b
[in,out] SFNode metadata  
[] SFBool mustEvaluate b
[in,out] MFString url b

Shape

Container field: children

[in,out] SFNode appearance b
[in,out] SFNode geometry b
[in,out] SFNode metadata  

Sound

Container field: children

[in,out] SFVec3f direction b
[in,out] SFFloat intensity b
[in,out] SFVec3f location b
[in,out] SFFloat maxBack b
[in,out] SFFloat maxFront b
[in,out] SFNode metadata  
[in,out] SFFloat minBack b
[in,out] SFFloat minFront b
[in,out] SFFloat priority b
[in,out] SFNode source b
[] SFBool spatialize b

Sphere

Container field: geometry

[in,out] SFNode metadata  
[] SFFloat radius b
[] SFBool solid  

SphereSensor

Container field: children

[in,out] SFBool autoOffset b
[in,out] SFString description  
[in,out] SFBool enabled b
[out] SFBool isActive b
[in,out] SFNode metadata  
[in,out] SFRotation offset b
[out] SFRotation rotation_changed b
[out] SFVec3f trackPoint_changed b

SpotLight

Container field: children

[in,out] SFFloat ambientIntensity b
[in,out] SFVec3f attenuation b
[in,out] SFFloat beamWidth b
[in,out] SFColor color b
[in,out] SFFloat cutOffAngle b
[in,out] SFVec3f direction b
[in,out] SFFloat intensity b
[in,out] SFVec3f location b
[in,out] SFNode metadata  
[in,out] SFBool on b
[in,out] SFFloat radius b

Switch

Container field: children

[in] MFNode addChildren  
[] SFVec3f bboxCenter  
[] SFVec3f bboxSize  
[in,out] MFNode children  
[in,out] MFNode choice v
[in,out] SFNode metadata  
[in] MFNode removeChildren  
[in,out] SFInt32 whichChoice b

Text

Container field: geometry

[in,out] SFNode fontStyle b
[in,out] MFFloat length b
[in,out] SFFloat maxExtent b
[in,out] SFNode metadata  
[in,out] MFString string b

TextTexture

Container field: texture

[in,out] SFNode fontStyle  
[in,out] SFNode metadata  
[in,out] SFVec2f size  
[in,out] MFString string  

Node TextTexture is a texture defined by text. The text is rendered with its font size (default: 1) in a rectangle whose size is specified by field size (default: 1 1), then stretched like other textures. Alignment is based on the whole rectangle, not the bounding box of the text; i.e. centered text is centered in the middle of the texture.

TextureCoordinate

Container field: texCoord

[in,out] SFNode metadata  
[in,out] MFVec2f point b

TextureMatrixTransform

Container field: textureTransform

[in,out] SFMatrix3f matrix  
[in,out] SFNode metadata  

Node TextureMatrixTransform can be used in field textureTransform of node Appearance in lieu of node TextureTransform. The texture transform is provided as a 3x3 matrix which describes the homogeneous transform of texture coordinates. It is more general than TextureTransform, which cannot describe shear transforms.

TextureTransform

Container field: textureTransform

[in,out] SFVec2f center b
[in,out] SFNode metadata  
[in,out] SFFloat rotation b
[in,out] SFVec2f scale b
[in,out] SFVec2f translation b

TimeSensor

Container field: children

[in,out] SFTime cycleInterval b
[out] SFTime cycleTime b
[in,out] SFBool enabled b
[out] SFFloat fraction_changed b
[out] SFBool isActive b
[in,out] SFBool loop b
[in,out] SFNode metadata  
[in,out] SFTime startTime b
[in,out] SFTime stopTime b
[out] SFTime time b

TimeTrigger

Container field: children

[in,out] SFNode metadata  
[in] SFBool set_boolean  
[out] SFTime triggerTime  

Torus

Container field: geometry

[in,out] SFFloat innerRadius  
[in,out] SFNode metadata  
[in,out] SFFloat outerRadius  
[in,out] SFBool solid  

TouchSensor

Container field: children

[in,out] SFString description  
[in,out] SFBool enabled b
[out] SFVec3f hitNormal_changed b
[out] SFVec3f hitPoint_changed b
[out] SFVec2f hitTexCoord_changed b
[out] SFBool isActive b
[out] SFBool isOver b
[in,out] SFNode metadata  
[out] SFTime touchTime b

Transform

Container field: children

[in] MFNode addChildren b
[] SFVec3f bboxCenter b
[] SFVec3f bboxSize b
[in,out] SFVec3f center b
[in,out] MFNode children b
[in,out] SFFloat factor  
[in,out] SFNode metadata  
[in] MFNode removeChildren b
[in,out] SFRotation rotation b
[in,out] SFVec3f scale b
[in,out] SFRotation scaleOrientation b
[in,out] SFVec3f translation b

The value of new field factor is used to weight the effect of rotation, scale and translation:

rotation
the angle of rotation (fourth component) is multiplied by factor;
scale
each of the 3 components s is replaced by sign(s)*exp(log(abs(s))*factor) if s is nonzero;
translation
the translation vector is multiplied by factor.

TriangleSet2D

Container field: geometry

[in,out] SFNode metadata  
[] SFBoolean solid  
[in,out] MFVec2f vertices  

Viewpoint

Container field: children

[out] SFTime bindTime b
[] SFString description b
[in,out] SFFloat fieldOfView b
[out] SFBool isBound b
[in,out] SFBool jump b
[in,out] SFNode metadata  
[in,out] SFRotation orientation b
[in,out] SFVec3f position b
[in] SFBool set_bind b

VisibilitySensor

Container field: children

[in,out] SFVec3f center b
[in,out] SFBool enabled b
[out] SFTime enterTime b
[out] SFTime exitTime b
[out] SFBool isActive b
[in,out] SFNode metadata  
[in,out] SFVec3f size b

WorldInfo

Container field: children

[] MFString info b
[in,out] SFNode metadata  
[] SFString title b

ImageTexture URL

Predefined image textures:

texture:none
No texture (maximum intensity specified for the material everywhere).
texture:grid
Grid, with a 10% band at the bottom and left of the cell at maximum intensity, and the remaining area at 40% of the maximum intensity.
texture:checkerboard
2x2 checkerboard, with the bottom-left and top-right squares at maximum intensity, and the remaining area at 40% of the maximum intensity.
texture:spot
Centered spot (disk) with maximum intensity, with an area of 50%, on a background at 40% of the maximum intensity.
texture:trispot
Two elliptic spots for triangular grid pattern. To obtain disks and a grid with main directions 60 degrees apart (its intended usage), the texture u axis should be stretched by a factor sqrt(3) (e.g. scale 1 1.732 in a TextureTransform node).
texture:tennisball
Line aimed to be used on a Sphere node to reproduce the motif of tennis balls.

Scripts

Inline JavaScript is supported, with url starting with ecmascript:, javascript: or vrmlscript:.

Object Browser contains a custom method rk4 to integrate ordinary differential equations using Runge-Kutta order 4 with fixed time step:

Browser.rk4(state, t0, tFinal, maxTimeStep, opt);

Arguments:

state
Object which contains the state in any suitable format, including the time for time-variant systems. Individual state values can be given descriptive names or even grouped in sub-objects or vectors for large systems.
t0
Start time (typically the time of the last call to Browser.rk4)
tFinal
Final time (typically the current time)
maxTimeStep
Maximum time step, should be chosen to take into account the dynamics of the system (typically 2-5 times smaller than the fastest mode). The interval from t0 to tFinal is split into an integer number of steps not larger than maxTimeStep
opt
Object containing functions describing the system, in the following fields:
getContStates
function (state) retrieving as an array the continuous-time states to be integrated from state object
setContStates
function (state, contStateVec) setting continuous-time states in state object from an array
setT
function (t) setting the current time (can be undefined for time-independent systems)
der
function (state) calculating the derivative of the continuous-time states, returned as an array.

Example: simple pendulum

The current time is stored in the state object field t0 for convenience, even if the system is time-invariant.

// Simple pendulum, length L
L = 1;
g = 9.81;
var opt = {
  getContStates: function (state) {
    return [state.theta, state.thetaDer];
  },
  setContStates: function (state, stateVec) {
    state.theta = stateVec[0];
    state.thetaDer = stateVec[1];
  },
  der: function (state) {
    return [
      state.thetaDer,
      -g/L * Math.sin(state.theta) - d * state.thetaDer
    ];
  }
};
state = {t0: 0, theta: 1, thetaDer: 0};
// Simulation until t
Browser.rk4(state, state.t0, t, 0.01, opt);
state.t0 = t;

Extended syntax

In addition to custom nodes, Calerga VR extends the syntax of the Classic VRML encoding.

Default field names

In Classic VRML encoding, the default container (default field name associated to each Node type as defined for X3D XML) can be omitted. Multiple values can be defined for MFNode fields. This also works with prototypes: a node referring to a prototype has the default container of its first child. Fields with a type different than SFNode or MFNode, or with a USE reference, must have an explicit field name.

Transform {
  rotation 1 0 0 1.58
  Shape {
    Box {
      size 3 0.5 3
    }
    Appearance {
      Material {
        diffuseColor 1 0 0
      }
    }
  }
  Shape {
    Sphere {}
    Appearance {
      ImageTexture {
        url "texture:checkerboard"
      }
    }
  }
}

Expressions

Expressions are a powerful extension to field references in prototype definitions and to routes. They can often replace simple scripts with a much more compact and more readable syntax.

In VRML Classic encoding, wherever IS name is permitted, the syntax (expr) stands for an expression which must be evaluated the first time the scene is rendered and when the values it refers to change.

In routes, ROUTE FROM srcNode.srcField FILTER (expr) TO destNode.destField replaces the value associated with srcNode.srcField with the result of the expression, where value refers to srcNode.srcField.

In XML encoding, expressions in <IS> elements are written as <connect nodeField="f" expression="expr"/>; filter expressions in routes are written as a filter="expr" attribute in <ROUTE> elements.

In JSON encoding, expressions in connect arrays are written as {"@nodeField":"f", "@expression":"expr"}; filter expressions in routes are written as a "@filter":"expr" field in ROUTE arrays.

The expression syntax is described below. It aims at simplicity and compactness.

Types

Operators

Functions

Arrays

Arrays are built by enclosing comma-separated values between brackets: [item1,item2,...]. The array type is defined only if the array is not empty. An array cannot contain items of different types.

Array indexing consists in getting a single scalar value from an array. The type of the scalar value is a number, a boolean, a string or a node, depending on the array type. The indexing syntax is array[index], where both array and index can be expressions. The first element has index 0. An out-of-bound index causes a run-time error.

Values

Example: led with boolean state

#X3D V3.3 utf8

PROTO Led [
  # default size: same as Box
  inputOutput SFVec3f size 2 2 2
  # default off color: dark gray
  inputOutput SFColor diffuseColor 0.2 0.2 0.2
  # default on color: bright green
  inputOutput SFColor emissiveColor 0 1 0
  # default state: off
  inputOutput SFBool state FALSE
] {
  Shape {
    geometry Box {
      size IS size
    }
    appearance Appearance {
      material Material {
        diffuseColor IS diffuseColor
        emissiveColor (state ? emissiveColor : [0, 0, 0])
      }
    }
  }
}

Led {
  # off: dark red
  diffuseColor 0.3 0.1 0.1
  # on: bright red
  emissiveColor 1 0 0
  state TRUE
}