@prefix :        <https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/ChangingFog.ttl#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema:  <http://schema.org/> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix x3d:     <https://www.web3d.org/specifications/x3d-4.0.xsd#> .
@prefix x3do:    <https://www.web3d.org/specifications/X3dOntology4.0#> .

:X3D a owl:NamedIndividual, x3do:X3D ;
  x3do:hasHead :head ;
  x3do:hasScene :Scene ;
  x3do:profile 'Immersive' ;
  x3do:version '3.3' ;
  x3do:noNamespaceSchemaLocation 'https://www.web3d.org/specifications/x3d-3.3.xsd' .
:head a owl:NamedIndividual, x3do:head ;
  x3do:hasParent :X3D ;
  x3do:hasMeta :meta_1_1, :meta_1_2, :meta_1_3, :meta_1_4, :meta_1_5, :meta_1_6, :meta_1_7, :meta_1_8, :meta_1_9, :meta_1_10, :meta_1_11 .
:meta_1_1 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'ChangingFog.x3d' ;
  x3do:name 'title' .
:meta_1_2 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'A Fog node that adjusts as the viewer&apos;s orientation and position changes. This is a good candidate to become a Prototype since Fog does not automatically bind when inlined.' ;
  x3do:name 'description' .
:meta_1_3 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Matthew Braun' ;
  x3do:name 'creator' .
:meta_1_4 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '20 September 2001' ;
  x3do:name 'created' .
:meta_1_5 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '20 October 2019' ;
  x3do:name 'modified' .
:meta_1_6 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'http://astronomy.swin.edu.au/pbourke/geometry/rotate/' ;
  x3do:name 'reference' .
:meta_1_7 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Copyright (c) Matthew Braun 2001' ;
  x3do:name 'rights' .
:meta_1_8 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Fog' ;
  x3do:name 'subject' .
:meta_1_9 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/ChangingFog.x3d' ;
  x3do:name 'identifier' .
:meta_1_10 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit' ;
  x3do:name 'generator' .
:meta_1_11 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '../license.html' ;
  x3do:name 'license' .
:meta dcterms:title "ChangingFog.x3d" .
:meta dcterms:description "A Fog node that adjusts as the viewer's orientation and position changes. This is a good candidate to become a Prototype since Fog does not automatically bind when inlined." .
:meta dcterms:creator "Matthew Braun" .
:meta dcterms:created "20 September 2001" .
:meta dcterms:modified "20 October 2019" .
:meta dcterms:reference "http://astronomy.swin.edu.au/pbourke/geometry/rotate/" .
:meta dcterms:rights "Copyright (c) Matthew Braun 2001" .
:meta dcterms:subject "Fog" .
:meta dcterms:identifier "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/KelpForestExhibit/ChangingFog.x3d" .
:meta dcterms:generator "X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit" .
:meta dcterms:license "../license.html" .
:Scene a owl:NamedIndividual, x3do:Scene ;
  x3do:hasParent :X3D ;
  x3do:hasChildren :WorldInfo_2_1, :NavigationInfo_2_2, :Viewpoint_2_3, :Viewpoint_2_4, :Viewpoint_2_5, :Viewpoint_2_6, :Viewpoint_2_7, :Viewpoint_2_8, :Viewpoint_2_9, :Viewpoint_2_10, :Water, :ProxSensor, :Clock, :ChangeVisibility, :Pointer, :Transform_2_20, :Transform_2_21, :Transform_2_22, :Transform_2_23, :Transform_2_24 ;
  x3do:hasROUTE :ROUTE_2_15, :ROUTE_2_16, :ROUTE_2_17, :ROUTE_2_18 .
:WorldInfo_2_1 a owl:NamedIndividual, x3do:WorldInfo ;
  x3do:hasParent :Scene ;
  x3do:title 'ChangingFog.x3d' .
:NavigationInfo_2_2 a owl:NamedIndividual, x3do:NavigationInfo ;
  x3do:hasParent :Scene ;
  x3do:avatarSize ( 0.01 0 0 ) .
:Viewpoint_2_3 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description 'Start' ;
  x3do:fieldOfView 0.9 ;
  x3do:position ( 0 0 0 ) .
:Viewpoint_2_4 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description 'Looking up from start' ;
  x3do:orientation ( 1 0 0 1.57 ) ;
  x3do:position ( 0 0 0 ) .
:Viewpoint_2_5 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description '10m above, looking straight up' ;
  x3do:orientation ( 1 0 0 1.57 ) ;
  x3do:position ( 0 10 0 ) .
:Viewpoint_2_6 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description '10m above start' ;
  x3do:position ( 0 10 0 ) .
:Viewpoint_2_7 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description '10m above, looking straight down' ;
  x3do:orientation ( 1 0 0 -1.57 ) ;
  x3do:position ( 0 10 0 ) .
:Viewpoint_2_8 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description '10m below, looking down' ;
  x3do:orientation ( 1 0 0 -1.57 ) ;
  x3do:position ( 0 -10 0 ) .
:Viewpoint_2_9 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description '10m below start' ;
  x3do:position ( 0 -10 0 ) .
:Viewpoint_2_10 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description '10m below, looking up' ;
  x3do:orientation ( 1 0 0 1.57 ) ;
  x3do:position ( 0 -10 0 ) .
:Water a owl:NamedIndividual, x3do:Fog ;
  x3do:hasParent :Scene ;
  x3do:DEF 'Water' ;
  x3do:color ( 0.2 0.2 0.4 ) ;
  x3do:fogType 'EXPONENTIAL' .
:ProxSensor a owl:NamedIndividual, x3do:ProximitySensor ;
  x3do:hasParent :Scene ;
  x3do:DEF 'ProxSensor' ;
  x3do:size ( 1000 1000 1000 ) .
:Clock a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :Scene ;
  x3do:DEF 'Clock' ;
  x3do:loop true .
:ChangeVisibility a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :Scene ;
  x3do:hasField :field_2_14_1, :field_2_14_2, :field_2_14_3, :field_2_14_4, :field_2_14_5 ;
  x3do:DEF 'ChangeVisibility' ;
  x3do:sourceCode """
ecmascript:
// REF: http://astronomy.swin.edu.au/pbourke/geometry/rotate/

function initialize () {
   visibility = 20;
   depth = 0;
   pos = (0,0,0);
   Browser.println ('Position output from ProximitySensor.');
}

function get_clock_hit (clock_msg) {
     run_script = true;
}

function get_depth ( position ) {

   pos = position;
   depth = position[1] - 30;   

}

function set_visibility( rotation ) {

 if (run_script) {

//z coordinate of the default viewpoint direction(0,0,-1)
   initZ = -1;  

   rX = rotation[0];  // x coordinate of the rotation
   rY = rotation[1];  // y coordinate of the rotation
   rZ = rotation[2];  // z coordinate of the rotation

   theta = rotation[3];  // angle of rotation in radians
	
Browser.println ('theta:' + theta);
     
   cosTheta = Math.cos(theta);
   sinTheta = Math.sin(theta);

Browser.println ('cosTheta:' + cosTheta + ' sinTheta:'+ sinTheta);


// calculate the y coordinate of the point after rotation
/* there are 8 other terms in the full conversion, but 6 are equal
to zero because of the choice of a starting point on the z-axis. The
other two are not calculated since all we need is the y coordinate
*/
   finalY = ((1 - cosTheta) * rY * rZ - rX * sinTheta) * initZ;

Browser.println ('final y:' + finalY);

//calculate the elevation/depression angle of the final point location

   elevation = Math.asin(finalY);

Browser.println ('elevation:' + elevation);

   directionFactor = 1 + 0.2 * (4 * elevation / Math.PI);
   depthAdjust = (60 + depth)/60
   depthFactor = Math.max(depthAdjust,0.05);

   visibility_changed =  60 * depthFactor * directionFactor; 
   Browser.println ('depth=' + depth + ', elevation=' + elevation + 
        ', visibility_changed=' + visibility_changed);
   run_script = false;
   
 }
}
""" .
:field_2_14_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ChangeVisibility ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'get_clock_hit' ;
  x3do:type 'SFTime' .
:field_2_14_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ChangeVisibility ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'run_script' ;
  x3do:type 'SFBool' ;
  x3do:value false .
:field_2_14_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ChangeVisibility ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'get_depth' ;
  x3do:type 'SFVec3f' .
:field_2_14_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ChangeVisibility ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'visibility_changed' ;
  x3do:type 'SFFloat' .
:field_2_14_5 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ChangeVisibility ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'set_visibility' ;
  x3do:type 'SFRotation' .
:ROUTE_2_15 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Scene ;
  x3do:fromField 'cycleTime' ;
  x3do:fromNode 'Clock' ;
  x3do:toField 'get_clock_hit' ;
  x3do:toNode 'ChangeVisibility' .
:ROUTE_2_16 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Scene ;
  x3do:fromField 'position_changed' ;
  x3do:fromNode 'ProxSensor' ;
  x3do:toField 'get_depth' ;
  x3do:toNode 'ChangeVisibility' .
:ROUTE_2_17 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Scene ;
  x3do:fromField 'orientation_changed' ;
  x3do:fromNode 'ProxSensor' ;
  x3do:toField 'set_visibility' ;
  x3do:toNode 'ChangeVisibility' .
:ROUTE_2_18 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Scene ;
  x3do:fromField 'visibility_changed' ;
  x3do:fromNode 'ChangeVisibility' ;
  x3do:toField 'visibilityRange' ;
  x3do:toNode 'Water' .
:Pointer a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Transform_2_19_1, :Shape_2_19_2 ;
  x3do:DEF 'Pointer' ;
  x3do:translation ( 0 0 -15 ) .
:Transform_2_19_1 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Pointer ;
  x3do:hasChildren :Shape_2_19_1_1 ;
  x3do:translation ( 0 4 0 ) .
:Shape_2_19_1_1 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Transform_2_19_1 ;
  x3do:hasGeometry :Cone_2_19_1_1_1 ;
  x3do:hasAppearance :ShapeApp .
:Cone_2_19_1_1_1 a owl:NamedIndividual, x3do:Cone ;
  x3do:hasParent :Shape_2_19_1_1 ;
  x3do:bottomRadius 0.4 .
:ShapeApp a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_19_1_1 ;
  x3do:hasMaterial :Material_2_19_1_1_2_1 ;
  x3do:DEF 'ShapeApp' .
:Material_2_19_1_1_2_1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :ShapeApp ;
  x3do:ambientIntensity 0.8 ;
  x3do:diffuseColor ( 1 1 0.3 ) ;
  x3do:shininess 0.6 .
:Shape_2_19_2 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Pointer ;
  x3do:hasGeometry :Cylinder_2_19_2_1 ;
  x3do:hasAppearance :ShapeApp-USE-1 .
:Cylinder_2_19_2_1 a owl:NamedIndividual, x3do:Cylinder ;
  x3do:hasParent :Shape_2_19_2 ;
  x3do:height 6 ;
  x3do:radius 0.2 .
:ShapeApp-USE-1 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_19_2 ;
  owl:sameAs :ShapeApp . # DEF matching this USE
:Transform_2_20 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Pointer-USE-1 ;
  x3do:translation ( 0 10 0 ) .
:Pointer-USE-1 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Transform_2_20 ;
  owl:sameAs :Pointer . # DEF matching this USE
:Transform_2_21 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Pointer-USE-2 ;
  x3do:translation ( 0 -10 0 ) .
:Pointer-USE-2 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Transform_2_21 ;
  owl:sameAs :Pointer . # DEF matching this USE
:Transform_2_22 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Disk ;
  x3do:translation ( 0 15 0 ) .
:Disk a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Transform_2_22 ;
  x3do:hasGeometry :Cylinder_2_22_1_1 ;
  x3do:hasAppearance :ShapeApp-USE-2 ;
  x3do:DEF 'Disk' .
:Cylinder_2_22_1_1 a owl:NamedIndividual, x3do:Cylinder ;
  x3do:hasParent :Disk ;
  x3do:height 0.01 .
:ShapeApp-USE-2 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Disk ;
  owl:sameAs :ShapeApp . # DEF matching this USE
:Transform_2_23 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Disk-USE-1 ;
  x3do:translation ( 0 -15 0 ) .
:Disk-USE-1 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Transform_2_23 ;
  owl:sameAs :Disk . # DEF matching this USE
:Transform_2_24 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :IFSBox ;
  x3do:scale ( 20 20 20 ) .
:IFSBox a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Transform_2_24 ;
  x3do:hasAppearance :Appearance_2_24_1_1 ;
  x3do:hasGeometry :IndexedFaceSet_2_24_1_2 ;
  x3do:DEF 'IFSBox' .
:Appearance_2_24_1_1 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :IFSBox ;
  x3do:hasMaterial :Material_2_24_1_1_1 .
:Material_2_24_1_1_1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :Appearance_2_24_1_1 ;
  x3do:diffuseColor ( 1 1 1 ) .
:IndexedFaceSet_2_24_1_2 a owl:NamedIndividual, x3do:IndexedFaceSet ;
  x3do:hasParent :IFSBox ;
  x3do:hasCoord :Coordinate_2_24_1_2_1 ;
  x3do:hasColor :Color_2_24_1_2_2 ;
  x3do:ccw false ;
  x3do:colorIndex ( 0 2 2 2 2 1 ) ;
  x3do:colorPerVertex false ;
  x3do:coordIndex ( 0 1 2 3 -1 7 6 5 4 -1 0 4 5 1 -1 1 5 6 2 -1 2 6 7 3 -1 3 7 4 0 ) .
:Coordinate_2_24_1_2_1 a owl:NamedIndividual, x3do:Coordinate ;
  x3do:hasParent :IndexedFaceSet_2_24_1_2 ;
  x3do:point ( -1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 -1.0 -1.0 -1.0 -1.0 -1.0 ) .
:Color_2_24_1_2_2 a owl:NamedIndividual, x3do:Color ;
  x3do:hasParent :IndexedFaceSet_2_24_1_2 ;
  x3do:color ( 1 1 1 0 0 0 0.2 0.2 0.8 ) .
