#X3D V4.0 utf8 PROFILE Immersive # [X3D] version=4.0 # [X3D] noNamespaceSchemaLocation=/specifications/x3d-4.0.xsd # X3D-to-ClassicVRML XSL translation autogenerated by X3dToClassicVrmlEncoding.xslt and X3dToVrml97.xslt # /x3d/content/X3dToClassicVrmlEncoding.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 [ inputOutput SFFloat ambientIntensity 0 inputOutput SFColor diffuseColor 0.5 0.5 0.5 inputOutput SFColor specularColor 0 0 0 inputOutput SFColor emissiveColor 0 0 0 inputOutput SFFloat shininess 0 inputOutput SFFloat transparency 0 inputOutput 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 { inputOutput SFFloat transparencyInitial IS transparency inputOutput SFFloat indexOfRefraction IS indexOfRefraction outputOnly 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 [ "ecmascript: // ### 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); Browser.println ('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 }