Skip to content

Commit

Permalink
fix(playcanvas): check for undefined props
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Aug 26, 2020
1 parent b448062 commit 3a2dedd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/adapter/playcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export function hijackPlayCanvas(pc) {
for (let i = 0; i < 9; i += 1) {
this.data[i] = first;
}
} else if (isNumber(first[0].w)) {
} else if (isNumber(first[0]?.w)) {
[first[0], first[1], first[2]].forEach(({ x, y, z }, i) => { this[i] = new Vec3(x, y, z); });
} else {
axes.forEach((ax, i) => { this[i] = ax; });
Expand All @@ -343,7 +343,7 @@ export function hijackPlayCanvas(pc) {
for (let i = 0; i < 16; i += 1) {
this.data[i] = first;
}
} else if (isNumber(first[0].x) && !isNumber(first[0].w)) {
} else if (first[0] && isNumber(first[0].x) && !isNumber(first[0].w)) {
[first[0], first[1], first[2]].forEach(({ x, y, z }, i) => { this[i] = new Vec4(x, y, z, 0.0); });
} else {
axes.forEach((ax, i) => { this[i] = ax; });
Expand Down
2 changes: 1 addition & 1 deletion src/utils/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function multiplyVecMat4(vecLeft, [column0, column1, column2, column3]) {
}

export function isNumber(nr) {
if (typeof nr === 'number' || (nr && nr.constructor === Number)) {
if (typeof nr === 'number' || nr?.constructor === Number) {
return true;
}
return false;
Expand Down

0 comments on commit 3a2dedd

Please sign in to comment.