[x3d-public] gltf metadata

Andreas Plesch andreasplesch at gmail.com
Fri Feb 1 07:42:31 PST 2019


Here is how x3dom currently translates gltf metadata into x3d. Since
x3dom translates the non-binary gltf data into dom and makes it
(optionally) available as a dom node tree under the inline, translated
metadata can then be accessed as well, to show somewhere or do
whatever.

gltf has the ability to provide unstructured or optionally structured
metadata for the global asset and for each resource. This is similar
to the Metadata nodes in x3d.

glTF metadata can be provided in an 'extras' property which is
available to each kind of node. In addition, the toplevel asset node
contains metadata in defined properties.

The asset node data is translated into a WorldInfo node in the following way.

The copyright, generator, version, and minversion properties of the
toplevel asset node go into WorldInfo as a MFString info field: '
"copyright:(c)2020 sb" "version:2.0" ..' .The property name is joined
together with its value by a colon. [ There are alternatives, such as
property name followed by property value. ]

extras of the toplevel asset node go into the WorldInfo metadata field
packaged inside a MetadataSet holding node with name 'global':

<WorldInfo info= ' "copyright:(c)2020 sb" "version:2.0" '
title='asset.extras.title value if given'>
  <MetadataSet name='global' containerfield='metadata'>
    <MetadataSet name='asset-extras' containerfield='value'>
      extras (see below)

The asset extras metadata are named 'asset-extras'.

There is no defined 'title' property in gltf but if there is an
asset.extras.title string property it goes in the title field of
WorldInfo.

[ I am starting to think that it would be better to not use the info
field and just have an additional entry into the global MetadataSet,
an 'asset-properties' entry ].

The 'global' holding node also contains the extras of the gltf scene node.

<WorldInfo>
  <MetadataSet name='global' containerfield='metadata'>
    <MetadataSet name='asset-extras' containerfield='value'>
      extras (see below)
    <MetadataSet name='scene-extras' containerfield='value'>
      extras (see below)

The scene extras metadata are name 'scene-extras'.

The scene metadata are put into WorldInfo metadata because X3D Scene
itself cannot have a Metadata node (X3D Metadata nodes are not child
nodes) and because using the META statements in the X3D header would
then require managing the X3D header. Also, it seems logical to group
all scene-wide data together.

All other extras properties in nodes go into metadata nodes as
required in the following way. The gltf extras json property can have
any json value, including arrays and objects. It is recommended to use
a json object as name:value map but any json value is allowed.
A json string becomes a MetadataString.
A json number becomes a MetadataFloat.
A json boolean becomes a MetadataBoolean.
A json array or object becomes a MetadataSet. An array is actually an
object with numerical, ordered keys: {'0':v0, '1':v1 ..}. It can be
treated as an object.
The name field for each metadata node is 'extras' by default or the
key name in case of values for MetadataSet.
Here are examples:
<Transform>
  <MetadataString name='extras' value='extras_value_string'
containerfield='metadata'/>
----
<Transform>
  <MetadataSet name='extras'  containerfield='metadata'>
    <MetadataString name='component' value='rotor' containerfield='value'/>
    <MetadataString name='warehouse' value='StarlingCity'
containerfield='value'/>
----
<WorldInfo>
  <MetadataSet name='global' containerfield='metadata'>
    <MetadataSet name='asset-extras' containerfield='value'>
      <MetadataString name='created' value='2/3/2345' containerfield='value'/>
      <MetadataString name='author' value='art artist' containerfield='value'/>
      <MetadataString name='license' value='CC 4.0,
http://license.org/CC' containerfield='value'/>
-----

This description is probably longer than the lines of code it takes to
implement this kind of translation.

Any input or feedback much appreciated while this effort is underway.

-Andreas


-- 
Andreas Plesch
Waltham, MA 02453



More information about the x3d-public mailing list