#VRML V2.0 utf8 # [X3D] VRML V4.0 utf8 # PROFILE Immersive # [X3D] version=4.0 # [X3D] noNamespaceSchemaLocation=/specifications/x3d-4.0.xsd # X3D-to-VRML-97 XSL translation autogenerated by X3dToVrml97.xslt # /x3d/content/X3dToVrml97.xslt # Transformation using XSLT processor: Saxonica # [head] # META "title" "RefractiveMaterial.x3d" # META "description" "X3D encodings example: create new node RefractiveMaterial for example PrototypesPlus." # META "creator" "Don Brutzman and Joe Williams" # META "created" "1 June 2002" # META "modified" "28 September 2025" # META "reference" "PrototypesPlus.x3d" # META "specificationSection" "X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, Annex C.7 Prototypes and alternate representations" # META "specificationUrl" "/specifications/X3Dv4Draft/ISO-IEC19776-1v4.0-CD/Part01/examples.html#PrototyesAndAlternateReps" # META "identifier" "/x3d/content/examples/Basic/X3dSpecifications/RefractiveMaterial.x3d" # META "generator" "X3D-Edit 4.0, /x3d/tools/X3D-Edit" # META "license" "../license.html" # [Scene] ========== ========== ========== # Protype definition for external use WorldInfo { title "RefractiveMaterial.x3d" } PROTO RefractiveMaterial [ exposedField SFFloat ambientIntensity 0 exposedField SFColor diffuseColor 0.5 0.5 0.5 exposedField SFColor specularColor 0 0 0 exposedField SFColor emissiveColor 0 0 0 exposedField SFFloat shininess 0 exposedField SFFloat transparency 0 exposedField SFFloat indexOfRefraction 0.1 ] { DEF RefractiveMaterialNode Material { ambientIntensity IS ambientIntensity diffuseColor IS diffuseColor specularColor IS specularColor emissiveColor IS emissiveColor shininess IS shininess transparency IS transparency } DEF RefractionScript Script { ### Warning: Script field 'transparencyInitial' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors. exposedField SFFloat transparencyInitial IS transparency ### Warning: Script field 'indexOfRefraction' has accessType 'inputOutput' (exposedField), which is only allowed in X3D Script node, not VRML97 Script node. Using exposedField anyway, may cause errors. exposedField SFFloat indexOfRefraction IS indexOfRefraction eventOut SFFloat transparency_changed ### Warning: Script 'var' declarations of variables are not persistent in contained ecmascript: code, values are lost after each call. Use definitions instead. url [ "javascript: // ### X3D Browser.print() not supported by all VRML97 viewers, instead simply using print() function initialize() { // arbitary example modification of usual node properties var newTransparency = 1.0 - ((1.0 - transparencyInitial) * indexOfRefraction); printingln ('indexOfRefraction=' + indexOfRefraction + ', transparencyInitial=' + transparencyInitial + ', transparency_changed=' + newTransparency); transparency_changed = newTransparency; } function set_transparencyInitial (eventValue) { // input eventValue received for inputOutput field transparencyInitial = eventValue; } function set_indexOfRefraction (eventValue) { // input eventValue received for inputOutput field indexOfRefraction = eventValue; } " ] } ROUTE RefractionScript.transparency_changed TO RefractiveMaterialNode.transparency }