Skip to content

Commit 6daac0e

Browse files
committed
Merge branch 'hotfix-5.0.3'
2 parents 0c4452d + 7f63474 commit 6daac0e

File tree

7 files changed

+44
-14
lines changed

7 files changed

+44
-14
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.0.2",
5+
"version": "5.0.3",
66
"repository": {
77
"type": "git",
88
"url": "https://github.com/xml3d/xml3d.js"

spec/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3810,6 +3810,8 @@ <h3>Box</h3>
38103810

38113811
Returns true if the given ray intersects this box.
38123812
</dd>
3813+
<dt>boolean contains(Vec3 point)</dt>
3814+
<dd>Returns true if the given point is inside the box.</dd>
38133815
<dt>DOMString toString()</dt>
38143816
<dd>A human readable string representation of this box.</dd>
38153817
</dl>

src/global.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ XML3D._parallel = XML3D._parallel != undefined ? XML3D._parallel : false;
2222
XML3D.xhtml = !!(document.doctype && new XMLSerializer().serializeToString(document.doctype).match(/xhtml/i));
2323

2424
XML3D.createElement = function(tagName) {
25-
return document.createElementNS(XML3D.xml3dNS, tagName);
25+
XML3D.debug.logWarning("This function is deprecated and will be removed in the next major release. Use document.createElement instead.");
26+
return document.createElement(tagName);
2627
};
2728

2829
XML3D.extend = assign;

src/init.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ function displayWebGLNotSupportedInfo(xml3dElement){
2727
var doDefault = XML3D.util.dispatchCustomEvent(xml3dElement, 'unsupported', false, true, null);
2828
if(doDefault){
2929
// Place xml3dElement inside an invisible div
30-
var hideDiv = document.createElementNS(XML3D.xhtmlNS, 'div');
30+
var hideDiv = document.createElement('div');
3131

3232
xml3dElement.parentNode.insertBefore(hideDiv, xml3dElement);
3333
hideDiv.appendChild(xml3dElement);
3434
//hideDiv.style.display = "none";
3535

36-
var infoDiv = document.createElementNS(XML3D.xhtmlNS, 'div');
36+
var infoDiv = document.createElement('div');
3737
if(xml3dElement.hasAttribute("class")){
3838
infoDiv.setAttribute("class", xml3dElement.getAttribute("class"));
3939
}
@@ -229,8 +229,12 @@ function resolveMutations(mutations){
229229

230230
} else if (mutation.type == 'attributes') {
231231
var mutationTarget = mutation.target;
232-
if (mutation.attributeName === "id" || mutation.attributeName === "class")
233-
mutationTarget = mutation.target.parentNode;
232+
if (mutation.attributeName === "id" || mutation.attributeName === "class") {
233+
mutationTarget = mutation.target.parentNode; // Start CSS re-eval at parent to honor sibling selectors
234+
if (!mutationTarget) {
235+
continue; // Target was removed from the DOM before this event was processed
236+
}
237+
}
234238
var cssTarget = mutationTarget._configured ? mutationTarget : mutationTarget.querySelector("xml3d");
235239
if(cssTarget && cssTarget._configured) { // xml3d is a child node
236240
var adaptersNames = Object.keys(cssTarget._configured.adapters).filter(function(a) {

src/types/box.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ Box.prototype.intersects = function(ray, opt) {
187187
return true;
188188
};
189189

190+
Box.prototype.contains = function(point) {
191+
var p = point.data ? point.data : point;
192+
return this.data[0] <= p[0] && p[0] <= this.data[3] &&
193+
this.data[1] <= p[1] && p[1] <= this.data[4] &&
194+
this.data[2] <= p[2] && p[2] <= this.data[5];
195+
};
196+
190197
Box.prototype.toString = function() {
191198
return 'XML3D.Box(' + this.data[0] + ', ' + this.data[1] + ', ' + this.data[2] + ', ' + this.data[3] + ', ' +
192199
this.data[4] + ', ' + this.data[5] + ')';

src/utils/cssMatrix.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -778,17 +778,15 @@ FirminCSSMatrix.prototype.setMatrixValue = function(domstr) {
778778
XML3D.debug.logError("Invalid CSS Matrix: ", domstr);
779779
return;
780780
}
781-
782-
for (i = 0; i < len; i++) {
783-
chunk = chunks[i];
784-
if (chunk.match(/^-?\d+(\.\d+)?$/)) {
781+
try {
782+
for (i = 0; i < len; i++) {
783+
chunk = chunks[i];
785784
points[i] = parseFloat(chunk);
786-
} else {
787-
XML3D.debug.logError("Invalid CSS Matrix: ", domstr);
788-
return;
789785
}
786+
} catch(e) {
787+
XML3D.debug.logError("Invalid CSS Matrix: ", domstr);
788+
return;
790789
}
791-
792790
for (i = 0; i < len; i++) {
793791
var point = is3d ?
794792
("m" + (Math.floor(i / 4) + 1)) + (i % 4 + 1) :

tests/css-transforms.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,21 @@ test("Change transform", 4, function () {
3939
test.fin(QUnit.start).done();
4040

4141
});
42+
43+
test("matrix3d with e notation", function() {
44+
stop();
45+
var frameLoaded = Q.fcall(promiseIFrameLoaded, "scenes/css-transforms.html");
46+
var group;
47+
48+
var test = frameLoaded.then(function(doc) {
49+
group = doc.getElementById("rootGroup");
50+
console.log(group.getLocalMatrix());
51+
group.setAttribute("style", "transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 20e-1, 0, -0.1e2, 1)");
52+
console.log(group.getLocalMatrix());
53+
return doc.getElementById("xml3dTest");
54+
}).then(promiseSceneRendered).then(function(s) {
55+
var actual = XML3DUnit.getPixelValue(getContextForXml3DElement(s), 300, 100);
56+
deepEqual(actual, [255, 0, 0, 255], "Group was moved to the right");
57+
});
58+
test.fin(QUnit.start).done();
59+
});

0 commit comments

Comments
 (0)