Skip to content
lachsen edited this page Dec 4, 2012 · 13 revisions

XML3D supports several formats for external resources

It is recommended to use external resources especially for large mesh data.

Table of Contents

XML3D JSON Format

The XML3D JSON Format supports generic data content as declared with a <data> element. The format currently only supports integer, bool and float datatypes, but no textures.

Definition

The format's structure with place holders:

{
  "format": "xml3d-json",
  "version": "0.4.0",
  "data": {
    "<INPUT-NAME>" : {
      "type": <TYPE>,
      "seq": [
        {
          "value": <INPUT-DATA-ARRAY>,
          "key" : <INPUT-KEY>
        },
        {
          "value": <INPUT-DATA-ARRAY>,
          "key" : <INPUT-KEY>
        },
        ...
      ]
    },
    "<INPUT-NAME>" : {
      "type": <TYPE>,
      "seq": [
        {
          "value": <INPUT-DATA-ARRAY>,
          "key" : <INPUT-KEY>
        },
        {
          "value": <INPUT-DATA-ARRAY>,
          "key" : <INPUT-KEY>
        },
        ...
      ]
    },
    ...
  }
}
Definitions of place holders:
INPUT-NAME
Name of the input element, corresponding to the name attribute of XML3D Input elements.
TYPE
Type of input element, corresponding to the tagname of XML3D Input elements (e.g. "int", "float", "float3", "float4x4" etc.)
INPUT-DATA-ARRAY
An array with the data of the input. Note: this data is provided as an array and not as string.
INPUT-KEY
The key of the input element, corresponding to the key attribute of XML3D Input elements. The "key" object property can be omitted and will be 0 in that case.

Examples #1

XML3D Code (Inline):

<mesh type="triangles" >
	<int name='index'>0 1 2</int>
	<float3 name='position'>-9.480105 -13.51214 10.48553 -7.449495 -14.95502 10.49484 -7.61096 -10.68768 10.55452</float3>
	<float3 name='normal'>-0.4716944 -0.6363447 0.610385 -0.121907 -0.6732379 0.7293075 -0.006795116 -0.08907415 0.9960018 </float3>
</mesh>

XML3D Code (Reference):

<mesh type="triangles" src="external.json" />

File external.json:

{
  "format": "xml3d-json",
  "version": "0.4.0",
  "data": {
    "index" : {
      "type": "int",
      "seq": [
        {
          "value": [0, 1, 2]
        }
      ]
    },
    "position" : {
      "type": "float3",
      "seq": [
        {
          "value": [-9.480105, -13.51214, 10.48553, -7.449495, -14.95502, 10.49484, -7.61096, -10.68768, 10.55452]
        }
      ]
    },
    "normal" : {
      "type": "float3",
      "seq": [
        {
          "value": [-0.4716944, -0.6363447, 0.610385, -0.121907, -0.6732379, 0.7293075, -0.006795116, -0.08907415, 0.9960018 ]
        }
      ]
    }
  }
}

XML3D XML Format

Clone this wiki locally