Skip to content

Migrate to XML3D 5.0

Kristian Sons edited this page Jul 8, 2015 · 30 revisions

The 5.0 release of XML3D is not backwards compatible to 4.x. Here is a list of changes you have to apply to your scene to migrate to version 5.0:

Change all previously camel-cased attribute names to lowercase

activeview, fieldofview, wraps, wrapt, wrapu, filtermin, filtermax, filtermip, scaleorientation

  • You can still use getAttribute and setAttribute with camel-cased names (eg. setAttribute("fieldOfView", 0.5) ). These will automatically be lowercased in XML3D 5.0
  • Element properties (eg. viewElement.fieldOfView) are still camel-cased.

getBoundingBox() changed

getBoundingBox() is no longer available on xml3d, group, mesh and model elements. There are now two separate functions available:

  • getLocalBoundingBox() - Get the bounding box of the element in object space
  • getWorldBoundingBox() - Get the bounding box of the element in world space (including all parent transformations).

If you are using getBoundingBox() now you should choose one of the two new functions instead, depending on what kind of bounding box you need.

<view> element "perspective" attribute is now "projection"

This attribute was renamed for clarity. Like before it should contain a URI to a <data> element with a <float4x4> value element named "projection". The supplied matrix will replace the camera's projection matrix.

No <lightshader> anymore

The definition of lights has changed in XML3D 5.0 (see this issue). The simplest way migrating is to

  • Move the value of the lightshader's script attribute to the lights model attribute (specifying the light model)
  • Rename urn:xml3d:lightshader:xxx to urn:xml3d:light:xxx in the light model defintion
  • Rename the <lightshader> element to <data>
  • Rename the light's shader attribute to src

Texture sampling parameters changed

The texture attributes to configure the texture sampling were not HTML5 compliant and thus we changed the names and merged some of them:

  • warpS and wrapT have been merged to wrap. Specify the wrap type (clamp, repeat) for s and t direction in order or just one value for the same wrap type in all directions
  • filterMin and filerMag have been merged to filter. Specify the filtering first for minification then for magnification (e.g. filter="linear-mipmap-linear linear").

Visibility is now set via CSS

Instead of setting the visibility via attribute like this

One can use the CSS display property now:

<mesh src="teapot.jsons" style="display: none;"></mesh>

or

document.querySelector("mesh").style.display = "none";

or (given there is a CSS style seletor setting class hidden)

<mesh src="teapot.jsons" class="hidden"></mesh>

or using jQuery:

$("mesh").hide(); // Hide all meshes
$("mesh").toggle(); // Toggle visibility of meshes

Default is to inherit the display value from the parent element. Works for <xml3d>, <group>, <mesh>, and <model>. To migrate from 4.9, just change all occurances of visibility="false" to style="display: none;".

Voilà!

Clone this wiki locally