<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "https://www.web3d.org/specifications/x3d-3.1.dtd">
<![CDATA[
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; }
]]>
<!-- Online at https://www.web3d.org/x3d/content/examples/Basic/ScriptConformance/CreateNodesFromPrototypeECMAScriptIndex.html -->
<!--
Color key:
<X3dNode
DEF='idName' field='value'/>
matches
<XmlElement
DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
<Prototype
name='ProtoName'>
<field
name='fieldName'/> </Prototype>
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources and X3D Scene Authoring Hints. -->