X3D file structure: Difference between revisions

The educational technology and digital learning wiki
Jump to navigation Jump to search
Line 8: Line 8:


* File header (XML, ClassicVRML, Compressed Binary)
* File header (XML, ClassicVRML, Compressed Binary)
* X3D header statement
* Start of the ''X3D root node'' including ''version'' and ''profile'' attributes
* Profile statement
* A ''head'' section with ''Component'' and ''Meta'' statements (both optional)
* A head section with ''Component'' and ''Meta'' statements (both optional)
* X3D ''scene'' graph and its child nodes
* X3D root node
* End of the X3D root node
* X3D scene graph child nodes


We shall shortly describe these elements below. But before, let's have a look at the code of a simple exemple scene, inserted XML comments identify the elements:
We shall shortly describe these elements below. But before, let's have a look at the code of a simple exemple scene, inserted XML comments identify the elements:
Line 19: Line 18:
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>


<!-- -------------------- X3D header and X3D root with profile declaration -->
<!-- -------------------- X3D header and X3D root node with profile declaration -->
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
                     "http://www.web3d.org/specifications/x3d-3.2.dtd">
                     "http://www.web3d.org/specifications/x3d-3.2.dtd">
Line 41: Line 40:
   </head>
   </head>


<!-- -------------------- the X3D scene -->
<!-- -------------------- the X3D scene node with X3D nodes -->
   <Scene>
   <Scene>
     <!-- Example scene to illustrate X3D nodes and fields (XML elements and attributes) -->
     <!-- Example scene to illustrate X3D nodes and fields (XML elements and attributes) -->
Line 73: Line 72:
</source>
</source>


=== File, X3D header and filename extensions ===
=== X3D file header and filename extensions ===


Since X3D has grown out of [[VRML]] it has both an [[XML]] and a VRML syntax. In addition, both formats can be delivered in compressed format.
Since X3D has grown out of [[VRML]] it has both an [[XML]] and a VRML syntax. In addition, both formats can be delivered in compressed format.
The Header for X3D / XML needs an XML declartion and an optional DTD. The [[XML Schema]] (XSD) is declared in the root node.
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
                    "http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Immersive' version='3.2'
    xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
    xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
</source>


The following file extensions should be used for X3D contents:
The following file extensions should be used for X3D contents:
Line 107: Line 118:
=== Profiles, components ===  
=== Profiles, components ===  


X3D X3D has a modular architecture that includes four baseline profiles which are are predefined collections of components.  
X3D has a modular architecture that defines 4 to 6 baseline profiles (depending on the version) which are are predefined collections of components. Profiles are defined with XML attributes in the X3D root node or as VRML statements on top.


In addition, within the ''head'' section, authors can specify more precisely what components are needed. Components are predefined collections of nodes and match chapters in the specification. Each profile can be augmented by adding other components
In addition, within the ''head'' section, authors can specify more precisely what components are needed. Components are predefined collections of nodes and match chapters in the specification. Each profile can be augmented by adding other components
Line 113: Line 124:
Both the mandatory profile definition and the optional components statements tells the X3D browser what level of support is needed for run-time operation.
Both the mandatory profile definition and the optional components statements tells the X3D browser what level of support is needed for run-time operation.


The 3.2 specification includes four profiles:
The 3.2 specification includes six profiles:
* '''Core''' is just the core (probably not useful for authors)
* '''Core''' is just the core (probably not useful for authors)
* '''Interchange''' is the basic profile for communicating between applications. It supports geometry, texturing, basic lighting, and animation
* '''Interchange''' is the basic profile for communicating between applications. It supports geometry, texturing, basic lighting, and animation
Line 124: Line 135:
[[image:x3dprofiles.gif|frame|none|X3D Baseline Profiles: Source: [http://www.web3d.org/about/overview/ What is X3D?], retrieved 11:53, 26 August 2010 (UTC)]]
[[image:x3dprofiles.gif|frame|none|X3D Baseline Profiles: Source: [http://www.web3d.org/about/overview/ What is X3D?], retrieved 11:53, 26 August 2010 (UTC)]]


Examples:
Examples of X3D profile declarations


<source lang="xml">
<source lang="xml">
Line 138: Line 149:
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
</X3D>
</X3D>
</source>
</source>


Examples of X3D ClassicVRML profile declarations
PROFILE Immersive
Additional components with respect to the ones includes in the declared profile can be included in the had section as in the following [http://x3dgraphics.com/examples/X3dForWebAuthors/Chapter01-TechnicalOverview/_pages/page01.html Header Profile Component Meta Example] (retrieved 11:59, 5 October 2010 (CEST)). The component tags raise the support level from Immersive profile to include other components included in the X3D 3.0 Full profile.
<source lang="xml">
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "http://www.web3d.org/specifications/x3d-3.1.dtd">
<X3D profile='Immersive' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>
<head>
<component level='1' name='DIS'/>
<component level='1' name='Geospatial'/>
<component level='1' name='H-Anim'/>
<component level='3' name='NURBS'/>
<!-- .... content deleted -->
</head>
</X3D>
</source>


=== Meta statements ===  
=== Meta statements ===  
Line 221: Line 253:
* [http://www.web3d.org/specifications/X3dSchemaDocumentation3.2/x3d-3.2.html X3D v3.2 Schema Documentation]
* [http://www.web3d.org/specifications/X3dSchemaDocumentation3.2/x3d-3.2.html X3D v3.2 Schema Documentation]
* [http://www.web3d.org/specifications/X3dDoctypeDocumentation3.2.html X3D v3.2 Doctype Documentation]
* [http://www.web3d.org/specifications/X3dDoctypeDocumentation3.2.html X3D v3.2 Doctype Documentation]
; X3D Examples
* [http://x3dgraphics.com/examples/X3dForWebAuthors/index.html 
X3D for Web Authors Examples Archive]. This archive also can used as a kind of manual.


== Credits and Copyright modificiation ==
== Credits and Copyright modificiation ==

Revision as of 11:59, 5 October 2010

Draft

This article or section is currently under construction

In principle, someone is working on it and there should be a better version in a not so distant future.
If you want to modify this page, please discuss it with the person working on it (see the "history")

Introduction

X3D scene files have a common file structure:

  • File header (XML, ClassicVRML, Compressed Binary)
  • Start of the X3D root node including version and profile attributes
  • A head section with Component and Meta statements (both optional)
  • X3D scene graph and its child nodes
  • End of the X3D root node

We shall shortly describe these elements below. But before, let's have a look at the code of a simple exemple scene, inserted XML comments identify the elements:

<?xml version="1.0" encoding="UTF-8"?>

<!-- -------------------- X3D header and X3D root node with profile declaration -->
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
                     "http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Immersive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>

<!-- -------------------- head section with included meta data -->
  <head>
    <meta content='HelloWorld.x3d' name='title'/>
    <meta content='Simple X3D example' name='description'/>
    <meta content='30 October 2000' name='created'/>
    <meta content='7 August 2010' name='modified'/>
    <meta content='Don Brutzman' name='creator'/>
    <meta content='http://www.web3D.org' name='reference'/>
    <meta content='http://x3dGraphics.com' name='reference'/>
    <meta content='http://www.web3d.org/x3d/content/examples/HelloWorld.x3d' name='identifier'/>
    <meta content='http://www.web3d.org/x3d/content/examples/HelloWorldTall.png' name='image'/>
    <meta content='http://www.web3d.org/x3d/content/examples/license.html' name='license'/>
    <meta content='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit' name='generator'/>
  </head>

<!-- -------------------- the X3D scene node with X3D nodes -->
  <Scene>
    <!-- Example scene to illustrate X3D nodes and fields (XML elements and attributes) -->
    <Group>
      <Viewpoint centerOfRotation='0 -1 0' description='Hello world!' position='0 -1 7'/>
      <Transform rotation='0 1 0 3'>
        <Shape>
          <Sphere/>
          <Appearance>
            <Material diffuseColor='0 0.5 1'/>
            <ImageTexture url='"earth-topo.png" "earth-topo.jpg" "earth-topo-small.gif" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.png" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo.jpg" "http://www.web3d.org/x3d/content/examples/Basic/earth-topo-small.gif"'/>
          </Appearance>
        </Shape>
      </Transform>
      <Transform translation='0 -2 0'>
        <Shape>
          <Text string='"Hello" "world!"'>
            <FontStyle justify='"MIDDLE" "MIDDLE"'/>
          </Text>
          <Appearance>
            <Material diffuseColor='0.1 0.5 1'/>
          </Appearance>
        </Shape>
      </Transform>
    </Group>
  </Scene>

<!-- -------------------- footer, closing X3D toot element -->
</X3D>

X3D file header and filename extensions

Since X3D has grown out of VRML it has both an XML and a VRML syntax. In addition, both formats can be delivered in compressed format.

The Header for X3D / XML needs an XML declartion and an optional DTD. The XML Schema (XSD) is declared in the root node.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
                     "http://www.web3d.org/specifications/x3d-3.2.dtd">
<X3D profile='Immersive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>


The following file extensions should be used for X3D contents:

X3D Encoding File Extension MIME Type
Classic VRML .x3dv model/x3d+vrml
XML .x3d model/x3d+xml
Binary .x3db model/x3d+binary

E.g. if you have an Apache server you could add the following lines to a *.conf file:

AddType model/x3d+xml .x3d
AddType model/x3d+vrml .x3dv
AddType model/x3d+binary .x3db
AddEncoding gzip .x3dvz
AddEncoding gzip .x3dbz

Profiles, components

X3D has a modular architecture that defines 4 to 6 baseline profiles (depending on the version) which are are predefined collections of components. Profiles are defined with XML attributes in the X3D root node or as VRML statements on top.

In addition, within the head section, authors can specify more precisely what components are needed. Components are predefined collections of nodes and match chapters in the specification. Each profile can be augmented by adding other components

Both the mandatory profile definition and the optional components statements tells the X3D browser what level of support is needed for run-time operation.

The 3.2 specification includes six profiles:

  • Core is just the core (probably not useful for authors)
  • Interchange is the basic profile for communicating between applications. It supports geometry, texturing, basic lighting, and animation
  • CADInterchange adds support for CADGeometry component nodes to Interchange Profile.
  • Interactive enables basic interaction with a 3D environment by adding various sensor nodes for user navigation and interaction (e.g., PlanseSensor, TouchSensor, etc.), enhanced timing, and additional lighting (Spotlight, PointLight).
  • Immersive enables full 3D graphics and interaction, including audio support, collision, fog, and scripting. Corresponds to the power of VRML 97 plus minor additions.
  • MPEG4Interactive
  • Full includes all defined nodes including NURBS, H-Anim (animated interactive Avatars) and GeoSpatial components.
X3D Baseline Profiles: Source: What is X3D?, retrieved 11:53, 26 August 2010 (UTC)

Examples of X3D profile declarations

<X3D profile='Immersive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
</X3D>
<X3D profile='Interactive' version='3.2' 
     xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
     xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
</X3D>

Examples of X3D ClassicVRML profile declarations

PROFILE Immersive

Additional components with respect to the ones includes in the declared profile can be included in the had section as in the following Header Profile Component Meta Example (retrieved 11:59, 5 October 2010 (CEST)). The component tags raise the support level from Immersive profile to include other components included in the X3D 3.0 Full profile.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.1//EN" "http://www.web3d.org/specifications/x3d-3.1.dtd">

<X3D profile='Immersive' version='3.1' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.1.xsd '>
<head>
<component level='1' name='DIS'/>
<component level='1' name='Geospatial'/>
<component level='1' name='H-Anim'/>
<component level='3' name='NURBS'/> 
<!-- .... content deleted -->
</head>
</X3D>

Meta statements

Meta statements provide information about the X3D scene as a whole

Information is provided as name-value pairs, for example

 <meta name='created' value='1 January 2008'/>

This approach is thus very general and a wide variety of metadata can be represented. The X3D approach matches same approach used by HTML for regular hypertext web pages.

The X3D scene graph

Each X3D file only can include one X3D scene according to XML principles. In other words there must be a single root element.

At the content level, the same principle as for HTML applies. There can be only a single scene in the same way that in HTML there is only one body

A very minimalistic valid X3D file would look like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.2//EN"
  "http://www.web3d.org/specifications/x3d-3.2.dtd">
 <X3D profile='Immersive' version='3.2'
      xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance'
      xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.2.xsd'>
 <head>
 </head>
 <Scene>
    <!-- Scene graph with a single red ball -->
    <Shape>
      <Sphere radius='2.0'/>
      <Appearance>
         <Material diffuseColor='1.0 0.0 0.0'/>
      </Appearance>
    </Shape>
 </Scene>
</X3D>

X3D ClassicVRML syntax

In our tutorials we shall not explain VRML syntax. See the VRML Primer and Tutorial we made over 10 years ago. We just point out that X3D/ClassicVRML is different from VRML1997, i.e. the ClassicVRML profile looks like VRML and uses the same syntax, but there are some changes between the last VRML standard (ISO/IEC 14772-1) and the new X3D-based ISO/IEC 19776-2. In particular, the scripting interface has been totally overhauled.

It is also important to understand the most X3D clients can render VRML 1997 (and the other way round if the VRML client is recent).

#X3D V3.2 utf8

PROFILE Immersive

META "title" "HelloWorld.x3d"
META "description" "Simple X3D example"
META "created" "30 October 2000"
META "modified" "7 August 2010"
META "creator" "Don Brutzman"
META "reference" "http://www.web3D.org"
META "reference" "http://x3dGraphics.com"
META "identifier" "http://www.web3d.org/x3d/content/examples/HelloWorld.x3d"
META "image" "http://www.web3d.org/x3d/content/examples/HelloWorldTall.png"
META "license" "http://www.web3d.org/x3d/content/examples/license.html"
META "generator" "X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit"

NavigationInfo { type [ "EXAMINE" "ANY" ] } ###  Default X3D NavigationInfo

# Example scene to illustrate a single X3D node in VRMLClassic syntax
Shape {
       geometry Sphere {  }
       appearance Appearance {
           material Material {
           diffuseColor 0 0.5 1
           }
       }
}

Links

Specification and Schema documentation
X3D Examples

X3D for Web Authors Examples Archive]. This archive also can used as a kind of manual.

Credits and Copyright modificiation