Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
None = 0,
Top = 1,
Bottom = -1,
}
interface CubeNavigationRotationMap {
up: Face;
down: Face;
left: Face;
right: Face;
}
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 } = {
}
interface CubeNavigationRotationMap {
up: Face;
down: Face;
left: Face;
right: Face;
}
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 },
Top = 1,
Bottom = -1,
}
interface CubeNavigationRotationMap {
up: Face;
down: Face;
left: Face;
right: Face;
}
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 },
if (count <= 0)
return undefined;
const json = this._featureJson;
const binary = this._featureBinary;
const batchIds = json.BATCH_ID ? new Int32Array(binary.buffer, binary.byteOffset + json.BATCH_ID.byteOffset, count) : undefined;
const positions = json.POSITION ? new Float32Array(binary.buffer, binary.byteOffset + json.POSITION.byteOffset, count * 3) : undefined;
const upNormals = json.NORMAL_UP ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_UP.byteOffset, count * 3) : undefined;
const rightNormals = json.NORMAL_RIGHT ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_RIGHT.byteOffset, count * 3) : undefined;
const scales = json.SCALE ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE.byteOffset, count) : undefined;
const nonUniformScales = json.SCALE_NON_UNIFORM ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE_NON_UNIFORM.byteOffset, count * 3) : undefined;
const matrix = Matrix3d.createIdentity();
const position = Point3d.createZero();
const upNormal = Vector3d.create(0, 0, 1);
const rightNormal = Vector3d.create(1, 0, 0);
const scale = Vector3d.create(1, 1, 1);
const transformCenter = this._range.center;
const transforms = new Float32Array(12 * count);
for (let i = 0; i < count; i++) {
const index = i * 3;
if (positions)
position.set(positions[index] - transformCenter.x, positions[index + 1] - transformCenter.y, positions[index + 2] - transformCenter.z);
if (upNormals || rightNormals) {
if (upNormals)
upNormal.set(upNormals[index], upNormals[index + 1], upNormals[index + 2]);
if (rightNormals)
rightNormal.set(rightNormals[index], rightNormals[index + 1], rightNormals[index + 2]);
const json = this._featureJson;
const binary = this._featureBinary;
const batchIds = json.BATCH_ID ? new Int32Array(binary.buffer, binary.byteOffset + json.BATCH_ID.byteOffset, count) : undefined;
const positions = json.POSITION ? new Float32Array(binary.buffer, binary.byteOffset + json.POSITION.byteOffset, count * 3) : undefined;
const upNormals = json.NORMAL_UP ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_UP.byteOffset, count * 3) : undefined;
const rightNormals = json.NORMAL_RIGHT ? new Float32Array(binary.buffer, binary.byteOffset + json.NORMAL_RIGHT.byteOffset, count * 3) : undefined;
const scales = json.SCALE ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE.byteOffset, count) : undefined;
const nonUniformScales = json.SCALE_NON_UNIFORM ? new Float32Array(binary.buffer, binary.byteOffset + json.SCALE_NON_UNIFORM.byteOffset, count * 3) : undefined;
const matrix = Matrix3d.createIdentity();
const position = Point3d.createZero();
const upNormal = Vector3d.create(0, 0, 1);
const rightNormal = Vector3d.create(1, 0, 0);
const scale = Vector3d.create(1, 1, 1);
const transformCenter = this._range.center;
const transforms = new Float32Array(12 * count);
for (let i = 0; i < count; i++) {
const index = i * 3;
if (positions)
position.set(positions[index] - transformCenter.x, positions[index + 1] - transformCenter.y, positions[index + 2] - transformCenter.z);
if (upNormals || rightNormals) {
if (upNormals)
upNormal.set(upNormals[index], upNormals[index + 1], upNormals[index + 2]);
if (rightNormals)
rightNormal.set(rightNormals[index], rightNormals[index + 1], rightNormals[index + 2]);
if (scales)
public static getDefaultOpenedMapSize = (paddingX: number = 0, paddingY: number = 0): Vector3d => {
return Vector3d.create(window.innerWidth / 3 - 2 * (window.innerWidth - paddingX), window.innerHeight / 3 - 2 * paddingY);
}
public static rangeFromBoundingVolume(boundingVolume: any): Range3d | undefined {
if (undefined === boundingVolume)
return undefined;
if (undefined !== boundingVolume.box) {
const box: number[] = boundingVolume.box;
const center = Point3d.create(box[0], box[1], box[2]);
const ux = Vector3d.create(box[3], box[4], box[5]);
const uy = Vector3d.create(box[6], box[7], box[8]);
const uz = Vector3d.create(box[9], box[10], box[11]);
const corners: Point3d[] = [];
for (let j = 0; j < 2; j++) {
for (let k = 0; k < 2; k++) {
for (let l = 0; l < 2; l++) {
corners.push(center.plus3Scaled(ux, (j ? -1.0 : 1.0), uy, (k ? -1.0 : 1.0), uz, (l ? -1.0 : 1.0)));
}
}
}
return Range3d.createArray(corners);
} else if (Array.isArray(boundingVolume.sphere)) {
const sphere: number[] = boundingVolume.sphere;
const center = Point3d.create(sphere[0], sphere[1], sphere[2]);
const radius = sphere[3];
return Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);
} else if (Array.isArray(boundingVolume.region)) {
const ecefLow = (new Cartographic(boundingVolume.region[0], boundingVolume.region[1], boundingVolume.region[4])).toEcef();
public static createFromCartographicOrigin(origin: Cartographic, point?: Point3d, angle?: Angle) {
const ecefOrigin = origin.toEcef();
const zVector = Vector3d.createFrom(ecefOrigin).normalize();
const xVector = Vector3d.create(-Math.sin(origin.longitude), Math.cos(origin.longitude), 0.0);
const matrix = Matrix3d.createRigidFromColumns(zVector!, xVector, AxisOrder.ZXY)!;
if (point !== undefined) {
const delta = matrix.multiplyVector(Vector3d.create(-point.x, -point.y, -point.z));
ecefOrigin.addInPlace(delta);
}
if (angle !== undefined)
matrix.multiplyMatrixMatrix(Matrix3d.createRotationAroundAxisIndex(AxisIndex.Z, angle), matrix);
return new EcefLocation({ origin: ecefOrigin, orientation: YawPitchRollAngles.createFromMatrix3d(matrix)! });
}
}
public static rangeFromBoundingVolume(boundingVolume: any): Range3d | undefined {
if (undefined === boundingVolume)
return undefined;
if (undefined !== boundingVolume.box) {
const box: number[] = boundingVolume.box;
const center = Point3d.create(box[0], box[1], box[2]);
const ux = Vector3d.create(box[3], box[4], box[5]);
const uy = Vector3d.create(box[6], box[7], box[8]);
const uz = Vector3d.create(box[9], box[10], box[11]);
const corners: Point3d[] = [];
for (let j = 0; j < 2; j++) {
for (let k = 0; k < 2; k++) {
for (let l = 0; l < 2; l++) {
corners.push(center.plus3Scaled(ux, (j ? -1.0 : 1.0), uy, (k ? -1.0 : 1.0), uz, (l ? -1.0 : 1.0)));
}
}
}
return Range3d.createArray(corners);
} else if (Array.isArray(boundingVolume.sphere)) {
const sphere: number[] = boundingVolume.sphere;
const center = Point3d.create(sphere[0], sphere[1], sphere[2]);
const radius = sphere[3];
return Range3d.createXYZXYZ(center.x - radius, center.y - radius, center.z - radius, center.x + radius, center.y + radius, center.z + radius);
} else if (Array.isArray(boundingVolume.region)) {
/** @internal */
export enum HitBoxZ {
None = 0,
Top = 1,
Bottom = -1,
}
interface CubeNavigationRotationMap {
up: Face;
down: Face;
left: Face;
right: Face;
}
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),
};