Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switch (this.props.face) {
case Face.Bottom:
reposition = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, -1);
reorient = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, 1);
break;
case Face.Right:
reposition = Matrix3d.createRowValues(0, 0, 1, 0, 1, 0, -1, 0, 0);
reorient = Matrix3d.createRowValues(0, 1, 0, 1, 0, 0, 0, 0, 1);
break;
case Face.Left:
reposition = Matrix3d.createRowValues(0, 0, -1, 0, 1, 0, 1, 0, 0);
reorient = Matrix3d.createRowValues(0, -1, 0, -1, 0, 0, 0, 0, 1);
break;
case Face.Back:
reposition = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
reorient = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, 1);
break;
case Face.Front:
reposition = Matrix3d.createRowValues(1, 0, 0, 0, 0, -1, 0, 1, 0);
reorient = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, 1);
break;
}
const repositioned = rotMatrix.multiplyMatrixMatrix(reposition);
const vect = repositioned.multiplyXYZ(0, 0, this._faceWidth);
const m = repositioned.multiplyMatrixMatrix(reorient);
const list = [
m.at(0, 0), -m.at(1, 0), m.at(2, 0), 0,
m.at(0, 1), -m.at(1, 1), m.at(2, 1), 0,
m.at(0, 2), -m.at(1, 2), m.at(2, 2), 0,
vect.at(0), -vect.at(1), vect.at(2) - this._faceWidth /* move back faceWidth so face is on screen level */, 1,
];
const transform = `matrix3d(${list.join(", ")})`;
reorient = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, 1);
break;
case Face.Right:
reposition = Matrix3d.createRowValues(0, 0, 1, 0, 1, 0, -1, 0, 0);
reorient = Matrix3d.createRowValues(0, 1, 0, 1, 0, 0, 0, 0, 1);
break;
case Face.Left:
reposition = Matrix3d.createRowValues(0, 0, -1, 0, 1, 0, 1, 0, 0);
reorient = Matrix3d.createRowValues(0, -1, 0, -1, 0, 0, 0, 0, 1);
break;
case Face.Back:
reposition = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
reorient = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, 1);
break;
case Face.Front:
reposition = Matrix3d.createRowValues(1, 0, 0, 0, 0, -1, 0, 1, 0);
reorient = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, 1);
break;
}
const repositioned = rotMatrix.multiplyMatrixMatrix(reposition);
const vect = repositioned.multiplyXYZ(0, 0, this._faceWidth);
const m = repositioned.multiplyMatrixMatrix(reorient);
const list = [
m.at(0, 0), -m.at(1, 0), m.at(2, 0), 0,
m.at(0, 1), -m.at(1, 1), m.at(2, 1), 0,
m.at(0, 2), -m.at(1, 2), m.at(2, 2), 0,
vect.at(0), -vect.at(1), vect.at(2) - this._faceWidth /* move back faceWidth so face is on screen level */, 1,
];
const transform = `matrix3d(${list.join(", ")})`;
const s: React.CSSProperties = {
transform,
WebkitTransform: transform,
let reposition: Matrix3d = Matrix3d.createIdentity();
switch (this.props.face) {
case Face.Bottom:
reposition = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, -1);
reorient = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, 1);
break;
case Face.Right:
reposition = Matrix3d.createRowValues(0, 0, 1, 0, 1, 0, -1, 0, 0);
reorient = Matrix3d.createRowValues(0, 1, 0, 1, 0, 0, 0, 0, 1);
break;
case Face.Left:
reposition = Matrix3d.createRowValues(0, 0, -1, 0, 1, 0, 1, 0, 0);
reorient = Matrix3d.createRowValues(0, -1, 0, -1, 0, 0, 0, 0, 1);
break;
case Face.Back:
reposition = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
reorient = Matrix3d.createRowValues(-1, 0, 0, 0, 1, 0, 0, 0, 1);
break;
case Face.Front:
reposition = Matrix3d.createRowValues(1, 0, 0, 0, 0, -1, 0, 1, 0);
reorient = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, 1);
break;
}
const repositioned = rotMatrix.multiplyMatrixMatrix(reposition);
const vect = repositioned.multiplyXYZ(0, 0, this._faceWidth);
const m = repositioned.multiplyMatrixMatrix(reorient);
const list = [
m.at(0, 0), -m.at(1, 0), m.at(2, 0), 0,
m.at(0, 1), -m.at(1, 1), m.at(2, 1), 0,
m.at(0, 2), -m.at(1, 2), m.at(2, 2), 0,
vect.at(0), -vect.at(1), vect.at(2) - this._faceWidth /* move back faceWidth so face is on screen level */, 1,
];
}
const cubeNavigationFaceLocs: { [key: string]: Vector3d } = {
[Face.Left]: Vector3d.create(HitBoxX.Left, HitBoxY.None, HitBoxZ.None),
[Face.Right]: Vector3d.create(HitBoxX.Right, HitBoxY.None, HitBoxZ.None),
[Face.Back]: Vector3d.create(HitBoxX.None, HitBoxY.Back, HitBoxZ.None),
[Face.Front]: Vector3d.create(HitBoxX.None, HitBoxY.Front, HitBoxZ.None),
[Face.Bottom]: Vector3d.create(HitBoxX.None, HitBoxY.None, HitBoxZ.Bottom),
[Face.Top]: Vector3d.create(HitBoxX.None, HitBoxY.None, HitBoxZ.Top),
};
const cubeNavigationFaceRotations: { [key: string]: Matrix3d } = {
[Face.Left]: Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0),
[Face.Right]: Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0),
[Face.Back]: Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0),
[Face.Front]: Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0),
[Face.Bottom]: Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1),
[Face.Top]: Matrix3d.createRowValues(1, 0, 0, 0, 1, 0, 0, 0, 1),
};
// data relating Up/Down/Left/Right directions relative to every surface
const cubeNavigationRoutes: { [key: string]: CubeNavigationRotationMap } = {
[Face.Front]: { up: Face.Top, down: Face.Bottom, left: Face.Left, right: Face.Right },
[Face.Back]: { up: Face.Top, down: Face.Bottom, left: Face.Right, right: Face.Left },
[Face.Top]: { up: Face.Back, down: Face.Front, left: Face.Left, right: Face.Right },
[Face.Bottom]: { up: Face.Front, down: Face.Back, left: Face.Left, right: Face.Right },
[Face.Right]: { up: Face.Top, down: Face.Bottom, left: Face.Front, right: Face.Back },
[Face.Left]: { up: Face.Top, down: Face.Bottom, left: Face.Back, right: Face.Front },
};
/** @internal */
export enum CubeHover {
function getMatrices(): Matrix3d[] {
if (undefined !== standardViewMatrices)
return standardViewMatrices;
standardViewMatrices = [];
standardViewMatrices[StandardViewId.Top] = Matrix3d.identity;
standardViewMatrices[StandardViewId.Bottom] = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1);
standardViewMatrices[StandardViewId.Left] = Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0);
standardViewMatrices[StandardViewId.Right] = Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0);
standardViewMatrices[StandardViewId.Front] = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
standardViewMatrices[StandardViewId.Back] = Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0);
standardViewMatrices[StandardViewId.Iso] = Matrix3d.createRowValues(
0.707106781186548, -0.70710678118654757, 0.00000000000000000,
0.408248290463863, 0.40824829046386302, 0.81649658092772603,
-0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices[StandardViewId.RightIso] = Matrix3d.createRowValues(
0.707106781186548, 0.70710678118654757, 0.00000000000000000,
-0.408248290463863, 0.40824829046386302, 0.81649658092772603,
0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices.forEach((mat) => Object.freeze(mat));
return standardViewMatrices;
}
function getMatrices(): Matrix3d[] {
if (undefined !== standardViewMatrices)
return standardViewMatrices;
standardViewMatrices = [];
standardViewMatrices[StandardViewId.Top] = Matrix3d.identity;
standardViewMatrices[StandardViewId.Bottom] = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1);
standardViewMatrices[StandardViewId.Left] = Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0);
standardViewMatrices[StandardViewId.Right] = Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0);
standardViewMatrices[StandardViewId.Front] = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
standardViewMatrices[StandardViewId.Back] = Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0);
standardViewMatrices[StandardViewId.Iso] = Matrix3d.createRowValues(
0.707106781186548, -0.70710678118654757, 0.00000000000000000,
0.408248290463863, 0.40824829046386302, 0.81649658092772603,
-0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices[StandardViewId.RightIso] = Matrix3d.createRowValues(
0.707106781186548, 0.70710678118654757, 0.00000000000000000,
-0.408248290463863, 0.40824829046386302, 0.81649658092772603,
0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices.forEach((mat) => Object.freeze(mat));
return standardViewMatrices;
}
function getMatrices(): Matrix3d[] {
if (undefined !== standardViewMatrices)
return standardViewMatrices;
standardViewMatrices = [];
standardViewMatrices[StandardViewId.Top] = Matrix3d.identity;
standardViewMatrices[StandardViewId.Bottom] = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1);
standardViewMatrices[StandardViewId.Left] = Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0);
standardViewMatrices[StandardViewId.Right] = Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0);
standardViewMatrices[StandardViewId.Front] = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
standardViewMatrices[StandardViewId.Back] = Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0);
standardViewMatrices[StandardViewId.Iso] = Matrix3d.createRowValues(
0.707106781186548, -0.70710678118654757, 0.00000000000000000,
0.408248290463863, 0.40824829046386302, 0.81649658092772603,
-0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices[StandardViewId.RightIso] = Matrix3d.createRowValues(
0.707106781186548, 0.70710678118654757, 0.00000000000000000,
-0.408248290463863, 0.40824829046386302, 0.81649658092772603,
0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices.forEach((mat) => Object.freeze(mat));
return standardViewMatrices;
}
function getMatrices(): Matrix3d[] {
if (undefined !== standardViewMatrices)
return standardViewMatrices;
standardViewMatrices = [];
standardViewMatrices[StandardViewId.Top] = Matrix3d.identity;
standardViewMatrices[StandardViewId.Bottom] = Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1);
standardViewMatrices[StandardViewId.Left] = Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0);
standardViewMatrices[StandardViewId.Right] = Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0);
standardViewMatrices[StandardViewId.Front] = Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0);
standardViewMatrices[StandardViewId.Back] = Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0);
standardViewMatrices[StandardViewId.Iso] = Matrix3d.createRowValues(
0.707106781186548, -0.70710678118654757, 0.00000000000000000,
0.408248290463863, 0.40824829046386302, 0.81649658092772603,
-0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices[StandardViewId.RightIso] = Matrix3d.createRowValues(
0.707106781186548, 0.70710678118654757, 0.00000000000000000,
-0.408248290463863, 0.40824829046386302, 0.81649658092772603,
0.577350269189626, -0.57735026918962573, 0.57735026918962573);
standardViewMatrices.forEach((mat) => Object.freeze(mat));
return standardViewMatrices;
}