in packages/miew/src/gfx/geometries/IsoSurface.js [105:147]
_prepareAxesAndDirs() {
const volData = this._volumetricData;
const cellSize = volData.getCellSize();
// calculate cell axes
const xAxis = this._xAxis;
const yAxis = this._yAxis;
const zAxis = this._zAxis;
const xDir = this._xDir;
const yDir = this._yDir;
const zDir = this._zDir;
xAxis.set(cellSize.x, 0, 0);
yAxis.set(0, cellSize.y, 0);
zAxis.set(0, 0, cellSize.z);
xDir.set(1, 0, 0);
yDir.set(0, 1, 0);
zDir.set(0, 0, 1);
// flip normals if coordinate system is in the wrong handedness
const tmp = new THREE.Vector3();
tmp.crossVectors(xDir, yDir);
if (tmp.dot(zDir) < 0) {
xDir.negate();
yDir.negate();
zDir.negate();
}
// check that the grid is in the all-positive octant of the coordinate system
if (xDir.x < 0 || xDir.y < 0 || xDir.z < 0
|| yDir.x < 0 || yDir.y < 0 || yDir.z < 0
|| zDir.x < 0 || zDir.y < 0 || zDir.z < 0) {
return false;
}
// check that the grid is axis-aligned
const notZero = (axe) => Math.abs(axe) > Number.EPSILON;
return !(notZero(xAxis.y) || notZero(xAxis.z)
|| notZero(yAxis.x) || notZero(yAxis.z)
|| notZero(zAxis.x) || notZero(zAxis.y));
}