@prefix :        <https://www.web3d.org/x3d/content/examples/Basic/course/CreateVrmlFromStringRandomBoxes.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.1' ;
  x3do:noNamespaceSchemaLocation 'https://www.web3d.org/specifications/x3d-3.1.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_12, :meta_1_13, :meta_1_14, :meta_1_15 .
:meta_1_1 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'CreateVrmlFromStringRandomBoxes.x3d' ;
  x3do:name 'title' .
:meta_1_2 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Sample world constructed in a Script node using the EcmaScript Browser call createVrmlFromString.' ;
  x3do:name 'description' .
:meta_1_3 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Vincent Gardet' ;
  x3do:name 'creator' .
:meta_1_4 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Curt Blais' ;
  x3do:name 'translator' .
:meta_1_5 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Don Brutzman' ;
  x3do:name 'contributor' .
:meta_1_6 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '23 April 2002' ;
  x3do:name 'created' .
:meta_1_7 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '12 October 2023' ;
  x3do:name 'modified' .
:meta_1_8 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'CreateX3dFromStringRandomSpheres.x3d' ;
  x3do:name 'reference' .
:meta_1_9 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'CreateVrmlFromStringRandomBoxes.png' ;
  x3do:name 'Image' .
:meta_1_10 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'See CreateVrmlFromString tutorial at' ;
  x3do:name 'reference' .
:meta_1_11 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'http://www.gardet.nom.fr/vrmlcity/tut_cvfs.htm' ;
  x3do:name 'reference' .
:meta_1_12 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'create VRML from string, javascript' ;
  x3do:name 'subject' .
:meta_1_13 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/content/examples/Basic/course/CreateVrmlFromStringRandomBoxes.x3d' ;
  x3do:name 'identifier' .
:meta_1_14 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit' ;
  x3do:name 'generator' .
:meta_1_15 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '../license.html' ;
  x3do:name 'license' .
:meta dcterms:title "CreateVrmlFromStringRandomBoxes.x3d" .
:meta dcterms:description "Sample world constructed in a Script node using the EcmaScript Browser call createVrmlFromString." .
:meta dcterms:creator "Vincent Gardet" .
:meta dcterms:translator "Curt Blais" .
:meta dcterms:created "23 April 2002" .
:meta dcterms:modified "12 October 2023" .
:meta dcterms:reference "CreateX3dFromStringRandomSpheres.x3d" .
:meta dcterms:Image "CreateVrmlFromStringRandomBoxes.png" .
:meta dcterms:reference "See CreateVrmlFromString tutorial at" .
:meta dcterms:reference "http://www.gardet.nom.fr/vrmlcity/tut_cvfs.htm" .
:meta dcterms:subject "create VRML from string, javascript" .
:meta dcterms:identifier "https://www.web3d.org/x3d/content/examples/Basic/course/CreateVrmlFromStringRandomBoxes.x3d" .
:meta dcterms:generator "X3D-Edit 4.0, 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, :Background_2_3, :DirectionalLight_2_4, :DirectionalLight_2_5, :DirectionalLight_2_6, :Viewpoint_2_7, :Viewpoint_2_8, :Shape_2_9, :Transform_2_10, :HoldsAutogeneratedContent, :BoxGeneratorScript ;
  x3do:hasROUTE :ROUTE_2_13 .
:WorldInfo_2_1 a owl:NamedIndividual, x3do:WorldInfo ;
  x3do:hasParent :Scene ;
  x3do:title 'CreateVrmlFromStringRandomBoxes.x3d' .
:NavigationInfo_2_2 a owl:NamedIndividual, x3do:NavigationInfo ;
  x3do:hasParent :Scene ;
  x3do:avatarSize ( 0.1 1.6 2.0 ) ;
  x3do:headlight false ;
  x3do:speed 5 ;
  x3do:type '"EXAMINE" "WALK" "ANY"' .
:Background_2_3 a owl:NamedIndividual, x3do:Background ;
  x3do:hasParent :Scene ;
  x3do:skyAngle ( 1.1 1.57 ) ;
  x3do:skyColor ( .3 .3 1 .4 .4 1 .7 .7 .9 ) .
:DirectionalLight_2_4 a owl:NamedIndividual, x3do:DirectionalLight ;
  x3do:hasParent :Scene ;
  x3do:direction ( 0 -0.5 -1 ) .
:DirectionalLight_2_5 a owl:NamedIndividual, x3do:DirectionalLight ;
  x3do:hasParent :Scene ;
  x3do:direction ( -1 -0.5 .5 ) ;
  x3do:intensity .9 .
:DirectionalLight_2_6 a owl:NamedIndividual, x3do:DirectionalLight ;
  x3do:hasParent :Scene ;
  x3do:direction ( 1 -0.5 .5 ) ;
  x3do:intensity .8 .
:Viewpoint_2_7 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description 'Interaction view' ;
  x3do:position ( 50 1.6 150 ) .
:Viewpoint_2_8 a owl:NamedIndividual, x3do:Viewpoint ;
  x3do:hasParent :Scene ;
  x3do:description 'Plan (top-down) view' ;
  x3do:orientation ( 1 0 0 -1.54 ) ;
  x3do:position ( 50 200 50 ) .
:Shape_2_9 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Scene ;
  x3do:hasAppearance :Appearance_2_9_1 ;
  x3do:hasGeometry :Box_2_9_2 .
:Appearance_2_9_1 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_9 ;
  x3do:hasMaterial :Material_2_9_1_1 .
:Material_2_9_1_1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :Appearance_2_9_1 ;
  x3do:diffuseColor ( .3 .3 1 ) ;
  x3do:transparency 0.5 .
:Box_2_9_2 a owl:NamedIndividual, x3do:Box ;
  x3do:hasParent :Shape_2_9 ;
  x3do:size ( 1000 0.01 1000 ) .
:Transform_2_10 a owl:NamedIndividual, x3do:Transform ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Billboard_2_10_1 ;
  x3do:translation ( 50 1.6 140 ) .
:Billboard_2_10_1 a owl:NamedIndividual, x3do:Billboard ;
  x3do:hasParent :Transform_2_10 ;
  x3do:hasChildren :Shape_2_10_1_1, :TouchText, :Shape_2_10_1_3 .
:Shape_2_10_1_1 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Billboard_2_10_1 ;
  x3do:hasAppearance :Appearance_2_10_1_1_1 ;
  x3do:hasGeometry :Text_2_10_1_1_2 .
:Appearance_2_10_1_1_1 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_10_1_1 ;
  x3do:hasMaterial :Material_2_10_1_1_1_1 .
:Material_2_10_1_1_1_1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :Appearance_2_10_1_1_1 ;
  x3do:diffuseColor ( 0.1 0.3 0.2 ) ;
  x3do:emissiveColor ( 0.3 0.6 0.9 ) .
:Text_2_10_1_1_2 a owl:NamedIndividual, x3do:Text ;
  x3do:hasParent :Shape_2_10_1_1 ;
  x3do:hasFontStyle :FontStyle_2_10_1_1_2_1 ;
  x3do:string '"Ten random boxes" "computed at runtime" "(select text to recompute)"' .
:FontStyle_2_10_1_1_2_1 a owl:NamedIndividual, x3do:FontStyle ;
  x3do:hasParent :Text_2_10_1_1_2 ;
  x3do:justify '"MIDDLE" "MIDDLE"' .
:TouchText a owl:NamedIndividual, x3do:TouchSensor ;
  x3do:hasParent :Billboard_2_10_1 ;
  x3do:DEF 'TouchText' ;
  x3do:description 'Touch text to recompute random boxes' .
:Shape_2_10_1_3 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Billboard_2_10_1 ;
  x3do:hasGeometry :Box_2_10_1_3_1 ;
  x3do:hasAppearance :Appearance_2_10_1_3_2 .
:Box_2_10_1_3_1 a owl:NamedIndividual, x3do:Box ;
  x3do:hasParent :Shape_2_10_1_3 ;
  x3do:size ( 8 2 0.1 ) .
:Appearance_2_10_1_3_2 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_10_1_3 ;
  x3do:hasMaterial :Material_2_10_1_3_2_1 .
:Material_2_10_1_3_2_1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :Appearance_2_10_1_3_2 ;
  x3do:transparency 1 .
:HoldsAutogeneratedContent a owl:NamedIndividual, x3do:Group ;
  x3do:hasParent :Scene ;
  x3do:DEF 'HoldsAutogeneratedContent' .
:BoxGeneratorScript a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :Scene ;
  x3do:hasField :field_2_12_1, :field_2_12_2 ;
  x3do:DEF 'BoxGeneratorScript' ;
  x3do:directOutput true ;
  x3do:sourceCode """
ecmascript:

function R () {
	return Math.random();
}
function recompute (isActive) {
	if (isActive==true) initialize();
}

function initialize() {
  for (i=0; i < 10; i++) {
    rand1 = 100*R();
    rand2 = 100*R();
    rand3 = 20*R();
    rand4 = 40*R();
    rand5 = 20*R();
    sceneString ='Transform {                                                    \n' +
                      '   translation ' + rand1 + ' 0 ' + rand2 + ' \n' +
                      '   children [                                            \n' +
                      '           Shape {                                       \n' +
                      '                   appearance Appearance {               \n' +
                      '                      material Material {                \n' +
                      '                         diffuseColor ' + R() + ' ' + R() + ' ' + R() + '\n' +
                      '                      }                                  \n' +
                      '                   }                                     \n' +
                      '                   geometry Box {                        \n' +
                      '                      size ' + rand3 + ' ' + rand4 + ' ' + rand5 + '\n' +
                      '                   }                                     \n' +
                      '           }                                             \n' +
                      '   ]                                                     \n' +
                      '}                                                        \n' +
                      '#########################################################\n';
       Browser.println (sceneString);
       newNode = Browser.createVrmlFromString(sceneString);
//     newNode = Browser.createX3dFromString(sceneString);
       ModifiableExternalNode.children[i] = newNode[0];
  }
}
""" .
:field_2_12_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :BoxGeneratorScript ;
  x3do:hasChildren :HoldsAutogeneratedContent-USE-1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'ModifiableExternalNode' ;
  x3do:type 'SFNode' .
:HoldsAutogeneratedContent-USE-1 a owl:NamedIndividual, x3do:Group ;
  x3do:hasParent :field_2_12_1 ;
  owl:sameAs :HoldsAutogeneratedContent . # DEF matching this USE
:field_2_12_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :BoxGeneratorScript ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'recompute' ;
  x3do:type 'SFBool' .
:ROUTE_2_13 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Scene ;
  x3do:fromField 'isActive' ;
  x3do:fromNode 'TouchText' ;
  x3do:toField 'recompute' ;
  x3do:toNode 'BoxGeneratorScript' .
