@prefix :        <https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/CreateNodesFromPrototypeECMAScript.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_1 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'CreateNodesFromPrototypeECMAScript.x3d' ;
  x3do:name 'title' .
:meta_1_2 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'This example shows creation of nodes from a prototype' ;
  x3do:name 'description' .
:meta_1_3 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D Specification' ;
  x3do:name 'creator' .
:meta_1_4 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '23 February 2005' ;
  x3do:name 'translated' .
: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 'X3D ECMAScript Script Authoring Interface (SAI)' ;
  x3do:name 'subject' .
:meta_1_7 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/CreateNodesFromPrototypeECMAScript.x3d' ;
  x3do:name 'identifier' .
:meta_1_8 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/specifications/ISO-IEC-19777-1-X3DLanguageBindings-ECMAScript/Part1/examples.html#CreateNodesFromAPrototype' ;
  x3do:name 'reference' .
:meta_1_9 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html' ;
  x3do:name 'generator' .
: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 "CreateNodesFromPrototypeECMAScript.x3d" .
:meta dcterms:description "This example shows creation of nodes from a prototype" .
:meta dcterms:creator "X3D Specification" .
:meta dcterms:translated "23 February 2005" .
:meta dcterms:modified "20 October 2019" .
:meta dcterms:subject "X3D ECMAScript Script Authoring Interface (SAI)" .
:meta dcterms:identifier "https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/CreateNodesFromPrototypeECMAScript.x3d" .
:meta dcterms:reference "https://www.web3d.org/x3d/specifications/ISO-IEC-19777-1-X3DLanguageBindings-ECMAScript/Part1/examples.html#CreateNodesFromAPrototype" .
:meta dcterms:generator "Vrml97ToX3dNist, http://ovrt.nist.gov/v2_x3d.html" .
: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, :SC ;
  x3do:hasProtoDeclare :ProtoDeclare_2_2 .
:WorldInfo_2_1 a owl:NamedIndividual, x3do:WorldInfo ;
  x3do:hasParent :Scene ;
  x3do:title 'CreateNodesFromPrototypeECMAScript.x3d' .
:ProtoDeclare_2_2 a owl:NamedIndividual, x3do:ProtoDeclare ;
  x3do:hasParent :Scene ;
  x3do:hasProtoInterface :ProtoInterface_2_2_1 ;
  x3do:hasProtoBody :ProtoBody_2_2_2 ;
  x3do:name 'ColoredSphere' .
:ProtoInterface_2_2_1 a owl:NamedIndividual, x3do:ProtoInterface ;
  x3do:hasParent :ProtoDeclare_2_2 ;
  x3do:hasField :field_2_2_1_1 .
:field_2_2_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :ProtoInterface_2_2_1 ;
  x3do:accessType 'initializeOnly' ;
  x3do:name 'color' ;
  x3do:type 'SFColor' ;
  x3do:value ( 0.0 0.0 0.0 ) .
:ProtoBody_2_2_2 a owl:NamedIndividual, x3do:ProtoBody ;
  x3do:hasParent :ProtoDeclare_2_2 ;
  x3do:hasChildren :Shape_2_2_2_1 .
:Shape_2_2_2_1 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :ProtoBody_2_2_2 ;
  x3do:hasAppearance :Appearance_2_2_2_1_1 ;
  x3do:hasGeometry :Sphere_2_2_2_1_2 .
:Appearance_2_2_2_1_1 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_2_2_1 ;
  x3do:hasMaterial :Material_2_2_2_1_1_1 .
:Material_2_2_2_1_1_1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :Appearance_2_2_2_1_1 ;
  x3do:hasIS :IS_2_2_2_1_1_1_1 .
:IS_2_2_2_1_1_1_1 a owl:NamedIndividual, x3do:IS ;
  x3do:hasParent :Material_2_2_2_1_1_1 ;
  x3do:hasConnect :connect_2_2_2_1_1_1_1_1 .
:connect_2_2_2_1_1_1_1_1 a owl:NamedIndividual, x3do:connect ;
  x3do:hasParent :IS_2_2_2_1_1_1_1 ;
  x3do:nodeField 'diffuseColor' ;
  x3do:protoField 'color' .
:Sphere_2_2_2_1_2 a owl:NamedIndividual, x3do:Sphere ;
  x3do:hasParent :Shape_2_2_2_1 .
:SC a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :Scene ;
  x3do:DEF 'SC' ;
  x3do:sourceCode """
ecmascript:

// Create nodes directly in the parent scene

function initialize()
{
    scene = Browser.currentScene;

    // Look through proto declarations for ColoredSphere
    protoDecls = scene.protoDeclarations;

    var protoDecl;

    for(i=0; i < protoDecls.length; i++) {
        if (protoDecls[i].name == 'ColoredSphere')
            protoDecl = protoDecls[i];
    }

    // Create an instance of RedSphere
    instance = protoDecl.newInstance();

    // Set the color field to Red
    instance.color = new SFColor(1,0,0);

    // Add the created proto to the scene
    scene.rootNodes[0] = instance;
}
""" .
