One of the first dependencies for a Declarative3D approach is the existence of complex data types. Here the vector, matrix and quaternion math are essential while other types like a type for colors would gain the general productivity. Complex base types are essential for 3D operations in computer graphics. The fact that geometric operations like an affine transformation in 3D space depends on a matrix of 4x4 = 16 elements leads to the fact, that it is a logical need to package the data and also the operations into a complex data type.

Other groups (SVG, CSS 3D Transform) have dealt with the absence of linear algebra in HTML development and have defined their own subset of such mathematics. There are also some JavaScript libraries (glMatrix, webgl-mjs, Sylvester) which handle the mathematics in runtime code. The fact that different areas besides 3D computer graphics have already shown the need of such mathematic constructs, leads us to claim the idea, that linear algebra mathematics and the dependent data types could also be declared outside the Declarative3D group for a W3C wide standard.

Contents

Use cases

It' a very valid question to ask why we need the access to internal scene graph information at all. Since we target is a declarative system, the answer is: It shouldn't be necessary for the majority of use cases. On the other hand, following the principle of: "Make simple things simple, but complex things possible", we can achieve more flexibility and a leaner standard by providing basic scene graph information.

Here are some use cases, where access to information such as transformation & view/camera matrices would be interesting:

Keep orientation of an object fixed to a reference point, which could be the current camera (aka Billboarding) but also to arbitrary other objects in 3D space

This section should link to our use case section as soon as we have real use cases for functionality above

Base data types

There should be complex base data types, defined for geometric 2D and 3D and also for the color space.

These are:

Vector2D, Vector3D, Vector4D

Matrix2D, Matrix3D, Matrix4D

Quaternion

ColorRGB, ColorRGBA

Vector, Quaternion & Matrix mathematics should handle operations that are needed for 2D or 3D geometric operations. The available functions could be related to these defined in GLSL for geometric functions. More complex functions defined by interfaces like BLAS (Basic Linear Algebra Subprograms) would be overkill.

For performance reason the definition and implementation should take care of performance issues:

Copy instructions should be minimized.

Interfaces should only work on references.

The base types should internally build upon TypedArrays and reflect these raw containers to the outside.

Another open point for discussion is the availability of array, build upon the addressed data types and the operations on such arrays of complex data types. While with TypedArrays it is possible to define a view into a TypedArray and operate on this subarray. SVG also defines such a type of array, called SVGPointLis & SVGTransformList. SIMD instructions on such an array are important for vertex based operations on the CPU like animation, morphing or blending.

Related technologies

WebGL

Graphic API’s like OpenGL and DirectX have been using vector and matrix math for years. By the fact that WebGL is based on the mobile branch of OpenGL (OpenGL ES) it slightly introduces vectors and matrices into the HTML world. While WebGL natively does not support any library for mathematic operations itself, it uses typed arrays to transfer data to the GPU by Uniforms and attributes. On the other hand, the shading language itself, in this case GLSL, supports vectors and matrices as native basic types a set of geometric functions for arithmetic mathematics on this types.

CSS

CSS 3D Transform brings the ability for 3D transformation of 2D elements from within the webpage. The specification includes a single matrix type: CSSMatrix but not a full set of basic complex types. The system is not designed for the use outside the context of transforming DOM elements.

SVG

Another system recently entered the HTML world, which already uses complex data types is SVG.
While their concept is based on a planar system and vector graphics, they have primary defined basis types for work in a 2D system. Beside the definition of a simple 2D point there is also a matrix for affine transformation operations. Another interesting data type they introduced is a type for colors with operations to convert between RGB and ICC. This system is also not designed for general linear algebra mathematics, because the functions are trimmed to a 2D space. Another drawback is that this system is not designed to handle multiple arithmetic operations:

For a single operation like ‘’the translation of a point’’ the system is sufficient.

For the reuse of the output data from this operation, the system is insufficient: The output can’t be used directly for a second operation. As an example, the input signature of a translation operation is SVGMatrix.translate(in float x, in float y) and therefore cannot handle complex data types like a SVGPoint as input.

X3D

The X3D DTDs and XML Schemas also provide a means to perform validation of typed data. Further capabilities or definitions in XML Schema would be helpful to allow direct validation of numeric arrays. Current practices rely on use of regular expressions (regexes) to ensure data validity, which tends to be a computationally expensive approach.

In general, the use of X3D base types allows authors to avoid the need for complex matrix mathematics. Instead scenes are typically defined using position and rotation information, which is simpler to compute and compose. This is a declarative approach. The use of matrix mathematics is also available as an option for authors who prefer to embed imperative computational scripts in their scenes.

XML Schema XSD 1.1

We should comment. Upon first inspection, there does not seem to be validation support for defining arrays of floating-point primitive arrays (e.g. MFRotation array of rotation values).

X3D schema definitions accomplish this task by using regular expressions (regexes) to define precise type checking of such arrays. This works but can be memory intensive for some applications when validating large arrays of values.

This section might have what we are looking for:

2.4.2.2 Construction by List
A ·list· datatype can be ·constructed· from another datatype (its ·item type·) by creating a ·value space·
that consists of finite-length sequences of zero or more values of its ·item type·. Datatypes so ·constructed·
have anySimpleType as their ·base type·. Note that since the ·value space· and ·lexical space· of any ·list·
datatype are necessarily subsets of the ·value space· and ·lexical space· of anySimpleType, any datatype
·constructed· as a ·list· is a ·restriction· of its base type.