@prefix :        <https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorPrototypeExpanded.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_12, :meta_1_13, :meta_1_14, :meta_1_15, :meta_1_16, :meta_1_17, :meta_1_18, :meta_1_19, :meta_1_20 .
:meta_1_1 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'MaterialModulatorPrototypeExpanded.x3d' ;
  x3do:name 'title' .
:meta_1_2 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Provide example for expansion of a MaterialModulator as regular X3D nodes, rather than a ProtoDeclare/ProtoInstance combination. MaterialModulator mimics a Material node and modulates diffuseColor field as an animation effect.' ;
  x3do:name 'description' .
:meta_1_3 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Don Brutzman, John Carlson, Roy Walmsley' ;
  x3do:name 'creator' .
:meta_1_4 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '2 July 2016' ;
  x3do:name 'created' .
:meta_1_5 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '15 July 2025' ;
  x3do:name 'modified' .
:meta_1_6 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D prototype expander, IS/connect, Script inputOutput field' ;
  x3do:name 'subject' .
:meta_1_7 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'MaterialModulator.png' ;
  x3do:name 'Image' .
:meta_1_8 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'MaterialModulator.x3d' ;
  x3do:name 'reference' .
:meta_1_9 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'JSON prototype expander https://github.com/coderextreme/X3DJSONLD' ;
  x3do:name 'reference' .
:meta_1_10 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Create corresponding web page describing Prototype Expander design.' ;
  x3do:name 'TODO' .
:meta_1_11 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Create stylesheet converter matching this Prototype Expander design pattern.' ;
  x3do:name 'TODO' .
:meta_1_12 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'Add external ROUTEs to original example as a further test case for Prototype Expander design.' ;
  x3do:name 'TODO' .
:meta_1_13 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://github.com/coderextreme/X3DJSONLD/blob/master/PrototypeExpander.js' ;
  x3do:name 'reference' .
:meta_1_14 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://github.com/coderextreme/X3DJSONLD/blob/master/ServerPrototypeExpander.js' ;
  x3do:name 'reference' .
:meta_1_15 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'X3D Tooltips: ProtoBody https://www.web3d.org/x3d/content/X3dTooltips.html#ProtoBody' ;
  x3do:name 'reference' .
:meta_1_16 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '4.4.4.3 PROTO definition semantics https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/concepts.html#PROTOdefinitionsemantics' ;
  x3do:name 'reference' .
:meta_1_17 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '[x3d-public] Prototype Expander, Question on design of instance expansions: http://web3d.org/pipermail/x3d-public_web3d.org/2016-July/004982.html' ;
  x3do:name 'reference' .
:meta_1_18 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content 'https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorPrototypeExpanded.x3d' ;
  x3do:name 'identifier' .
:meta_1_19 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_20 a owl:NamedIndividual, x3do:meta ;
  x3do:hasParent :head ;
  x3do:content '../license.html' ;
  x3do:name 'license' .
:meta dcterms:title "MaterialModulatorPrototypeExpanded.x3d" .
:meta dcterms:description "Provide example for expansion of a MaterialModulator as regular X3D nodes, rather than a ProtoDeclare/ProtoInstance combination. MaterialModulator mimics a Material node and modulates diffuseColor field as an animation effect." .
:meta dcterms:creator "Don Brutzman, John Carlson, Roy Walmsley" .
:meta dcterms:created "2 July 2016" .
:meta dcterms:modified "15 July 2025" .
:meta dcterms:subject "X3D prototype expander, IS/connect, Script inputOutput field" .
:meta dcterms:Image "MaterialModulator.png" .
:meta dcterms:reference "MaterialModulator.x3d" .
:meta dcterms:reference "JSON prototype expander https://github.com/coderextreme/X3DJSONLD" .
:meta dcterms:reference "https://github.com/coderextreme/X3DJSONLD/blob/master/PrototypeExpander.js" .
:meta dcterms:reference "https://github.com/coderextreme/X3DJSONLD/blob/master/ServerPrototypeExpander.js" .
:meta dcterms:reference "X3D Tooltips: ProtoBody https://www.web3d.org/x3d/content/X3dTooltips.html#ProtoBody" .
:meta dcterms:reference "4.4.4.3 PROTO definition semantics https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/concepts.html#PROTOdefinitionsemantics" .
:meta dcterms:reference "[x3d-public] Prototype Expander, Question on design of instance expansions: http://web3d.org/pipermail/x3d-public_web3d.org/2016-July/004982.html" .
:meta dcterms:identifier "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter14Prototypes/MaterialModulatorPrototypeExpanded.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, :Shape_2_2, :HideAdditionalPrototypeBodyNodesExpanded1 .
:WorldInfo_2_1 a owl:NamedIndividual, x3do:WorldInfo ;
  x3do:hasParent :Scene ;
  x3do:title 'MaterialModulatorPrototypeExpanded.x3d' .
:Shape_2_2 a owl:NamedIndividual, x3do:Shape ;
  x3do:hasParent :Scene ;
  x3do:hasGeometry :Sphere_2_2_1 ;
  x3do:hasAppearance :Appearance_2_2_2 .
:Sphere_2_2_1 a owl:NamedIndividual, x3do:Sphere ;
  x3do:hasParent :Shape_2_2 .
:Appearance_2_2_2 a owl:NamedIndividual, x3do:Appearance ;
  x3do:hasParent :Shape_2_2 ;
  x3do:hasMaterial :MaterialModulatorNodeExpanded1 .
:MaterialModulatorNodeExpanded1 a owl:NamedIndividual, x3do:Material ;
  x3do:hasParent :Appearance_2_2_2 ;
  x3do:DEF 'MaterialModulatorNodeExpanded1' ;
  x3do:diffuseColor ( 0.5 0.1 0.1 ) .
:HideAdditionalPrototypeBodyNodesExpanded1 a owl:NamedIndividual, x3do:Switch ;
  x3do:hasParent :Scene ;
  x3do:hasChildren :Group_2_3_1 ;
  x3do:DEF 'HideAdditionalPrototypeBodyNodesExpanded1' ;
  x3do:whichChoice -1 .
:Group_2_3_1 a owl:NamedIndividual, x3do:Group ;
  x3do:hasParent :HideAdditionalPrototypeBodyNodesExpanded1 ;
  x3do:hasChildren :MaterialModulatorScriptExpanded1, :ModulationClockExpanded1 ;
  x3do:hasROUTE :ROUTE_2_3_1_2, :ROUTE_2_3_1_4 .
:MaterialModulatorScriptExpanded1 a owl:NamedIndividual, x3do:Script ;
  x3do:hasParent :Group_2_3_1 ;
  x3do:hasField :field_2_3_1_1_1, :field_2_3_1_1_2, :field_2_3_1_1_3, :field_2_3_1_1_4 ;
  x3do:DEF 'MaterialModulatorScriptExpanded1' ;
  x3do:sourceCode """
ecmascript:
function initialize ()
{
    newColor     = diffuseColor; // start with original color
//  diffuseColor = diffuseColor; // retain original color, silence warning
}
function clockTrigger (timeValue)
{
    if (!enabled) return;
    red   = newColor.r;
    green = newColor.g;
    blue  = newColor.b;
    
    // note different modulation rates for each color component, % is modulus operator
    newColor = new SFColor ((red + 0.02) % 1, (green + 0.03) % 1, (blue + 0.04) % 1);   
    Browser.println ('diffuseColor=(' + red +',' + green + ',' + blue + ') newColor=' + newColor.toString());
}
function set_enabled (newValue)
{
	enabled = newValue;
}
function set_diffuseColor (newValue)
{
    newColor = newValue;
}
""" .
:field_2_3_1_1_1 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :MaterialModulatorScriptExpanded1 ;
  x3do:accessType 'inputOutput' ;
  x3do:name 'enabled' ;
  x3do:type 'SFBool' ;
  x3do:value true .
:field_2_3_1_1_2 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :MaterialModulatorScriptExpanded1 ;
  x3do:accessType 'inputOutput' ;
  x3do:name 'diffuseColor' ;
  x3do:type 'SFColor' ;
  x3do:value ( 0.5 0.1 0.1 ) .
:field_2_3_1_1_3 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :MaterialModulatorScriptExpanded1 ;
  x3do:accessType 'outputOnly' ;
  x3do:name 'newColor' ;
  x3do:type 'SFColor' .
:field_2_3_1_1_4 a owl:NamedIndividual, x3do:field ;
  x3do:hasParent :MaterialModulatorScriptExpanded1 ;
  x3do:accessType 'inputOnly' ;
  x3do:name 'clockTrigger' ;
  x3do:type 'SFTime' .
:ROUTE_2_3_1_2 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Group_2_3_1 ;
  x3do:fromField 'newColor' ;
  x3do:fromNode 'MaterialModulatorScriptExpanded1' ;
  x3do:toField 'diffuseColor' ;
  x3do:toNode 'MaterialModulatorNodeExpanded1' .
:ModulationClockExpanded1 a owl:NamedIndividual, x3do:TimeSensor ;
  x3do:hasParent :Group_2_3_1 ;
  x3do:DEF 'ModulationClockExpanded1' ;
  x3do:cycleInterval '0.1' ;
  x3do:loop true .
:ROUTE_2_3_1_4 a owl:NamedIndividual, x3do:ROUTE ;
  x3do:hasParent :Group_2_3_1 ;
  x3do:fromField 'cycleTime' ;
  x3do:fromNode 'ModulationClockExpanded1' ;
  x3do:toField 'clockTrigger' ;
  x3do:toNode 'MaterialModulatorScriptExpanded1' .
