Skip to content

Commit ced36ce

Browse files
committed
Merge branch 'hotfix-5.1.4'
2 parents 5a000d8 + 0a2d5bb commit ced36ce

File tree

7 files changed

+97
-28
lines changed

7 files changed

+97
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "xml3d.js",
33
"description": "XML3D implementation based on JS and WebGL",
44
"homepage": "http://ww.xml3d.org",
5-
"version": "5.1.3",
5+
"version": "5.1.4",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/xml3d/xml3d.js"

spec/index.html

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2456,11 +2456,8 @@ <h2>Point</h2>
24562456

24572457
<p>WebGL primitive: <code>POINT</code></p>
24582458

2459-
<p>Points are drawn from a list of vertex positions, which each position being drawn as a single point.</p>
2460-
2461-
<div class="note">Currently to change the size of the drawn points, or to draw them as textured sprites, it
2462-
is necessary to define a custom material shader.
2463-
</div>
2459+
<p><dfn>The point primitive</dfn> is drawn from a list of vertex positions, with each position being drawn as a single point. Points
2460+
must use either the <a>point material model</a> or a custom material designed for point rendering. </p>
24642461
</section>
24652462

24662463
<section>
@@ -2758,6 +2755,65 @@ <h2>Phong</h2>
27582755
}
27592756
</pre>
27602757
</section>
2758+
<section>
2759+
<h2>Point</h2>
2760+
2761+
<p>URN: <code>urn:xml3d:material:point</code></p>
2762+
2763+
<div class="attributes">Parameters:
2764+
<table>
2765+
<tbody>
2766+
<tr>
2767+
<th>Name</th>
2768+
<th>Type</th>
2769+
<th>Default</th>
2770+
<th>Description</th>
2771+
</tr>
2772+
<tr>
2773+
<td>diffuseColor</td>
2774+
<td>float3</td>
2775+
<td>1 1 1</td>
2776+
<td>The objects RGB color</td>
2777+
</tr>
2778+
<tr>
2779+
<td>useVertexColor</td>
2780+
<td>bool</td>
2781+
<td>false</td>
2782+
<td>if true, the vertex attribute 'color' is used to color the object.</td>
2783+
</tr>
2784+
<tr>
2785+
<td>texCoordOffset</td>
2786+
<td>float2</td>
2787+
<td>0 0</td>
2788+
<td>An offset to add to the texture coordinates for each point.</td>
2789+
</tr>
2790+
<tr>
2791+
<td>texCoordSize</td>
2792+
<td>float2</td>
2793+
<td>1 1</td>
2794+
<td>A scale factor to multiply the texture coordinates of each point with. Only applies to
2795+
the implicit texture coordinate defined by gl_PointCoord, not the optional <code>texcoord</code> vertex attribute.
2796+
See the note below for more information.</td>
2797+
</tr>
2798+
<tr>
2799+
<td>pointSize</td>
2800+
<td>float</td>
2801+
<td>1</td>
2802+
<td>The base size of each point. Will be scaled by distance from the camera.</td>
2803+
</tr>
2804+
</tbody>
2805+
</table>
2806+
<div class="note">
2807+
<p> For points, texture coordinates are a mixture of the <code>texcoord</code> attribute and the <code>gl_PointCoord</code>
2808+
value provided by WebGL. The final texture coordinate for each fragment is calculated as follows: </p>
2809+
2810+
<pre> vec2 uv = texcoord + texCoordOffset + (gl_PointCoord * texCoordSize);</pre>
2811+
</div>
2812+
</div>
2813+
<p>
2814+
The <dfn>point material model</dfn> is always used in conjunction with <a>the point primitive</a> type.
2815+
</p>
2816+
</section>
27612817
</section>
27622818

27632819
<section>

src/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@ This folder contains all sources files used to generate the final **xml3d.js** l
66

77
Subfolders:
88
* [asset](asset/) - Implementation of the XML3D asset concept
9-
* [base](base/) - Base systems used throughout xml3d.js, such as resource manager, base adapter classes etc.
9+
* [base](base/) - Base adapter classes.
1010
* [contrib](contrib/) - External libraries
11-
* [data](data/) - The data adpater - the connecting piece between XML3D and Xflow for inline nodes as well as external resources
11+
* [data](data/) - The data adpaters - the connecting piece between XML3D and Xflow for inline nodes as well as external resources
1212
* [interface](interface/) - Connection of XML3D with the DOM
1313
* [math](math/) - A small collection of math functions to complement glMatrix
1414
* [renderer](renderer/) - The rendering implementation. WebGL specific code should stay in here.
15-
* [types](types/) - External types used by XML3D, such as Boundingbox, Vec3, Matrix or Data Observer
15+
* [resource](resource/) - Classes related to loading external resources and resolving connections between DOM elements or documents
16+
* [types](types/) - Math types provided by XML3D, such as Box, Vec3, Matrix or Data Observer
1617
* [until](utils/) - Misc. utility functions used throughout xml3d.js
17-
* [xflow](xflow/) - All code related to the Xflow library. Independent of most other source code.
18+
* [xflow](xflow/) - All code related to the Xflow data processing library. Independent of most other source code.

src/renderer/renderer/lights/light-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ LightManager.prototype = {
100100
var length = entry.lightModels.length;
101101
if (!length) {
102102
entry.parameters = {};
103+
this._inUpdate = false;
103104
return;
104105
}
105106
var model = entry.lightModels[0];
@@ -110,7 +111,6 @@ LightManager.prototype = {
110111
});
111112
entry.changed = true;
112113
this._inUpdate = false;
113-
114114
}
115115
};
116116

src/renderer/renderer/scene/renderlight.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ var NODE_TYPE = Constants.NODE_TYPE;
66
var EVENT_TYPE = Constants.EVENT_TYPE;
77

88
var tmp_worldMatrix = XML3D.math.mat4.create();
9+
var identity_mat4 = XML3D.math.mat4.create();
910

1011
/** @const */
1112
var WORLD_MATRIX_OFFSET = 0;
1213
/** @const */
1314
var LOCAL_MATRIX_OFFSET = WORLD_MATRIX_OFFSET + 16;
1415
/** @const */
15-
var ENTRY_SIZE = LOCAL_MATRIX_OFFSET;
16+
var ENTRY_SIZE = 32;
1617

1718
var c_BoundingBox = new XML3D.Box();
1819

@@ -42,6 +43,9 @@ var RenderLight = function (scene, pageEntry, opt) {
4243
RenderNode.call(this, NODE_TYPE.LIGHT, scene, pageEntry, opt);
4344
opt = opt || {};
4445
var configuration = opt.configuration || {};
46+
// Matrices need to be set to identity to avoid non-affine matrices during the rest of the light construction
47+
this.setLocalMatrix(identity_mat4);
48+
this.setWorldMatrix(identity_mat4);
4549
this.setLightType(configuration.model, configuration.dataNode);
4650
};
4751
RenderLight.ENTRY_SIZE = ENTRY_SIZE;

src/xflow/operator/default/createTransform.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var TMP_VEC = XML3D.math.vec3.create();
44
var TMP_QUAT = XML3D.math.quat.create();
55
var mat4 = XML3D.math.mat4;
6+
var quat = XML3D.math.quat;
67

78
Xflow.registerOperator("xflow.createTransform", {
89
outputs: [{type: 'float4x4', name: 'result'}],
@@ -16,20 +17,23 @@
1617
var dest = result.subarray(i * 16);
1718
mat4.identity(dest);
1819
translation && mat4.translate(dest, dest, info.iterFlag[0] ? translation.subarray(i*3) : translation);
19-
center && mat4.translate(dest, dest, info.iterFlag[0] ? center.subarray(i*3) : center);
20+
center && mat4.translate(dest, dest, info.iterFlag[3] ? center.subarray(i*3) : center);
2021
if (rotation) {
21-
mat4.fromRotationTranslation(TMP_MATRIX, info.iterFlag[1] ? rotation.subarray(i*4) : rotation, [0, 0, 0]);
22+
mat4.fromQuat(TMP_MATRIX, info.iterFlag[1] ? rotation.subarray(i*4) : rotation);
2223
mat4.multiply(dest, dest, TMP_MATRIX);
2324
}
24-
if (scaleOrientation) {
25-
mat4.fromRotationTranslation(TMP_MATRIX, info.iterFlag[4] ? scaleOrientation.subarray(i*4) : scaleOrientation, [0, 0, 0]);
26-
mat4.multiply(dest, dest, TMP_MATRIX);
27-
}
28-
scale && mat4.scale(dest, dest, info.iterFlag[2] ? scale.subarray(i*3) : scale);
29-
if (scaleOrientation) {
30-
XML3D.math.quat.copy(TMP_QUAT, info.iterFlag[4] ? scaleOrientation.subarray(i*4) : scaleOrientation)
31-
mat4.fromRotationTranslation(TMP_MATRIX, XML3D.math.quat.negate(TMP_QUAT, TMP_QUAT), [0, 0, 0]);
32-
mat4.multiply(dest, dest, TMP_MATRIX);
25+
if (scale) {
26+
if (scaleOrientation) {
27+
quat.copy(TMP_QUAT, info.iterFlag[4] ? scaleOrientation.subarray(i*4) : scaleOrientation)
28+
mat4.fromQuat(TMP_MATRIX, TMP_QUAT);
29+
mat4.multiply(dest, dest, TMP_MATRIX);
30+
}
31+
mat4.scale(dest, dest, info.iterFlag[2] ? scale.subarray(i * 3) : scale);
32+
if (scaleOrientation) {
33+
quat.invert(TMP_QUAT, TMP_QUAT);
34+
mat4.fromQuat(TMP_MATRIX, TMP_QUAT);
35+
mat4.multiply(dest, dest, TMP_MATRIX);
36+
}
3337
}
3438

3539
center && mat4.translate(dest, dest, XML3D.math.vec3.negate(TMP_VEC, info.iterFlag[3] ? center.subarray(i*3) : center));

src/xflow/processing/channel-node.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,12 +227,14 @@ function synchronizeChildren(channelNode){
227227
// Now synchronize all children (either referenced data node, or real children)
228228
// TODO: Change here if we change behaviour of src attribute
229229
if(dataNode._sourceNode){
230-
dataNode._sourceNode._getOrCreateChannelNode(channelNode.substitution).synchronize();
230+
var sub = dataNode._sourceNode._getOrCreateChannelNode(channelNode.substitution);
231+
sub && sub.synchronize();
231232
}
232233
else{
233234
for(var i = 0; i < dataNode._children.length; ++i){
234235
if(dataNode._children[i]._getOrCreateChannelNode){
235-
dataNode._children[i]._getOrCreateChannelNode(channelNode.substitution).synchronize();
236+
var sub = dataNode._children[i]._getOrCreateChannelNode(channelNode.substitution);
237+
sub && sub.synchronize();
236238
}
237239
}
238240
}
@@ -246,7 +248,8 @@ function updateInputChannels(channelNode){
246248
var owner = channelNode.owner;
247249
// TODO: Change here if we change behaviour of src attribute
248250
if(owner._sourceNode){
249-
channelNode.inputChannels.merge(owner._sourceNode._getOrCreateChannelNode(channelNode.substitution).outputChannels, 0);
251+
var sub = owner._sourceNode._getOrCreateChannelNode(channelNode.substitution);
252+
sub && channelNode.inputChannels.merge(sub.outputChannels, 0);
250253
}
251254
else{
252255
var children = owner._children;
@@ -287,7 +290,8 @@ function mergeInputChannelInputNodes(channelNode, children) {
287290
function mergeInputChannelDataNodes(channelNode, children) {
288291
for (var i = 0; i < children.length; ++i) {
289292
if (children[i]._getOrCreateChannelNode) { // Child is a DataNode
290-
channelNode.inputChannels.merge(children[i]._getOrCreateChannelNode(channelNode.substitution).outputChannels, i);
293+
var sub = children[i]._getOrCreateChannelNode(channelNode.substitution);
294+
sub && channelNode.inputChannels.merge(sub.outputChannels, i);
291295
}
292296
}
293297
}
@@ -310,7 +314,7 @@ function updateComputedChannels(channelNode){
310314
}
311315

312316
if(oldDataflowChannelNode && oldDataflowChannelNode != channelNode.dataflowChannelNode){
313-
oldDataflowChannelNode.owner._removeSubstitutionNode(oldDataflowChannelNode);
317+
oldDataflowChannelNode.owner && oldDataflowChannelNode.owner._removeSubstitutionNode(oldDataflowChannelNode);
314318
}
315319
}
316320

0 commit comments

Comments
 (0)