xml3d / xml3d.js

The WebGL/JS implementation of XML3D
Other
75 stars 25 forks source link

Discard <lightshader> #111

Closed ksons closed 8 years ago

ksons commented 9 years ago

In XML3D 4.x it was necessary to use two nodes to define a light: The <lightshader> element defines a (reusable) light configuration and the used light model (e.g. urn:xml3d:lightshader:point). The <light> element in turn instances a light configuration and therefor determines the light's position using the scene's transformation hierarchy.

Users found it cumbersome to declare two nodes to define a single light. The design is also questionable since the XML3D's data concept allows sharing light configurations anyway (using a generic <data> node).

Consequently, we remove the <lightshader> element from XML3D. Instead, the light parameters are defined as children of the <light>, using the src attribute of the <light> pointing to any internal or external resource that defines the parameters or any other combination the data compositing of XML3D allows for. The light model is defined using the `model attribute of the <light> element.

Example:

 <light model="urn:xml3d:light:point" style="transform: translateX(5px)">
    <float3 name="position">1 0 0</float3> 
    <float3 name="color">1 0 0</float3>
    <float name="intensity">2.5</float>
    <data src="more-light-parameters.json"/>
  </light>

We have kept the URN style of the model because we want to allow programmable light shaders in the future, which will be referenced via URL as well.

In summary, the <light> is becoming more similar to a <mesh> node. This is intentional because we want to be able to define emissive geometry as lights in the future. Then, a light is a "specialized" geometry node that emits light only. To make the light more similar to a mesh, we will introduce an iterator concept to the light node which will allows to define multiple emitters in a single light element. We will file a separate issue for this functionality.