/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
BoundingRectangle_default
} from "./chunk-44QAAS4P.js";
import {
CornerType_default,
PolylineVolumeGeometryLibrary_default
} from "./chunk-3IFRSGEY.js";
import "./chunk-QN6TBED4.js";
import "./chunk-C3EQ27WF.js";
import "./chunk-YK3QIKY7.js";
import "./chunk-NDDI2LWR.js";
import {
PolygonPipeline_default,
WindingOrder_default
} from "./chunk-TI3TRKIC.js";
import {
arrayRemoveDuplicates_default
} from "./chunk-57H6I3SV.js";
import "./chunk-JSQJDZI4.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
GeometryAttributes_default
} from "./chunk-X7IQYYHF.js";
import {
GeometryAttribute_default,
Geometry_default,
PrimitiveType_default
} from "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import "./chunk-6SQMLVGV.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import {
Cartesian2_default,
Cartesian3_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/PolylineVolumeOutlineGeometry.js
function computeAttributes(positions, shape) {
const attributes = new GeometryAttributes_default();
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
const shapeLength = shape.length;
const vertexCount = attributes.position.values.length / 3;
const positionLength = positions.length / 3;
const shapeCount = positionLength / shapeLength;
const indices = IndexDatatype_default.createTypedArray(
vertexCount,
2 * shapeLength * (shapeCount + 1)
);
let i, j;
let index = 0;
i = 0;
let offset = i * shapeLength;
for (j = 0; j < shapeLength - 1; j++) {
indices[index++] = j + offset;
indices[index++] = j + offset + 1;
}
indices[index++] = shapeLength - 1 + offset;
indices[index++] = offset;
i = shapeCount - 1;
offset = i * shapeLength;
for (j = 0; j < shapeLength - 1; j++) {
indices[index++] = j + offset;
indices[index++] = j + offset + 1;
}
indices[index++] = shapeLength - 1 + offset;
indices[index++] = offset;
for (i = 0; i < shapeCount - 1; i++) {
const firstOffset = shapeLength * i;
const secondOffset = firstOffset + shapeLength;
for (j = 0; j < shapeLength; j++) {
indices[index++] = j + firstOffset;
indices[index++] = j + secondOffset;
}
}
const geometry = new Geometry_default({
attributes,
indices: IndexDatatype_default.createTypedArray(vertexCount, indices),
boundingSphere: BoundingSphere_default.fromVertices(positions),
primitiveType: PrimitiveType_default.LINES
});
return geometry;
}
function PolylineVolumeOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.polylinePositions;
const shape = options.shapePositions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.polylinePositions is required.");
}
if (!defined_default(shape)) {
throw new DeveloperError_default("options.shapePositions is required.");
}
this._positions = positions;
this._shape = shape;
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.default)
);
this._cornerType = defaultValue_default(options.cornerType, CornerType_default.ROUNDED);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._workerName = "createPolylineVolumeOutlineGeometry";
let numComponents = 1 + positions.length * Cartesian3_default.packedLength;
numComponents += 1 + shape.length * Cartesian2_default.packedLength;
this.packedLength = numComponents + Ellipsoid_default.packedLength + 2;
}
PolylineVolumeOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length = positions.length;
array[startingIndex++] = length;
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const shape = value._shape;
length = shape.length;
array[startingIndex++] = length;
for (i = 0; i < length; ++i, startingIndex += Cartesian2_default.packedLength) {
Cartesian2_default.pack(shape[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._cornerType;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions = {
polylinePositions: void 0,
shapePositions: void 0,
ellipsoid: scratchEllipsoid,
height: void 0,
cornerType: void 0,
granularity: void 0
};
PolylineVolumeOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length = array[startingIndex++];
const positions = new Array(length);
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length = array[startingIndex++];
const shape = new Array(length);
for (i = 0; i < length; ++i, startingIndex += Cartesian2_default.packedLength) {
shape[i] = Cartesian2_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Ellipsoid_default.packedLength;
const cornerType = array[startingIndex++];
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions.polylinePositions = positions;
scratchOptions.shapePositions = shape;
scratchOptions.cornerType = cornerType;
scratchOptions.granularity = granularity;
return new PolylineVolumeOutlineGeometry(scratchOptions);
}
result._positions = positions;
result._shape = shape;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._cornerType = cornerType;
result._granularity = granularity;
return result;
};
var brScratch = new BoundingRectangle_default();
PolylineVolumeOutlineGeometry.createGeometry = function(polylineVolumeOutlineGeometry) {
const positions = polylineVolumeOutlineGeometry._positions;
const cleanPositions = arrayRemoveDuplicates_default(
positions,
Cartesian3_default.equalsEpsilon
);
let shape2D = polylineVolumeOutlineGeometry._shape;
shape2D = PolylineVolumeGeometryLibrary_default.removeDuplicatesFromShape(shape2D);
if (cleanPositions.length < 2 || shape2D.length < 3) {
return void 0;
}
if (PolygonPipeline_default.computeWindingOrder2D(shape2D) === WindingOrder_default.CLOCKWISE) {
shape2D.reverse();
}
const boundingRectangle = BoundingRectangle_default.fromPoints(shape2D, brScratch);
const computedPositions = PolylineVolumeGeometryLibrary_default.computePositions(
cleanPositions,
shape2D,
boundingRectangle,
polylineVolumeOutlineGeometry,
false
);
return computeAttributes(computedPositions, shape2D);
};
var PolylineVolumeOutlineGeometry_default = PolylineVolumeOutlineGeometry;
// packages/engine/Source/Workers/createPolylineVolumeOutlineGeometry.js
function createPolylineVolumeOutlineGeometry(polylineVolumeOutlineGeometry, offset) {
if (defined_default(offset)) {
polylineVolumeOutlineGeometry = PolylineVolumeOutlineGeometry_default.unpack(
polylineVolumeOutlineGeometry,
offset
);
}
polylineVolumeOutlineGeometry._ellipsoid = Ellipsoid_default.clone(
polylineVolumeOutlineGeometry._ellipsoid
);
return PolylineVolumeOutlineGeometry_default.createGeometry(
polylineVolumeOutlineGeometry
);
}
var createPolylineVolumeOutlineGeometry_default = createPolylineVolumeOutlineGeometry;
export {
createPolylineVolumeOutlineGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
RectangleGeometryLibrary_default
} from "./chunk-BVKITG4N.js";
import {
GeometryInstance_default
} from "./chunk-YSIJTJ7N.js";
import {
GeometryPipeline_default
} from "./chunk-7ZZ5LMZY.js";
import "./chunk-LJ2JQHJT.js";
import "./chunk-NGZJIN5Z.js";
import {
GeometryOffsetAttribute_default
} from "./chunk-GBT7MJ6X.js";
import {
VertexFormat_default
} from "./chunk-JBSKHTNX.js";
import {
PolygonPipeline_default
} from "./chunk-TI3TRKIC.js";
import "./chunk-JSQJDZI4.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
GeometryAttributes_default
} from "./chunk-X7IQYYHF.js";
import {
GeometryAttribute_default,
Geometry_default,
PrimitiveType_default
} from "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import {
Matrix2_default,
Quaternion_default,
Rectangle_default
} from "./chunk-6SQMLVGV.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import {
Cartesian2_default,
Cartesian3_default,
Cartographic_default,
Ellipsoid_default,
Matrix3_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
Check_default,
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/RectangleGeometry.js
var positionScratch = new Cartesian3_default();
var normalScratch = new Cartesian3_default();
var tangentScratch = new Cartesian3_default();
var bitangentScratch = new Cartesian3_default();
var rectangleScratch = new Rectangle_default();
var stScratch = new Cartesian2_default();
var bottomBoundingSphere = new BoundingSphere_default();
var topBoundingSphere = new BoundingSphere_default();
function createAttributes(vertexFormat, attributes) {
const geo = new Geometry_default({
attributes: new GeometryAttributes_default(),
primitiveType: PrimitiveType_default.TRIANGLES
});
geo.attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: attributes.positions
});
if (vertexFormat.normal) {
geo.attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attributes.normals
});
}
if (vertexFormat.tangent) {
geo.attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attributes.tangents
});
}
if (vertexFormat.bitangent) {
geo.attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: attributes.bitangents
});
}
return geo;
}
function calculateAttributes(positions, vertexFormat, ellipsoid, tangentRotationMatrix) {
const length = positions.length;
const normals = vertexFormat.normal ? new Float32Array(length) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(length) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(length) : void 0;
let attrIndex = 0;
const bitangent = bitangentScratch;
const tangent = tangentScratch;
let normal = normalScratch;
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (let i = 0; i < length; i += 3) {
const p = Cartesian3_default.fromArray(positions, i, positionScratch);
const attrIndex1 = attrIndex + 1;
const attrIndex2 = attrIndex + 2;
normal = ellipsoid.geodeticSurfaceNormal(p, normal);
if (vertexFormat.tangent || vertexFormat.bitangent) {
Cartesian3_default.cross(Cartesian3_default.UNIT_Z, normal, tangent);
Matrix3_default.multiplyByVector(tangentRotationMatrix, tangent, tangent);
Cartesian3_default.normalize(tangent, tangent);
if (vertexFormat.bitangent) {
Cartesian3_default.normalize(
Cartesian3_default.cross(normal, tangent, bitangent),
bitangent
);
}
}
if (vertexFormat.normal) {
normals[attrIndex] = normal.x;
normals[attrIndex1] = normal.y;
normals[attrIndex2] = normal.z;
}
if (vertexFormat.tangent) {
tangents[attrIndex] = tangent.x;
tangents[attrIndex1] = tangent.y;
tangents[attrIndex2] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[attrIndex] = bitangent.x;
bitangents[attrIndex1] = bitangent.y;
bitangents[attrIndex2] = bitangent.z;
}
attrIndex += 3;
}
}
return createAttributes(vertexFormat, {
positions,
normals,
tangents,
bitangents
});
}
var v1Scratch = new Cartesian3_default();
var v2Scratch = new Cartesian3_default();
function calculateAttributesWall(positions, vertexFormat, ellipsoid) {
const length = positions.length;
const normals = vertexFormat.normal ? new Float32Array(length) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(length) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(length) : void 0;
let normalIndex = 0;
let tangentIndex = 0;
let bitangentIndex = 0;
let recomputeNormal = true;
let bitangent = bitangentScratch;
let tangent = tangentScratch;
let normal = normalScratch;
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
for (let i = 0; i < length; i += 6) {
const p = Cartesian3_default.fromArray(positions, i, positionScratch);
const p1 = Cartesian3_default.fromArray(positions, (i + 6) % length, v1Scratch);
if (recomputeNormal) {
const p2 = Cartesian3_default.fromArray(positions, (i + 3) % length, v2Scratch);
Cartesian3_default.subtract(p1, p, p1);
Cartesian3_default.subtract(p2, p, p2);
normal = Cartesian3_default.normalize(Cartesian3_default.cross(p2, p1, normal), normal);
recomputeNormal = false;
}
if (Cartesian3_default.equalsEpsilon(p1, p, Math_default.EPSILON10)) {
recomputeNormal = true;
}
if (vertexFormat.tangent || vertexFormat.bitangent) {
bitangent = ellipsoid.geodeticSurfaceNormal(p, bitangent);
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.cross(bitangent, normal, tangent),
tangent
);
}
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
return createAttributes(vertexFormat, {
positions,
normals,
tangents,
bitangents
});
}
function constructRectangle(rectangleGeometry, computedOptions) {
const vertexFormat = rectangleGeometry._vertexFormat;
const ellipsoid = rectangleGeometry._ellipsoid;
const height = computedOptions.height;
const width = computedOptions.width;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let rowStart = 0;
let rowEnd = height;
let rowHeight = height;
let size = 0;
if (northCap) {
rowStart = 1;
rowHeight -= 1;
size += 1;
}
if (southCap) {
rowEnd -= 1;
rowHeight -= 1;
size += 1;
}
size += width * rowHeight;
const positions = vertexFormat.position ? new Float64Array(size * 3) : void 0;
const textureCoordinates = vertexFormat.st ? new Float32Array(size * 2) : void 0;
let posIndex = 0;
let stIndex = 0;
const position = positionScratch;
const st = stScratch;
let minX = Number.MAX_VALUE;
let minY = Number.MAX_VALUE;
let maxX = -Number.MAX_VALUE;
let maxY = -Number.MAX_VALUE;
for (let row = rowStart; row < rowEnd; ++row) {
for (let col = 0; col < width; ++col) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
vertexFormat.st,
row,
col,
position,
st
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
if (vertexFormat.st) {
textureCoordinates[stIndex++] = st.x;
textureCoordinates[stIndex++] = st.y;
minX = Math.min(minX, st.x);
minY = Math.min(minY, st.y);
maxX = Math.max(maxX, st.x);
maxY = Math.max(maxY, st.y);
}
}
}
if (northCap) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
vertexFormat.st,
0,
0,
position,
st
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
if (vertexFormat.st) {
textureCoordinates[stIndex++] = st.x;
textureCoordinates[stIndex++] = st.y;
minX = st.x;
minY = st.y;
maxX = st.x;
maxY = st.y;
}
}
if (southCap) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
vertexFormat.st,
height - 1,
0,
position,
st
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex] = position.z;
if (vertexFormat.st) {
textureCoordinates[stIndex++] = st.x;
textureCoordinates[stIndex] = st.y;
minX = Math.min(minX, st.x);
minY = Math.min(minY, st.y);
maxX = Math.max(maxX, st.x);
maxY = Math.max(maxY, st.y);
}
}
if (vertexFormat.st && (minX < 0 || minY < 0 || maxX > 1 || maxY > 1)) {
for (let k = 0; k < textureCoordinates.length; k += 2) {
textureCoordinates[k] = (textureCoordinates[k] - minX) / (maxX - minX);
textureCoordinates[k + 1] = (textureCoordinates[k + 1] - minY) / (maxY - minY);
}
}
const geo = calculateAttributes(
positions,
vertexFormat,
ellipsoid,
computedOptions.tangentRotationMatrix
);
let indicesSize = 6 * (width - 1) * (rowHeight - 1);
if (northCap) {
indicesSize += 3 * (width - 1);
}
if (southCap) {
indicesSize += 3 * (width - 1);
}
const indices = IndexDatatype_default.createTypedArray(size, indicesSize);
let index = 0;
let indicesIndex = 0;
let i;
for (i = 0; i < rowHeight - 1; ++i) {
for (let j = 0; j < width - 1; ++j) {
const upperLeft = index;
const lowerLeft = upperLeft + width;
const lowerRight = lowerLeft + 1;
const upperRight = upperLeft + 1;
indices[indicesIndex++] = upperLeft;
indices[indicesIndex++] = lowerLeft;
indices[indicesIndex++] = upperRight;
indices[indicesIndex++] = upperRight;
indices[indicesIndex++] = lowerLeft;
indices[indicesIndex++] = lowerRight;
++index;
}
++index;
}
if (northCap || southCap) {
let northIndex = size - 1;
const southIndex = size - 1;
if (northCap && southCap) {
northIndex = size - 2;
}
let p1;
let p2;
index = 0;
if (northCap) {
for (i = 0; i < width - 1; i++) {
p1 = index;
p2 = p1 + 1;
indices[indicesIndex++] = northIndex;
indices[indicesIndex++] = p1;
indices[indicesIndex++] = p2;
++index;
}
}
if (southCap) {
index = (rowHeight - 1) * width;
for (i = 0; i < width - 1; i++) {
p1 = index;
p2 = p1 + 1;
indices[indicesIndex++] = p1;
indices[indicesIndex++] = southIndex;
indices[indicesIndex++] = p2;
++index;
}
}
}
geo.indices = indices;
if (vertexFormat.st) {
geo.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
return geo;
}
function addWallPositions(wallPositions, posIndex, i, topPositions, bottomPositions) {
wallPositions[posIndex++] = topPositions[i];
wallPositions[posIndex++] = topPositions[i + 1];
wallPositions[posIndex++] = topPositions[i + 2];
wallPositions[posIndex++] = bottomPositions[i];
wallPositions[posIndex++] = bottomPositions[i + 1];
wallPositions[posIndex] = bottomPositions[i + 2];
return wallPositions;
}
function addWallTextureCoordinates(wallTextures, stIndex, i, st) {
wallTextures[stIndex++] = st[i];
wallTextures[stIndex++] = st[i + 1];
wallTextures[stIndex++] = st[i];
wallTextures[stIndex] = st[i + 1];
return wallTextures;
}
var scratchVertexFormat = new VertexFormat_default();
function constructExtrudedRectangle(rectangleGeometry, computedOptions) {
const shadowVolume = rectangleGeometry._shadowVolume;
const offsetAttributeValue = rectangleGeometry._offsetAttribute;
const vertexFormat = rectangleGeometry._vertexFormat;
const minHeight = rectangleGeometry._extrudedHeight;
const maxHeight = rectangleGeometry._surfaceHeight;
const ellipsoid = rectangleGeometry._ellipsoid;
const height = computedOptions.height;
const width = computedOptions.width;
let i;
if (shadowVolume) {
const newVertexFormat = VertexFormat_default.clone(
vertexFormat,
scratchVertexFormat
);
newVertexFormat.normal = true;
rectangleGeometry._vertexFormat = newVertexFormat;
}
const topBottomGeo = constructRectangle(rectangleGeometry, computedOptions);
if (shadowVolume) {
rectangleGeometry._vertexFormat = vertexFormat;
}
let topPositions = PolygonPipeline_default.scaleToGeodeticHeight(
topBottomGeo.attributes.position.values,
maxHeight,
ellipsoid,
false
);
topPositions = new Float64Array(topPositions);
let length = topPositions.length;
const newLength = length * 2;
const positions = new Float64Array(newLength);
positions.set(topPositions);
const bottomPositions = PolygonPipeline_default.scaleToGeodeticHeight(
topBottomGeo.attributes.position.values,
minHeight,
ellipsoid
);
positions.set(bottomPositions, length);
topBottomGeo.attributes.position.values = positions;
const normals = vertexFormat.normal ? new Float32Array(newLength) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(newLength) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(newLength) : void 0;
const textures = vertexFormat.st ? new Float32Array(newLength / 3 * 2) : void 0;
let topSt;
let topNormals;
if (vertexFormat.normal) {
topNormals = topBottomGeo.attributes.normal.values;
normals.set(topNormals);
for (i = 0; i < length; i++) {
topNormals[i] = -topNormals[i];
}
normals.set(topNormals, length);
topBottomGeo.attributes.normal.values = normals;
}
if (shadowVolume) {
topNormals = topBottomGeo.attributes.normal.values;
if (!vertexFormat.normal) {
topBottomGeo.attributes.normal = void 0;
}
const extrudeNormals = new Float32Array(newLength);
for (i = 0; i < length; i++) {
topNormals[i] = -topNormals[i];
}
extrudeNormals.set(topNormals, length);
topBottomGeo.attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: extrudeNormals
});
}
let offsetValue;
const hasOffsets = defined_default(offsetAttributeValue);
if (hasOffsets) {
const size = length / 3 * 2;
let offsetAttribute = new Uint8Array(size);
if (offsetAttributeValue === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
offsetValue = offsetAttributeValue === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
topBottomGeo.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
if (vertexFormat.tangent) {
const topTangents = topBottomGeo.attributes.tangent.values;
tangents.set(topTangents);
for (i = 0; i < length; i++) {
topTangents[i] = -topTangents[i];
}
tangents.set(topTangents, length);
topBottomGeo.attributes.tangent.values = tangents;
}
if (vertexFormat.bitangent) {
const topBitangents = topBottomGeo.attributes.bitangent.values;
bitangents.set(topBitangents);
bitangents.set(topBitangents, length);
topBottomGeo.attributes.bitangent.values = bitangents;
}
if (vertexFormat.st) {
topSt = topBottomGeo.attributes.st.values;
textures.set(topSt);
textures.set(topSt, length / 3 * 2);
topBottomGeo.attributes.st.values = textures;
}
const indices = topBottomGeo.indices;
const indicesLength = indices.length;
const posLength = length / 3;
const newIndices = IndexDatatype_default.createTypedArray(
newLength / 3,
indicesLength * 2
);
newIndices.set(indices);
for (i = 0; i < indicesLength; i += 3) {
newIndices[i + indicesLength] = indices[i + 2] + posLength;
newIndices[i + 1 + indicesLength] = indices[i + 1] + posLength;
newIndices[i + 2 + indicesLength] = indices[i] + posLength;
}
topBottomGeo.indices = newIndices;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let rowHeight = height;
let widthMultiplier = 2;
let perimeterPositions = 0;
let corners = 4;
let dupliateCorners = 4;
if (northCap) {
widthMultiplier -= 1;
rowHeight -= 1;
perimeterPositions += 1;
corners -= 2;
dupliateCorners -= 1;
}
if (southCap) {
widthMultiplier -= 1;
rowHeight -= 1;
perimeterPositions += 1;
corners -= 2;
dupliateCorners -= 1;
}
perimeterPositions += widthMultiplier * width + 2 * rowHeight - corners;
const wallCount = (perimeterPositions + dupliateCorners) * 2;
let wallPositions = new Float64Array(wallCount * 3);
const wallExtrudeNormals = shadowVolume ? new Float32Array(wallCount * 3) : void 0;
let wallOffsetAttribute = hasOffsets ? new Uint8Array(wallCount) : void 0;
let wallTextures = vertexFormat.st ? new Float32Array(wallCount * 2) : void 0;
const computeTopOffsets = offsetAttributeValue === GeometryOffsetAttribute_default.TOP;
if (hasOffsets && !computeTopOffsets) {
offsetValue = offsetAttributeValue === GeometryOffsetAttribute_default.ALL ? 1 : 0;
wallOffsetAttribute = wallOffsetAttribute.fill(offsetValue);
}
let posIndex = 0;
let stIndex = 0;
let extrudeNormalIndex = 0;
let wallOffsetIndex = 0;
const area = width * rowHeight;
let threeI;
for (i = 0; i < area; i += width) {
threeI = i * 3;
wallPositions = addWallPositions(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
if (!southCap) {
for (i = area - width; i < area; i++) {
threeI = i * 3;
wallPositions = addWallPositions(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
} else {
const southIndex = northCap ? area + 1 : area;
threeI = southIndex * 3;
for (i = 0; i < 2; i++) {
wallPositions = addWallPositions(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
southIndex * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
}
for (i = area - 1; i > 0; i -= width) {
threeI = i * 3;
wallPositions = addWallPositions(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
if (!northCap) {
for (i = width - 1; i >= 0; i--) {
threeI = i * 3;
wallPositions = addWallPositions(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
i * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
} else {
const northIndex = area;
threeI = northIndex * 3;
for (i = 0; i < 2; i++) {
wallPositions = addWallPositions(
wallPositions,
posIndex,
threeI,
topPositions,
bottomPositions
);
posIndex += 6;
if (vertexFormat.st) {
wallTextures = addWallTextureCoordinates(
wallTextures,
stIndex,
northIndex * 2,
topSt
);
stIndex += 4;
}
if (shadowVolume) {
extrudeNormalIndex += 3;
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 1];
wallExtrudeNormals[extrudeNormalIndex++] = topNormals[threeI + 2];
}
if (computeTopOffsets) {
wallOffsetAttribute[wallOffsetIndex++] = 1;
wallOffsetIndex += 1;
}
}
}
let geo = calculateAttributesWall(wallPositions, vertexFormat, ellipsoid);
if (vertexFormat.st) {
geo.attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: wallTextures
});
}
if (shadowVolume) {
geo.attributes.extrudeDirection = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: wallExtrudeNormals
});
}
if (hasOffsets) {
geo.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: wallOffsetAttribute
});
}
const wallIndices = IndexDatatype_default.createTypedArray(
wallCount,
perimeterPositions * 6
);
let upperLeft;
let lowerLeft;
let lowerRight;
let upperRight;
length = wallPositions.length / 3;
let index = 0;
for (i = 0; i < length - 1; i += 2) {
upperLeft = i;
upperRight = (upperLeft + 2) % length;
const p1 = Cartesian3_default.fromArray(wallPositions, upperLeft * 3, v1Scratch);
const p2 = Cartesian3_default.fromArray(wallPositions, upperRight * 3, v2Scratch);
if (Cartesian3_default.equalsEpsilon(p1, p2, Math_default.EPSILON10)) {
continue;
}
lowerLeft = (upperLeft + 1) % length;
lowerRight = (lowerLeft + 2) % length;
wallIndices[index++] = upperLeft;
wallIndices[index++] = lowerLeft;
wallIndices[index++] = upperRight;
wallIndices[index++] = upperRight;
wallIndices[index++] = lowerLeft;
wallIndices[index++] = lowerRight;
}
geo.indices = wallIndices;
geo = GeometryPipeline_default.combineInstances([
new GeometryInstance_default({
geometry: topBottomGeo
}),
new GeometryInstance_default({
geometry: geo
})
]);
return geo[0];
}
var scratchRectanglePoints = [
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default(),
new Cartesian3_default()
];
var nwScratch = new Cartographic_default();
var stNwScratch = new Cartographic_default();
function computeRectangle(rectangle, granularity, rotation, ellipsoid, result) {
if (rotation === 0) {
return Rectangle_default.clone(rectangle, result);
}
const computedOptions = RectangleGeometryLibrary_default.computeOptions(
rectangle,
granularity,
rotation,
0,
rectangleScratch,
nwScratch
);
const height = computedOptions.height;
const width = computedOptions.width;
const positions = scratchRectanglePoints;
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
0,
0,
positions[0]
);
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
0,
width - 1,
positions[1]
);
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
height - 1,
0,
positions[2]
);
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
height - 1,
width - 1,
positions[3]
);
return Rectangle_default.fromCartesianArray(positions, ellipsoid, result);
}
function RectangleGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const rectangle = options.rectangle;
Check_default.typeOf.object("rectangle", rectangle);
Rectangle_default.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError_default(
"options.rectangle.north must be greater than or equal to options.rectangle.south"
);
}
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._rectangle = Rectangle_default.clone(rectangle);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._ellipsoid = Ellipsoid_default.clone(
defaultValue_default(options.ellipsoid, Ellipsoid_default.default)
);
this._surfaceHeight = Math.max(height, extrudedHeight);
this._rotation = defaultValue_default(options.rotation, 0);
this._stRotation = defaultValue_default(options.stRotation, 0);
this._vertexFormat = VertexFormat_default.clone(
defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT)
);
this._extrudedHeight = Math.min(height, extrudedHeight);
this._shadowVolume = defaultValue_default(options.shadowVolume, false);
this._workerName = "createRectangleGeometry";
this._offsetAttribute = options.offsetAttribute;
this._rotatedRectangle = void 0;
this._textureCoordinateRotationPoints = void 0;
}
RectangleGeometry.packedLength = Rectangle_default.packedLength + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 7;
RectangleGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
Rectangle_default.pack(value._rectangle, array, startingIndex);
startingIndex += Rectangle_default.packedLength;
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._surfaceHeight;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._stRotation;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex++] = value._shadowVolume ? 1 : 0;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchRectangle = new Rectangle_default();
var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions = {
rectangle: scratchRectangle,
ellipsoid: scratchEllipsoid,
vertexFormat: scratchVertexFormat,
granularity: void 0,
height: void 0,
rotation: void 0,
stRotation: void 0,
extrudedHeight: void 0,
shadowVolume: void 0,
offsetAttribute: void 0
};
RectangleGeometry.unpack = function(array, startingIndex, result) {
Check_default.defined("array", array);
startingIndex = defaultValue_default(startingIndex, 0);
const rectangle = Rectangle_default.unpack(array, startingIndex, scratchRectangle);
startingIndex += Rectangle_default.packedLength;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat
);
startingIndex += VertexFormat_default.packedLength;
const granularity = array[startingIndex++];
const surfaceHeight = array[startingIndex++];
const rotation = array[startingIndex++];
const stRotation = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const shadowVolume = array[startingIndex++] === 1;
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions.granularity = granularity;
scratchOptions.height = surfaceHeight;
scratchOptions.rotation = rotation;
scratchOptions.stRotation = stRotation;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.shadowVolume = shadowVolume;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new RectangleGeometry(scratchOptions);
}
result._rectangle = Rectangle_default.clone(rectangle, result._rectangle);
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._granularity = granularity;
result._surfaceHeight = surfaceHeight;
result._rotation = rotation;
result._stRotation = stRotation;
result._extrudedHeight = extrudedHeight;
result._shadowVolume = shadowVolume;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
RectangleGeometry.computeRectangle = function(options, result) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const rectangle = options.rectangle;
Check_default.typeOf.object("rectangle", rectangle);
Rectangle_default.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError_default(
"options.rectangle.north must be greater than or equal to options.rectangle.south"
);
}
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.default);
const rotation = defaultValue_default(options.rotation, 0);
return computeRectangle(rectangle, granularity, rotation, ellipsoid, result);
};
var tangentRotationMatrixScratch = new Matrix3_default();
var quaternionScratch = new Quaternion_default();
var centerScratch = new Cartographic_default();
RectangleGeometry.createGeometry = function(rectangleGeometry) {
if (Math_default.equalsEpsilon(
rectangleGeometry._rectangle.north,
rectangleGeometry._rectangle.south,
Math_default.EPSILON10
) || Math_default.equalsEpsilon(
rectangleGeometry._rectangle.east,
rectangleGeometry._rectangle.west,
Math_default.EPSILON10
)) {
return void 0;
}
let rectangle = rectangleGeometry._rectangle;
const ellipsoid = rectangleGeometry._ellipsoid;
const rotation = rectangleGeometry._rotation;
const stRotation = rectangleGeometry._stRotation;
const vertexFormat = rectangleGeometry._vertexFormat;
const computedOptions = RectangleGeometryLibrary_default.computeOptions(
rectangle,
rectangleGeometry._granularity,
rotation,
stRotation,
rectangleScratch,
nwScratch,
stNwScratch
);
const tangentRotationMatrix = tangentRotationMatrixScratch;
if (stRotation !== 0 || rotation !== 0) {
const center = Rectangle_default.center(rectangle, centerScratch);
const axis = ellipsoid.geodeticSurfaceNormalCartographic(center, v1Scratch);
Quaternion_default.fromAxisAngle(axis, -stRotation, quaternionScratch);
Matrix3_default.fromQuaternion(quaternionScratch, tangentRotationMatrix);
} else {
Matrix3_default.clone(Matrix3_default.IDENTITY, tangentRotationMatrix);
}
const surfaceHeight = rectangleGeometry._surfaceHeight;
const extrudedHeight = rectangleGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
surfaceHeight,
extrudedHeight,
0,
Math_default.EPSILON2
);
computedOptions.lonScalar = 1 / rectangleGeometry._rectangle.width;
computedOptions.latScalar = 1 / rectangleGeometry._rectangle.height;
computedOptions.tangentRotationMatrix = tangentRotationMatrix;
let geometry;
let boundingSphere;
rectangle = rectangleGeometry._rectangle;
if (extrude) {
geometry = constructExtrudedRectangle(rectangleGeometry, computedOptions);
const topBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight,
topBoundingSphere
);
const bottomBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
extrudedHeight,
bottomBoundingSphere
);
boundingSphere = BoundingSphere_default.union(topBS, bottomBS);
} else {
geometry = constructRectangle(rectangleGeometry, computedOptions);
geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
geometry.attributes.position.values,
surfaceHeight,
ellipsoid,
false
);
if (defined_default(rectangleGeometry._offsetAttribute)) {
const length = geometry.attributes.position.values.length;
const offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length / 3).fill(offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
boundingSphere = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight
);
}
if (!vertexFormat.position) {
delete geometry.attributes.position;
}
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: geometry.primitiveType,
boundingSphere,
offsetAttribute: rectangleGeometry._offsetAttribute
});
};
RectangleGeometry.createShadowVolume = function(rectangleGeometry, minHeightFunc, maxHeightFunc) {
const granularity = rectangleGeometry._granularity;
const ellipsoid = rectangleGeometry._ellipsoid;
const minHeight = minHeightFunc(granularity, ellipsoid);
const maxHeight = maxHeightFunc(granularity, ellipsoid);
return new RectangleGeometry({
rectangle: rectangleGeometry._rectangle,
rotation: rectangleGeometry._rotation,
ellipsoid,
stRotation: rectangleGeometry._stRotation,
granularity,
extrudedHeight: maxHeight,
height: minHeight,
vertexFormat: VertexFormat_default.POSITION_ONLY,
shadowVolume: true
});
};
var unrotatedTextureRectangleScratch = new Rectangle_default();
var points2DScratch = [new Cartesian2_default(), new Cartesian2_default(), new Cartesian2_default()];
var rotation2DScratch = new Matrix2_default();
var rectangleCenterScratch = new Cartographic_default();
function textureCoordinateRotationPoints(rectangleGeometry) {
if (rectangleGeometry._stRotation === 0) {
return [0, 0, 0, 1, 1, 0];
}
const rectangle = Rectangle_default.clone(
rectangleGeometry._rectangle,
unrotatedTextureRectangleScratch
);
const granularity = rectangleGeometry._granularity;
const ellipsoid = rectangleGeometry._ellipsoid;
const rotation = rectangleGeometry._rotation - rectangleGeometry._stRotation;
const unrotatedTextureRectangle = computeRectangle(
rectangle,
granularity,
rotation,
ellipsoid,
unrotatedTextureRectangleScratch
);
const points2D = points2DScratch;
points2D[0].x = unrotatedTextureRectangle.west;
points2D[0].y = unrotatedTextureRectangle.south;
points2D[1].x = unrotatedTextureRectangle.west;
points2D[1].y = unrotatedTextureRectangle.north;
points2D[2].x = unrotatedTextureRectangle.east;
points2D[2].y = unrotatedTextureRectangle.south;
const boundingRectangle = rectangleGeometry.rectangle;
const toDesiredInComputed = Matrix2_default.fromRotation(
rectangleGeometry._stRotation,
rotation2DScratch
);
const boundingRectangleCenter = Rectangle_default.center(
boundingRectangle,
rectangleCenterScratch
);
for (let i = 0; i < 3; ++i) {
const point2D = points2D[i];
point2D.x -= boundingRectangleCenter.longitude;
point2D.y -= boundingRectangleCenter.latitude;
Matrix2_default.multiplyByVector(toDesiredInComputed, point2D, point2D);
point2D.x += boundingRectangleCenter.longitude;
point2D.y += boundingRectangleCenter.latitude;
point2D.x = (point2D.x - boundingRectangle.west) / boundingRectangle.width;
point2D.y = (point2D.y - boundingRectangle.south) / boundingRectangle.height;
}
const minXYCorner = points2D[0];
const maxYCorner = points2D[1];
const maxXCorner = points2D[2];
const result = new Array(6);
Cartesian2_default.pack(minXYCorner, result);
Cartesian2_default.pack(maxYCorner, result, 2);
Cartesian2_default.pack(maxXCorner, result, 4);
return result;
}
Object.defineProperties(RectangleGeometry.prototype, {
/**
* @private
*/
rectangle: {
get: function() {
if (!defined_default(this._rotatedRectangle)) {
this._rotatedRectangle = computeRectangle(
this._rectangle,
this._granularity,
this._rotation,
this._ellipsoid
);
}
return this._rotatedRectangle;
}
},
/**
* For remapping texture coordinates when rendering RectangleGeometries as GroundPrimitives.
* This version permits skew in textures by computing offsets directly in cartographic space and
* more accurately approximates rendering RectangleGeometries with height as standard Primitives.
* @see Geometry#_textureCoordinateRotationPoints
* @private
*/
textureCoordinateRotationPoints: {
get: function() {
if (!defined_default(this._textureCoordinateRotationPoints)) {
this._textureCoordinateRotationPoints = textureCoordinateRotationPoints(
this
);
}
return this._textureCoordinateRotationPoints;
}
}
});
var RectangleGeometry_default = RectangleGeometry;
// packages/engine/Source/Workers/createRectangleGeometry.js
function createRectangleGeometry(rectangleGeometry, offset) {
if (defined_default(offset)) {
rectangleGeometry = RectangleGeometry_default.unpack(rectangleGeometry, offset);
}
rectangleGeometry._ellipsoid = Ellipsoid_default.clone(rectangleGeometry._ellipsoid);
rectangleGeometry._rectangle = Rectangle_default.clone(rectangleGeometry._rectangle);
return RectangleGeometry_default.createGeometry(rectangleGeometry);
}
var createRectangleGeometry_default = createRectangleGeometry;
export {
createRectangleGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
RectangleGeometryLibrary_default
} from "./chunk-BVKITG4N.js";
import {
GeometryOffsetAttribute_default
} from "./chunk-GBT7MJ6X.js";
import {
PolygonPipeline_default
} from "./chunk-TI3TRKIC.js";
import "./chunk-JSQJDZI4.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
GeometryAttributes_default
} from "./chunk-X7IQYYHF.js";
import {
GeometryAttribute_default,
Geometry_default,
PrimitiveType_default
} from "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import {
Rectangle_default
} from "./chunk-6SQMLVGV.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/RectangleOutlineGeometry.js
var bottomBoundingSphere = new BoundingSphere_default();
var topBoundingSphere = new BoundingSphere_default();
var positionScratch = new Cartesian3_default();
var rectangleScratch = new Rectangle_default();
function constructRectangle(geometry, computedOptions) {
const ellipsoid = geometry._ellipsoid;
const height = computedOptions.height;
const width = computedOptions.width;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let rowHeight = height;
let widthMultiplier = 2;
let size = 0;
let corners = 4;
if (northCap) {
widthMultiplier -= 1;
rowHeight -= 1;
size += 1;
corners -= 2;
}
if (southCap) {
widthMultiplier -= 1;
rowHeight -= 1;
size += 1;
corners -= 2;
}
size += widthMultiplier * width + 2 * rowHeight - corners;
const positions = new Float64Array(size * 3);
let posIndex = 0;
let row = 0;
let col;
const position = positionScratch;
if (northCap) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
0,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
} else {
for (col = 0; col < width; col++) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
}
col = width - 1;
for (row = 1; row < height; row++) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
row = height - 1;
if (!southCap) {
for (col = width - 2; col >= 0; col--) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
}
col = 0;
for (row = height - 2; row > 0; row--) {
RectangleGeometryLibrary_default.computePosition(
computedOptions,
ellipsoid,
false,
row,
col,
position
);
positions[posIndex++] = position.x;
positions[posIndex++] = position.y;
positions[posIndex++] = position.z;
}
const indicesSize = positions.length / 3 * 2;
const indices = IndexDatatype_default.createTypedArray(
positions.length / 3,
indicesSize
);
let index = 0;
for (let i = 0; i < positions.length / 3 - 1; i++) {
indices[index++] = i;
indices[index++] = i + 1;
}
indices[index++] = positions.length / 3 - 1;
indices[index++] = 0;
const geo = new Geometry_default({
attributes: new GeometryAttributes_default(),
primitiveType: PrimitiveType_default.LINES
});
geo.attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
geo.indices = indices;
return geo;
}
function constructExtrudedRectangle(rectangleGeometry, computedOptions) {
const maxHeight = rectangleGeometry._surfaceHeight;
const minHeight = rectangleGeometry._extrudedHeight;
const ellipsoid = rectangleGeometry._ellipsoid;
const geo = constructRectangle(rectangleGeometry, computedOptions);
const height = computedOptions.height;
const width = computedOptions.width;
const topPositions = PolygonPipeline_default.scaleToGeodeticHeight(
geo.attributes.position.values,
maxHeight,
ellipsoid,
false
);
let length = topPositions.length;
const positions = new Float64Array(length * 2);
positions.set(topPositions);
const bottomPositions = PolygonPipeline_default.scaleToGeodeticHeight(
geo.attributes.position.values,
minHeight,
ellipsoid
);
positions.set(bottomPositions, length);
geo.attributes.position.values = positions;
const northCap = computedOptions.northCap;
const southCap = computedOptions.southCap;
let corners = 4;
if (northCap) {
corners -= 1;
}
if (southCap) {
corners -= 1;
}
const indicesSize = (positions.length / 3 + corners) * 2;
const indices = IndexDatatype_default.createTypedArray(
positions.length / 3,
indicesSize
);
length = positions.length / 6;
let index = 0;
for (let i = 0; i < length - 1; i++) {
indices[index++] = i;
indices[index++] = i + 1;
indices[index++] = i + length;
indices[index++] = i + length + 1;
}
indices[index++] = length - 1;
indices[index++] = 0;
indices[index++] = length + length - 1;
indices[index++] = length;
indices[index++] = 0;
indices[index++] = length;
let bottomCorner;
if (northCap) {
bottomCorner = height - 1;
} else {
const topRightCorner = width - 1;
indices[index++] = topRightCorner;
indices[index++] = topRightCorner + length;
bottomCorner = width + height - 2;
}
indices[index++] = bottomCorner;
indices[index++] = bottomCorner + length;
if (!southCap) {
const bottomLeftCorner = width + bottomCorner - 1;
indices[index++] = bottomLeftCorner;
indices[index] = bottomLeftCorner + length;
}
geo.indices = indices;
return geo;
}
function RectangleOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const rectangle = options.rectangle;
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.default);
const rotation = defaultValue_default(options.rotation, 0);
if (!defined_default(rectangle)) {
throw new DeveloperError_default("rectangle is required.");
}
Rectangle_default.validate(rectangle);
if (rectangle.north < rectangle.south) {
throw new DeveloperError_default(
"options.rectangle.north must be greater than options.rectangle.south"
);
}
const height = defaultValue_default(options.height, 0);
const extrudedHeight = defaultValue_default(options.extrudedHeight, height);
this._rectangle = Rectangle_default.clone(rectangle);
this._granularity = granularity;
this._ellipsoid = ellipsoid;
this._surfaceHeight = Math.max(height, extrudedHeight);
this._rotation = rotation;
this._extrudedHeight = Math.min(height, extrudedHeight);
this._offsetAttribute = options.offsetAttribute;
this._workerName = "createRectangleOutlineGeometry";
}
RectangleOutlineGeometry.packedLength = Rectangle_default.packedLength + Ellipsoid_default.packedLength + 5;
RectangleOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
Rectangle_default.pack(value._rectangle, array, startingIndex);
startingIndex += Rectangle_default.packedLength;
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._granularity;
array[startingIndex++] = value._surfaceHeight;
array[startingIndex++] = value._rotation;
array[startingIndex++] = value._extrudedHeight;
array[startingIndex] = defaultValue_default(value._offsetAttribute, -1);
return array;
};
var scratchRectangle = new Rectangle_default();
var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions = {
rectangle: scratchRectangle,
ellipsoid: scratchEllipsoid,
granularity: void 0,
height: void 0,
rotation: void 0,
extrudedHeight: void 0,
offsetAttribute: void 0
};
RectangleOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
const rectangle = Rectangle_default.unpack(array, startingIndex, scratchRectangle);
startingIndex += Rectangle_default.packedLength;
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Ellipsoid_default.packedLength;
const granularity = array[startingIndex++];
const height = array[startingIndex++];
const rotation = array[startingIndex++];
const extrudedHeight = array[startingIndex++];
const offsetAttribute = array[startingIndex];
if (!defined_default(result)) {
scratchOptions.granularity = granularity;
scratchOptions.height = height;
scratchOptions.rotation = rotation;
scratchOptions.extrudedHeight = extrudedHeight;
scratchOptions.offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return new RectangleOutlineGeometry(scratchOptions);
}
result._rectangle = Rectangle_default.clone(rectangle, result._rectangle);
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._surfaceHeight = height;
result._rotation = rotation;
result._extrudedHeight = extrudedHeight;
result._offsetAttribute = offsetAttribute === -1 ? void 0 : offsetAttribute;
return result;
};
var nwScratch = new Cartographic_default();
RectangleOutlineGeometry.createGeometry = function(rectangleGeometry) {
const rectangle = rectangleGeometry._rectangle;
const ellipsoid = rectangleGeometry._ellipsoid;
const computedOptions = RectangleGeometryLibrary_default.computeOptions(
rectangle,
rectangleGeometry._granularity,
rectangleGeometry._rotation,
0,
rectangleScratch,
nwScratch
);
let geometry;
let boundingSphere;
if (Math_default.equalsEpsilon(
rectangle.north,
rectangle.south,
Math_default.EPSILON10
) || Math_default.equalsEpsilon(
rectangle.east,
rectangle.west,
Math_default.EPSILON10
)) {
return void 0;
}
const surfaceHeight = rectangleGeometry._surfaceHeight;
const extrudedHeight = rectangleGeometry._extrudedHeight;
const extrude = !Math_default.equalsEpsilon(
surfaceHeight,
extrudedHeight,
0,
Math_default.EPSILON2
);
let offsetValue;
if (extrude) {
geometry = constructExtrudedRectangle(rectangleGeometry, computedOptions);
if (defined_default(rectangleGeometry._offsetAttribute)) {
const size = geometry.attributes.position.values.length / 3;
let offsetAttribute = new Uint8Array(size);
if (rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.TOP) {
offsetAttribute = offsetAttribute.fill(1, 0, size / 2);
} else {
offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
offsetAttribute = offsetAttribute.fill(offsetValue);
}
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: offsetAttribute
});
}
const topBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight,
topBoundingSphere
);
const bottomBS = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
extrudedHeight,
bottomBoundingSphere
);
boundingSphere = BoundingSphere_default.union(topBS, bottomBS);
} else {
geometry = constructRectangle(rectangleGeometry, computedOptions);
geometry.attributes.position.values = PolygonPipeline_default.scaleToGeodeticHeight(
geometry.attributes.position.values,
surfaceHeight,
ellipsoid,
false
);
if (defined_default(rectangleGeometry._offsetAttribute)) {
const length = geometry.attributes.position.values.length;
offsetValue = rectangleGeometry._offsetAttribute === GeometryOffsetAttribute_default.NONE ? 0 : 1;
const applyOffset = new Uint8Array(length / 3).fill(offsetValue);
geometry.attributes.applyOffset = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 1,
values: applyOffset
});
}
boundingSphere = BoundingSphere_default.fromRectangle3D(
rectangle,
ellipsoid,
surfaceHeight
);
}
return new Geometry_default({
attributes: geometry.attributes,
indices: geometry.indices,
primitiveType: PrimitiveType_default.LINES,
boundingSphere,
offsetAttribute: rectangleGeometry._offsetAttribute
});
};
var RectangleOutlineGeometry_default = RectangleOutlineGeometry;
// packages/engine/Source/Workers/createRectangleOutlineGeometry.js
function createRectangleOutlineGeometry(rectangleGeometry, offset) {
if (defined_default(offset)) {
rectangleGeometry = RectangleOutlineGeometry_default.unpack(
rectangleGeometry,
offset
);
}
rectangleGeometry._ellipsoid = Ellipsoid_default.clone(rectangleGeometry._ellipsoid);
rectangleGeometry._rectangle = Rectangle_default.clone(rectangleGeometry._rectangle);
return RectangleOutlineGeometry_default.createGeometry(rectangleGeometry);
}
var createRectangleOutlineGeometry_default = createRectangleOutlineGeometry;
export {
createRectangleOutlineGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
Color_default
} from "./chunk-HP5XLODI.js";
import {
ArcType_default
} from "./chunk-XWOUPGUF.js";
import {
PolylinePipeline_default
} from "./chunk-QN6TBED4.js";
import "./chunk-C3EQ27WF.js";
import "./chunk-JSQJDZI4.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
GeometryAttributes_default
} from "./chunk-X7IQYYHF.js";
import {
GeometryAttribute_default,
Geometry_default,
PrimitiveType_default
} from "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import "./chunk-6SQMLVGV.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/SimplePolylineGeometry.js
function interpolateColors(p0, p1, color0, color1, minDistance, array, offset) {
const numPoints = PolylinePipeline_default.numberOfPoints(p0, p1, minDistance);
let i;
const r0 = color0.red;
const g0 = color0.green;
const b0 = color0.blue;
const a0 = color0.alpha;
const r1 = color1.red;
const g1 = color1.green;
const b1 = color1.blue;
const a1 = color1.alpha;
if (Color_default.equals(color0, color1)) {
for (i = 0; i < numPoints; i++) {
array[offset++] = Color_default.floatToByte(r0);
array[offset++] = Color_default.floatToByte(g0);
array[offset++] = Color_default.floatToByte(b0);
array[offset++] = Color_default.floatToByte(a0);
}
return offset;
}
const redPerVertex = (r1 - r0) / numPoints;
const greenPerVertex = (g1 - g0) / numPoints;
const bluePerVertex = (b1 - b0) / numPoints;
const alphaPerVertex = (a1 - a0) / numPoints;
let index = offset;
for (i = 0; i < numPoints; i++) {
array[index++] = Color_default.floatToByte(r0 + i * redPerVertex);
array[index++] = Color_default.floatToByte(g0 + i * greenPerVertex);
array[index++] = Color_default.floatToByte(b0 + i * bluePerVertex);
array[index++] = Color_default.floatToByte(a0 + i * alphaPerVertex);
}
return index;
}
function SimplePolylineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
const colors = options.colors;
const colorsPerVertex = defaultValue_default(options.colorsPerVertex, false);
if (!defined_default(positions) || positions.length < 2) {
throw new DeveloperError_default("At least two positions are required.");
}
if (defined_default(colors) && (colorsPerVertex && colors.length < positions.length || !colorsPerVertex && colors.length < positions.length - 1)) {
throw new DeveloperError_default("colors has an invalid length.");
}
this._positions = positions;
this._colors = colors;
this._colorsPerVertex = colorsPerVertex;
this._arcType = defaultValue_default(options.arcType, ArcType_default.GEODESIC);
this._granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
this._ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.default);
this._workerName = "createSimplePolylineGeometry";
let numComponents = 1 + positions.length * Cartesian3_default.packedLength;
numComponents += defined_default(colors) ? 1 + colors.length * Color_default.packedLength : 1;
this.packedLength = numComponents + Ellipsoid_default.packedLength + 3;
}
SimplePolylineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length = positions.length;
array[startingIndex++] = length;
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const colors = value._colors;
length = defined_default(colors) ? colors.length : 0;
array[startingIndex++] = length;
for (i = 0; i < length; ++i, startingIndex += Color_default.packedLength) {
Color_default.pack(colors[i], array, startingIndex);
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex++] = value._colorsPerVertex ? 1 : 0;
array[startingIndex++] = value._arcType;
array[startingIndex] = value._granularity;
return array;
};
SimplePolylineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length = array[startingIndex++];
const positions = new Array(length);
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length = array[startingIndex++];
const colors = length > 0 ? new Array(length) : void 0;
for (i = 0; i < length; ++i, startingIndex += Color_default.packedLength) {
colors[i] = Color_default.unpack(array, startingIndex);
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
const colorsPerVertex = array[startingIndex++] === 1;
const arcType = array[startingIndex++];
const granularity = array[startingIndex];
if (!defined_default(result)) {
return new SimplePolylineGeometry({
positions,
colors,
ellipsoid,
colorsPerVertex,
arcType,
granularity
});
}
result._positions = positions;
result._colors = colors;
result._ellipsoid = ellipsoid;
result._colorsPerVertex = colorsPerVertex;
result._arcType = arcType;
result._granularity = granularity;
return result;
};
var scratchArray1 = new Array(2);
var scratchArray2 = new Array(2);
var generateArcOptionsScratch = {
positions: scratchArray1,
height: scratchArray2,
ellipsoid: void 0,
minDistance: void 0,
granularity: void 0
};
SimplePolylineGeometry.createGeometry = function(simplePolylineGeometry) {
const positions = simplePolylineGeometry._positions;
const colors = simplePolylineGeometry._colors;
const colorsPerVertex = simplePolylineGeometry._colorsPerVertex;
const arcType = simplePolylineGeometry._arcType;
const granularity = simplePolylineGeometry._granularity;
const ellipsoid = simplePolylineGeometry._ellipsoid;
const minDistance = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
const perSegmentColors = defined_default(colors) && !colorsPerVertex;
let i;
const length = positions.length;
let positionValues;
let numberOfPositions;
let colorValues;
let color;
let offset = 0;
if (arcType === ArcType_default.GEODESIC || arcType === ArcType_default.RHUMB) {
let subdivisionSize;
let numberOfPointsFunction;
let generateArcFunction;
if (arcType === ArcType_default.GEODESIC) {
subdivisionSize = Math_default.chordLength(
granularity,
ellipsoid.maximumRadius
);
numberOfPointsFunction = PolylinePipeline_default.numberOfPoints;
generateArcFunction = PolylinePipeline_default.generateArc;
} else {
subdivisionSize = granularity;
numberOfPointsFunction = PolylinePipeline_default.numberOfPointsRhumbLine;
generateArcFunction = PolylinePipeline_default.generateRhumbArc;
}
const heights = PolylinePipeline_default.extractHeights(positions, ellipsoid);
const generateArcOptions = generateArcOptionsScratch;
if (arcType === ArcType_default.GEODESIC) {
generateArcOptions.minDistance = minDistance;
} else {
generateArcOptions.granularity = granularity;
}
generateArcOptions.ellipsoid = ellipsoid;
if (perSegmentColors) {
let positionCount = 0;
for (i = 0; i < length - 1; i++) {
positionCount += numberOfPointsFunction(
positions[i],
positions[i + 1],
subdivisionSize
) + 1;
}
positionValues = new Float64Array(positionCount * 3);
colorValues = new Uint8Array(positionCount * 4);
generateArcOptions.positions = scratchArray1;
generateArcOptions.height = scratchArray2;
let ci = 0;
for (i = 0; i < length - 1; ++i) {
scratchArray1[0] = positions[i];
scratchArray1[1] = positions[i + 1];
scratchArray2[0] = heights[i];
scratchArray2[1] = heights[i + 1];
const pos = generateArcFunction(generateArcOptions);
if (defined_default(colors)) {
const segLen = pos.length / 3;
color = colors[i];
for (let k = 0; k < segLen; ++k) {
colorValues[ci++] = Color_default.floatToByte(color.red);
colorValues[ci++] = Color_default.floatToByte(color.green);
colorValues[ci++] = Color_default.floatToByte(color.blue);
colorValues[ci++] = Color_default.floatToByte(color.alpha);
}
}
positionValues.set(pos, offset);
offset += pos.length;
}
} else {
generateArcOptions.positions = positions;
generateArcOptions.height = heights;
positionValues = new Float64Array(
generateArcFunction(generateArcOptions)
);
if (defined_default(colors)) {
colorValues = new Uint8Array(positionValues.length / 3 * 4);
for (i = 0; i < length - 1; ++i) {
const p0 = positions[i];
const p1 = positions[i + 1];
const c0 = colors[i];
const c1 = colors[i + 1];
offset = interpolateColors(
p0,
p1,
c0,
c1,
minDistance,
colorValues,
offset
);
}
const lastColor = colors[length - 1];
colorValues[offset++] = Color_default.floatToByte(lastColor.red);
colorValues[offset++] = Color_default.floatToByte(lastColor.green);
colorValues[offset++] = Color_default.floatToByte(lastColor.blue);
colorValues[offset++] = Color_default.floatToByte(lastColor.alpha);
}
}
} else {
numberOfPositions = perSegmentColors ? length * 2 - 2 : length;
positionValues = new Float64Array(numberOfPositions * 3);
colorValues = defined_default(colors) ? new Uint8Array(numberOfPositions * 4) : void 0;
let positionIndex = 0;
let colorIndex = 0;
for (i = 0; i < length; ++i) {
const p = positions[i];
if (perSegmentColors && i > 0) {
Cartesian3_default.pack(p, positionValues, positionIndex);
positionIndex += 3;
color = colors[i - 1];
colorValues[colorIndex++] = Color_default.floatToByte(color.red);
colorValues[colorIndex++] = Color_default.floatToByte(color.green);
colorValues[colorIndex++] = Color_default.floatToByte(color.blue);
colorValues[colorIndex++] = Color_default.floatToByte(color.alpha);
}
if (perSegmentColors && i === length - 1) {
break;
}
Cartesian3_default.pack(p, positionValues, positionIndex);
positionIndex += 3;
if (defined_default(colors)) {
color = colors[i];
colorValues[colorIndex++] = Color_default.floatToByte(color.red);
colorValues[colorIndex++] = Color_default.floatToByte(color.green);
colorValues[colorIndex++] = Color_default.floatToByte(color.blue);
colorValues[colorIndex++] = Color_default.floatToByte(color.alpha);
}
}
}
const attributes = new GeometryAttributes_default();
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positionValues
});
if (defined_default(colors)) {
attributes.color = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.UNSIGNED_BYTE,
componentsPerAttribute: 4,
values: colorValues,
normalize: true
});
}
numberOfPositions = positionValues.length / 3;
const numberOfIndices = (numberOfPositions - 1) * 2;
const indices = IndexDatatype_default.createTypedArray(
numberOfPositions,
numberOfIndices
);
let index = 0;
for (i = 0; i < numberOfPositions - 1; ++i) {
indices[index++] = i;
indices[index++] = i + 1;
}
return new Geometry_default({
attributes,
indices,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: BoundingSphere_default.fromPoints(positions)
});
};
var SimplePolylineGeometry_default = SimplePolylineGeometry;
// packages/engine/Source/Workers/createSimplePolylineGeometry.js
function createSimplePolylineGeometry(simplePolylineGeometry, offset) {
if (defined_default(offset)) {
simplePolylineGeometry = SimplePolylineGeometry_default.unpack(
simplePolylineGeometry,
offset
);
}
simplePolylineGeometry._ellipsoid = Ellipsoid_default.clone(
simplePolylineGeometry._ellipsoid
);
return SimplePolylineGeometry_default.createGeometry(simplePolylineGeometry);
}
var createSimplePolylineGeometry_default = createSimplePolylineGeometry;
export {
createSimplePolylineGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
EllipsoidGeometry_default
} from "./chunk-IZGUQO6Q.js";
import "./chunk-GBT7MJ6X.js";
import {
VertexFormat_default
} from "./chunk-JBSKHTNX.js";
import "./chunk-C4WPMOKT.js";
import "./chunk-X7IQYYHF.js";
import "./chunk-JXVLNVXC.js";
import "./chunk-KHZNBFOH.js";
import "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default
} from "./chunk-FFLMY4TE.js";
import "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
Check_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/SphereGeometry.js
function SphereGeometry(options) {
const radius = defaultValue_default(options.radius, 1);
const radii = new Cartesian3_default(radius, radius, radius);
const ellipsoidOptions = {
radii,
stackPartitions: options.stackPartitions,
slicePartitions: options.slicePartitions,
vertexFormat: options.vertexFormat
};
this._ellipsoidGeometry = new EllipsoidGeometry_default(ellipsoidOptions);
this._workerName = "createSphereGeometry";
}
SphereGeometry.packedLength = EllipsoidGeometry_default.packedLength;
SphereGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
return EllipsoidGeometry_default.pack(value._ellipsoidGeometry, array, startingIndex);
};
var scratchEllipsoidGeometry = new EllipsoidGeometry_default();
var scratchOptions = {
radius: void 0,
radii: new Cartesian3_default(),
vertexFormat: new VertexFormat_default(),
stackPartitions: void 0,
slicePartitions: void 0
};
SphereGeometry.unpack = function(array, startingIndex, result) {
const ellipsoidGeometry = EllipsoidGeometry_default.unpack(
array,
startingIndex,
scratchEllipsoidGeometry
);
scratchOptions.vertexFormat = VertexFormat_default.clone(
ellipsoidGeometry._vertexFormat,
scratchOptions.vertexFormat
);
scratchOptions.stackPartitions = ellipsoidGeometry._stackPartitions;
scratchOptions.slicePartitions = ellipsoidGeometry._slicePartitions;
if (!defined_default(result)) {
scratchOptions.radius = ellipsoidGeometry._radii.x;
return new SphereGeometry(scratchOptions);
}
Cartesian3_default.clone(ellipsoidGeometry._radii, scratchOptions.radii);
result._ellipsoidGeometry = new EllipsoidGeometry_default(scratchOptions);
return result;
};
SphereGeometry.createGeometry = function(sphereGeometry) {
return EllipsoidGeometry_default.createGeometry(sphereGeometry._ellipsoidGeometry);
};
var SphereGeometry_default = SphereGeometry;
// packages/engine/Source/Workers/createSphereGeometry.js
function createSphereGeometry(sphereGeometry, offset) {
if (defined_default(offset)) {
sphereGeometry = SphereGeometry_default.unpack(sphereGeometry, offset);
}
return SphereGeometry_default.createGeometry(sphereGeometry);
}
var createSphereGeometry_default = createSphereGeometry;
export {
createSphereGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
EllipsoidOutlineGeometry_default
} from "./chunk-OPP2SKMA.js";
import "./chunk-GBT7MJ6X.js";
import "./chunk-C4WPMOKT.js";
import "./chunk-X7IQYYHF.js";
import "./chunk-JXVLNVXC.js";
import "./chunk-KHZNBFOH.js";
import "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default
} from "./chunk-FFLMY4TE.js";
import "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
Check_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/SphereOutlineGeometry.js
function SphereOutlineGeometry(options) {
const radius = defaultValue_default(options.radius, 1);
const radii = new Cartesian3_default(radius, radius, radius);
const ellipsoidOptions = {
radii,
stackPartitions: options.stackPartitions,
slicePartitions: options.slicePartitions,
subdivisions: options.subdivisions
};
this._ellipsoidGeometry = new EllipsoidOutlineGeometry_default(ellipsoidOptions);
this._workerName = "createSphereOutlineGeometry";
}
SphereOutlineGeometry.packedLength = EllipsoidOutlineGeometry_default.packedLength;
SphereOutlineGeometry.pack = function(value, array, startingIndex) {
Check_default.typeOf.object("value", value);
return EllipsoidOutlineGeometry_default.pack(
value._ellipsoidGeometry,
array,
startingIndex
);
};
var scratchEllipsoidGeometry = new EllipsoidOutlineGeometry_default();
var scratchOptions = {
radius: void 0,
radii: new Cartesian3_default(),
stackPartitions: void 0,
slicePartitions: void 0,
subdivisions: void 0
};
SphereOutlineGeometry.unpack = function(array, startingIndex, result) {
const ellipsoidGeometry = EllipsoidOutlineGeometry_default.unpack(
array,
startingIndex,
scratchEllipsoidGeometry
);
scratchOptions.stackPartitions = ellipsoidGeometry._stackPartitions;
scratchOptions.slicePartitions = ellipsoidGeometry._slicePartitions;
scratchOptions.subdivisions = ellipsoidGeometry._subdivisions;
if (!defined_default(result)) {
scratchOptions.radius = ellipsoidGeometry._radii.x;
return new SphereOutlineGeometry(scratchOptions);
}
Cartesian3_default.clone(ellipsoidGeometry._radii, scratchOptions.radii);
result._ellipsoidGeometry = new EllipsoidOutlineGeometry_default(scratchOptions);
return result;
};
SphereOutlineGeometry.createGeometry = function(sphereGeometry) {
return EllipsoidOutlineGeometry_default.createGeometry(
sphereGeometry._ellipsoidGeometry
);
};
var SphereOutlineGeometry_default = SphereOutlineGeometry;
// packages/engine/Source/Workers/createSphereOutlineGeometry.js
function createSphereOutlineGeometry(sphereGeometry, offset) {
if (defined_default(offset)) {
sphereGeometry = SphereOutlineGeometry_default.unpack(sphereGeometry, offset);
}
return SphereOutlineGeometry_default.createGeometry(sphereGeometry);
}
var createSphereOutlineGeometry_default = createSphereOutlineGeometry;
export {
createSphereOutlineGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import "./chunk-YCDZX5LS.js";
export {
createTaskProcessorWorker_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
AttributeCompression_default
} from "./chunk-LJ2JQHJT.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
Rectangle_default,
combine_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import "./chunk-YCDZX5LS.js";
// packages/engine/Source/Workers/createVectorTileClampedPolylines.js
var MAX_SHORT = 32767;
var MITER_BREAK = Math.cos(Math_default.toRadians(150));
var scratchBVCartographic = new Cartographic_default();
var scratchEncodedPosition = new Cartesian3_default();
function decodePositions(uBuffer, vBuffer, heightBuffer, rectangle, minimumHeight, maximumHeight, ellipsoid) {
const positionsLength = uBuffer.length;
const decodedPositions = new Float64Array(positionsLength * 3);
for (let i = 0; i < positionsLength; ++i) {
const u = uBuffer[i];
const v = vBuffer[i];
const h = heightBuffer[i];
const lon = Math_default.lerp(rectangle.west, rectangle.east, u / MAX_SHORT);
const lat = Math_default.lerp(
rectangle.south,
rectangle.north,
v / MAX_SHORT
);
const alt = Math_default.lerp(minimumHeight, maximumHeight, h / MAX_SHORT);
const cartographic = Cartographic_default.fromRadians(
lon,
lat,
alt,
scratchBVCartographic
);
const decodedPosition = ellipsoid.cartographicToCartesian(
cartographic,
scratchEncodedPosition
);
Cartesian3_default.pack(decodedPosition, decodedPositions, i * 3);
}
return decodedPositions;
}
function getPositionOffsets(counts) {
const countsLength = counts.length;
const positionOffsets = new Uint32Array(countsLength + 1);
let offset = 0;
for (let i = 0; i < countsLength; ++i) {
positionOffsets[i] = offset;
offset += counts[i];
}
positionOffsets[countsLength] = offset;
return positionOffsets;
}
var previousCompressedCartographicScratch = new Cartographic_default();
var currentCompressedCartographicScratch = new Cartographic_default();
function removeDuplicates(uBuffer, vBuffer, heightBuffer, counts) {
const countsLength = counts.length;
const positionsLength = uBuffer.length;
const markRemoval = new Uint8Array(positionsLength);
const previous = previousCompressedCartographicScratch;
const current = currentCompressedCartographicScratch;
let offset = 0;
for (let i = 0; i < countsLength; i++) {
const count = counts[i];
let updatedCount = count;
for (let j = 1; j < count; j++) {
const index = offset + j;
const previousIndex = index - 1;
current.longitude = uBuffer[index];
current.latitude = vBuffer[index];
previous.longitude = uBuffer[previousIndex];
previous.latitude = vBuffer[previousIndex];
if (Cartographic_default.equals(current, previous)) {
updatedCount--;
markRemoval[previousIndex] = 1;
}
}
counts[i] = updatedCount;
offset += count;
}
let nextAvailableIndex = 0;
for (let k = 0; k < positionsLength; k++) {
if (markRemoval[k] !== 1) {
uBuffer[nextAvailableIndex] = uBuffer[k];
vBuffer[nextAvailableIndex] = vBuffer[k];
heightBuffer[nextAvailableIndex] = heightBuffer[k];
nextAvailableIndex++;
}
}
}
function VertexAttributesAndIndices(volumesCount) {
const vertexCount = volumesCount * 8;
const vec3Floats = vertexCount * 3;
const vec4Floats = vertexCount * 4;
this.startEllipsoidNormals = new Float32Array(vec3Floats);
this.endEllipsoidNormals = new Float32Array(vec3Floats);
this.startPositionAndHeights = new Float32Array(vec4Floats);
this.startFaceNormalAndVertexCornerIds = new Float32Array(vec4Floats);
this.endPositionAndHeights = new Float32Array(vec4Floats);
this.endFaceNormalAndHalfWidths = new Float32Array(vec4Floats);
this.vertexBatchIds = new Uint16Array(vertexCount);
this.indices = IndexDatatype_default.createTypedArray(vertexCount, 36 * volumesCount);
this.vec3Offset = 0;
this.vec4Offset = 0;
this.batchIdOffset = 0;
this.indexOffset = 0;
this.volumeStartIndex = 0;
}
var towardCurrScratch = new Cartesian3_default();
var towardNextScratch = new Cartesian3_default();
function computeMiteredNormal(previousPosition, position, nextPosition, ellipsoidSurfaceNormal, result) {
const towardNext = Cartesian3_default.subtract(
nextPosition,
position,
towardNextScratch
);
let towardCurr = Cartesian3_default.subtract(
position,
previousPosition,
towardCurrScratch
);
Cartesian3_default.normalize(towardNext, towardNext);
Cartesian3_default.normalize(towardCurr, towardCurr);
if (Cartesian3_default.dot(towardNext, towardCurr) < MITER_BREAK) {
towardCurr = Cartesian3_default.multiplyByScalar(
towardCurr,
-1,
towardCurrScratch
);
}
Cartesian3_default.add(towardNext, towardCurr, result);
if (Cartesian3_default.equals(result, Cartesian3_default.ZERO)) {
result = Cartesian3_default.subtract(previousPosition, position);
}
Cartesian3_default.cross(result, ellipsoidSurfaceNormal, result);
Cartesian3_default.cross(ellipsoidSurfaceNormal, result, result);
Cartesian3_default.normalize(result, result);
return result;
}
var REFERENCE_INDICES = [
0,
2,
6,
0,
6,
4,
// right
0,
1,
3,
0,
3,
2,
// start face
0,
4,
5,
0,
5,
1,
// bottom
5,
3,
1,
5,
7,
3,
// left
7,
5,
4,
7,
4,
6,
// end face
7,
6,
2,
7,
2,
3
// top
];
var REFERENCE_INDICES_LENGTH = REFERENCE_INDICES.length;
var positionScratch = new Cartesian3_default();
var scratchStartEllipsoidNormal = new Cartesian3_default();
var scratchStartFaceNormal = new Cartesian3_default();
var scratchEndEllipsoidNormal = new Cartesian3_default();
var scratchEndFaceNormal = new Cartesian3_default();
VertexAttributesAndIndices.prototype.addVolume = function(preStartRTC, startRTC, endRTC, postEndRTC, startHeight, endHeight, halfWidth, batchId, center, ellipsoid) {
let position = Cartesian3_default.add(startRTC, center, positionScratch);
const startEllipsoidNormal = ellipsoid.geodeticSurfaceNormal(
position,
scratchStartEllipsoidNormal
);
position = Cartesian3_default.add(endRTC, center, positionScratch);
const endEllipsoidNormal = ellipsoid.geodeticSurfaceNormal(
position,
scratchEndEllipsoidNormal
);
const startFaceNormal = computeMiteredNormal(
preStartRTC,
startRTC,
endRTC,
startEllipsoidNormal,
scratchStartFaceNormal
);
const endFaceNormal = computeMiteredNormal(
postEndRTC,
endRTC,
startRTC,
endEllipsoidNormal,
scratchEndFaceNormal
);
const startEllipsoidNormals = this.startEllipsoidNormals;
const endEllipsoidNormals = this.endEllipsoidNormals;
const startPositionAndHeights = this.startPositionAndHeights;
const startFaceNormalAndVertexCornerIds = this.startFaceNormalAndVertexCornerIds;
const endPositionAndHeights = this.endPositionAndHeights;
const endFaceNormalAndHalfWidths = this.endFaceNormalAndHalfWidths;
const vertexBatchIds = this.vertexBatchIds;
let batchIdOffset = this.batchIdOffset;
let vec3Offset = this.vec3Offset;
let vec4Offset = this.vec4Offset;
let i;
for (i = 0; i < 8; i++) {
Cartesian3_default.pack(startEllipsoidNormal, startEllipsoidNormals, vec3Offset);
Cartesian3_default.pack(endEllipsoidNormal, endEllipsoidNormals, vec3Offset);
Cartesian3_default.pack(startRTC, startPositionAndHeights, vec4Offset);
startPositionAndHeights[vec4Offset + 3] = startHeight;
Cartesian3_default.pack(endRTC, endPositionAndHeights, vec4Offset);
endPositionAndHeights[vec4Offset + 3] = endHeight;
Cartesian3_default.pack(
startFaceNormal,
startFaceNormalAndVertexCornerIds,
vec4Offset
);
startFaceNormalAndVertexCornerIds[vec4Offset + 3] = i;
Cartesian3_default.pack(endFaceNormal, endFaceNormalAndHalfWidths, vec4Offset);
endFaceNormalAndHalfWidths[vec4Offset + 3] = halfWidth;
vertexBatchIds[batchIdOffset++] = batchId;
vec3Offset += 3;
vec4Offset += 4;
}
this.batchIdOffset = batchIdOffset;
this.vec3Offset = vec3Offset;
this.vec4Offset = vec4Offset;
const indices = this.indices;
const volumeStartIndex = this.volumeStartIndex;
const indexOffset = this.indexOffset;
for (i = 0; i < REFERENCE_INDICES_LENGTH; i++) {
indices[indexOffset + i] = REFERENCE_INDICES[i] + volumeStartIndex;
}
this.volumeStartIndex += 8;
this.indexOffset += REFERENCE_INDICES_LENGTH;
};
var scratchRectangle = new Rectangle_default();
var scratchEllipsoid = new Ellipsoid_default();
var scratchCenter = new Cartesian3_default();
var scratchPrev = new Cartesian3_default();
var scratchP0 = new Cartesian3_default();
var scratchP1 = new Cartesian3_default();
var scratchNext = new Cartesian3_default();
function createVectorTileClampedPolylines(parameters, transferableObjects) {
const encodedPositions = new Uint16Array(parameters.positions);
const widths = new Uint16Array(parameters.widths);
const counts = new Uint32Array(parameters.counts);
const batchIds = new Uint16Array(parameters.batchIds);
const rectangle = scratchRectangle;
const ellipsoid = scratchEllipsoid;
const center = scratchCenter;
const packedBuffer = new Float64Array(parameters.packedBuffer);
let offset = 0;
const minimumHeight = packedBuffer[offset++];
const maximumHeight = packedBuffer[offset++];
Rectangle_default.unpack(packedBuffer, offset, rectangle);
offset += Rectangle_default.packedLength;
Ellipsoid_default.unpack(packedBuffer, offset, ellipsoid);
offset += Ellipsoid_default.packedLength;
Cartesian3_default.unpack(packedBuffer, offset, center);
let i;
let positionsLength = encodedPositions.length / 3;
const uBuffer = encodedPositions.subarray(0, positionsLength);
const vBuffer = encodedPositions.subarray(
positionsLength,
2 * positionsLength
);
const heightBuffer = encodedPositions.subarray(
2 * positionsLength,
3 * positionsLength
);
AttributeCompression_default.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);
removeDuplicates(uBuffer, vBuffer, heightBuffer, counts);
const countsLength = counts.length;
let volumesCount = 0;
for (i = 0; i < countsLength; i++) {
const polylinePositionCount = counts[i];
volumesCount += polylinePositionCount - 1;
}
const attribsAndIndices = new VertexAttributesAndIndices(volumesCount);
const positions = decodePositions(
uBuffer,
vBuffer,
heightBuffer,
rectangle,
minimumHeight,
maximumHeight,
ellipsoid,
center
);
positionsLength = uBuffer.length;
const positionsRTC = new Float32Array(positionsLength * 3);
for (i = 0; i < positionsLength; ++i) {
positionsRTC[i * 3] = positions[i * 3] - center.x;
positionsRTC[i * 3 + 1] = positions[i * 3 + 1] - center.y;
positionsRTC[i * 3 + 2] = positions[i * 3 + 2] - center.z;
}
let currentPositionIndex = 0;
let currentHeightIndex = 0;
for (i = 0; i < countsLength; i++) {
const polylineVolumeCount = counts[i] - 1;
const halfWidth = widths[i] * 0.5;
const batchId = batchIds[i];
const volumeFirstPositionIndex = currentPositionIndex;
for (let j = 0; j < polylineVolumeCount; j++) {
const volumeStart = Cartesian3_default.unpack(
positionsRTC,
currentPositionIndex,
scratchP0
);
const volumeEnd = Cartesian3_default.unpack(
positionsRTC,
currentPositionIndex + 3,
scratchP1
);
let startHeight = heightBuffer[currentHeightIndex];
let endHeight = heightBuffer[currentHeightIndex + 1];
startHeight = Math_default.lerp(
minimumHeight,
maximumHeight,
startHeight / MAX_SHORT
);
endHeight = Math_default.lerp(
minimumHeight,
maximumHeight,
endHeight / MAX_SHORT
);
currentHeightIndex++;
let preStart = scratchPrev;
let postEnd = scratchNext;
if (j === 0) {
const finalPositionIndex = volumeFirstPositionIndex + polylineVolumeCount * 3;
const finalPosition = Cartesian3_default.unpack(
positionsRTC,
finalPositionIndex,
scratchPrev
);
if (Cartesian3_default.equals(finalPosition, volumeStart)) {
Cartesian3_default.unpack(positionsRTC, finalPositionIndex - 3, preStart);
} else {
const offsetPastStart = Cartesian3_default.subtract(
volumeStart,
volumeEnd,
scratchPrev
);
preStart = Cartesian3_default.add(offsetPastStart, volumeStart, scratchPrev);
}
} else {
Cartesian3_default.unpack(positionsRTC, currentPositionIndex - 3, preStart);
}
if (j === polylineVolumeCount - 1) {
const firstPosition = Cartesian3_default.unpack(
positionsRTC,
volumeFirstPositionIndex,
scratchNext
);
if (Cartesian3_default.equals(firstPosition, volumeEnd)) {
Cartesian3_default.unpack(
positionsRTC,
volumeFirstPositionIndex + 3,
postEnd
);
} else {
const offsetPastEnd = Cartesian3_default.subtract(
volumeEnd,
volumeStart,
scratchNext
);
postEnd = Cartesian3_default.add(offsetPastEnd, volumeEnd, scratchNext);
}
} else {
Cartesian3_default.unpack(positionsRTC, currentPositionIndex + 6, postEnd);
}
attribsAndIndices.addVolume(
preStart,
volumeStart,
volumeEnd,
postEnd,
startHeight,
endHeight,
halfWidth,
batchId,
center,
ellipsoid
);
currentPositionIndex += 3;
}
currentPositionIndex += 3;
currentHeightIndex++;
}
const indices = attribsAndIndices.indices;
transferableObjects.push(attribsAndIndices.startEllipsoidNormals.buffer);
transferableObjects.push(attribsAndIndices.endEllipsoidNormals.buffer);
transferableObjects.push(attribsAndIndices.startPositionAndHeights.buffer);
transferableObjects.push(
attribsAndIndices.startFaceNormalAndVertexCornerIds.buffer
);
transferableObjects.push(attribsAndIndices.endPositionAndHeights.buffer);
transferableObjects.push(attribsAndIndices.endFaceNormalAndHalfWidths.buffer);
transferableObjects.push(attribsAndIndices.vertexBatchIds.buffer);
transferableObjects.push(indices.buffer);
let results = {
indexDatatype: indices.BYTES_PER_ELEMENT === 2 ? IndexDatatype_default.UNSIGNED_SHORT : IndexDatatype_default.UNSIGNED_INT,
startEllipsoidNormals: attribsAndIndices.startEllipsoidNormals.buffer,
endEllipsoidNormals: attribsAndIndices.endEllipsoidNormals.buffer,
startPositionAndHeights: attribsAndIndices.startPositionAndHeights.buffer,
startFaceNormalAndVertexCornerIds: attribsAndIndices.startFaceNormalAndVertexCornerIds.buffer,
endPositionAndHeights: attribsAndIndices.endPositionAndHeights.buffer,
endFaceNormalAndHalfWidths: attribsAndIndices.endFaceNormalAndHalfWidths.buffer,
vertexBatchIds: attribsAndIndices.vertexBatchIds.buffer,
indices: indices.buffer
};
if (parameters.keepDecodedPositions) {
const positionOffsets = getPositionOffsets(counts);
transferableObjects.push(positions.buffer, positionOffsets.buffer);
results = combine_default(results, {
decodedPositions: positions.buffer,
decodedPositionOffsets: positionOffsets.buffer
});
}
return results;
}
var createVectorTileClampedPolylines_default = createTaskProcessorWorker_default(createVectorTileClampedPolylines);
export {
createVectorTileClampedPolylines_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
Color_default
} from "./chunk-HP5XLODI.js";
import {
CylinderGeometry_default
} from "./chunk-L5GODJAR.js";
import "./chunk-O72GZTSE.js";
import {
EllipsoidGeometry_default
} from "./chunk-IZGUQO6Q.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
BoxGeometry_default
} from "./chunk-HJMNR3GC.js";
import "./chunk-GBT7MJ6X.js";
import "./chunk-JBSKHTNX.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import "./chunk-X7IQYYHF.js";
import "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import {
Matrix4_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default
} from "./chunk-FFLMY4TE.js";
import "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Scene/Vector3DTileBatch.js
function Vector3DTileBatch(options) {
this.offset = options.offset;
this.count = options.count;
this.color = options.color;
this.batchIds = options.batchIds;
}
var Vector3DTileBatch_default = Vector3DTileBatch;
// packages/engine/Source/Workers/createVectorTileGeometries.js
var scratchCartesian = new Cartesian3_default();
var packedBoxLength = Matrix4_default.packedLength + Cartesian3_default.packedLength;
var packedCylinderLength = Matrix4_default.packedLength + 2;
var packedEllipsoidLength = Matrix4_default.packedLength + Cartesian3_default.packedLength;
var packedSphereLength = Cartesian3_default.packedLength + 1;
var scratchModelMatrixAndBV = {
modelMatrix: new Matrix4_default(),
boundingVolume: new BoundingSphere_default()
};
function boxModelMatrixAndBoundingVolume(boxes, index) {
let boxIndex = index * packedBoxLength;
const dimensions = Cartesian3_default.unpack(boxes, boxIndex, scratchCartesian);
boxIndex += Cartesian3_default.packedLength;
const boxModelMatrix = Matrix4_default.unpack(
boxes,
boxIndex,
scratchModelMatrixAndBV.modelMatrix
);
Matrix4_default.multiplyByScale(boxModelMatrix, dimensions, boxModelMatrix);
const boundingVolume = scratchModelMatrixAndBV.boundingVolume;
Cartesian3_default.clone(Cartesian3_default.ZERO, boundingVolume.center);
boundingVolume.radius = Math.sqrt(3);
return scratchModelMatrixAndBV;
}
function cylinderModelMatrixAndBoundingVolume(cylinders, index) {
let cylinderIndex = index * packedCylinderLength;
const cylinderRadius = cylinders[cylinderIndex++];
const length = cylinders[cylinderIndex++];
const scale = Cartesian3_default.fromElements(
cylinderRadius,
cylinderRadius,
length,
scratchCartesian
);
const cylinderModelMatrix = Matrix4_default.unpack(
cylinders,
cylinderIndex,
scratchModelMatrixAndBV.modelMatrix
);
Matrix4_default.multiplyByScale(cylinderModelMatrix, scale, cylinderModelMatrix);
const boundingVolume = scratchModelMatrixAndBV.boundingVolume;
Cartesian3_default.clone(Cartesian3_default.ZERO, boundingVolume.center);
boundingVolume.radius = Math.sqrt(2);
return scratchModelMatrixAndBV;
}
function ellipsoidModelMatrixAndBoundingVolume(ellipsoids, index) {
let ellipsoidIndex = index * packedEllipsoidLength;
const radii = Cartesian3_default.unpack(ellipsoids, ellipsoidIndex, scratchCartesian);
ellipsoidIndex += Cartesian3_default.packedLength;
const ellipsoidModelMatrix = Matrix4_default.unpack(
ellipsoids,
ellipsoidIndex,
scratchModelMatrixAndBV.modelMatrix
);
Matrix4_default.multiplyByScale(ellipsoidModelMatrix, radii, ellipsoidModelMatrix);
const boundingVolume = scratchModelMatrixAndBV.boundingVolume;
Cartesian3_default.clone(Cartesian3_default.ZERO, boundingVolume.center);
boundingVolume.radius = 1;
return scratchModelMatrixAndBV;
}
function sphereModelMatrixAndBoundingVolume(spheres, index) {
let sphereIndex = index * packedSphereLength;
const sphereRadius = spheres[sphereIndex++];
const sphereTranslation = Cartesian3_default.unpack(
spheres,
sphereIndex,
scratchCartesian
);
const sphereModelMatrix = Matrix4_default.fromTranslation(
sphereTranslation,
scratchModelMatrixAndBV.modelMatrix
);
Matrix4_default.multiplyByUniformScale(
sphereModelMatrix,
sphereRadius,
sphereModelMatrix
);
const boundingVolume = scratchModelMatrixAndBV.boundingVolume;
Cartesian3_default.clone(Cartesian3_default.ZERO, boundingVolume.center);
boundingVolume.radius = 1;
return scratchModelMatrixAndBV;
}
var scratchPosition = new Cartesian3_default();
function createPrimitive(options, primitive, primitiveBatchIds, geometry, getModelMatrixAndBoundingVolume) {
if (!defined_default(primitive)) {
return;
}
const numberOfPrimitives = primitiveBatchIds.length;
const geometryPositions = geometry.attributes.position.values;
const geometryIndices = geometry.indices;
const positions = options.positions;
const vertexBatchIds = options.vertexBatchIds;
const indices = options.indices;
const batchIds = options.batchIds;
const batchTableColors = options.batchTableColors;
const batchedIndices = options.batchedIndices;
const indexOffsets = options.indexOffsets;
const indexCounts = options.indexCounts;
const boundingVolumes = options.boundingVolumes;
const modelMatrix = options.modelMatrix;
const center = options.center;
let positionOffset = options.positionOffset;
let batchIdIndex = options.batchIdIndex;
let indexOffset = options.indexOffset;
const batchedIndicesOffset = options.batchedIndicesOffset;
for (let i = 0; i < numberOfPrimitives; ++i) {
const primitiveModelMatrixAndBV = getModelMatrixAndBoundingVolume(
primitive,
i
);
const primitiveModelMatrix = primitiveModelMatrixAndBV.modelMatrix;
Matrix4_default.multiply(modelMatrix, primitiveModelMatrix, primitiveModelMatrix);
const batchId = primitiveBatchIds[i];
const positionsLength = geometryPositions.length;
for (let j = 0; j < positionsLength; j += 3) {
const position = Cartesian3_default.unpack(geometryPositions, j, scratchPosition);
Matrix4_default.multiplyByPoint(primitiveModelMatrix, position, position);
Cartesian3_default.subtract(position, center, position);
Cartesian3_default.pack(position, positions, positionOffset * 3 + j);
vertexBatchIds[batchIdIndex++] = batchId;
}
const indicesLength = geometryIndices.length;
for (let k = 0; k < indicesLength; ++k) {
indices[indexOffset + k] = geometryIndices[k] + positionOffset;
}
const offset = i + batchedIndicesOffset;
batchedIndices[offset] = new Vector3DTileBatch_default({
offset: indexOffset,
count: indicesLength,
color: Color_default.fromRgba(batchTableColors[batchId]),
batchIds: [batchId]
});
batchIds[offset] = batchId;
indexOffsets[offset] = indexOffset;
indexCounts[offset] = indicesLength;
boundingVolumes[offset] = BoundingSphere_default.transform(
primitiveModelMatrixAndBV.boundingVolume,
primitiveModelMatrix
);
positionOffset += positionsLength / 3;
indexOffset += indicesLength;
}
options.positionOffset = positionOffset;
options.batchIdIndex = batchIdIndex;
options.indexOffset = indexOffset;
options.batchedIndicesOffset += numberOfPrimitives;
}
var scratchCenter = new Cartesian3_default();
var scratchMatrix4 = new Matrix4_default();
function unpackBuffer(buffer) {
const packedBuffer = new Float64Array(buffer);
let offset = 0;
Cartesian3_default.unpack(packedBuffer, offset, scratchCenter);
offset += Cartesian3_default.packedLength;
Matrix4_default.unpack(packedBuffer, offset, scratchMatrix4);
}
function packedBatchedIndicesLength(batchedIndices) {
const length = batchedIndices.length;
let count = 0;
for (let i = 0; i < length; ++i) {
count += Color_default.packedLength + 3 + batchedIndices[i].batchIds.length;
}
return count;
}
function packBuffer(indicesBytesPerElement, batchedIndices, boundingVolumes) {
const numBVs = boundingVolumes.length;
const length = 1 + 1 + numBVs * BoundingSphere_default.packedLength + 1 + packedBatchedIndicesLength(batchedIndices);
const packedBuffer = new Float64Array(length);
let offset = 0;
packedBuffer[offset++] = indicesBytesPerElement;
packedBuffer[offset++] = numBVs;
for (let i = 0; i < numBVs; ++i) {
BoundingSphere_default.pack(boundingVolumes[i], packedBuffer, offset);
offset += BoundingSphere_default.packedLength;
}
const indicesLength = batchedIndices.length;
packedBuffer[offset++] = indicesLength;
for (let j = 0; j < indicesLength; ++j) {
const batchedIndex = batchedIndices[j];
Color_default.pack(batchedIndex.color, packedBuffer, offset);
offset += Color_default.packedLength;
packedBuffer[offset++] = batchedIndex.offset;
packedBuffer[offset++] = batchedIndex.count;
const batchIds = batchedIndex.batchIds;
const batchIdsLength = batchIds.length;
packedBuffer[offset++] = batchIdsLength;
for (let k = 0; k < batchIdsLength; ++k) {
packedBuffer[offset++] = batchIds[k];
}
}
return packedBuffer;
}
function createVectorTileGeometries(parameters, transferableObjects) {
const boxes = defined_default(parameters.boxes) ? new Float32Array(parameters.boxes) : void 0;
const boxBatchIds = defined_default(parameters.boxBatchIds) ? new Uint16Array(parameters.boxBatchIds) : void 0;
const cylinders = defined_default(parameters.cylinders) ? new Float32Array(parameters.cylinders) : void 0;
const cylinderBatchIds = defined_default(parameters.cylinderBatchIds) ? new Uint16Array(parameters.cylinderBatchIds) : void 0;
const ellipsoids = defined_default(parameters.ellipsoids) ? new Float32Array(parameters.ellipsoids) : void 0;
const ellipsoidBatchIds = defined_default(parameters.ellipsoidBatchIds) ? new Uint16Array(parameters.ellipsoidBatchIds) : void 0;
const spheres = defined_default(parameters.spheres) ? new Float32Array(parameters.spheres) : void 0;
const sphereBatchIds = defined_default(parameters.sphereBatchIds) ? new Uint16Array(parameters.sphereBatchIds) : void 0;
const numberOfBoxes = defined_default(boxes) ? boxBatchIds.length : 0;
const numberOfCylinders = defined_default(cylinders) ? cylinderBatchIds.length : 0;
const numberOfEllipsoids = defined_default(ellipsoids) ? ellipsoidBatchIds.length : 0;
const numberOfSpheres = defined_default(spheres) ? sphereBatchIds.length : 0;
const boxGeometry = BoxGeometry_default.getUnitBox();
const cylinderGeometry = CylinderGeometry_default.getUnitCylinder();
const ellipsoidGeometry = EllipsoidGeometry_default.getUnitEllipsoid();
const boxPositions = boxGeometry.attributes.position.values;
const cylinderPositions = cylinderGeometry.attributes.position.values;
const ellipsoidPositions = ellipsoidGeometry.attributes.position.values;
let numberOfPositions = boxPositions.length * numberOfBoxes;
numberOfPositions += cylinderPositions.length * numberOfCylinders;
numberOfPositions += ellipsoidPositions.length * (numberOfEllipsoids + numberOfSpheres);
const boxIndices = boxGeometry.indices;
const cylinderIndices = cylinderGeometry.indices;
const ellipsoidIndices = ellipsoidGeometry.indices;
let numberOfIndices = boxIndices.length * numberOfBoxes;
numberOfIndices += cylinderIndices.length * numberOfCylinders;
numberOfIndices += ellipsoidIndices.length * (numberOfEllipsoids + numberOfSpheres);
const positions = new Float32Array(numberOfPositions);
const vertexBatchIds = new Uint16Array(numberOfPositions / 3);
const indices = IndexDatatype_default.createTypedArray(
numberOfPositions / 3,
numberOfIndices
);
const numberOfGeometries = numberOfBoxes + numberOfCylinders + numberOfEllipsoids + numberOfSpheres;
const batchIds = new Uint16Array(numberOfGeometries);
const batchedIndices = new Array(numberOfGeometries);
const indexOffsets = new Uint32Array(numberOfGeometries);
const indexCounts = new Uint32Array(numberOfGeometries);
const boundingVolumes = new Array(numberOfGeometries);
unpackBuffer(parameters.packedBuffer);
const options = {
batchTableColors: new Uint32Array(parameters.batchTableColors),
positions,
vertexBatchIds,
indices,
batchIds,
batchedIndices,
indexOffsets,
indexCounts,
boundingVolumes,
positionOffset: 0,
batchIdIndex: 0,
indexOffset: 0,
batchedIndicesOffset: 0,
modelMatrix: scratchMatrix4,
center: scratchCenter
};
createPrimitive(
options,
boxes,
boxBatchIds,
boxGeometry,
boxModelMatrixAndBoundingVolume
);
createPrimitive(
options,
cylinders,
cylinderBatchIds,
cylinderGeometry,
cylinderModelMatrixAndBoundingVolume
);
createPrimitive(
options,
ellipsoids,
ellipsoidBatchIds,
ellipsoidGeometry,
ellipsoidModelMatrixAndBoundingVolume
);
createPrimitive(
options,
spheres,
sphereBatchIds,
ellipsoidGeometry,
sphereModelMatrixAndBoundingVolume
);
const packedBuffer = packBuffer(
indices.BYTES_PER_ELEMENT,
batchedIndices,
boundingVolumes
);
transferableObjects.push(
positions.buffer,
vertexBatchIds.buffer,
indices.buffer
);
transferableObjects.push(
batchIds.buffer,
indexOffsets.buffer,
indexCounts.buffer
);
transferableObjects.push(packedBuffer.buffer);
return {
positions: positions.buffer,
vertexBatchIds: vertexBatchIds.buffer,
indices: indices.buffer,
indexOffsets: indexOffsets.buffer,
indexCounts: indexCounts.buffer,
batchIds: batchIds.buffer,
packedBuffer: packedBuffer.buffer
};
}
var createVectorTileGeometries_default = createTaskProcessorWorker_default(createVectorTileGeometries);
export {
createVectorTileGeometries_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
AttributeCompression_default
} from "./chunk-LJ2JQHJT.js";
import {
Rectangle_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import "./chunk-YCDZX5LS.js";
// packages/engine/Source/Workers/createVectorTilePoints.js
var maxShort = 32767;
var scratchBVCartographic = new Cartographic_default();
var scratchEncodedPosition = new Cartesian3_default();
var scratchRectangle = new Rectangle_default();
var scratchEllipsoid = new Ellipsoid_default();
var scratchMinMaxHeights = {
min: void 0,
max: void 0
};
function unpackBuffer(packedBuffer) {
packedBuffer = new Float64Array(packedBuffer);
let offset = 0;
scratchMinMaxHeights.min = packedBuffer[offset++];
scratchMinMaxHeights.max = packedBuffer[offset++];
Rectangle_default.unpack(packedBuffer, offset, scratchRectangle);
offset += Rectangle_default.packedLength;
Ellipsoid_default.unpack(packedBuffer, offset, scratchEllipsoid);
}
function createVectorTilePoints(parameters, transferableObjects) {
const positions = new Uint16Array(parameters.positions);
unpackBuffer(parameters.packedBuffer);
const rectangle = scratchRectangle;
const ellipsoid = scratchEllipsoid;
const minimumHeight = scratchMinMaxHeights.min;
const maximumHeight = scratchMinMaxHeights.max;
const positionsLength = positions.length / 3;
const uBuffer = positions.subarray(0, positionsLength);
const vBuffer = positions.subarray(positionsLength, 2 * positionsLength);
const heightBuffer = positions.subarray(
2 * positionsLength,
3 * positionsLength
);
AttributeCompression_default.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);
const decoded = new Float64Array(positions.length);
for (let i = 0; i < positionsLength; ++i) {
const u = uBuffer[i];
const v = vBuffer[i];
const h = heightBuffer[i];
const lon = Math_default.lerp(rectangle.west, rectangle.east, u / maxShort);
const lat = Math_default.lerp(rectangle.south, rectangle.north, v / maxShort);
const alt = Math_default.lerp(minimumHeight, maximumHeight, h / maxShort);
const cartographic = Cartographic_default.fromRadians(
lon,
lat,
alt,
scratchBVCartographic
);
const decodedPosition = ellipsoid.cartographicToCartesian(
cartographic,
scratchEncodedPosition
);
Cartesian3_default.pack(decodedPosition, decoded, i * 3);
}
transferableObjects.push(decoded.buffer);
return {
positions: decoded.buffer
};
}
var createVectorTilePoints_default = createTaskProcessorWorker_default(createVectorTilePoints);
export {
createVectorTilePoints_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
Color_default
} from "./chunk-HP5XLODI.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
OrientedBoundingBox_default
} from "./chunk-2PTKXHJB.js";
import {
AttributeCompression_default
} from "./chunk-LJ2JQHJT.js";
import "./chunk-YK3QIKY7.js";
import "./chunk-NDDI2LWR.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import "./chunk-KHZNBFOH.js";
import {
Rectangle_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Workers/createVectorTilePolygons.js
var scratchCenter = new Cartesian3_default();
var scratchEllipsoid = new Ellipsoid_default();
var scratchRectangle = new Rectangle_default();
var scratchScalars = {
min: void 0,
max: void 0,
indexBytesPerElement: void 0
};
function unpackBuffer(buffer) {
const packedBuffer = new Float64Array(buffer);
let offset = 0;
scratchScalars.indexBytesPerElement = packedBuffer[offset++];
scratchScalars.min = packedBuffer[offset++];
scratchScalars.max = packedBuffer[offset++];
Cartesian3_default.unpack(packedBuffer, offset, scratchCenter);
offset += Cartesian3_default.packedLength;
Ellipsoid_default.unpack(packedBuffer, offset, scratchEllipsoid);
offset += Ellipsoid_default.packedLength;
Rectangle_default.unpack(packedBuffer, offset, scratchRectangle);
}
function packedBatchedIndicesLength(batchedIndices) {
const length = batchedIndices.length;
let count = 0;
for (let i = 0; i < length; ++i) {
count += Color_default.packedLength + 3 + batchedIndices[i].batchIds.length;
}
return count;
}
function packBuffer(indexDatatype, boundingVolumes, batchedIndices) {
const numBVs = boundingVolumes.length;
const length = 1 + 1 + numBVs * OrientedBoundingBox_default.packedLength + 1 + packedBatchedIndicesLength(batchedIndices);
const packedBuffer = new Float64Array(length);
let offset = 0;
packedBuffer[offset++] = indexDatatype;
packedBuffer[offset++] = numBVs;
for (let i = 0; i < numBVs; ++i) {
OrientedBoundingBox_default.pack(boundingVolumes[i], packedBuffer, offset);
offset += OrientedBoundingBox_default.packedLength;
}
const indicesLength = batchedIndices.length;
packedBuffer[offset++] = indicesLength;
for (let j = 0; j < indicesLength; ++j) {
const batchedIndex = batchedIndices[j];
Color_default.pack(batchedIndex.color, packedBuffer, offset);
offset += Color_default.packedLength;
packedBuffer[offset++] = batchedIndex.offset;
packedBuffer[offset++] = batchedIndex.count;
const batchIds = batchedIndex.batchIds;
const batchIdsLength = batchIds.length;
packedBuffer[offset++] = batchIdsLength;
for (let k = 0; k < batchIdsLength; ++k) {
packedBuffer[offset++] = batchIds[k];
}
}
return packedBuffer;
}
var maxShort = 32767;
var scratchEncodedPosition = new Cartesian3_default();
var scratchNormal = new Cartesian3_default();
var scratchScaledNormal = new Cartesian3_default();
var scratchMinHeightPosition = new Cartesian3_default();
var scratchMaxHeightPosition = new Cartesian3_default();
var scratchBVCartographic = new Cartographic_default();
var scratchBVRectangle = new Rectangle_default();
function createVectorTilePolygons(parameters, transferableObjects) {
unpackBuffer(parameters.packedBuffer);
let indices;
const indexBytesPerElement = scratchScalars.indexBytesPerElement;
if (indexBytesPerElement === 2) {
indices = new Uint16Array(parameters.indices);
} else {
indices = new Uint32Array(parameters.indices);
}
const positions = new Uint16Array(parameters.positions);
const counts = new Uint32Array(parameters.counts);
const indexCounts = new Uint32Array(parameters.indexCounts);
const batchIds = new Uint32Array(parameters.batchIds);
const batchTableColors = new Uint32Array(parameters.batchTableColors);
const boundingVolumes = new Array(counts.length);
const center = scratchCenter;
const ellipsoid = scratchEllipsoid;
let rectangle = scratchRectangle;
const minHeight = scratchScalars.min;
const maxHeight = scratchScalars.max;
let minimumHeights = parameters.minimumHeights;
let maximumHeights = parameters.maximumHeights;
if (defined_default(minimumHeights) && defined_default(maximumHeights)) {
minimumHeights = new Float32Array(minimumHeights);
maximumHeights = new Float32Array(maximumHeights);
}
let i;
let j;
let rgba;
const positionsLength = positions.length / 2;
const uBuffer = positions.subarray(0, positionsLength);
const vBuffer = positions.subarray(positionsLength, 2 * positionsLength);
AttributeCompression_default.zigZagDeltaDecode(uBuffer, vBuffer);
const decodedPositions = new Float64Array(positionsLength * 3);
for (i = 0; i < positionsLength; ++i) {
const u = uBuffer[i];
const v = vBuffer[i];
const x = Math_default.lerp(rectangle.west, rectangle.east, u / maxShort);
const y = Math_default.lerp(rectangle.south, rectangle.north, v / maxShort);
const cart = Cartographic_default.fromRadians(x, y, 0, scratchBVCartographic);
const decodedPosition = ellipsoid.cartographicToCartesian(
cart,
scratchEncodedPosition
);
Cartesian3_default.pack(decodedPosition, decodedPositions, i * 3);
}
const countsLength = counts.length;
const offsets = new Array(countsLength);
const indexOffsets = new Array(countsLength);
let currentOffset = 0;
let currentIndexOffset = 0;
for (i = 0; i < countsLength; ++i) {
offsets[i] = currentOffset;
indexOffsets[i] = currentIndexOffset;
currentOffset += counts[i];
currentIndexOffset += indexCounts[i];
}
const batchedPositions = new Float32Array(positionsLength * 3 * 2);
const batchedIds = new Uint16Array(positionsLength * 2);
const batchedIndexOffsets = new Uint32Array(indexOffsets.length);
const batchedIndexCounts = new Uint32Array(indexCounts.length);
let batchedIndices = [];
const colorToBuffers = {};
for (i = 0; i < countsLength; ++i) {
rgba = batchTableColors[i];
if (!defined_default(colorToBuffers[rgba])) {
colorToBuffers[rgba] = {
positionLength: counts[i],
indexLength: indexCounts[i],
offset: 0,
indexOffset: 0,
batchIds: [i]
};
} else {
colorToBuffers[rgba].positionLength += counts[i];
colorToBuffers[rgba].indexLength += indexCounts[i];
colorToBuffers[rgba].batchIds.push(i);
}
}
let buffer;
let byColorPositionOffset = 0;
let byColorIndexOffset = 0;
for (rgba in colorToBuffers) {
if (colorToBuffers.hasOwnProperty(rgba)) {
buffer = colorToBuffers[rgba];
buffer.offset = byColorPositionOffset;
buffer.indexOffset = byColorIndexOffset;
const positionLength = buffer.positionLength * 2;
const indexLength = buffer.indexLength * 2 + buffer.positionLength * 6;
byColorPositionOffset += positionLength;
byColorIndexOffset += indexLength;
buffer.indexLength = indexLength;
}
}
const batchedDrawCalls = [];
for (rgba in colorToBuffers) {
if (colorToBuffers.hasOwnProperty(rgba)) {
buffer = colorToBuffers[rgba];
batchedDrawCalls.push({
color: Color_default.fromRgba(parseInt(rgba)),
offset: buffer.indexOffset,
count: buffer.indexLength,
batchIds: buffer.batchIds
});
}
}
for (i = 0; i < countsLength; ++i) {
rgba = batchTableColors[i];
buffer = colorToBuffers[rgba];
const positionOffset = buffer.offset;
let positionIndex = positionOffset * 3;
let batchIdIndex = positionOffset;
const polygonOffset = offsets[i];
const polygonCount = counts[i];
const batchId = batchIds[i];
let polygonMinimumHeight = minHeight;
let polygonMaximumHeight = maxHeight;
if (defined_default(minimumHeights) && defined_default(maximumHeights)) {
polygonMinimumHeight = minimumHeights[i];
polygonMaximumHeight = maximumHeights[i];
}
let minLat = Number.POSITIVE_INFINITY;
let maxLat = Number.NEGATIVE_INFINITY;
let minLon = Number.POSITIVE_INFINITY;
let maxLon = Number.NEGATIVE_INFINITY;
for (j = 0; j < polygonCount; ++j) {
const position = Cartesian3_default.unpack(
decodedPositions,
polygonOffset * 3 + j * 3,
scratchEncodedPosition
);
ellipsoid.scaleToGeodeticSurface(position, position);
const carto = ellipsoid.cartesianToCartographic(
position,
scratchBVCartographic
);
const lat = carto.latitude;
const lon = carto.longitude;
minLat = Math.min(lat, minLat);
maxLat = Math.max(lat, maxLat);
minLon = Math.min(lon, minLon);
maxLon = Math.max(lon, maxLon);
const normal = ellipsoid.geodeticSurfaceNormal(position, scratchNormal);
let scaledNormal = Cartesian3_default.multiplyByScalar(
normal,
polygonMinimumHeight,
scratchScaledNormal
);
const minHeightPosition = Cartesian3_default.add(
position,
scaledNormal,
scratchMinHeightPosition
);
scaledNormal = Cartesian3_default.multiplyByScalar(
normal,
polygonMaximumHeight,
scaledNormal
);
const maxHeightPosition = Cartesian3_default.add(
position,
scaledNormal,
scratchMaxHeightPosition
);
Cartesian3_default.subtract(maxHeightPosition, center, maxHeightPosition);
Cartesian3_default.subtract(minHeightPosition, center, minHeightPosition);
Cartesian3_default.pack(maxHeightPosition, batchedPositions, positionIndex);
Cartesian3_default.pack(minHeightPosition, batchedPositions, positionIndex + 3);
batchedIds[batchIdIndex] = batchId;
batchedIds[batchIdIndex + 1] = batchId;
positionIndex += 6;
batchIdIndex += 2;
}
rectangle = scratchBVRectangle;
rectangle.west = minLon;
rectangle.east = maxLon;
rectangle.south = minLat;
rectangle.north = maxLat;
boundingVolumes[i] = OrientedBoundingBox_default.fromRectangle(
rectangle,
minHeight,
maxHeight,
ellipsoid
);
let indicesIndex = buffer.indexOffset;
const indexOffset = indexOffsets[i];
const indexCount = indexCounts[i];
batchedIndexOffsets[i] = indicesIndex;
for (j = 0; j < indexCount; j += 3) {
const i0 = indices[indexOffset + j] - polygonOffset;
const i1 = indices[indexOffset + j + 1] - polygonOffset;
const i2 = indices[indexOffset + j + 2] - polygonOffset;
batchedIndices[indicesIndex++] = i0 * 2 + positionOffset;
batchedIndices[indicesIndex++] = i1 * 2 + positionOffset;
batchedIndices[indicesIndex++] = i2 * 2 + positionOffset;
batchedIndices[indicesIndex++] = i2 * 2 + 1 + positionOffset;
batchedIndices[indicesIndex++] = i1 * 2 + 1 + positionOffset;
batchedIndices[indicesIndex++] = i0 * 2 + 1 + positionOffset;
}
for (j = 0; j < polygonCount; ++j) {
const v0 = j;
const v1 = (j + 1) % polygonCount;
batchedIndices[indicesIndex++] = v0 * 2 + 1 + positionOffset;
batchedIndices[indicesIndex++] = v1 * 2 + positionOffset;
batchedIndices[indicesIndex++] = v0 * 2 + positionOffset;
batchedIndices[indicesIndex++] = v0 * 2 + 1 + positionOffset;
batchedIndices[indicesIndex++] = v1 * 2 + 1 + positionOffset;
batchedIndices[indicesIndex++] = v1 * 2 + positionOffset;
}
buffer.offset += polygonCount * 2;
buffer.indexOffset = indicesIndex;
batchedIndexCounts[i] = indicesIndex - batchedIndexOffsets[i];
}
batchedIndices = IndexDatatype_default.createTypedArray(
batchedPositions.length / 3,
batchedIndices
);
const batchedIndicesLength = batchedDrawCalls.length;
for (let m = 0; m < batchedIndicesLength; ++m) {
const tempIds = batchedDrawCalls[m].batchIds;
let count = 0;
const tempIdsLength = tempIds.length;
for (let n = 0; n < tempIdsLength; ++n) {
count += batchedIndexCounts[tempIds[n]];
}
batchedDrawCalls[m].count = count;
}
const indexDatatype = batchedIndices.BYTES_PER_ELEMENT === 2 ? IndexDatatype_default.UNSIGNED_SHORT : IndexDatatype_default.UNSIGNED_INT;
const packedBuffer = packBuffer(
indexDatatype,
boundingVolumes,
batchedDrawCalls
);
transferableObjects.push(
batchedPositions.buffer,
batchedIndices.buffer,
batchedIndexOffsets.buffer,
batchedIndexCounts.buffer,
batchedIds.buffer,
packedBuffer.buffer
);
return {
positions: batchedPositions.buffer,
indices: batchedIndices.buffer,
indexOffsets: batchedIndexOffsets.buffer,
indexCounts: batchedIndexCounts.buffer,
batchIds: batchedIds.buffer,
packedBuffer: packedBuffer.buffer
};
}
var createVectorTilePolygons_default = createTaskProcessorWorker_default(createVectorTilePolygons);
export {
createVectorTilePolygons_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
AttributeCompression_default
} from "./chunk-LJ2JQHJT.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
Rectangle_default,
combine_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/decodeVectorPolylinePositions.js
var maxShort = 32767;
var scratchBVCartographic = new Cartographic_default();
var scratchEncodedPosition = new Cartesian3_default();
function decodeVectorPolylinePositions(positions, rectangle, minimumHeight, maximumHeight, ellipsoid) {
const positionsLength = positions.length / 3;
const uBuffer = positions.subarray(0, positionsLength);
const vBuffer = positions.subarray(positionsLength, 2 * positionsLength);
const heightBuffer = positions.subarray(
2 * positionsLength,
3 * positionsLength
);
AttributeCompression_default.zigZagDeltaDecode(uBuffer, vBuffer, heightBuffer);
const decoded = new Float64Array(positions.length);
for (let i = 0; i < positionsLength; ++i) {
const u = uBuffer[i];
const v = vBuffer[i];
const h = heightBuffer[i];
const lon = Math_default.lerp(rectangle.west, rectangle.east, u / maxShort);
const lat = Math_default.lerp(rectangle.south, rectangle.north, v / maxShort);
const alt = Math_default.lerp(minimumHeight, maximumHeight, h / maxShort);
const cartographic = Cartographic_default.fromRadians(
lon,
lat,
alt,
scratchBVCartographic
);
const decodedPosition = ellipsoid.cartographicToCartesian(
cartographic,
scratchEncodedPosition
);
Cartesian3_default.pack(decodedPosition, decoded, i * 3);
}
return decoded;
}
var decodeVectorPolylinePositions_default = decodeVectorPolylinePositions;
// packages/engine/Source/Workers/createVectorTilePolylines.js
var scratchRectangle = new Rectangle_default();
var scratchEllipsoid = new Ellipsoid_default();
var scratchCenter = new Cartesian3_default();
var scratchMinMaxHeights = {
min: void 0,
max: void 0
};
function unpackBuffer(packedBuffer) {
packedBuffer = new Float64Array(packedBuffer);
let offset = 0;
scratchMinMaxHeights.min = packedBuffer[offset++];
scratchMinMaxHeights.max = packedBuffer[offset++];
Rectangle_default.unpack(packedBuffer, offset, scratchRectangle);
offset += Rectangle_default.packedLength;
Ellipsoid_default.unpack(packedBuffer, offset, scratchEllipsoid);
offset += Ellipsoid_default.packedLength;
Cartesian3_default.unpack(packedBuffer, offset, scratchCenter);
}
function getPositionOffsets(counts) {
const countsLength = counts.length;
const positionOffsets = new Uint32Array(countsLength + 1);
let offset = 0;
for (let i = 0; i < countsLength; ++i) {
positionOffsets[i] = offset;
offset += counts[i];
}
positionOffsets[countsLength] = offset;
return positionOffsets;
}
var scratchP0 = new Cartesian3_default();
var scratchP1 = new Cartesian3_default();
var scratchPrev = new Cartesian3_default();
var scratchCur = new Cartesian3_default();
var scratchNext = new Cartesian3_default();
function createVectorTilePolylines(parameters, transferableObjects) {
const encodedPositions = new Uint16Array(parameters.positions);
const widths = new Uint16Array(parameters.widths);
const counts = new Uint32Array(parameters.counts);
const batchIds = new Uint16Array(parameters.batchIds);
unpackBuffer(parameters.packedBuffer);
const rectangle = scratchRectangle;
const ellipsoid = scratchEllipsoid;
const center = scratchCenter;
const minimumHeight = scratchMinMaxHeights.min;
const maximumHeight = scratchMinMaxHeights.max;
const positions = decodeVectorPolylinePositions_default(
encodedPositions,
rectangle,
minimumHeight,
maximumHeight,
ellipsoid
);
const positionsLength = positions.length / 3;
const size = positionsLength * 4 - 4;
const curPositions = new Float32Array(size * 3);
const prevPositions = new Float32Array(size * 3);
const nextPositions = new Float32Array(size * 3);
const expandAndWidth = new Float32Array(size * 2);
const vertexBatchIds = new Uint16Array(size);
let positionIndex = 0;
let expandAndWidthIndex = 0;
let batchIdIndex = 0;
let i;
let offset = 0;
let length = counts.length;
for (i = 0; i < length; ++i) {
const count = counts[i];
const width = widths[i];
const batchId = batchIds[i];
for (let j = 0; j < count; ++j) {
let previous;
if (j === 0) {
const p0 = Cartesian3_default.unpack(positions, offset * 3, scratchP0);
const p1 = Cartesian3_default.unpack(positions, (offset + 1) * 3, scratchP1);
previous = Cartesian3_default.subtract(p0, p1, scratchPrev);
Cartesian3_default.add(p0, previous, previous);
} else {
previous = Cartesian3_default.unpack(
positions,
(offset + j - 1) * 3,
scratchPrev
);
}
const current = Cartesian3_default.unpack(
positions,
(offset + j) * 3,
scratchCur
);
let next;
if (j === count - 1) {
const p2 = Cartesian3_default.unpack(
positions,
(offset + count - 1) * 3,
scratchP0
);
const p3 = Cartesian3_default.unpack(
positions,
(offset + count - 2) * 3,
scratchP1
);
next = Cartesian3_default.subtract(p2, p3, scratchNext);
Cartesian3_default.add(p2, next, next);
} else {
next = Cartesian3_default.unpack(positions, (offset + j + 1) * 3, scratchNext);
}
Cartesian3_default.subtract(previous, center, previous);
Cartesian3_default.subtract(current, center, current);
Cartesian3_default.subtract(next, center, next);
const startK = j === 0 ? 2 : 0;
const endK = j === count - 1 ? 2 : 4;
for (let k = startK; k < endK; ++k) {
Cartesian3_default.pack(current, curPositions, positionIndex);
Cartesian3_default.pack(previous, prevPositions, positionIndex);
Cartesian3_default.pack(next, nextPositions, positionIndex);
positionIndex += 3;
const direction = k - 2 < 0 ? -1 : 1;
expandAndWidth[expandAndWidthIndex++] = 2 * (k % 2) - 1;
expandAndWidth[expandAndWidthIndex++] = direction * width;
vertexBatchIds[batchIdIndex++] = batchId;
}
}
offset += count;
}
const indices = IndexDatatype_default.createTypedArray(size, positionsLength * 6 - 6);
let index = 0;
let indicesIndex = 0;
length = positionsLength - 1;
for (i = 0; i < length; ++i) {
indices[indicesIndex++] = index;
indices[indicesIndex++] = index + 2;
indices[indicesIndex++] = index + 1;
indices[indicesIndex++] = index + 1;
indices[indicesIndex++] = index + 2;
indices[indicesIndex++] = index + 3;
index += 4;
}
transferableObjects.push(
curPositions.buffer,
prevPositions.buffer,
nextPositions.buffer
);
transferableObjects.push(
expandAndWidth.buffer,
vertexBatchIds.buffer,
indices.buffer
);
let results = {
indexDatatype: indices.BYTES_PER_ELEMENT === 2 ? IndexDatatype_default.UNSIGNED_SHORT : IndexDatatype_default.UNSIGNED_INT,
currentPositions: curPositions.buffer,
previousPositions: prevPositions.buffer,
nextPositions: nextPositions.buffer,
expandAndWidth: expandAndWidth.buffer,
batchIds: vertexBatchIds.buffer,
indices: indices.buffer
};
if (parameters.keepDecodedPositions) {
const positionOffsets = getPositionOffsets(counts);
transferableObjects.push(positions.buffer, positionOffsets.buffer);
results = combine_default(results, {
decodedPositions: positions.buffer,
decodedPositionOffsets: positionOffsets.buffer
});
}
return results;
}
var createVectorTilePolylines_default = createTaskProcessorWorker_default(createVectorTilePolylines);
export {
createVectorTilePolylines_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
EllipsoidalOccluder_default,
TerrainEncoding_default
} from "./chunk-56EDBCGT.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
WebMercatorProjection_default
} from "./chunk-RJM36CNY.js";
import {
OrientedBoundingBox_default
} from "./chunk-2PTKXHJB.js";
import "./chunk-LJ2JQHJT.js";
import "./chunk-YK3QIKY7.js";
import {
AxisAlignedBoundingBox_default
} from "./chunk-NDDI2LWR.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import {
Matrix4_default,
Rectangle_default,
Transforms_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian2_default,
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import {
RuntimeError_default
} from "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js
var sizeOfUint16 = Uint16Array.BYTES_PER_ELEMENT;
var sizeOfInt32 = Int32Array.BYTES_PER_ELEMENT;
var sizeOfUint32 = Uint32Array.BYTES_PER_ELEMENT;
var sizeOfFloat = Float32Array.BYTES_PER_ELEMENT;
var sizeOfDouble = Float64Array.BYTES_PER_ELEMENT;
function indexOfEpsilon(arr, elem, elemType) {
elemType = defaultValue_default(elemType, Math_default);
const count = arr.length;
for (let i = 0; i < count; ++i) {
if (elemType.equalsEpsilon(arr[i], elem, Math_default.EPSILON12)) {
return i;
}
}
return -1;
}
function createVerticesFromGoogleEarthEnterpriseBuffer(parameters, transferableObjects) {
parameters.ellipsoid = Ellipsoid_default.clone(parameters.ellipsoid);
parameters.rectangle = Rectangle_default.clone(parameters.rectangle);
const statistics = processBuffer(
parameters.buffer,
parameters.relativeToCenter,
parameters.ellipsoid,
parameters.rectangle,
parameters.nativeRectangle,
parameters.exaggeration,
parameters.exaggerationRelativeHeight,
parameters.skirtHeight,
parameters.includeWebMercatorT,
parameters.negativeAltitudeExponentBias,
parameters.negativeElevationThreshold
);
const vertices = statistics.vertices;
transferableObjects.push(vertices.buffer);
const indices = statistics.indices;
transferableObjects.push(indices.buffer);
return {
vertices: vertices.buffer,
indices: indices.buffer,
numberOfAttributes: statistics.encoding.stride,
minimumHeight: statistics.minimumHeight,
maximumHeight: statistics.maximumHeight,
boundingSphere3D: statistics.boundingSphere3D,
orientedBoundingBox: statistics.orientedBoundingBox,
occludeePointInScaledSpace: statistics.occludeePointInScaledSpace,
encoding: statistics.encoding,
vertexCountWithoutSkirts: statistics.vertexCountWithoutSkirts,
indexCountWithoutSkirts: statistics.indexCountWithoutSkirts,
westIndicesSouthToNorth: statistics.westIndicesSouthToNorth,
southIndicesEastToWest: statistics.southIndicesEastToWest,
eastIndicesNorthToSouth: statistics.eastIndicesNorthToSouth,
northIndicesWestToEast: statistics.northIndicesWestToEast
};
}
var scratchCartographic = new Cartographic_default();
var scratchCartesian = new Cartesian3_default();
var minimumScratch = new Cartesian3_default();
var maximumScratch = new Cartesian3_default();
var matrix4Scratch = new Matrix4_default();
function processBuffer(buffer, relativeToCenter, ellipsoid, rectangle, nativeRectangle, exaggeration, exaggerationRelativeHeight, skirtHeight, includeWebMercatorT, negativeAltitudeExponentBias, negativeElevationThreshold) {
let geographicWest;
let geographicSouth;
let geographicEast;
let geographicNorth;
let rectangleWidth, rectangleHeight;
if (!defined_default(rectangle)) {
geographicWest = Math_default.toRadians(nativeRectangle.west);
geographicSouth = Math_default.toRadians(nativeRectangle.south);
geographicEast = Math_default.toRadians(nativeRectangle.east);
geographicNorth = Math_default.toRadians(nativeRectangle.north);
rectangleWidth = Math_default.toRadians(rectangle.width);
rectangleHeight = Math_default.toRadians(rectangle.height);
} else {
geographicWest = rectangle.west;
geographicSouth = rectangle.south;
geographicEast = rectangle.east;
geographicNorth = rectangle.north;
rectangleWidth = rectangle.width;
rectangleHeight = rectangle.height;
}
const quadBorderLatitudes = [geographicSouth, geographicNorth];
const quadBorderLongitudes = [geographicWest, geographicEast];
const fromENU = Transforms_default.eastNorthUpToFixedFrame(
relativeToCenter,
ellipsoid
);
const toENU = Matrix4_default.inverseTransformation(fromENU, matrix4Scratch);
let southMercatorY;
let oneOverMercatorHeight;
if (includeWebMercatorT) {
southMercatorY = WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(
geographicSouth
);
oneOverMercatorHeight = 1 / (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(geographicNorth) - southMercatorY);
}
const hasExaggeration = exaggeration !== 1;
const includeGeodeticSurfaceNormals = hasExaggeration;
const dv = new DataView(buffer);
let minHeight = Number.POSITIVE_INFINITY;
let maxHeight = Number.NEGATIVE_INFINITY;
const minimum = minimumScratch;
minimum.x = Number.POSITIVE_INFINITY;
minimum.y = Number.POSITIVE_INFINITY;
minimum.z = Number.POSITIVE_INFINITY;
const maximum = maximumScratch;
maximum.x = Number.NEGATIVE_INFINITY;
maximum.y = Number.NEGATIVE_INFINITY;
maximum.z = Number.NEGATIVE_INFINITY;
let offset = 0;
let size = 0;
let indicesSize = 0;
let quadSize;
let quad;
for (quad = 0; quad < 4; ++quad) {
let o = offset;
quadSize = dv.getUint32(o, true);
o += sizeOfUint32;
const x = Math_default.toRadians(dv.getFloat64(o, true) * 180);
o += sizeOfDouble;
if (indexOfEpsilon(quadBorderLongitudes, x) === -1) {
quadBorderLongitudes.push(x);
}
const y = Math_default.toRadians(dv.getFloat64(o, true) * 180);
o += sizeOfDouble;
if (indexOfEpsilon(quadBorderLatitudes, y) === -1) {
quadBorderLatitudes.push(y);
}
o += 2 * sizeOfDouble;
let c = dv.getInt32(o, true);
o += sizeOfInt32;
size += c;
c = dv.getInt32(o, true);
indicesSize += c * 3;
offset += quadSize + sizeOfUint32;
}
const quadBorderPoints = [];
const quadBorderIndices = [];
const positions = new Array(size);
const uvs = new Array(size);
const heights = new Array(size);
const webMercatorTs = includeWebMercatorT ? new Array(size) : [];
const geodeticSurfaceNormals = includeGeodeticSurfaceNormals ? new Array(size) : [];
const indices = new Array(indicesSize);
const westBorder = [];
const southBorder = [];
const eastBorder = [];
const northBorder = [];
let pointOffset = 0;
let indicesOffset = 0;
offset = 0;
for (quad = 0; quad < 4; ++quad) {
quadSize = dv.getUint32(offset, true);
offset += sizeOfUint32;
const startQuad = offset;
const originX = Math_default.toRadians(dv.getFloat64(offset, true) * 180);
offset += sizeOfDouble;
const originY = Math_default.toRadians(dv.getFloat64(offset, true) * 180);
offset += sizeOfDouble;
const stepX = Math_default.toRadians(dv.getFloat64(offset, true) * 180);
const halfStepX = stepX * 0.5;
offset += sizeOfDouble;
const stepY = Math_default.toRadians(dv.getFloat64(offset, true) * 180);
const halfStepY = stepY * 0.5;
offset += sizeOfDouble;
const numPoints = dv.getInt32(offset, true);
offset += sizeOfInt32;
const numFaces = dv.getInt32(offset, true);
offset += sizeOfInt32;
offset += sizeOfInt32;
const indicesMapping = new Array(numPoints);
for (let i = 0; i < numPoints; ++i) {
const longitude = originX + dv.getUint8(offset++) * stepX;
scratchCartographic.longitude = longitude;
const latitude = originY + dv.getUint8(offset++) * stepY;
scratchCartographic.latitude = latitude;
let height = dv.getFloat32(offset, true);
offset += sizeOfFloat;
if (height !== 0 && height < negativeElevationThreshold) {
height *= -Math.pow(2, negativeAltitudeExponentBias);
}
height *= 6371010;
scratchCartographic.height = height;
if (indexOfEpsilon(quadBorderLongitudes, longitude) !== -1 || indexOfEpsilon(quadBorderLatitudes, latitude) !== -1) {
const index = indexOfEpsilon(
quadBorderPoints,
scratchCartographic,
Cartographic_default
);
if (index === -1) {
quadBorderPoints.push(Cartographic_default.clone(scratchCartographic));
quadBorderIndices.push(pointOffset);
} else {
indicesMapping[i] = quadBorderIndices[index];
continue;
}
}
indicesMapping[i] = pointOffset;
if (Math.abs(longitude - geographicWest) < halfStepX) {
westBorder.push({
index: pointOffset,
cartographic: Cartographic_default.clone(scratchCartographic)
});
} else if (Math.abs(longitude - geographicEast) < halfStepX) {
eastBorder.push({
index: pointOffset,
cartographic: Cartographic_default.clone(scratchCartographic)
});
} else if (Math.abs(latitude - geographicSouth) < halfStepY) {
southBorder.push({
index: pointOffset,
cartographic: Cartographic_default.clone(scratchCartographic)
});
} else if (Math.abs(latitude - geographicNorth) < halfStepY) {
northBorder.push({
index: pointOffset,
cartographic: Cartographic_default.clone(scratchCartographic)
});
}
minHeight = Math.min(height, minHeight);
maxHeight = Math.max(height, maxHeight);
heights[pointOffset] = height;
const pos = ellipsoid.cartographicToCartesian(scratchCartographic);
positions[pointOffset] = pos;
if (includeWebMercatorT) {
webMercatorTs[pointOffset] = (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(latitude) - southMercatorY) * oneOverMercatorHeight;
}
if (includeGeodeticSurfaceNormals) {
const normal = ellipsoid.geodeticSurfaceNormal(pos);
geodeticSurfaceNormals[pointOffset] = normal;
}
Matrix4_default.multiplyByPoint(toENU, pos, scratchCartesian);
Cartesian3_default.minimumByComponent(scratchCartesian, minimum, minimum);
Cartesian3_default.maximumByComponent(scratchCartesian, maximum, maximum);
let u = (longitude - geographicWest) / (geographicEast - geographicWest);
u = Math_default.clamp(u, 0, 1);
let v = (latitude - geographicSouth) / (geographicNorth - geographicSouth);
v = Math_default.clamp(v, 0, 1);
uvs[pointOffset] = new Cartesian2_default(u, v);
++pointOffset;
}
const facesElementCount = numFaces * 3;
for (let j = 0; j < facesElementCount; ++j, ++indicesOffset) {
indices[indicesOffset] = indicesMapping[dv.getUint16(offset, true)];
offset += sizeOfUint16;
}
if (quadSize !== offset - startQuad) {
throw new RuntimeError_default("Invalid terrain tile.");
}
}
positions.length = pointOffset;
uvs.length = pointOffset;
heights.length = pointOffset;
if (includeWebMercatorT) {
webMercatorTs.length = pointOffset;
}
if (includeGeodeticSurfaceNormals) {
geodeticSurfaceNormals.length = pointOffset;
}
const vertexCountWithoutSkirts = pointOffset;
const indexCountWithoutSkirts = indicesOffset;
const skirtOptions = {
hMin: minHeight,
lastBorderPoint: void 0,
skirtHeight,
toENU,
ellipsoid,
minimum,
maximum
};
westBorder.sort(function(a, b) {
return b.cartographic.latitude - a.cartographic.latitude;
});
southBorder.sort(function(a, b) {
return a.cartographic.longitude - b.cartographic.longitude;
});
eastBorder.sort(function(a, b) {
return a.cartographic.latitude - b.cartographic.latitude;
});
northBorder.sort(function(a, b) {
return b.cartographic.longitude - a.cartographic.longitude;
});
const percentage = 1e-5;
addSkirt(
positions,
heights,
uvs,
webMercatorTs,
geodeticSurfaceNormals,
indices,
skirtOptions,
westBorder,
-percentage * rectangleWidth,
true,
-percentage * rectangleHeight
);
addSkirt(
positions,
heights,
uvs,
webMercatorTs,
geodeticSurfaceNormals,
indices,
skirtOptions,
southBorder,
-percentage * rectangleHeight,
false
);
addSkirt(
positions,
heights,
uvs,
webMercatorTs,
geodeticSurfaceNormals,
indices,
skirtOptions,
eastBorder,
percentage * rectangleWidth,
true,
percentage * rectangleHeight
);
addSkirt(
positions,
heights,
uvs,
webMercatorTs,
geodeticSurfaceNormals,
indices,
skirtOptions,
northBorder,
percentage * rectangleHeight,
false
);
if (westBorder.length > 0 && northBorder.length > 0) {
const firstBorderIndex = westBorder[0].index;
const firstSkirtIndex = vertexCountWithoutSkirts;
const lastBorderIndex = northBorder[northBorder.length - 1].index;
const lastSkirtIndex = positions.length - 1;
indices.push(
lastBorderIndex,
lastSkirtIndex,
firstSkirtIndex,
firstSkirtIndex,
firstBorderIndex,
lastBorderIndex
);
}
size = positions.length;
const boundingSphere3D = BoundingSphere_default.fromPoints(positions);
let orientedBoundingBox;
if (defined_default(rectangle)) {
orientedBoundingBox = OrientedBoundingBox_default.fromRectangle(
rectangle,
minHeight,
maxHeight,
ellipsoid
);
}
const occluder = new EllipsoidalOccluder_default(ellipsoid);
const occludeePointInScaledSpace = occluder.computeHorizonCullingPointPossiblyUnderEllipsoid(
relativeToCenter,
positions,
minHeight
);
const aaBox = new AxisAlignedBoundingBox_default(minimum, maximum, relativeToCenter);
const encoding = new TerrainEncoding_default(
relativeToCenter,
aaBox,
skirtOptions.hMin,
maxHeight,
fromENU,
false,
includeWebMercatorT,
includeGeodeticSurfaceNormals,
exaggeration,
exaggerationRelativeHeight
);
const vertices = new Float32Array(size * encoding.stride);
let bufferIndex = 0;
for (let k = 0; k < size; ++k) {
bufferIndex = encoding.encode(
vertices,
bufferIndex,
positions[k],
uvs[k],
heights[k],
void 0,
webMercatorTs[k],
geodeticSurfaceNormals[k]
);
}
const westIndicesSouthToNorth = westBorder.map(function(vertex) {
return vertex.index;
}).reverse();
const southIndicesEastToWest = southBorder.map(function(vertex) {
return vertex.index;
}).reverse();
const eastIndicesNorthToSouth = eastBorder.map(function(vertex) {
return vertex.index;
}).reverse();
const northIndicesWestToEast = northBorder.map(function(vertex) {
return vertex.index;
}).reverse();
southIndicesEastToWest.unshift(
eastIndicesNorthToSouth[eastIndicesNorthToSouth.length - 1]
);
southIndicesEastToWest.push(westIndicesSouthToNorth[0]);
northIndicesWestToEast.unshift(
westIndicesSouthToNorth[westIndicesSouthToNorth.length - 1]
);
northIndicesWestToEast.push(eastIndicesNorthToSouth[0]);
return {
vertices,
indices: new Uint16Array(indices),
maximumHeight: maxHeight,
minimumHeight: minHeight,
encoding,
boundingSphere3D,
orientedBoundingBox,
occludeePointInScaledSpace,
vertexCountWithoutSkirts,
indexCountWithoutSkirts,
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast
};
}
function addSkirt(positions, heights, uvs, webMercatorTs, geodeticSurfaceNormals, indices, skirtOptions, borderPoints, fudgeFactor, eastOrWest, cornerFudge) {
const count = borderPoints.length;
for (let j = 0; j < count; ++j) {
const borderPoint = borderPoints[j];
const borderCartographic = borderPoint.cartographic;
const borderIndex = borderPoint.index;
const currentIndex = positions.length;
const longitude = borderCartographic.longitude;
let latitude = borderCartographic.latitude;
latitude = Math_default.clamp(
latitude,
-Math_default.PI_OVER_TWO,
Math_default.PI_OVER_TWO
);
const height = borderCartographic.height - skirtOptions.skirtHeight;
skirtOptions.hMin = Math.min(skirtOptions.hMin, height);
Cartographic_default.fromRadians(longitude, latitude, height, scratchCartographic);
if (eastOrWest) {
scratchCartographic.longitude += fudgeFactor;
}
if (!eastOrWest) {
scratchCartographic.latitude += fudgeFactor;
} else if (j === count - 1) {
scratchCartographic.latitude += cornerFudge;
} else if (j === 0) {
scratchCartographic.latitude -= cornerFudge;
}
const pos = skirtOptions.ellipsoid.cartographicToCartesian(
scratchCartographic
);
positions.push(pos);
heights.push(height);
uvs.push(Cartesian2_default.clone(uvs[borderIndex]));
if (webMercatorTs.length > 0) {
webMercatorTs.push(webMercatorTs[borderIndex]);
}
if (geodeticSurfaceNormals.length > 0) {
geodeticSurfaceNormals.push(geodeticSurfaceNormals[borderIndex]);
}
Matrix4_default.multiplyByPoint(skirtOptions.toENU, pos, scratchCartesian);
const minimum = skirtOptions.minimum;
const maximum = skirtOptions.maximum;
Cartesian3_default.minimumByComponent(scratchCartesian, minimum, minimum);
Cartesian3_default.maximumByComponent(scratchCartesian, maximum, maximum);
const lastBorderPoint = skirtOptions.lastBorderPoint;
if (defined_default(lastBorderPoint)) {
const lastBorderIndex = lastBorderPoint.index;
indices.push(
lastBorderIndex,
currentIndex - 1,
currentIndex,
currentIndex,
borderIndex,
lastBorderIndex
);
}
skirtOptions.lastBorderPoint = borderPoint;
}
}
var createVerticesFromGoogleEarthEnterpriseBuffer_default = createTaskProcessorWorker_default(
createVerticesFromGoogleEarthEnterpriseBuffer
);
export {
createVerticesFromGoogleEarthEnterpriseBuffer_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
EllipsoidalOccluder_default,
TerrainEncoding_default
} from "./chunk-56EDBCGT.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
WebMercatorProjection_default
} from "./chunk-RJM36CNY.js";
import {
OrientedBoundingBox_default
} from "./chunk-2PTKXHJB.js";
import "./chunk-LJ2JQHJT.js";
import "./chunk-YK3QIKY7.js";
import {
AxisAlignedBoundingBox_default
} from "./chunk-NDDI2LWR.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import {
Matrix4_default,
Rectangle_default,
Transforms_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian2_default,
Cartesian3_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import {
RuntimeError_default
} from "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
__commonJS,
__toESM,
defined_default
} from "./chunk-YCDZX5LS.js";
// node_modules/lerc/LercDecode.js
var require_LercDecode = __commonJS({
"node_modules/lerc/LercDecode.js"(exports, module) {
/* Copyright 2015-2018 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */
(function() {
var LercDecode = function() {
var CntZImage = {};
CntZImage.defaultNoDataValue = -34027999387901484e22;
CntZImage.decode = function(input, options) {
options = options || {};
var skipMask = options.encodedMaskData || options.encodedMaskData === null;
var parsedData = parse(input, options.inputOffset || 0, skipMask);
var noDataValue = options.noDataValue !== null ? options.noDataValue : CntZImage.defaultNoDataValue;
var uncompressedData = uncompressPixelValues(
parsedData,
options.pixelType || Float32Array,
options.encodedMaskData,
noDataValue,
options.returnMask
);
var result = {
width: parsedData.width,
height: parsedData.height,
pixelData: uncompressedData.resultPixels,
minValue: uncompressedData.minValue,
maxValue: parsedData.pixels.maxValue,
noDataValue
};
if (uncompressedData.resultMask) {
result.maskData = uncompressedData.resultMask;
}
if (options.returnEncodedMask && parsedData.mask) {
result.encodedMaskData = parsedData.mask.bitset ? parsedData.mask.bitset : null;
}
if (options.returnFileInfo) {
result.fileInfo = formatFileInfo(parsedData);
if (options.computeUsedBitDepths) {
result.fileInfo.bitDepths = computeUsedBitDepths(parsedData);
}
}
return result;
};
var uncompressPixelValues = function(data, TypedArrayClass, maskBitset, noDataValue, storeDecodedMask) {
var blockIdx = 0;
var numX = data.pixels.numBlocksX;
var numY = data.pixels.numBlocksY;
var blockWidth = Math.floor(data.width / numX);
var blockHeight = Math.floor(data.height / numY);
var scale = 2 * data.maxZError;
var minValue = Number.MAX_VALUE, currentValue;
maskBitset = maskBitset || (data.mask ? data.mask.bitset : null);
var resultPixels, resultMask;
resultPixels = new TypedArrayClass(data.width * data.height);
if (storeDecodedMask && maskBitset) {
resultMask = new Uint8Array(data.width * data.height);
}
var blockDataBuffer = new Float32Array(blockWidth * blockHeight);
var xx, yy;
for (var y = 0; y <= numY; y++) {
var thisBlockHeight = y !== numY ? blockHeight : data.height % numY;
if (thisBlockHeight === 0) {
continue;
}
for (var x = 0; x <= numX; x++) {
var thisBlockWidth = x !== numX ? blockWidth : data.width % numX;
if (thisBlockWidth === 0) {
continue;
}
var outPtr = y * data.width * blockHeight + x * blockWidth;
var outStride = data.width - thisBlockWidth;
var block = data.pixels.blocks[blockIdx];
var blockData, blockPtr, constValue;
if (block.encoding < 2) {
if (block.encoding === 0) {
blockData = block.rawData;
} else {
unstuff(block.stuffedData, block.bitsPerPixel, block.numValidPixels, block.offset, scale, blockDataBuffer, data.pixels.maxValue);
blockData = blockDataBuffer;
}
blockPtr = 0;
} else if (block.encoding === 2) {
constValue = 0;
} else {
constValue = block.offset;
}
var maskByte;
if (maskBitset) {
for (yy = 0; yy < thisBlockHeight; yy++) {
if (outPtr & 7) {
maskByte = maskBitset[outPtr >> 3];
maskByte <<= outPtr & 7;
}
for (xx = 0; xx < thisBlockWidth; xx++) {
if (!(outPtr & 7)) {
maskByte = maskBitset[outPtr >> 3];
}
if (maskByte & 128) {
if (resultMask) {
resultMask[outPtr] = 1;
}
currentValue = block.encoding < 2 ? blockData[blockPtr++] : constValue;
minValue = minValue > currentValue ? currentValue : minValue;
resultPixels[outPtr++] = currentValue;
} else {
if (resultMask) {
resultMask[outPtr] = 0;
}
resultPixels[outPtr++] = noDataValue;
}
maskByte <<= 1;
}
outPtr += outStride;
}
} else {
if (block.encoding < 2) {
for (yy = 0; yy < thisBlockHeight; yy++) {
for (xx = 0; xx < thisBlockWidth; xx++) {
currentValue = blockData[blockPtr++];
minValue = minValue > currentValue ? currentValue : minValue;
resultPixels[outPtr++] = currentValue;
}
outPtr += outStride;
}
} else {
minValue = minValue > constValue ? constValue : minValue;
for (yy = 0; yy < thisBlockHeight; yy++) {
for (xx = 0; xx < thisBlockWidth; xx++) {
resultPixels[outPtr++] = constValue;
}
outPtr += outStride;
}
}
}
if (block.encoding === 1 && blockPtr !== block.numValidPixels) {
throw "Block and Mask do not match";
}
blockIdx++;
}
}
return {
resultPixels,
resultMask,
minValue
};
};
var formatFileInfo = function(data) {
return {
"fileIdentifierString": data.fileIdentifierString,
"fileVersion": data.fileVersion,
"imageType": data.imageType,
"height": data.height,
"width": data.width,
"maxZError": data.maxZError,
"eofOffset": data.eofOffset,
"mask": data.mask ? {
"numBlocksX": data.mask.numBlocksX,
"numBlocksY": data.mask.numBlocksY,
"numBytes": data.mask.numBytes,
"maxValue": data.mask.maxValue
} : null,
"pixels": {
"numBlocksX": data.pixels.numBlocksX,
"numBlocksY": data.pixels.numBlocksY,
"numBytes": data.pixels.numBytes,
"maxValue": data.pixels.maxValue,
"noDataValue": data.noDataValue
}
};
};
var computeUsedBitDepths = function(data) {
var numBlocks = data.pixels.numBlocksX * data.pixels.numBlocksY;
var bitDepths = {};
for (var i = 0; i < numBlocks; i++) {
var block = data.pixels.blocks[i];
if (block.encoding === 0) {
bitDepths.float32 = true;
} else if (block.encoding === 1) {
bitDepths[block.bitsPerPixel] = true;
} else {
bitDepths[0] = true;
}
}
return Object.keys(bitDepths);
};
var parse = function(input, fp, skipMask) {
var data = {};
var fileIdView = new Uint8Array(input, fp, 10);
data.fileIdentifierString = String.fromCharCode.apply(null, fileIdView);
if (data.fileIdentifierString.trim() !== "CntZImage") {
throw "Unexpected file identifier string: " + data.fileIdentifierString;
}
fp += 10;
var view = new DataView(input, fp, 24);
data.fileVersion = view.getInt32(0, true);
data.imageType = view.getInt32(4, true);
data.height = view.getUint32(8, true);
data.width = view.getUint32(12, true);
data.maxZError = view.getFloat64(16, true);
fp += 24;
if (!skipMask) {
view = new DataView(input, fp, 16);
data.mask = {};
data.mask.numBlocksY = view.getUint32(0, true);
data.mask.numBlocksX = view.getUint32(4, true);
data.mask.numBytes = view.getUint32(8, true);
data.mask.maxValue = view.getFloat32(12, true);
fp += 16;
if (data.mask.numBytes > 0) {
var bitset = new Uint8Array(Math.ceil(data.width * data.height / 8));
view = new DataView(input, fp, data.mask.numBytes);
var cnt = view.getInt16(0, true);
var ip = 2, op = 0;
do {
if (cnt > 0) {
while (cnt--) {
bitset[op++] = view.getUint8(ip++);
}
} else {
var val = view.getUint8(ip++);
cnt = -cnt;
while (cnt--) {
bitset[op++] = val;
}
}
cnt = view.getInt16(ip, true);
ip += 2;
} while (ip < data.mask.numBytes);
if (cnt !== -32768 || op < bitset.length) {
throw "Unexpected end of mask RLE encoding";
}
data.mask.bitset = bitset;
fp += data.mask.numBytes;
} else if ((data.mask.numBytes | data.mask.numBlocksY | data.mask.maxValue) === 0) {
data.mask.bitset = new Uint8Array(Math.ceil(data.width * data.height / 8));
}
}
view = new DataView(input, fp, 16);
data.pixels = {};
data.pixels.numBlocksY = view.getUint32(0, true);
data.pixels.numBlocksX = view.getUint32(4, true);
data.pixels.numBytes = view.getUint32(8, true);
data.pixels.maxValue = view.getFloat32(12, true);
fp += 16;
var numBlocksX = data.pixels.numBlocksX;
var numBlocksY = data.pixels.numBlocksY;
var actualNumBlocksX = numBlocksX + (data.width % numBlocksX > 0 ? 1 : 0);
var actualNumBlocksY = numBlocksY + (data.height % numBlocksY > 0 ? 1 : 0);
data.pixels.blocks = new Array(actualNumBlocksX * actualNumBlocksY);
var blockI = 0;
for (var blockY = 0; blockY < actualNumBlocksY; blockY++) {
for (var blockX = 0; blockX < actualNumBlocksX; blockX++) {
var size = 0;
var bytesLeft = input.byteLength - fp;
view = new DataView(input, fp, Math.min(10, bytesLeft));
var block = {};
data.pixels.blocks[blockI++] = block;
var headerByte = view.getUint8(0);
size++;
block.encoding = headerByte & 63;
if (block.encoding > 3) {
throw "Invalid block encoding (" + block.encoding + ")";
}
if (block.encoding === 2) {
fp++;
continue;
}
if (headerByte !== 0 && headerByte !== 2) {
headerByte >>= 6;
block.offsetType = headerByte;
if (headerByte === 2) {
block.offset = view.getInt8(1);
size++;
} else if (headerByte === 1) {
block.offset = view.getInt16(1, true);
size += 2;
} else if (headerByte === 0) {
block.offset = view.getFloat32(1, true);
size += 4;
} else {
throw "Invalid block offset type";
}
if (block.encoding === 1) {
headerByte = view.getUint8(size);
size++;
block.bitsPerPixel = headerByte & 63;
headerByte >>= 6;
block.numValidPixelsType = headerByte;
if (headerByte === 2) {
block.numValidPixels = view.getUint8(size);
size++;
} else if (headerByte === 1) {
block.numValidPixels = view.getUint16(size, true);
size += 2;
} else if (headerByte === 0) {
block.numValidPixels = view.getUint32(size, true);
size += 4;
} else {
throw "Invalid valid pixel count type";
}
}
}
fp += size;
if (block.encoding === 3) {
continue;
}
var arrayBuf, store8;
if (block.encoding === 0) {
var numPixels = (data.pixels.numBytes - 1) / 4;
if (numPixels !== Math.floor(numPixels)) {
throw "uncompressed block has invalid length";
}
arrayBuf = new ArrayBuffer(numPixels * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, fp, numPixels * 4));
var rawData = new Float32Array(arrayBuf);
block.rawData = rawData;
fp += numPixels * 4;
} else if (block.encoding === 1) {
var dataBytes = Math.ceil(block.numValidPixels * block.bitsPerPixel / 8);
var dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, fp, dataBytes));
block.stuffedData = new Uint32Array(arrayBuf);
fp += dataBytes;
}
}
}
data.eofOffset = fp;
return data;
};
var unstuff = function(src, bitsPerPixel, numPixels, offset, scale, dest, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0;
var n, buffer;
var nmax = Math.ceil((maxValue - offset) / scale);
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
var missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n < nmax ? offset + n * scale : maxValue;
}
return dest;
};
return CntZImage;
}();
var Lerc2Decode = function() {
"use strict";
var BitStuffer = {
//methods ending with 2 are for the new byte order used by Lerc2.3 and above.
//originalUnstuff is used to unpack Huffman code table. code is duplicated to unstuffx for performance reasons.
unstuff: function(src, dest, bitsPerPixel, numPixels, lutArr, offset, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0;
var n, buffer, missingBits, nmax;
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
if (lutArr) {
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = lutArr[n];
}
} else {
nmax = Math.ceil((maxValue - offset) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n < nmax ? offset + n * scale : maxValue;
}
}
},
unstuffLUT: function(src, bitsPerPixel, numPixels, offset, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o = 0, missingBits = 0, bitsLeft = 0, n = 0;
var buffer;
var dest = [];
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
var nmax = Math.ceil((maxValue - offset) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n < nmax ? offset + n * scale : maxValue;
}
dest.unshift(offset);
return dest;
},
unstuff2: function(src, dest, bitsPerPixel, numPixels, lutArr, offset, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0, bitPos = 0;
var n, buffer, missingBits;
if (lutArr) {
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = lutArr[n];
}
} else {
var nmax = Math.ceil((maxValue - offset) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = n < nmax ? offset + n * scale : maxValue;
}
}
return dest;
},
unstuffLUT2: function(src, bitsPerPixel, numPixels, offset, scale, maxValue) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o = 0, missingBits = 0, bitsLeft = 0, n = 0, bitPos = 0;
var buffer;
var dest = [];
var nmax = Math.ceil((maxValue - offset) / scale);
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = n < nmax ? offset + n * scale : maxValue;
}
dest.unshift(offset);
return dest;
},
originalUnstuff: function(src, dest, bitsPerPixel, numPixels) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0;
var n, buffer, missingBits;
var numInvalidTailBytes = src.length * 4 - Math.ceil(bitsPerPixel * numPixels / 8);
src[src.length - 1] <<= 8 * numInvalidTailBytes;
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitsLeft - bitsPerPixel & bitMask;
bitsLeft -= bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = (buffer & bitMask) << missingBits & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n += buffer >>> bitsLeft;
}
dest[o] = n;
}
return dest;
},
originalUnstuff2: function(src, dest, bitsPerPixel, numPixels) {
var bitMask = (1 << bitsPerPixel) - 1;
var i = 0, o;
var bitsLeft = 0, bitPos = 0;
var n, buffer, missingBits;
for (o = 0; o < numPixels; o++) {
if (bitsLeft === 0) {
buffer = src[i++];
bitsLeft = 32;
bitPos = 0;
}
if (bitsLeft >= bitsPerPixel) {
n = buffer >>> bitPos & bitMask;
bitsLeft -= bitsPerPixel;
bitPos += bitsPerPixel;
} else {
missingBits = bitsPerPixel - bitsLeft;
n = buffer >>> bitPos & bitMask;
buffer = src[i++];
bitsLeft = 32 - missingBits;
n |= (buffer & (1 << missingBits) - 1) << bitsPerPixel - missingBits;
bitPos = missingBits;
}
dest[o] = n;
}
return dest;
}
};
var Lerc2Helpers = {
HUFFMAN_LUT_BITS_MAX: 12,
//use 2^12 lut, treat it like constant
computeChecksumFletcher32: function(input) {
var sum1 = 65535, sum2 = 65535;
var len = input.length;
var words = Math.floor(len / 2);
var i = 0;
while (words) {
var tlen = words >= 359 ? 359 : words;
words -= tlen;
do {
sum1 += input[i++] << 8;
sum2 += sum1 += input[i++];
} while (--tlen);
sum1 = (sum1 & 65535) + (sum1 >>> 16);
sum2 = (sum2 & 65535) + (sum2 >>> 16);
}
if (len & 1) {
sum2 += sum1 += input[i] << 8;
}
sum1 = (sum1 & 65535) + (sum1 >>> 16);
sum2 = (sum2 & 65535) + (sum2 >>> 16);
return (sum2 << 16 | sum1) >>> 0;
},
readHeaderInfo: function(input, data) {
var ptr = data.ptr;
var fileIdView = new Uint8Array(input, ptr, 6);
var headerInfo = {};
headerInfo.fileIdentifierString = String.fromCharCode.apply(null, fileIdView);
if (headerInfo.fileIdentifierString.lastIndexOf("Lerc2", 0) !== 0) {
throw "Unexpected file identifier string (expect Lerc2 ): " + headerInfo.fileIdentifierString;
}
ptr += 6;
var view = new DataView(input, ptr, 8);
var fileVersion = view.getInt32(0, true);
headerInfo.fileVersion = fileVersion;
ptr += 4;
if (fileVersion >= 3) {
headerInfo.checksum = view.getUint32(4, true);
ptr += 4;
}
view = new DataView(input, ptr, 12);
headerInfo.height = view.getUint32(0, true);
headerInfo.width = view.getUint32(4, true);
ptr += 8;
if (fileVersion >= 4) {
headerInfo.numDims = view.getUint32(8, true);
ptr += 4;
} else {
headerInfo.numDims = 1;
}
view = new DataView(input, ptr, 40);
headerInfo.numValidPixel = view.getUint32(0, true);
headerInfo.microBlockSize = view.getInt32(4, true);
headerInfo.blobSize = view.getInt32(8, true);
headerInfo.imageType = view.getInt32(12, true);
headerInfo.maxZError = view.getFloat64(16, true);
headerInfo.zMin = view.getFloat64(24, true);
headerInfo.zMax = view.getFloat64(32, true);
ptr += 40;
data.headerInfo = headerInfo;
data.ptr = ptr;
var checksum, keyLength;
if (fileVersion >= 3) {
keyLength = fileVersion >= 4 ? 52 : 48;
checksum = this.computeChecksumFletcher32(new Uint8Array(input, ptr - keyLength, headerInfo.blobSize - 14));
if (checksum !== headerInfo.checksum) {
throw "Checksum failed.";
}
}
return true;
},
checkMinMaxRanges: function(input, data) {
var headerInfo = data.headerInfo;
var OutPixelTypeArray = this.getDataTypeArray(headerInfo.imageType);
var rangeBytes = headerInfo.numDims * this.getDataTypeSize(headerInfo.imageType);
var minValues = this.readSubArray(input, data.ptr, OutPixelTypeArray, rangeBytes);
var maxValues = this.readSubArray(input, data.ptr + rangeBytes, OutPixelTypeArray, rangeBytes);
data.ptr += 2 * rangeBytes;
var i, equal = true;
for (i = 0; i < headerInfo.numDims; i++) {
if (minValues[i] !== maxValues[i]) {
equal = false;
break;
}
}
headerInfo.minValues = minValues;
headerInfo.maxValues = maxValues;
return equal;
},
readSubArray: function(input, ptr, OutPixelTypeArray, numBytes) {
var rawData;
if (OutPixelTypeArray === Uint8Array) {
rawData = new Uint8Array(input, ptr, numBytes);
} else {
var arrayBuf = new ArrayBuffer(numBytes);
var store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, ptr, numBytes));
rawData = new OutPixelTypeArray(arrayBuf);
}
return rawData;
},
readMask: function(input, data) {
var ptr = data.ptr;
var headerInfo = data.headerInfo;
var numPixels = headerInfo.width * headerInfo.height;
var numValidPixel = headerInfo.numValidPixel;
var view = new DataView(input, ptr, 4);
var mask = {};
mask.numBytes = view.getUint32(0, true);
ptr += 4;
if ((0 === numValidPixel || numPixels === numValidPixel) && 0 !== mask.numBytes) {
throw "invalid mask";
}
var bitset, resultMask;
if (numValidPixel === 0) {
bitset = new Uint8Array(Math.ceil(numPixels / 8));
mask.bitset = bitset;
resultMask = new Uint8Array(numPixels);
data.pixels.resultMask = resultMask;
ptr += mask.numBytes;
} else if (mask.numBytes > 0) {
bitset = new Uint8Array(Math.ceil(numPixels / 8));
view = new DataView(input, ptr, mask.numBytes);
var cnt = view.getInt16(0, true);
var ip = 2, op = 0, val = 0;
do {
if (cnt > 0) {
while (cnt--) {
bitset[op++] = view.getUint8(ip++);
}
} else {
val = view.getUint8(ip++);
cnt = -cnt;
while (cnt--) {
bitset[op++] = val;
}
}
cnt = view.getInt16(ip, true);
ip += 2;
} while (ip < mask.numBytes);
if (cnt !== -32768 || op < bitset.length) {
throw "Unexpected end of mask RLE encoding";
}
resultMask = new Uint8Array(numPixels);
var mb = 0, k = 0;
for (k = 0; k < numPixels; k++) {
if (k & 7) {
mb = bitset[k >> 3];
mb <<= k & 7;
} else {
mb = bitset[k >> 3];
}
if (mb & 128) {
resultMask[k] = 1;
}
}
data.pixels.resultMask = resultMask;
mask.bitset = bitset;
ptr += mask.numBytes;
}
data.ptr = ptr;
data.mask = mask;
return true;
},
readDataOneSweep: function(input, data, OutPixelTypeArray) {
var ptr = data.ptr;
var headerInfo = data.headerInfo;
var numDims = headerInfo.numDims;
var numPixels = headerInfo.width * headerInfo.height;
var imageType = headerInfo.imageType;
var numBytes = headerInfo.numValidPixel * Lerc2Helpers.getDataTypeSize(imageType) * numDims;
var rawData;
var mask = data.pixels.resultMask;
if (OutPixelTypeArray === Uint8Array) {
rawData = new Uint8Array(input, ptr, numBytes);
} else {
var arrayBuf = new ArrayBuffer(numBytes);
var store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, ptr, numBytes));
rawData = new OutPixelTypeArray(arrayBuf);
}
if (rawData.length === numPixels * numDims) {
data.pixels.resultPixels = rawData;
} else {
data.pixels.resultPixels = new OutPixelTypeArray(numPixels * numDims);
var z = 0, k = 0, i = 0, nStart = 0;
if (numDims > 1) {
for (i = 0; i < numDims; i++) {
nStart = i * numPixels;
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[nStart + k] = rawData[z++];
}
}
}
} else {
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[k] = rawData[z++];
}
}
}
}
ptr += numBytes;
data.ptr = ptr;
return true;
},
readHuffmanTree: function(input, data) {
var BITS_MAX = this.HUFFMAN_LUT_BITS_MAX;
var view = new DataView(input, data.ptr, 16);
data.ptr += 16;
var version = view.getInt32(0, true);
if (version < 2) {
throw "unsupported Huffman version";
}
var size = view.getInt32(4, true);
var i0 = view.getInt32(8, true);
var i1 = view.getInt32(12, true);
if (i0 >= i1) {
return false;
}
var blockDataBuffer = new Uint32Array(i1 - i0);
Lerc2Helpers.decodeBits(input, data, blockDataBuffer);
var codeTable = [];
var i, j, k, len;
for (i = i0; i < i1; i++) {
j = i - (i < size ? 0 : size);
codeTable[j] = { first: blockDataBuffer[i - i0], second: null };
}
var dataBytes = input.byteLength - data.ptr;
var dataWords = Math.ceil(dataBytes / 4);
var arrayBuf = new ArrayBuffer(dataWords * 4);
var store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, dataBytes));
var stuffedData = new Uint32Array(arrayBuf);
var bitPos = 0, word, srcPtr = 0;
word = stuffedData[0];
for (i = i0; i < i1; i++) {
j = i - (i < size ? 0 : size);
len = codeTable[j].first;
if (len > 0) {
codeTable[j].second = word << bitPos >>> 32 - len;
if (32 - bitPos >= len) {
bitPos += len;
if (bitPos === 32) {
bitPos = 0;
srcPtr++;
word = stuffedData[srcPtr];
}
} else {
bitPos += len - 32;
srcPtr++;
word = stuffedData[srcPtr];
codeTable[j].second |= word >>> 32 - bitPos;
}
}
}
var numBitsLUT = 0, numBitsLUTQick = 0;
var tree = new TreeNode();
for (i = 0; i < codeTable.length; i++) {
if (codeTable[i] !== void 0) {
numBitsLUT = Math.max(numBitsLUT, codeTable[i].first);
}
}
if (numBitsLUT >= BITS_MAX) {
numBitsLUTQick = BITS_MAX;
} else {
numBitsLUTQick = numBitsLUT;
}
if (numBitsLUT >= 30) {
console.log("WARning, large NUM LUT BITS IS " + numBitsLUT);
}
var decodeLut = [], entry, code, numEntries, jj, currentBit, node;
for (i = i0; i < i1; i++) {
j = i - (i < size ? 0 : size);
len = codeTable[j].first;
if (len > 0) {
entry = [len, j];
if (len <= numBitsLUTQick) {
code = codeTable[j].second << numBitsLUTQick - len;
numEntries = 1 << numBitsLUTQick - len;
for (k = 0; k < numEntries; k++) {
decodeLut[code | k] = entry;
}
} else {
code = codeTable[j].second;
node = tree;
for (jj = len - 1; jj >= 0; jj--) {
currentBit = code >>> jj & 1;
if (currentBit) {
if (!node.right) {
node.right = new TreeNode();
}
node = node.right;
} else {
if (!node.left) {
node.left = new TreeNode();
}
node = node.left;
}
if (jj === 0 && !node.val) {
node.val = entry[1];
}
}
}
}
}
return {
decodeLut,
numBitsLUTQick,
numBitsLUT,
tree,
stuffedData,
srcPtr,
bitPos
};
},
readHuffman: function(input, data, OutPixelTypeArray) {
var headerInfo = data.headerInfo;
var numDims = headerInfo.numDims;
var height = data.headerInfo.height;
var width = data.headerInfo.width;
var numPixels = width * height;
var huffmanInfo = this.readHuffmanTree(input, data);
var decodeLut = huffmanInfo.decodeLut;
var tree = huffmanInfo.tree;
var stuffedData = huffmanInfo.stuffedData;
var srcPtr = huffmanInfo.srcPtr;
var bitPos = huffmanInfo.bitPos;
var numBitsLUTQick = huffmanInfo.numBitsLUTQick;
var numBitsLUT = huffmanInfo.numBitsLUT;
var offset = data.headerInfo.imageType === 0 ? 128 : 0;
var node, val, delta, mask = data.pixels.resultMask, valTmp, valTmpQuick, currentBit;
var i, j, k, ii;
var prevVal = 0;
if (bitPos > 0) {
srcPtr++;
bitPos = 0;
}
var word = stuffedData[srcPtr];
var deltaEncode = data.encodeMode === 1;
var resultPixelsAllDim = new OutPixelTypeArray(numPixels * numDims);
var resultPixels = resultPixelsAllDim;
var iDim;
for (iDim = 0; iDim < headerInfo.numDims; iDim++) {
if (numDims > 1) {
resultPixels = new OutPixelTypeArray(resultPixelsAllDim.buffer, numPixels * iDim, numPixels);
prevVal = 0;
}
if (data.headerInfo.numValidPixel === width * height) {
for (k = 0, i = 0; i < height; i++) {
for (j = 0; j < width; j++, k++) {
val = 0;
valTmp = word << bitPos >>> 32 - numBitsLUTQick;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUTQick) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUTQick;
valTmpQuick = valTmp;
}
if (decodeLut[valTmpQuick]) {
val = decodeLut[valTmpQuick][1];
bitPos += decodeLut[valTmpQuick][0];
} else {
valTmp = word << bitPos >>> 32 - numBitsLUT;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUT) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUT;
valTmpQuick = valTmp;
}
node = tree;
for (ii = 0; ii < numBitsLUT; ii++) {
currentBit = valTmp >>> numBitsLUT - ii - 1 & 1;
node = currentBit ? node.right : node.left;
if (!(node.left || node.right)) {
val = node.val;
bitPos = bitPos + ii + 1;
break;
}
}
}
if (bitPos >= 32) {
bitPos -= 32;
srcPtr++;
word = stuffedData[srcPtr];
}
delta = val - offset;
if (deltaEncode) {
if (j > 0) {
delta += prevVal;
} else if (i > 0) {
delta += resultPixels[k - width];
} else {
delta += prevVal;
}
delta &= 255;
resultPixels[k] = delta;
prevVal = delta;
} else {
resultPixels[k] = delta;
}
}
}
} else {
for (k = 0, i = 0; i < height; i++) {
for (j = 0; j < width; j++, k++) {
if (mask[k]) {
val = 0;
valTmp = word << bitPos >>> 32 - numBitsLUTQick;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUTQick) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUTQick;
valTmpQuick = valTmp;
}
if (decodeLut[valTmpQuick]) {
val = decodeLut[valTmpQuick][1];
bitPos += decodeLut[valTmpQuick][0];
} else {
valTmp = word << bitPos >>> 32 - numBitsLUT;
valTmpQuick = valTmp;
if (32 - bitPos < numBitsLUT) {
valTmp |= stuffedData[srcPtr + 1] >>> 64 - bitPos - numBitsLUT;
valTmpQuick = valTmp;
}
node = tree;
for (ii = 0; ii < numBitsLUT; ii++) {
currentBit = valTmp >>> numBitsLUT - ii - 1 & 1;
node = currentBit ? node.right : node.left;
if (!(node.left || node.right)) {
val = node.val;
bitPos = bitPos + ii + 1;
break;
}
}
}
if (bitPos >= 32) {
bitPos -= 32;
srcPtr++;
word = stuffedData[srcPtr];
}
delta = val - offset;
if (deltaEncode) {
if (j > 0 && mask[k - 1]) {
delta += prevVal;
} else if (i > 0 && mask[k - width]) {
delta += resultPixels[k - width];
} else {
delta += prevVal;
}
delta &= 255;
resultPixels[k] = delta;
prevVal = delta;
} else {
resultPixels[k] = delta;
}
}
}
}
}
data.ptr = data.ptr + (srcPtr + 1) * 4 + (bitPos > 0 ? 4 : 0);
}
data.pixels.resultPixels = resultPixelsAllDim;
},
decodeBits: function(input, data, blockDataBuffer, offset, iDim) {
{
var headerInfo = data.headerInfo;
var fileVersion = headerInfo.fileVersion;
var blockPtr = 0;
var view = new DataView(input, data.ptr, 5);
var headerByte = view.getUint8(0);
blockPtr++;
var bits67 = headerByte >> 6;
var n = bits67 === 0 ? 4 : 3 - bits67;
var doLut = (headerByte & 32) > 0 ? true : false;
var numBits = headerByte & 31;
var numElements = 0;
if (n === 1) {
numElements = view.getUint8(blockPtr);
blockPtr++;
} else if (n === 2) {
numElements = view.getUint16(blockPtr, true);
blockPtr += 2;
} else if (n === 4) {
numElements = view.getUint32(blockPtr, true);
blockPtr += 4;
} else {
throw "Invalid valid pixel count type";
}
var scale = 2 * headerInfo.maxZError;
var stuffedData, arrayBuf, store8, dataBytes, dataWords;
var lutArr, lutData, lutBytes, lutBitsPerElement, bitsPerPixel;
var zMax = headerInfo.numDims > 1 ? headerInfo.maxValues[iDim] : headerInfo.zMax;
if (doLut) {
data.counter.lut++;
lutBytes = view.getUint8(blockPtr);
lutBitsPerElement = numBits;
blockPtr++;
dataBytes = Math.ceil((lutBytes - 1) * numBits / 8);
dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
data.ptr += blockPtr;
store8.set(new Uint8Array(input, data.ptr, dataBytes));
lutData = new Uint32Array(arrayBuf);
data.ptr += dataBytes;
bitsPerPixel = 0;
while (lutBytes - 1 >>> bitsPerPixel) {
bitsPerPixel++;
}
dataBytes = Math.ceil(numElements * bitsPerPixel / 8);
dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, dataBytes));
stuffedData = new Uint32Array(arrayBuf);
data.ptr += dataBytes;
if (fileVersion >= 3) {
lutArr = BitStuffer.unstuffLUT2(lutData, numBits, lutBytes - 1, offset, scale, zMax);
} else {
lutArr = BitStuffer.unstuffLUT(lutData, numBits, lutBytes - 1, offset, scale, zMax);
}
if (fileVersion >= 3) {
BitStuffer.unstuff2(stuffedData, blockDataBuffer, bitsPerPixel, numElements, lutArr);
} else {
BitStuffer.unstuff(stuffedData, blockDataBuffer, bitsPerPixel, numElements, lutArr);
}
} else {
data.counter.bitstuffer++;
bitsPerPixel = numBits;
data.ptr += blockPtr;
if (bitsPerPixel > 0) {
dataBytes = Math.ceil(numElements * bitsPerPixel / 8);
dataWords = Math.ceil(dataBytes / 4);
arrayBuf = new ArrayBuffer(dataWords * 4);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, dataBytes));
stuffedData = new Uint32Array(arrayBuf);
data.ptr += dataBytes;
if (fileVersion >= 3) {
if (offset == null) {
BitStuffer.originalUnstuff2(stuffedData, blockDataBuffer, bitsPerPixel, numElements);
} else {
BitStuffer.unstuff2(stuffedData, blockDataBuffer, bitsPerPixel, numElements, false, offset, scale, zMax);
}
} else {
if (offset == null) {
BitStuffer.originalUnstuff(stuffedData, blockDataBuffer, bitsPerPixel, numElements);
} else {
BitStuffer.unstuff(stuffedData, blockDataBuffer, bitsPerPixel, numElements, false, offset, scale, zMax);
}
}
}
}
}
},
readTiles: function(input, data, OutPixelTypeArray) {
var headerInfo = data.headerInfo;
var width = headerInfo.width;
var height = headerInfo.height;
var microBlockSize = headerInfo.microBlockSize;
var imageType = headerInfo.imageType;
var dataTypeSize = Lerc2Helpers.getDataTypeSize(imageType);
var numBlocksX = Math.ceil(width / microBlockSize);
var numBlocksY = Math.ceil(height / microBlockSize);
data.pixels.numBlocksY = numBlocksY;
data.pixels.numBlocksX = numBlocksX;
data.pixels.ptr = 0;
var row = 0, col = 0, blockY = 0, blockX = 0, thisBlockHeight = 0, thisBlockWidth = 0, bytesLeft = 0, headerByte = 0, bits67 = 0, testCode = 0, outPtr = 0, outStride = 0, numBytes = 0, bytesleft = 0, z = 0, blockPtr = 0;
var view, block, arrayBuf, store8, rawData;
var blockEncoding;
var blockDataBuffer = new OutPixelTypeArray(microBlockSize * microBlockSize);
var lastBlockHeight = height % microBlockSize || microBlockSize;
var lastBlockWidth = width % microBlockSize || microBlockSize;
var offsetType, offset;
var numDims = headerInfo.numDims, iDim;
var mask = data.pixels.resultMask;
var resultPixels = data.pixels.resultPixels;
for (blockY = 0; blockY < numBlocksY; blockY++) {
thisBlockHeight = blockY !== numBlocksY - 1 ? microBlockSize : lastBlockHeight;
for (blockX = 0; blockX < numBlocksX; blockX++) {
thisBlockWidth = blockX !== numBlocksX - 1 ? microBlockSize : lastBlockWidth;
outPtr = blockY * width * microBlockSize + blockX * microBlockSize;
outStride = width - thisBlockWidth;
for (iDim = 0; iDim < numDims; iDim++) {
if (numDims > 1) {
resultPixels = new OutPixelTypeArray(data.pixels.resultPixels.buffer, width * height * iDim * dataTypeSize, width * height);
}
bytesLeft = input.byteLength - data.ptr;
view = new DataView(input, data.ptr, Math.min(10, bytesLeft));
block = {};
blockPtr = 0;
headerByte = view.getUint8(0);
blockPtr++;
bits67 = headerByte >> 6 & 255;
testCode = headerByte >> 2 & 15;
if (testCode !== (blockX * microBlockSize >> 3 & 15)) {
throw "integrity issue";
}
blockEncoding = headerByte & 3;
if (blockEncoding > 3) {
data.ptr += blockPtr;
throw "Invalid block encoding (" + blockEncoding + ")";
} else if (blockEncoding === 2) {
data.counter.constant++;
data.ptr += blockPtr;
continue;
} else if (blockEncoding === 0) {
data.counter.uncompressed++;
data.ptr += blockPtr;
numBytes = thisBlockHeight * thisBlockWidth * dataTypeSize;
bytesleft = input.byteLength - data.ptr;
numBytes = numBytes < bytesleft ? numBytes : bytesleft;
arrayBuf = new ArrayBuffer(numBytes % dataTypeSize === 0 ? numBytes : numBytes + dataTypeSize - numBytes % dataTypeSize);
store8 = new Uint8Array(arrayBuf);
store8.set(new Uint8Array(input, data.ptr, numBytes));
rawData = new OutPixelTypeArray(arrayBuf);
z = 0;
if (mask) {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
if (mask[outPtr]) {
resultPixels[outPtr] = rawData[z++];
}
outPtr++;
}
outPtr += outStride;
}
} else {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
resultPixels[outPtr++] = rawData[z++];
}
outPtr += outStride;
}
}
data.ptr += z * dataTypeSize;
} else {
offsetType = Lerc2Helpers.getDataTypeUsed(imageType, bits67);
offset = Lerc2Helpers.getOnePixel(block, blockPtr, offsetType, view);
blockPtr += Lerc2Helpers.getDataTypeSize(offsetType);
if (blockEncoding === 3) {
data.ptr += blockPtr;
data.counter.constantoffset++;
if (mask) {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
if (mask[outPtr]) {
resultPixels[outPtr] = offset;
}
outPtr++;
}
outPtr += outStride;
}
} else {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
resultPixels[outPtr++] = offset;
}
outPtr += outStride;
}
}
} else {
data.ptr += blockPtr;
Lerc2Helpers.decodeBits(input, data, blockDataBuffer, offset, iDim);
blockPtr = 0;
if (mask) {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
if (mask[outPtr]) {
resultPixels[outPtr] = blockDataBuffer[blockPtr++];
}
outPtr++;
}
outPtr += outStride;
}
} else {
for (row = 0; row < thisBlockHeight; row++) {
for (col = 0; col < thisBlockWidth; col++) {
resultPixels[outPtr++] = blockDataBuffer[blockPtr++];
}
outPtr += outStride;
}
}
}
}
}
}
}
},
/*****************
* private methods (helper methods)
*****************/
formatFileInfo: function(data) {
return {
"fileIdentifierString": data.headerInfo.fileIdentifierString,
"fileVersion": data.headerInfo.fileVersion,
"imageType": data.headerInfo.imageType,
"height": data.headerInfo.height,
"width": data.headerInfo.width,
"numValidPixel": data.headerInfo.numValidPixel,
"microBlockSize": data.headerInfo.microBlockSize,
"blobSize": data.headerInfo.blobSize,
"maxZError": data.headerInfo.maxZError,
"pixelType": Lerc2Helpers.getPixelType(data.headerInfo.imageType),
"eofOffset": data.eofOffset,
"mask": data.mask ? {
"numBytes": data.mask.numBytes
} : null,
"pixels": {
"numBlocksX": data.pixels.numBlocksX,
"numBlocksY": data.pixels.numBlocksY,
//"numBytes": data.pixels.numBytes,
"maxValue": data.headerInfo.zMax,
"minValue": data.headerInfo.zMin,
"noDataValue": data.noDataValue
}
};
},
constructConstantSurface: function(data) {
var val = data.headerInfo.zMax;
var numDims = data.headerInfo.numDims;
var numPixels = data.headerInfo.height * data.headerInfo.width;
var numPixelAllDims = numPixels * numDims;
var i = 0, k = 0, nStart = 0;
var mask = data.pixels.resultMask;
if (mask) {
if (numDims > 1) {
for (i = 0; i < numDims; i++) {
nStart = i * numPixels;
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[nStart + k] = val;
}
}
}
} else {
for (k = 0; k < numPixels; k++) {
if (mask[k]) {
data.pixels.resultPixels[k] = val;
}
}
}
} else {
if (data.pixels.resultPixels.fill) {
data.pixels.resultPixels.fill(val);
} else {
for (k = 0; k < numPixelAllDims; k++) {
data.pixels.resultPixels[k] = val;
}
}
}
return;
},
getDataTypeArray: function(t) {
var tp;
switch (t) {
case 0:
tp = Int8Array;
break;
case 1:
tp = Uint8Array;
break;
case 2:
tp = Int16Array;
break;
case 3:
tp = Uint16Array;
break;
case 4:
tp = Int32Array;
break;
case 5:
tp = Uint32Array;
break;
case 6:
tp = Float32Array;
break;
case 7:
tp = Float64Array;
break;
default:
tp = Float32Array;
}
return tp;
},
getPixelType: function(t) {
var tp;
switch (t) {
case 0:
tp = "S8";
break;
case 1:
tp = "U8";
break;
case 2:
tp = "S16";
break;
case 3:
tp = "U16";
break;
case 4:
tp = "S32";
break;
case 5:
tp = "U32";
break;
case 6:
tp = "F32";
break;
case 7:
tp = "F64";
break;
default:
tp = "F32";
}
return tp;
},
isValidPixelValue: function(t, val) {
if (val == null) {
return false;
}
var isValid;
switch (t) {
case 0:
isValid = val >= -128 && val <= 127;
break;
case 1:
isValid = val >= 0 && val <= 255;
break;
case 2:
isValid = val >= -32768 && val <= 32767;
break;
case 3:
isValid = val >= 0 && val <= 65536;
break;
case 4:
isValid = val >= -2147483648 && val <= 2147483647;
break;
case 5:
isValid = val >= 0 && val <= 4294967296;
break;
case 6:
isValid = val >= -34027999387901484e22 && val <= 34027999387901484e22;
break;
case 7:
isValid = val >= 5e-324 && val <= 17976931348623157e292;
break;
default:
isValid = false;
}
return isValid;
},
getDataTypeSize: function(t) {
var s = 0;
switch (t) {
case 0:
//ubyte
case 1:
s = 1;
break;
case 2:
//short
case 3:
s = 2;
break;
case 4:
case 5:
case 6:
s = 4;
break;
case 7:
s = 8;
break;
default:
s = t;
}
return s;
},
getDataTypeUsed: function(dt, tc) {
var t = dt;
switch (dt) {
case 2:
//short
case 4:
t = dt - tc;
break;
case 3:
//ushort
case 5:
t = dt - 2 * tc;
break;
case 6:
if (0 === tc) {
t = dt;
} else if (1 === tc) {
t = 2;
} else {
t = 1;
}
break;
case 7:
if (0 === tc) {
t = dt;
} else {
t = dt - 2 * tc + 1;
}
break;
default:
t = dt;
break;
}
return t;
},
getOnePixel: function(block, blockPtr, offsetType, view) {
var temp = 0;
switch (offsetType) {
case 0:
temp = view.getInt8(blockPtr);
break;
case 1:
temp = view.getUint8(blockPtr);
break;
case 2:
temp = view.getInt16(blockPtr, true);
break;
case 3:
temp = view.getUint16(blockPtr, true);
break;
case 4:
temp = view.getInt32(blockPtr, true);
break;
case 5:
temp = view.getUInt32(blockPtr, true);
break;
case 6:
temp = view.getFloat32(blockPtr, true);
break;
case 7:
temp = view.getFloat64(blockPtr, true);
break;
default:
throw "the decoder does not understand this pixel type";
}
return temp;
}
};
var TreeNode = function(val, left, right) {
this.val = val;
this.left = left;
this.right = right;
};
var Lerc2Decode2 = {
/*
* ********removed options compared to LERC1. We can bring some of them back if needed.
* removed pixel type. LERC2 is typed and doesn't require user to give pixel type
* changed encodedMaskData to maskData. LERC2 's js version make it faster to use maskData directly.
* removed returnMask. mask is used by LERC2 internally and is cost free. In case of user input mask, it's returned as well and has neglible cost.
* removed nodatavalue. Because LERC2 pixels are typed, nodatavalue will sacrify a useful value for many types (8bit, 16bit) etc,
* user has to be knowledgable enough about raster and their data to avoid usability issues. so nodata value is simply removed now.
* We can add it back later if their's a clear requirement.
* removed encodedMask. This option was not implemented in LercDecode. It can be done after decoding (less efficient)
* removed computeUsedBitDepths.
*
*
* response changes compared to LERC1
* 1. encodedMaskData is not available
* 2. noDataValue is optional (returns only if user's noDataValue is with in the valid data type range)
* 3. maskData is always available
*/
/*****************
* public properties
******************/
//HUFFMAN_LUT_BITS_MAX: 12, //use 2^12 lut, not configurable
/*****************
* public methods
*****************/
/**
* Decode a LERC2 byte stream and return an object containing the pixel data and optional metadata.
*
* @param {ArrayBuffer} input The LERC input byte stream
* @param {object} [options] options Decoding options
* @param {number} [options.inputOffset] The number of bytes to skip in the input byte stream. A valid LERC file is expected at that position
* @param {boolean} [options.returnFileInfo] If true, the return value will have a fileInfo property that contains metadata obtained from the LERC headers and the decoding process
*/
decode: function(input, options) {
options = options || {};
var noDataValue = options.noDataValue;
var i = 0, data = {};
data.ptr = options.inputOffset || 0;
data.pixels = {};
if (!Lerc2Helpers.readHeaderInfo(input, data)) {
return;
}
var headerInfo = data.headerInfo;
var fileVersion = headerInfo.fileVersion;
var OutPixelTypeArray = Lerc2Helpers.getDataTypeArray(headerInfo.imageType);
Lerc2Helpers.readMask(input, data);
if (headerInfo.numValidPixel !== headerInfo.width * headerInfo.height && !data.pixels.resultMask) {
data.pixels.resultMask = options.maskData;
}
var numPixels = headerInfo.width * headerInfo.height;
data.pixels.resultPixels = new OutPixelTypeArray(numPixels * headerInfo.numDims);
data.counter = {
onesweep: 0,
uncompressed: 0,
lut: 0,
bitstuffer: 0,
constant: 0,
constantoffset: 0
};
if (headerInfo.numValidPixel !== 0) {
if (headerInfo.zMax === headerInfo.zMin) {
Lerc2Helpers.constructConstantSurface(data);
} else if (fileVersion >= 4 && Lerc2Helpers.checkMinMaxRanges(input, data)) {
Lerc2Helpers.constructConstantSurface(data);
} else {
var view = new DataView(input, data.ptr, 2);
var bReadDataOneSweep = view.getUint8(0);
data.ptr++;
if (bReadDataOneSweep) {
Lerc2Helpers.readDataOneSweep(input, data, OutPixelTypeArray);
} else {
if (fileVersion > 1 && headerInfo.imageType <= 1 && Math.abs(headerInfo.maxZError - 0.5) < 1e-5) {
var flagHuffman = view.getUint8(1);
data.ptr++;
data.encodeMode = flagHuffman;
if (flagHuffman > 2 || fileVersion < 4 && flagHuffman > 1) {
throw "Invalid Huffman flag " + flagHuffman;
}
if (flagHuffman) {
Lerc2Helpers.readHuffman(input, data, OutPixelTypeArray);
} else {
Lerc2Helpers.readTiles(input, data, OutPixelTypeArray);
}
} else {
Lerc2Helpers.readTiles(input, data, OutPixelTypeArray);
}
}
}
}
data.eofOffset = data.ptr;
var diff;
if (options.inputOffset) {
diff = data.headerInfo.blobSize + options.inputOffset - data.ptr;
if (Math.abs(diff) >= 1) {
data.eofOffset = options.inputOffset + data.headerInfo.blobSize;
}
} else {
diff = data.headerInfo.blobSize - data.ptr;
if (Math.abs(diff) >= 1) {
data.eofOffset = data.headerInfo.blobSize;
}
}
var result = {
width: headerInfo.width,
height: headerInfo.height,
pixelData: data.pixels.resultPixels,
minValue: headerInfo.zMin,
maxValue: headerInfo.zMax,
validPixelCount: headerInfo.numValidPixel,
dimCount: headerInfo.numDims,
dimStats: {
minValues: headerInfo.minValues,
maxValues: headerInfo.maxValues
},
maskData: data.pixels.resultMask
//noDataValue: noDataValue
};
if (data.pixels.resultMask && Lerc2Helpers.isValidPixelValue(headerInfo.imageType, noDataValue)) {
var mask = data.pixels.resultMask;
for (i = 0; i < numPixels; i++) {
if (!mask[i]) {
result.pixelData[i] = noDataValue;
}
}
result.noDataValue = noDataValue;
}
data.noDataValue = noDataValue;
if (options.returnFileInfo) {
result.fileInfo = Lerc2Helpers.formatFileInfo(data);
}
return result;
},
getBandCount: function(input) {
var count = 0;
var i = 0;
var temp = {};
temp.ptr = 0;
temp.pixels = {};
while (i < input.byteLength - 58) {
Lerc2Helpers.readHeaderInfo(input, temp);
i += temp.headerInfo.blobSize;
count++;
temp.ptr = i;
}
return count;
}
};
return Lerc2Decode2;
}();
var isPlatformLittleEndian = function() {
var a = new ArrayBuffer(4);
var b = new Uint8Array(a);
var c = new Uint32Array(a);
c[0] = 1;
return b[0] === 1;
}();
var Lerc2 = {
/************wrapper**********************************************/
/**
* A wrapper for decoding both LERC1 and LERC2 byte streams capable of handling multiband pixel blocks for various pixel types.
*
* @alias module:Lerc
* @param {ArrayBuffer} input The LERC input byte stream
* @param {object} [options] The decoding options below are optional.
* @param {number} [options.inputOffset] The number of bytes to skip in the input byte stream. A valid Lerc file is expected at that position.
* @param {string} [options.pixelType] (LERC1 only) Default value is F32. Valid pixel types for input are U8/S8/S16/U16/S32/U32/F32.
* @param {number} [options.noDataValue] (LERC1 only). It is recommended to use the returned mask instead of setting this value.
* @returns {{width, height, pixels, pixelType, mask, statistics}}
* @property {number} width Width of decoded image.
* @property {number} height Height of decoded image.
* @property {array} pixels [band1, band2, …] Each band is a typed array of width*height.
* @property {string} pixelType The type of pixels represented in the output.
* @property {mask} mask Typed array with a size of width*height, or null if all pixels are valid.
* @property {array} statistics [statistics_band1, statistics_band2, …] Each element is a statistics object representing min and max values
**/
decode: function(encodedData, options) {
if (!isPlatformLittleEndian) {
throw "Big endian system is not supported.";
}
options = options || {};
var inputOffset = options.inputOffset || 0;
var fileIdView = new Uint8Array(encodedData, inputOffset, 10);
var fileIdentifierString = String.fromCharCode.apply(null, fileIdView);
var lerc, majorVersion;
if (fileIdentifierString.trim() === "CntZImage") {
lerc = LercDecode;
majorVersion = 1;
} else if (fileIdentifierString.substring(0, 5) === "Lerc2") {
lerc = Lerc2Decode;
majorVersion = 2;
} else {
throw "Unexpected file identifier string: " + fileIdentifierString;
}
var iPlane = 0, eof = encodedData.byteLength - 10, encodedMaskData, bandMasks = [], bandMask, maskData;
var decodedPixelBlock = {
width: 0,
height: 0,
pixels: [],
pixelType: options.pixelType,
mask: null,
statistics: []
};
while (inputOffset < eof) {
var result = lerc.decode(encodedData, {
inputOffset,
//for both lerc1 and lerc2
encodedMaskData,
//lerc1 only
maskData,
//lerc2 only
returnMask: iPlane === 0 ? true : false,
//lerc1 only
returnEncodedMask: iPlane === 0 ? true : false,
//lerc1 only
returnFileInfo: true,
//for both lerc1 and lerc2
pixelType: options.pixelType || null,
//lerc1 only
noDataValue: options.noDataValue || null
//lerc1 only
});
inputOffset = result.fileInfo.eofOffset;
if (iPlane === 0) {
encodedMaskData = result.encodedMaskData;
maskData = result.maskData;
decodedPixelBlock.width = result.width;
decodedPixelBlock.height = result.height;
decodedPixelBlock.dimCount = result.dimCount || 1;
decodedPixelBlock.pixelType = result.pixelType || result.fileInfo.pixelType;
decodedPixelBlock.mask = result.maskData;
}
if (majorVersion > 1 && result.fileInfo.mask && result.fileInfo.mask.numBytes > 0) {
bandMasks.push(result.maskData);
}
iPlane++;
decodedPixelBlock.pixels.push(result.pixelData);
decodedPixelBlock.statistics.push({
minValue: result.minValue,
maxValue: result.maxValue,
noDataValue: result.noDataValue,
dimStats: result.dimStats
});
}
var i, j, numPixels;
if (majorVersion > 1 && bandMasks.length > 1) {
numPixels = decodedPixelBlock.width * decodedPixelBlock.height;
decodedPixelBlock.bandMasks = bandMasks;
maskData = new Uint8Array(numPixels);
maskData.set(bandMasks[0]);
for (i = 1; i < bandMasks.length; i++) {
bandMask = bandMasks[i];
for (j = 0; j < numPixels; j++) {
maskData[j] = maskData[j] & bandMask[j];
}
}
decodedPixelBlock.maskData = maskData;
}
return decodedPixelBlock;
}
};
if (typeof define === "function" && define.amd) {
define([], function() {
return Lerc2;
});
} else if (typeof module !== "undefined" && module.exports) {
module.exports = Lerc2;
} else {
this.Lerc = Lerc2;
}
})();
}
});
// packages/engine/Source/Core/HeightmapEncoding.js
var HeightmapEncoding = {
/**
* No encoding
*
* @type {number}
* @constant
*/
NONE: 0,
/**
* LERC encoding
*
* @type {number}
* @constant
*
* @see {@link https://github.com/Esri/lerc|The LERC specification}
*/
LERC: 1
};
var HeightmapEncoding_default = Object.freeze(HeightmapEncoding);
// packages/engine/Source/Core/HeightmapTessellator.js
var HeightmapTessellator = {};
HeightmapTessellator.DEFAULT_STRUCTURE = Object.freeze({
heightScale: 1,
heightOffset: 0,
elementsPerHeight: 1,
stride: 1,
elementMultiplier: 256,
isBigEndian: false
});
var cartesian3Scratch = new Cartesian3_default();
var matrix4Scratch = new Matrix4_default();
var minimumScratch = new Cartesian3_default();
var maximumScratch = new Cartesian3_default();
HeightmapTessellator.computeVertices = function(options) {
if (!defined_default(options) || !defined_default(options.heightmap)) {
throw new DeveloperError_default("options.heightmap is required.");
}
if (!defined_default(options.width) || !defined_default(options.height)) {
throw new DeveloperError_default("options.width and options.height are required.");
}
if (!defined_default(options.nativeRectangle)) {
throw new DeveloperError_default("options.nativeRectangle is required.");
}
if (!defined_default(options.skirtHeight)) {
throw new DeveloperError_default("options.skirtHeight is required.");
}
const cos = Math.cos;
const sin = Math.sin;
const sqrt = Math.sqrt;
const atan = Math.atan;
const exp = Math.exp;
const piOverTwo = Math_default.PI_OVER_TWO;
const toRadians = Math_default.toRadians;
const heightmap = options.heightmap;
const width = options.width;
const height = options.height;
const skirtHeight = options.skirtHeight;
const hasSkirts = skirtHeight > 0;
const isGeographic = defaultValue_default(options.isGeographic, true);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.default);
const oneOverGlobeSemimajorAxis = 1 / ellipsoid.maximumRadius;
const nativeRectangle = Rectangle_default.clone(options.nativeRectangle);
const rectangle = Rectangle_default.clone(options.rectangle);
let geographicWest;
let geographicSouth;
let geographicEast;
let geographicNorth;
if (!defined_default(rectangle)) {
if (isGeographic) {
geographicWest = toRadians(nativeRectangle.west);
geographicSouth = toRadians(nativeRectangle.south);
geographicEast = toRadians(nativeRectangle.east);
geographicNorth = toRadians(nativeRectangle.north);
} else {
geographicWest = nativeRectangle.west * oneOverGlobeSemimajorAxis;
geographicSouth = piOverTwo - 2 * atan(exp(-nativeRectangle.south * oneOverGlobeSemimajorAxis));
geographicEast = nativeRectangle.east * oneOverGlobeSemimajorAxis;
geographicNorth = piOverTwo - 2 * atan(exp(-nativeRectangle.north * oneOverGlobeSemimajorAxis));
}
} else {
geographicWest = rectangle.west;
geographicSouth = rectangle.south;
geographicEast = rectangle.east;
geographicNorth = rectangle.north;
}
let relativeToCenter = options.relativeToCenter;
const hasRelativeToCenter = defined_default(relativeToCenter);
relativeToCenter = hasRelativeToCenter ? relativeToCenter : Cartesian3_default.ZERO;
const includeWebMercatorT = defaultValue_default(options.includeWebMercatorT, false);
const exaggeration = defaultValue_default(options.exaggeration, 1);
const exaggerationRelativeHeight = defaultValue_default(
options.exaggerationRelativeHeight,
0
);
const hasExaggeration = exaggeration !== 1;
const includeGeodeticSurfaceNormals = hasExaggeration;
const structure = defaultValue_default(
options.structure,
HeightmapTessellator.DEFAULT_STRUCTURE
);
const heightScale = defaultValue_default(
structure.heightScale,
HeightmapTessellator.DEFAULT_STRUCTURE.heightScale
);
const heightOffset = defaultValue_default(
structure.heightOffset,
HeightmapTessellator.DEFAULT_STRUCTURE.heightOffset
);
const elementsPerHeight = defaultValue_default(
structure.elementsPerHeight,
HeightmapTessellator.DEFAULT_STRUCTURE.elementsPerHeight
);
const stride = defaultValue_default(
structure.stride,
HeightmapTessellator.DEFAULT_STRUCTURE.stride
);
const elementMultiplier = defaultValue_default(
structure.elementMultiplier,
HeightmapTessellator.DEFAULT_STRUCTURE.elementMultiplier
);
const isBigEndian = defaultValue_default(
structure.isBigEndian,
HeightmapTessellator.DEFAULT_STRUCTURE.isBigEndian
);
let rectangleWidth = Rectangle_default.computeWidth(nativeRectangle);
let rectangleHeight = Rectangle_default.computeHeight(nativeRectangle);
const granularityX = rectangleWidth / (width - 1);
const granularityY = rectangleHeight / (height - 1);
if (!isGeographic) {
rectangleWidth *= oneOverGlobeSemimajorAxis;
rectangleHeight *= oneOverGlobeSemimajorAxis;
}
const radiiSquared = ellipsoid.radiiSquared;
const radiiSquaredX = radiiSquared.x;
const radiiSquaredY = radiiSquared.y;
const radiiSquaredZ = radiiSquared.z;
let minimumHeight = 65536;
let maximumHeight = -65536;
const fromENU = Transforms_default.eastNorthUpToFixedFrame(
relativeToCenter,
ellipsoid
);
const toENU = Matrix4_default.inverseTransformation(fromENU, matrix4Scratch);
let southMercatorY;
let oneOverMercatorHeight;
if (includeWebMercatorT) {
southMercatorY = WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(
geographicSouth
);
oneOverMercatorHeight = 1 / (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(geographicNorth) - southMercatorY);
}
const minimum = minimumScratch;
minimum.x = Number.POSITIVE_INFINITY;
minimum.y = Number.POSITIVE_INFINITY;
minimum.z = Number.POSITIVE_INFINITY;
const maximum = maximumScratch;
maximum.x = Number.NEGATIVE_INFINITY;
maximum.y = Number.NEGATIVE_INFINITY;
maximum.z = Number.NEGATIVE_INFINITY;
let hMin = Number.POSITIVE_INFINITY;
const gridVertexCount = width * height;
const edgeVertexCount = skirtHeight > 0 ? width * 2 + height * 2 : 0;
const vertexCount = gridVertexCount + edgeVertexCount;
const positions = new Array(vertexCount);
const heights = new Array(vertexCount);
const uvs = new Array(vertexCount);
const webMercatorTs = includeWebMercatorT ? new Array(vertexCount) : [];
const geodeticSurfaceNormals = includeGeodeticSurfaceNormals ? new Array(vertexCount) : [];
let startRow = 0;
let endRow = height;
let startCol = 0;
let endCol = width;
if (hasSkirts) {
--startRow;
++endRow;
--startCol;
++endCol;
}
const skirtOffsetPercentage = 1e-5;
for (let rowIndex = startRow; rowIndex < endRow; ++rowIndex) {
let row = rowIndex;
if (row < 0) {
row = 0;
}
if (row >= height) {
row = height - 1;
}
let latitude = nativeRectangle.north - granularityY * row;
if (!isGeographic) {
latitude = piOverTwo - 2 * atan(exp(-latitude * oneOverGlobeSemimajorAxis));
} else {
latitude = toRadians(latitude);
}
let v = (latitude - geographicSouth) / (geographicNorth - geographicSouth);
v = Math_default.clamp(v, 0, 1);
const isNorthEdge = rowIndex === startRow;
const isSouthEdge = rowIndex === endRow - 1;
if (skirtHeight > 0) {
if (isNorthEdge) {
latitude += skirtOffsetPercentage * rectangleHeight;
} else if (isSouthEdge) {
latitude -= skirtOffsetPercentage * rectangleHeight;
}
}
const cosLatitude = cos(latitude);
const nZ = sin(latitude);
const kZ = radiiSquaredZ * nZ;
let webMercatorT;
if (includeWebMercatorT) {
webMercatorT = (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(latitude) - southMercatorY) * oneOverMercatorHeight;
}
for (let colIndex = startCol; colIndex < endCol; ++colIndex) {
let col = colIndex;
if (col < 0) {
col = 0;
}
if (col >= width) {
col = width - 1;
}
const terrainOffset = row * (width * stride) + col * stride;
let heightSample;
if (elementsPerHeight === 1) {
heightSample = heightmap[terrainOffset];
} else {
heightSample = 0;
let elementOffset;
if (isBigEndian) {
for (elementOffset = 0; elementOffset < elementsPerHeight; ++elementOffset) {
heightSample = heightSample * elementMultiplier + heightmap[terrainOffset + elementOffset];
}
} else {
for (elementOffset = elementsPerHeight - 1; elementOffset >= 0; --elementOffset) {
heightSample = heightSample * elementMultiplier + heightmap[terrainOffset + elementOffset];
}
}
}
heightSample = heightSample * heightScale + heightOffset;
maximumHeight = Math.max(maximumHeight, heightSample);
minimumHeight = Math.min(minimumHeight, heightSample);
let longitude = nativeRectangle.west + granularityX * col;
if (!isGeographic) {
longitude = longitude * oneOverGlobeSemimajorAxis;
} else {
longitude = toRadians(longitude);
}
let u = (longitude - geographicWest) / (geographicEast - geographicWest);
u = Math_default.clamp(u, 0, 1);
let index = row * width + col;
if (skirtHeight > 0) {
const isWestEdge = colIndex === startCol;
const isEastEdge = colIndex === endCol - 1;
const isEdge = isNorthEdge || isSouthEdge || isWestEdge || isEastEdge;
const isCorner = (isNorthEdge || isSouthEdge) && (isWestEdge || isEastEdge);
if (isCorner) {
continue;
} else if (isEdge) {
heightSample -= skirtHeight;
if (isWestEdge) {
index = gridVertexCount + (height - row - 1);
longitude -= skirtOffsetPercentage * rectangleWidth;
} else if (isSouthEdge) {
index = gridVertexCount + height + (width - col - 1);
} else if (isEastEdge) {
index = gridVertexCount + height + width + row;
longitude += skirtOffsetPercentage * rectangleWidth;
} else if (isNorthEdge) {
index = gridVertexCount + height + width + height + col;
}
}
}
const nX = cosLatitude * cos(longitude);
const nY = cosLatitude * sin(longitude);
const kX = radiiSquaredX * nX;
const kY = radiiSquaredY * nY;
const gamma = sqrt(kX * nX + kY * nY + kZ * nZ);
const oneOverGamma = 1 / gamma;
const rSurfaceX = kX * oneOverGamma;
const rSurfaceY = kY * oneOverGamma;
const rSurfaceZ = kZ * oneOverGamma;
const position = new Cartesian3_default();
position.x = rSurfaceX + nX * heightSample;
position.y = rSurfaceY + nY * heightSample;
position.z = rSurfaceZ + nZ * heightSample;
Matrix4_default.multiplyByPoint(toENU, position, cartesian3Scratch);
Cartesian3_default.minimumByComponent(cartesian3Scratch, minimum, minimum);
Cartesian3_default.maximumByComponent(cartesian3Scratch, maximum, maximum);
hMin = Math.min(hMin, heightSample);
positions[index] = position;
uvs[index] = new Cartesian2_default(u, v);
heights[index] = heightSample;
if (includeWebMercatorT) {
webMercatorTs[index] = webMercatorT;
}
if (includeGeodeticSurfaceNormals) {
geodeticSurfaceNormals[index] = ellipsoid.geodeticSurfaceNormal(
position
);
}
}
}
const boundingSphere3D = BoundingSphere_default.fromPoints(positions);
let orientedBoundingBox;
if (defined_default(rectangle)) {
orientedBoundingBox = OrientedBoundingBox_default.fromRectangle(
rectangle,
minimumHeight,
maximumHeight,
ellipsoid
);
}
let occludeePointInScaledSpace;
if (hasRelativeToCenter) {
const occluder = new EllipsoidalOccluder_default(ellipsoid);
occludeePointInScaledSpace = occluder.computeHorizonCullingPointPossiblyUnderEllipsoid(
relativeToCenter,
positions,
minimumHeight
);
}
const aaBox = new AxisAlignedBoundingBox_default(minimum, maximum, relativeToCenter);
const encoding = new TerrainEncoding_default(
relativeToCenter,
aaBox,
hMin,
maximumHeight,
fromENU,
false,
includeWebMercatorT,
includeGeodeticSurfaceNormals,
exaggeration,
exaggerationRelativeHeight
);
const vertices = new Float32Array(vertexCount * encoding.stride);
let bufferIndex = 0;
for (let j = 0; j < vertexCount; ++j) {
bufferIndex = encoding.encode(
vertices,
bufferIndex,
positions[j],
uvs[j],
heights[j],
void 0,
webMercatorTs[j],
geodeticSurfaceNormals[j]
);
}
return {
vertices,
maximumHeight,
minimumHeight,
encoding,
boundingSphere3D,
orientedBoundingBox,
occludeePointInScaledSpace
};
};
var HeightmapTessellator_default = HeightmapTessellator;
// packages/engine/Source/Workers/createVerticesFromHeightmap.js
var import_lerc = __toESM(require_LercDecode(), 1);
function createVerticesFromHeightmap(parameters, transferableObjects) {
if (parameters.encoding === HeightmapEncoding_default.LERC) {
let result;
try {
result = import_lerc.default.decode(parameters.heightmap);
} catch (error) {
throw new RuntimeError_default(error);
}
const lercStatistics = result.statistics[0];
if (lercStatistics.minValue === Number.MAX_VALUE) {
throw new RuntimeError_default("Invalid tile data");
}
parameters.heightmap = result.pixels[0];
parameters.width = result.width;
parameters.height = result.height;
}
parameters.ellipsoid = Ellipsoid_default.clone(parameters.ellipsoid);
parameters.rectangle = Rectangle_default.clone(parameters.rectangle);
const statistics = HeightmapTessellator_default.computeVertices(parameters);
const vertices = statistics.vertices;
transferableObjects.push(vertices.buffer);
return {
vertices: vertices.buffer,
numberOfAttributes: statistics.encoding.stride,
minimumHeight: statistics.minimumHeight,
maximumHeight: statistics.maximumHeight,
gridWidth: parameters.width,
gridHeight: parameters.height,
boundingSphere3D: statistics.boundingSphere3D,
orientedBoundingBox: statistics.orientedBoundingBox,
occludeePointInScaledSpace: statistics.occludeePointInScaledSpace,
encoding: statistics.encoding,
westIndicesSouthToNorth: statistics.westIndicesSouthToNorth,
southIndicesEastToWest: statistics.southIndicesEastToWest,
eastIndicesNorthToSouth: statistics.eastIndicesNorthToSouth,
northIndicesWestToEast: statistics.northIndicesWestToEast
};
}
var createVerticesFromHeightmap_default = createTaskProcessorWorker_default(createVerticesFromHeightmap);
export {
createVerticesFromHeightmap_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
EllipsoidalOccluder_default,
TerrainEncoding_default
} from "./chunk-56EDBCGT.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
WebMercatorProjection_default
} from "./chunk-RJM36CNY.js";
import "./chunk-LJ2JQHJT.js";
import {
AxisAlignedBoundingBox_default
} from "./chunk-NDDI2LWR.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import "./chunk-KHZNBFOH.js";
import {
Matrix4_default,
Rectangle_default,
Transforms_default
} from "./chunk-6SQMLVGV.js";
import "./chunk-XIUSRWL6.js";
import {
Cartesian2_default,
Cartesian3_default,
Cartographic_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/TerrainProvider.js
function TerrainProvider() {
DeveloperError_default.throwInstantiationError();
}
Object.defineProperties(TerrainProvider.prototype, {
/**
* Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing
* to the event, you will be notified of the error and can potentially recover from it. Event listeners
* are passed an instance of {@link TileProviderError}.
* @memberof TerrainProvider.prototype
* @type {Event<TerrainProvider.ErrorEvent>}
* @readonly
*/
errorEvent: {
get: DeveloperError_default.throwInstantiationError
},
/**
* Gets the credit to display when this terrain provider is active. Typically this is used to credit
* the source of the terrain.
* @memberof TerrainProvider.prototype
* @type {Credit}
* @readonly
*/
credit: {
get: DeveloperError_default.throwInstantiationError
},
/**
* Gets the tiling scheme used by the provider.
* @memberof TerrainProvider.prototype
* @type {TilingScheme}
* @readonly
*/
tilingScheme: {
get: DeveloperError_default.throwInstantiationError
},
/**
* Gets a value indicating whether or not the provider includes a water mask. The water mask
* indicates which areas of the globe are water rather than land, so they can be rendered
* as a reflective surface with animated waves.
* @memberof TerrainProvider.prototype
* @type {boolean}
* @readonly
*/
hasWaterMask: {
get: DeveloperError_default.throwInstantiationError
},
/**
* Gets a value indicating whether or not the requested tiles include vertex normals.
* @memberof TerrainProvider.prototype
* @type {boolean}
* @readonly
*/
hasVertexNormals: {
get: DeveloperError_default.throwInstantiationError
},
/**
* Gets an object that can be used to determine availability of terrain from this provider, such as
* at points and in rectangles. This property may be undefined if availability
* information is not available.
* @memberof TerrainProvider.prototype
* @type {TileAvailability}
* @readonly
*/
availability: {
get: DeveloperError_default.throwInstantiationError
}
});
var regularGridIndicesCache = [];
TerrainProvider.getRegularGridIndices = function(width, height) {
if (width * height >= Math_default.FOUR_GIGABYTES) {
throw new DeveloperError_default(
"The total number of vertices (width * height) must be less than 4,294,967,296."
);
}
let byWidth = regularGridIndicesCache[width];
if (!defined_default(byWidth)) {
regularGridIndicesCache[width] = byWidth = [];
}
let indices = byWidth[height];
if (!defined_default(indices)) {
if (width * height < Math_default.SIXTY_FOUR_KILOBYTES) {
indices = byWidth[height] = new Uint16Array(
(width - 1) * (height - 1) * 6
);
} else {
indices = byWidth[height] = new Uint32Array(
(width - 1) * (height - 1) * 6
);
}
addRegularGridIndices(width, height, indices, 0);
}
return indices;
};
var regularGridAndEdgeIndicesCache = [];
TerrainProvider.getRegularGridIndicesAndEdgeIndices = function(width, height) {
if (width * height >= Math_default.FOUR_GIGABYTES) {
throw new DeveloperError_default(
"The total number of vertices (width * height) must be less than 4,294,967,296."
);
}
let byWidth = regularGridAndEdgeIndicesCache[width];
if (!defined_default(byWidth)) {
regularGridAndEdgeIndicesCache[width] = byWidth = [];
}
let indicesAndEdges = byWidth[height];
if (!defined_default(indicesAndEdges)) {
const indices = TerrainProvider.getRegularGridIndices(width, height);
const edgeIndices = getEdgeIndices(width, height);
const westIndicesSouthToNorth = edgeIndices.westIndicesSouthToNorth;
const southIndicesEastToWest = edgeIndices.southIndicesEastToWest;
const eastIndicesNorthToSouth = edgeIndices.eastIndicesNorthToSouth;
const northIndicesWestToEast = edgeIndices.northIndicesWestToEast;
indicesAndEdges = byWidth[height] = {
indices,
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast
};
}
return indicesAndEdges;
};
var regularGridAndSkirtAndEdgeIndicesCache = [];
TerrainProvider.getRegularGridAndSkirtIndicesAndEdgeIndices = function(width, height) {
if (width * height >= Math_default.FOUR_GIGABYTES) {
throw new DeveloperError_default(
"The total number of vertices (width * height) must be less than 4,294,967,296."
);
}
let byWidth = regularGridAndSkirtAndEdgeIndicesCache[width];
if (!defined_default(byWidth)) {
regularGridAndSkirtAndEdgeIndicesCache[width] = byWidth = [];
}
let indicesAndEdges = byWidth[height];
if (!defined_default(indicesAndEdges)) {
const gridVertexCount = width * height;
const gridIndexCount = (width - 1) * (height - 1) * 6;
const edgeVertexCount = width * 2 + height * 2;
const edgeIndexCount = Math.max(0, edgeVertexCount - 4) * 6;
const vertexCount = gridVertexCount + edgeVertexCount;
const indexCount = gridIndexCount + edgeIndexCount;
const edgeIndices = getEdgeIndices(width, height);
const westIndicesSouthToNorth = edgeIndices.westIndicesSouthToNorth;
const southIndicesEastToWest = edgeIndices.southIndicesEastToWest;
const eastIndicesNorthToSouth = edgeIndices.eastIndicesNorthToSouth;
const northIndicesWestToEast = edgeIndices.northIndicesWestToEast;
const indices = IndexDatatype_default.createTypedArray(vertexCount, indexCount);
addRegularGridIndices(width, height, indices, 0);
TerrainProvider.addSkirtIndices(
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast,
gridVertexCount,
indices,
gridIndexCount
);
indicesAndEdges = byWidth[height] = {
indices,
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast,
indexCountWithoutSkirts: gridIndexCount
};
}
return indicesAndEdges;
};
TerrainProvider.addSkirtIndices = function(westIndicesSouthToNorth, southIndicesEastToWest, eastIndicesNorthToSouth, northIndicesWestToEast, vertexCount, indices, offset) {
let vertexIndex = vertexCount;
offset = addSkirtIndices(
westIndicesSouthToNorth,
vertexIndex,
indices,
offset
);
vertexIndex += westIndicesSouthToNorth.length;
offset = addSkirtIndices(
southIndicesEastToWest,
vertexIndex,
indices,
offset
);
vertexIndex += southIndicesEastToWest.length;
offset = addSkirtIndices(
eastIndicesNorthToSouth,
vertexIndex,
indices,
offset
);
vertexIndex += eastIndicesNorthToSouth.length;
addSkirtIndices(northIndicesWestToEast, vertexIndex, indices, offset);
};
function getEdgeIndices(width, height) {
const westIndicesSouthToNorth = new Array(height);
const southIndicesEastToWest = new Array(width);
const eastIndicesNorthToSouth = new Array(height);
const northIndicesWestToEast = new Array(width);
let i;
for (i = 0; i < width; ++i) {
northIndicesWestToEast[i] = i;
southIndicesEastToWest[i] = width * height - 1 - i;
}
for (i = 0; i < height; ++i) {
eastIndicesNorthToSouth[i] = (i + 1) * width - 1;
westIndicesSouthToNorth[i] = (height - i - 1) * width;
}
return {
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast
};
}
function addRegularGridIndices(width, height, indices, offset) {
let index = 0;
for (let j = 0; j < height - 1; ++j) {
for (let i = 0; i < width - 1; ++i) {
const upperLeft = index;
const lowerLeft = upperLeft + width;
const lowerRight = lowerLeft + 1;
const upperRight = upperLeft + 1;
indices[offset++] = upperLeft;
indices[offset++] = lowerLeft;
indices[offset++] = upperRight;
indices[offset++] = upperRight;
indices[offset++] = lowerLeft;
indices[offset++] = lowerRight;
++index;
}
++index;
}
}
function addSkirtIndices(edgeIndices, vertexIndex, indices, offset) {
let previousIndex = edgeIndices[0];
const length = edgeIndices.length;
for (let i = 1; i < length; ++i) {
const index = edgeIndices[i];
indices[offset++] = previousIndex;
indices[offset++] = index;
indices[offset++] = vertexIndex;
indices[offset++] = vertexIndex;
indices[offset++] = index;
indices[offset++] = vertexIndex + 1;
previousIndex = index;
++vertexIndex;
}
return offset;
}
TerrainProvider.heightmapTerrainQuality = 0.25;
TerrainProvider.getEstimatedLevelZeroGeometricErrorForAHeightmap = function(ellipsoid, tileImageWidth, numberOfTilesAtLevelZero) {
return ellipsoid.maximumRadius * 2 * Math.PI * TerrainProvider.heightmapTerrainQuality / (tileImageWidth * numberOfTilesAtLevelZero);
};
TerrainProvider.prototype.requestTileGeometry = DeveloperError_default.throwInstantiationError;
TerrainProvider.prototype.getLevelMaximumGeometricError = DeveloperError_default.throwInstantiationError;
TerrainProvider.prototype.getTileDataAvailable = DeveloperError_default.throwInstantiationError;
TerrainProvider.prototype.loadTileDataAvailability = DeveloperError_default.throwInstantiationError;
var TerrainProvider_default = TerrainProvider;
// packages/engine/Source/Workers/createVerticesFromQuantizedTerrainMesh.js
var maxShort = 32767;
var cartesian3Scratch = new Cartesian3_default();
var scratchMinimum = new Cartesian3_default();
var scratchMaximum = new Cartesian3_default();
var cartographicScratch = new Cartographic_default();
var toPack = new Cartesian2_default();
function createVerticesFromQuantizedTerrainMesh(parameters, transferableObjects) {
const quantizedVertices = parameters.quantizedVertices;
const quantizedVertexCount = quantizedVertices.length / 3;
const octEncodedNormals = parameters.octEncodedNormals;
const edgeVertexCount = parameters.westIndices.length + parameters.eastIndices.length + parameters.southIndices.length + parameters.northIndices.length;
const includeWebMercatorT = parameters.includeWebMercatorT;
const exaggeration = parameters.exaggeration;
const exaggerationRelativeHeight = parameters.exaggerationRelativeHeight;
const hasExaggeration = exaggeration !== 1;
const includeGeodeticSurfaceNormals = hasExaggeration;
const rectangle = Rectangle_default.clone(parameters.rectangle);
const west = rectangle.west;
const south = rectangle.south;
const east = rectangle.east;
const north = rectangle.north;
const ellipsoid = Ellipsoid_default.clone(parameters.ellipsoid);
const minimumHeight = parameters.minimumHeight;
const maximumHeight = parameters.maximumHeight;
const center = parameters.relativeToCenter;
const fromENU = Transforms_default.eastNorthUpToFixedFrame(center, ellipsoid);
const toENU = Matrix4_default.inverseTransformation(fromENU, new Matrix4_default());
let southMercatorY;
let oneOverMercatorHeight;
if (includeWebMercatorT) {
southMercatorY = WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(
south
);
oneOverMercatorHeight = 1 / (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(north) - southMercatorY);
}
const uBuffer = quantizedVertices.subarray(0, quantizedVertexCount);
const vBuffer = quantizedVertices.subarray(
quantizedVertexCount,
2 * quantizedVertexCount
);
const heightBuffer = quantizedVertices.subarray(
quantizedVertexCount * 2,
3 * quantizedVertexCount
);
const hasVertexNormals = defined_default(octEncodedNormals);
const uvs = new Array(quantizedVertexCount);
const heights = new Array(quantizedVertexCount);
const positions = new Array(quantizedVertexCount);
const webMercatorTs = includeWebMercatorT ? new Array(quantizedVertexCount) : [];
const geodeticSurfaceNormals = includeGeodeticSurfaceNormals ? new Array(quantizedVertexCount) : [];
const minimum = scratchMinimum;
minimum.x = Number.POSITIVE_INFINITY;
minimum.y = Number.POSITIVE_INFINITY;
minimum.z = Number.POSITIVE_INFINITY;
const maximum = scratchMaximum;
maximum.x = Number.NEGATIVE_INFINITY;
maximum.y = Number.NEGATIVE_INFINITY;
maximum.z = Number.NEGATIVE_INFINITY;
let minLongitude = Number.POSITIVE_INFINITY;
let maxLongitude = Number.NEGATIVE_INFINITY;
let minLatitude = Number.POSITIVE_INFINITY;
let maxLatitude = Number.NEGATIVE_INFINITY;
for (let i = 0; i < quantizedVertexCount; ++i) {
const rawU = uBuffer[i];
const rawV = vBuffer[i];
const u = rawU / maxShort;
const v = rawV / maxShort;
const height = Math_default.lerp(
minimumHeight,
maximumHeight,
heightBuffer[i] / maxShort
);
cartographicScratch.longitude = Math_default.lerp(west, east, u);
cartographicScratch.latitude = Math_default.lerp(south, north, v);
cartographicScratch.height = height;
minLongitude = Math.min(cartographicScratch.longitude, minLongitude);
maxLongitude = Math.max(cartographicScratch.longitude, maxLongitude);
minLatitude = Math.min(cartographicScratch.latitude, minLatitude);
maxLatitude = Math.max(cartographicScratch.latitude, maxLatitude);
const position = ellipsoid.cartographicToCartesian(cartographicScratch);
uvs[i] = new Cartesian2_default(u, v);
heights[i] = height;
positions[i] = position;
if (includeWebMercatorT) {
webMercatorTs[i] = (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(
cartographicScratch.latitude
) - southMercatorY) * oneOverMercatorHeight;
}
if (includeGeodeticSurfaceNormals) {
geodeticSurfaceNormals[i] = ellipsoid.geodeticSurfaceNormal(position);
}
Matrix4_default.multiplyByPoint(toENU, position, cartesian3Scratch);
Cartesian3_default.minimumByComponent(cartesian3Scratch, minimum, minimum);
Cartesian3_default.maximumByComponent(cartesian3Scratch, maximum, maximum);
}
const westIndicesSouthToNorth = copyAndSort(parameters.westIndices, function(a, b) {
return uvs[a].y - uvs[b].y;
});
const eastIndicesNorthToSouth = copyAndSort(parameters.eastIndices, function(a, b) {
return uvs[b].y - uvs[a].y;
});
const southIndicesEastToWest = copyAndSort(parameters.southIndices, function(a, b) {
return uvs[b].x - uvs[a].x;
});
const northIndicesWestToEast = copyAndSort(parameters.northIndices, function(a, b) {
return uvs[a].x - uvs[b].x;
});
let occludeePointInScaledSpace;
if (minimumHeight < 0) {
const occluder = new EllipsoidalOccluder_default(ellipsoid);
occludeePointInScaledSpace = occluder.computeHorizonCullingPointPossiblyUnderEllipsoid(
center,
positions,
minimumHeight
);
}
let hMin = minimumHeight;
hMin = Math.min(
hMin,
findMinMaxSkirts(
parameters.westIndices,
parameters.westSkirtHeight,
heights,
uvs,
rectangle,
ellipsoid,
toENU,
minimum,
maximum
)
);
hMin = Math.min(
hMin,
findMinMaxSkirts(
parameters.southIndices,
parameters.southSkirtHeight,
heights,
uvs,
rectangle,
ellipsoid,
toENU,
minimum,
maximum
)
);
hMin = Math.min(
hMin,
findMinMaxSkirts(
parameters.eastIndices,
parameters.eastSkirtHeight,
heights,
uvs,
rectangle,
ellipsoid,
toENU,
minimum,
maximum
)
);
hMin = Math.min(
hMin,
findMinMaxSkirts(
parameters.northIndices,
parameters.northSkirtHeight,
heights,
uvs,
rectangle,
ellipsoid,
toENU,
minimum,
maximum
)
);
const aaBox = new AxisAlignedBoundingBox_default(minimum, maximum, center);
const encoding = new TerrainEncoding_default(
center,
aaBox,
hMin,
maximumHeight,
fromENU,
hasVertexNormals,
includeWebMercatorT,
includeGeodeticSurfaceNormals,
exaggeration,
exaggerationRelativeHeight
);
const vertexStride = encoding.stride;
const size = quantizedVertexCount * vertexStride + edgeVertexCount * vertexStride;
const vertexBuffer = new Float32Array(size);
let bufferIndex = 0;
for (let j = 0; j < quantizedVertexCount; ++j) {
if (hasVertexNormals) {
const n = j * 2;
toPack.x = octEncodedNormals[n];
toPack.y = octEncodedNormals[n + 1];
}
bufferIndex = encoding.encode(
vertexBuffer,
bufferIndex,
positions[j],
uvs[j],
heights[j],
toPack,
webMercatorTs[j],
geodeticSurfaceNormals[j]
);
}
const edgeTriangleCount = Math.max(0, (edgeVertexCount - 4) * 2);
const indexBufferLength = parameters.indices.length + edgeTriangleCount * 3;
const indexBuffer = IndexDatatype_default.createTypedArray(
quantizedVertexCount + edgeVertexCount,
indexBufferLength
);
indexBuffer.set(parameters.indices, 0);
const percentage = 1e-4;
const lonOffset = (maxLongitude - minLongitude) * percentage;
const latOffset = (maxLatitude - minLatitude) * percentage;
const westLongitudeOffset = -lonOffset;
const westLatitudeOffset = 0;
const eastLongitudeOffset = lonOffset;
const eastLatitudeOffset = 0;
const northLongitudeOffset = 0;
const northLatitudeOffset = latOffset;
const southLongitudeOffset = 0;
const southLatitudeOffset = -latOffset;
let vertexBufferIndex = quantizedVertexCount * vertexStride;
addSkirt(
vertexBuffer,
vertexBufferIndex,
westIndicesSouthToNorth,
encoding,
heights,
uvs,
octEncodedNormals,
ellipsoid,
rectangle,
parameters.westSkirtHeight,
southMercatorY,
oneOverMercatorHeight,
westLongitudeOffset,
westLatitudeOffset
);
vertexBufferIndex += parameters.westIndices.length * vertexStride;
addSkirt(
vertexBuffer,
vertexBufferIndex,
southIndicesEastToWest,
encoding,
heights,
uvs,
octEncodedNormals,
ellipsoid,
rectangle,
parameters.southSkirtHeight,
southMercatorY,
oneOverMercatorHeight,
southLongitudeOffset,
southLatitudeOffset
);
vertexBufferIndex += parameters.southIndices.length * vertexStride;
addSkirt(
vertexBuffer,
vertexBufferIndex,
eastIndicesNorthToSouth,
encoding,
heights,
uvs,
octEncodedNormals,
ellipsoid,
rectangle,
parameters.eastSkirtHeight,
southMercatorY,
oneOverMercatorHeight,
eastLongitudeOffset,
eastLatitudeOffset
);
vertexBufferIndex += parameters.eastIndices.length * vertexStride;
addSkirt(
vertexBuffer,
vertexBufferIndex,
northIndicesWestToEast,
encoding,
heights,
uvs,
octEncodedNormals,
ellipsoid,
rectangle,
parameters.northSkirtHeight,
southMercatorY,
oneOverMercatorHeight,
northLongitudeOffset,
northLatitudeOffset
);
TerrainProvider_default.addSkirtIndices(
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast,
quantizedVertexCount,
indexBuffer,
parameters.indices.length
);
transferableObjects.push(vertexBuffer.buffer, indexBuffer.buffer);
return {
vertices: vertexBuffer.buffer,
indices: indexBuffer.buffer,
westIndicesSouthToNorth,
southIndicesEastToWest,
eastIndicesNorthToSouth,
northIndicesWestToEast,
vertexStride,
center,
minimumHeight,
maximumHeight,
occludeePointInScaledSpace,
encoding,
indexCountWithoutSkirts: parameters.indices.length
};
}
function findMinMaxSkirts(edgeIndices, edgeHeight, heights, uvs, rectangle, ellipsoid, toENU, minimum, maximum) {
let hMin = Number.POSITIVE_INFINITY;
const north = rectangle.north;
const south = rectangle.south;
let east = rectangle.east;
const west = rectangle.west;
if (east < west) {
east += Math_default.TWO_PI;
}
const length = edgeIndices.length;
for (let i = 0; i < length; ++i) {
const index = edgeIndices[i];
const h = heights[index];
const uv = uvs[index];
cartographicScratch.longitude = Math_default.lerp(west, east, uv.x);
cartographicScratch.latitude = Math_default.lerp(south, north, uv.y);
cartographicScratch.height = h - edgeHeight;
const position = ellipsoid.cartographicToCartesian(
cartographicScratch,
cartesian3Scratch
);
Matrix4_default.multiplyByPoint(toENU, position, position);
Cartesian3_default.minimumByComponent(position, minimum, minimum);
Cartesian3_default.maximumByComponent(position, maximum, maximum);
hMin = Math.min(hMin, cartographicScratch.height);
}
return hMin;
}
function addSkirt(vertexBuffer, vertexBufferIndex, edgeVertices, encoding, heights, uvs, octEncodedNormals, ellipsoid, rectangle, skirtLength, southMercatorY, oneOverMercatorHeight, longitudeOffset, latitudeOffset) {
const hasVertexNormals = defined_default(octEncodedNormals);
const north = rectangle.north;
const south = rectangle.south;
let east = rectangle.east;
const west = rectangle.west;
if (east < west) {
east += Math_default.TWO_PI;
}
const length = edgeVertices.length;
for (let i = 0; i < length; ++i) {
const index = edgeVertices[i];
const h = heights[index];
const uv = uvs[index];
cartographicScratch.longitude = Math_default.lerp(west, east, uv.x) + longitudeOffset;
cartographicScratch.latitude = Math_default.lerp(south, north, uv.y) + latitudeOffset;
cartographicScratch.height = h - skirtLength;
const position = ellipsoid.cartographicToCartesian(
cartographicScratch,
cartesian3Scratch
);
if (hasVertexNormals) {
const n = index * 2;
toPack.x = octEncodedNormals[n];
toPack.y = octEncodedNormals[n + 1];
}
let webMercatorT;
if (encoding.hasWebMercatorT) {
webMercatorT = (WebMercatorProjection_default.geodeticLatitudeToMercatorAngle(
cartographicScratch.latitude
) - southMercatorY) * oneOverMercatorHeight;
}
let geodeticSurfaceNormal;
if (encoding.hasGeodeticSurfaceNormals) {
geodeticSurfaceNormal = ellipsoid.geodeticSurfaceNormal(position);
}
vertexBufferIndex = encoding.encode(
vertexBuffer,
vertexBufferIndex,
position,
uv,
cartographicScratch.height,
toPack,
webMercatorT,
geodeticSurfaceNormal
);
}
}
function copyAndSort(typedArray, comparator) {
let copy;
if (typeof typedArray.slice === "function") {
copy = typedArray.slice();
if (typeof copy.sort !== "function") {
copy = void 0;
}
}
if (!defined_default(copy)) {
copy = Array.prototype.slice.call(typedArray);
}
copy.sort(comparator);
return copy;
}
var createVerticesFromQuantizedTerrainMesh_default = createTaskProcessorWorker_default(
createVerticesFromQuantizedTerrainMesh
);
export {
createVerticesFromQuantizedTerrainMesh_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
WallGeometryLibrary_default
} from "./chunk-RTJKHZWU.js";
import "./chunk-QN6TBED4.js";
import "./chunk-C3EQ27WF.js";
import {
VertexFormat_default
} from "./chunk-JBSKHTNX.js";
import "./chunk-57H6I3SV.js";
import "./chunk-JSQJDZI4.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
GeometryAttributes_default
} from "./chunk-X7IQYYHF.js";
import {
GeometryAttribute_default,
Geometry_default,
PrimitiveType_default
} from "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import "./chunk-6SQMLVGV.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/WallGeometry.js
var scratchCartesian3Position1 = new Cartesian3_default();
var scratchCartesian3Position2 = new Cartesian3_default();
var scratchCartesian3Position4 = new Cartesian3_default();
var scratchCartesian3Position5 = new Cartesian3_default();
var scratchBitangent = new Cartesian3_default();
var scratchTangent = new Cartesian3_default();
var scratchNormal = new Cartesian3_default();
function WallGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const wallPositions = options.positions;
const maximumHeights = options.maximumHeights;
const minimumHeights = options.minimumHeights;
if (!defined_default(wallPositions)) {
throw new DeveloperError_default("options.positions is required.");
}
if (defined_default(maximumHeights) && maximumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.maximumHeights must have the same length."
);
}
if (defined_default(minimumHeights) && minimumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.minimumHeights must have the same length."
);
}
const vertexFormat = defaultValue_default(options.vertexFormat, VertexFormat_default.DEFAULT);
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.default);
this._positions = wallPositions;
this._minimumHeights = minimumHeights;
this._maximumHeights = maximumHeights;
this._vertexFormat = VertexFormat_default.clone(vertexFormat);
this._granularity = granularity;
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._workerName = "createWallGeometry";
let numComponents = 1 + wallPositions.length * Cartesian3_default.packedLength + 2;
if (defined_default(minimumHeights)) {
numComponents += minimumHeights.length;
}
if (defined_default(maximumHeights)) {
numComponents += maximumHeights.length;
}
this.packedLength = numComponents + Ellipsoid_default.packedLength + VertexFormat_default.packedLength + 1;
}
WallGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length = positions.length;
array[startingIndex++] = length;
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const minimumHeights = value._minimumHeights;
length = defined_default(minimumHeights) ? minimumHeights.length : 0;
array[startingIndex++] = length;
if (defined_default(minimumHeights)) {
for (i = 0; i < length; ++i) {
array[startingIndex++] = minimumHeights[i];
}
}
const maximumHeights = value._maximumHeights;
length = defined_default(maximumHeights) ? maximumHeights.length : 0;
array[startingIndex++] = length;
if (defined_default(maximumHeights)) {
for (i = 0; i < length; ++i) {
array[startingIndex++] = maximumHeights[i];
}
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
VertexFormat_default.pack(value._vertexFormat, array, startingIndex);
startingIndex += VertexFormat_default.packedLength;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchVertexFormat = new VertexFormat_default();
var scratchOptions = {
positions: void 0,
minimumHeights: void 0,
maximumHeights: void 0,
ellipsoid: scratchEllipsoid,
vertexFormat: scratchVertexFormat,
granularity: void 0
};
WallGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length = array[startingIndex++];
const positions = new Array(length);
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length = array[startingIndex++];
let minimumHeights;
if (length > 0) {
minimumHeights = new Array(length);
for (i = 0; i < length; ++i) {
minimumHeights[i] = array[startingIndex++];
}
}
length = array[startingIndex++];
let maximumHeights;
if (length > 0) {
maximumHeights = new Array(length);
for (i = 0; i < length; ++i) {
maximumHeights[i] = array[startingIndex++];
}
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Ellipsoid_default.packedLength;
const vertexFormat = VertexFormat_default.unpack(
array,
startingIndex,
scratchVertexFormat
);
startingIndex += VertexFormat_default.packedLength;
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions.positions = positions;
scratchOptions.minimumHeights = minimumHeights;
scratchOptions.maximumHeights = maximumHeights;
scratchOptions.granularity = granularity;
return new WallGeometry(scratchOptions);
}
result._positions = positions;
result._minimumHeights = minimumHeights;
result._maximumHeights = maximumHeights;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._vertexFormat = VertexFormat_default.clone(vertexFormat, result._vertexFormat);
result._granularity = granularity;
return result;
};
WallGeometry.fromConstantHeights = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.positions is required.");
}
let minHeights;
let maxHeights;
const min = options.minimumHeight;
const max = options.maximumHeight;
const doMin = defined_default(min);
const doMax = defined_default(max);
if (doMin || doMax) {
const length = positions.length;
minHeights = doMin ? new Array(length) : void 0;
maxHeights = doMax ? new Array(length) : void 0;
for (let i = 0; i < length; ++i) {
if (doMin) {
minHeights[i] = min;
}
if (doMax) {
maxHeights[i] = max;
}
}
}
const newOptions = {
positions,
maximumHeights: maxHeights,
minimumHeights: minHeights,
ellipsoid: options.ellipsoid,
vertexFormat: options.vertexFormat
};
return new WallGeometry(newOptions);
};
WallGeometry.createGeometry = function(wallGeometry) {
const wallPositions = wallGeometry._positions;
const minimumHeights = wallGeometry._minimumHeights;
const maximumHeights = wallGeometry._maximumHeights;
const vertexFormat = wallGeometry._vertexFormat;
const granularity = wallGeometry._granularity;
const ellipsoid = wallGeometry._ellipsoid;
const pos = WallGeometryLibrary_default.computePositions(
ellipsoid,
wallPositions,
maximumHeights,
minimumHeights,
granularity,
true
);
if (!defined_default(pos)) {
return;
}
const bottomPositions = pos.bottomPositions;
const topPositions = pos.topPositions;
const numCorners = pos.numCorners;
let length = topPositions.length;
let size = length * 2;
const positions = vertexFormat.position ? new Float64Array(size) : void 0;
const normals = vertexFormat.normal ? new Float32Array(size) : void 0;
const tangents = vertexFormat.tangent ? new Float32Array(size) : void 0;
const bitangents = vertexFormat.bitangent ? new Float32Array(size) : void 0;
const textureCoordinates = vertexFormat.st ? new Float32Array(size / 3 * 2) : void 0;
let positionIndex = 0;
let normalIndex = 0;
let bitangentIndex = 0;
let tangentIndex = 0;
let stIndex = 0;
let normal = scratchNormal;
let tangent = scratchTangent;
let bitangent = scratchBitangent;
let recomputeNormal = true;
length /= 3;
let i;
let s = 0;
const ds = 1 / (length - numCorners - 1);
for (i = 0; i < length; ++i) {
const i3 = i * 3;
const topPosition = Cartesian3_default.fromArray(
topPositions,
i3,
scratchCartesian3Position1
);
const bottomPosition = Cartesian3_default.fromArray(
bottomPositions,
i3,
scratchCartesian3Position2
);
if (vertexFormat.position) {
positions[positionIndex++] = bottomPosition.x;
positions[positionIndex++] = bottomPosition.y;
positions[positionIndex++] = bottomPosition.z;
positions[positionIndex++] = topPosition.x;
positions[positionIndex++] = topPosition.y;
positions[positionIndex++] = topPosition.z;
}
if (vertexFormat.st) {
textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 0;
textureCoordinates[stIndex++] = s;
textureCoordinates[stIndex++] = 1;
}
if (vertexFormat.normal || vertexFormat.tangent || vertexFormat.bitangent) {
let nextTop = Cartesian3_default.clone(
Cartesian3_default.ZERO,
scratchCartesian3Position5
);
const groundPosition = Cartesian3_default.subtract(
topPosition,
ellipsoid.geodeticSurfaceNormal(
topPosition,
scratchCartesian3Position2
),
scratchCartesian3Position2
);
if (i + 1 < length) {
nextTop = Cartesian3_default.fromArray(
topPositions,
i3 + 3,
scratchCartesian3Position5
);
}
if (recomputeNormal) {
const scalednextPosition = Cartesian3_default.subtract(
nextTop,
topPosition,
scratchCartesian3Position4
);
const scaledGroundPosition = Cartesian3_default.subtract(
groundPosition,
topPosition,
scratchCartesian3Position1
);
normal = Cartesian3_default.normalize(
Cartesian3_default.cross(scaledGroundPosition, scalednextPosition, normal),
normal
);
recomputeNormal = false;
}
if (Cartesian3_default.equalsEpsilon(topPosition, nextTop, Math_default.EPSILON10)) {
recomputeNormal = true;
} else {
s += ds;
if (vertexFormat.tangent) {
tangent = Cartesian3_default.normalize(
Cartesian3_default.subtract(nextTop, topPosition, tangent),
tangent
);
}
if (vertexFormat.bitangent) {
bitangent = Cartesian3_default.normalize(
Cartesian3_default.cross(normal, tangent, bitangent),
bitangent
);
}
}
if (vertexFormat.normal) {
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
normals[normalIndex++] = normal.x;
normals[normalIndex++] = normal.y;
normals[normalIndex++] = normal.z;
}
if (vertexFormat.tangent) {
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
tangents[tangentIndex++] = tangent.x;
tangents[tangentIndex++] = tangent.y;
tangents[tangentIndex++] = tangent.z;
}
if (vertexFormat.bitangent) {
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
bitangents[bitangentIndex++] = bitangent.x;
bitangents[bitangentIndex++] = bitangent.y;
bitangents[bitangentIndex++] = bitangent.z;
}
}
}
const attributes = new GeometryAttributes_default();
if (vertexFormat.position) {
attributes.position = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
});
}
if (vertexFormat.normal) {
attributes.normal = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: normals
});
}
if (vertexFormat.tangent) {
attributes.tangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: tangents
});
}
if (vertexFormat.bitangent) {
attributes.bitangent = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 3,
values: bitangents
});
}
if (vertexFormat.st) {
attributes.st = new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.FLOAT,
componentsPerAttribute: 2,
values: textureCoordinates
});
}
const numVertices = size / 3;
size -= 6 * (numCorners + 1);
const indices = IndexDatatype_default.createTypedArray(numVertices, size);
let edgeIndex = 0;
for (i = 0; i < numVertices - 2; i += 2) {
const LL = i;
const LR = i + 2;
const pl = Cartesian3_default.fromArray(
positions,
LL * 3,
scratchCartesian3Position1
);
const pr = Cartesian3_default.fromArray(
positions,
LR * 3,
scratchCartesian3Position2
);
if (Cartesian3_default.equalsEpsilon(pl, pr, Math_default.EPSILON10)) {
continue;
}
const UL = i + 1;
const UR = i + 3;
indices[edgeIndex++] = UL;
indices[edgeIndex++] = LL;
indices[edgeIndex++] = UR;
indices[edgeIndex++] = UR;
indices[edgeIndex++] = LL;
indices[edgeIndex++] = LR;
}
return new Geometry_default({
attributes,
indices,
primitiveType: PrimitiveType_default.TRIANGLES,
boundingSphere: new BoundingSphere_default.fromVertices(positions)
});
};
var WallGeometry_default = WallGeometry;
// packages/engine/Source/Workers/createWallGeometry.js
function createWallGeometry(wallGeometry, offset) {
if (defined_default(offset)) {
wallGeometry = WallGeometry_default.unpack(wallGeometry, offset);
}
wallGeometry._ellipsoid = Ellipsoid_default.clone(wallGeometry._ellipsoid);
return WallGeometry_default.createGeometry(wallGeometry);
}
var createWallGeometry_default = createWallGeometry;
export {
createWallGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
WallGeometryLibrary_default
} from "./chunk-RTJKHZWU.js";
import "./chunk-QN6TBED4.js";
import "./chunk-C3EQ27WF.js";
import "./chunk-57H6I3SV.js";
import "./chunk-JSQJDZI4.js";
import "./chunk-QQOZO7KO.js";
import "./chunk-EDLRS3AW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
GeometryAttributes_default
} from "./chunk-X7IQYYHF.js";
import {
GeometryAttribute_default,
Geometry_default,
PrimitiveType_default
} from "./chunk-JXVLNVXC.js";
import {
BoundingSphere_default
} from "./chunk-KHZNBFOH.js";
import "./chunk-6SQMLVGV.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import {
Cartesian3_default,
Ellipsoid_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import "./chunk-LLAF3CPH.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
DeveloperError_default
} from "./chunk-P6TRGU3S.js";
import {
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Core/WallOutlineGeometry.js
var scratchCartesian3Position1 = new Cartesian3_default();
var scratchCartesian3Position2 = new Cartesian3_default();
function WallOutlineGeometry(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const wallPositions = options.positions;
const maximumHeights = options.maximumHeights;
const minimumHeights = options.minimumHeights;
if (!defined_default(wallPositions)) {
throw new DeveloperError_default("options.positions is required.");
}
if (defined_default(maximumHeights) && maximumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.maximumHeights must have the same length."
);
}
if (defined_default(minimumHeights) && minimumHeights.length !== wallPositions.length) {
throw new DeveloperError_default(
"options.positions and options.minimumHeights must have the same length."
);
}
const granularity = defaultValue_default(
options.granularity,
Math_default.RADIANS_PER_DEGREE
);
const ellipsoid = defaultValue_default(options.ellipsoid, Ellipsoid_default.default);
this._positions = wallPositions;
this._minimumHeights = minimumHeights;
this._maximumHeights = maximumHeights;
this._granularity = granularity;
this._ellipsoid = Ellipsoid_default.clone(ellipsoid);
this._workerName = "createWallOutlineGeometry";
let numComponents = 1 + wallPositions.length * Cartesian3_default.packedLength + 2;
if (defined_default(minimumHeights)) {
numComponents += minimumHeights.length;
}
if (defined_default(maximumHeights)) {
numComponents += maximumHeights.length;
}
this.packedLength = numComponents + Ellipsoid_default.packedLength + 1;
}
WallOutlineGeometry.pack = function(value, array, startingIndex) {
if (!defined_default(value)) {
throw new DeveloperError_default("value is required");
}
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
const positions = value._positions;
let length = positions.length;
array[startingIndex++] = length;
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
Cartesian3_default.pack(positions[i], array, startingIndex);
}
const minimumHeights = value._minimumHeights;
length = defined_default(minimumHeights) ? minimumHeights.length : 0;
array[startingIndex++] = length;
if (defined_default(minimumHeights)) {
for (i = 0; i < length; ++i) {
array[startingIndex++] = minimumHeights[i];
}
}
const maximumHeights = value._maximumHeights;
length = defined_default(maximumHeights) ? maximumHeights.length : 0;
array[startingIndex++] = length;
if (defined_default(maximumHeights)) {
for (i = 0; i < length; ++i) {
array[startingIndex++] = maximumHeights[i];
}
}
Ellipsoid_default.pack(value._ellipsoid, array, startingIndex);
startingIndex += Ellipsoid_default.packedLength;
array[startingIndex] = value._granularity;
return array;
};
var scratchEllipsoid = Ellipsoid_default.clone(Ellipsoid_default.UNIT_SPHERE);
var scratchOptions = {
positions: void 0,
minimumHeights: void 0,
maximumHeights: void 0,
ellipsoid: scratchEllipsoid,
granularity: void 0
};
WallOutlineGeometry.unpack = function(array, startingIndex, result) {
if (!defined_default(array)) {
throw new DeveloperError_default("array is required");
}
startingIndex = defaultValue_default(startingIndex, 0);
let i;
let length = array[startingIndex++];
const positions = new Array(length);
for (i = 0; i < length; ++i, startingIndex += Cartesian3_default.packedLength) {
positions[i] = Cartesian3_default.unpack(array, startingIndex);
}
length = array[startingIndex++];
let minimumHeights;
if (length > 0) {
minimumHeights = new Array(length);
for (i = 0; i < length; ++i) {
minimumHeights[i] = array[startingIndex++];
}
}
length = array[startingIndex++];
let maximumHeights;
if (length > 0) {
maximumHeights = new Array(length);
for (i = 0; i < length; ++i) {
maximumHeights[i] = array[startingIndex++];
}
}
const ellipsoid = Ellipsoid_default.unpack(array, startingIndex, scratchEllipsoid);
startingIndex += Ellipsoid_default.packedLength;
const granularity = array[startingIndex];
if (!defined_default(result)) {
scratchOptions.positions = positions;
scratchOptions.minimumHeights = minimumHeights;
scratchOptions.maximumHeights = maximumHeights;
scratchOptions.granularity = granularity;
return new WallOutlineGeometry(scratchOptions);
}
result._positions = positions;
result._minimumHeights = minimumHeights;
result._maximumHeights = maximumHeights;
result._ellipsoid = Ellipsoid_default.clone(ellipsoid, result._ellipsoid);
result._granularity = granularity;
return result;
};
WallOutlineGeometry.fromConstantHeights = function(options) {
options = defaultValue_default(options, defaultValue_default.EMPTY_OBJECT);
const positions = options.positions;
if (!defined_default(positions)) {
throw new DeveloperError_default("options.positions is required.");
}
let minHeights;
let maxHeights;
const min = options.minimumHeight;
const max = options.maximumHeight;
const doMin = defined_default(min);
const doMax = defined_default(max);
if (doMin || doMax) {
const length = positions.length;
minHeights = doMin ? new Array(length) : void 0;
maxHeights = doMax ? new Array(length) : void 0;
for (let i = 0; i < length; ++i) {
if (doMin) {
minHeights[i] = min;
}
if (doMax) {
maxHeights[i] = max;
}
}
}
const newOptions = {
positions,
maximumHeights: maxHeights,
minimumHeights: minHeights,
ellipsoid: options.ellipsoid
};
return new WallOutlineGeometry(newOptions);
};
WallOutlineGeometry.createGeometry = function(wallGeometry) {
const wallPositions = wallGeometry._positions;
const minimumHeights = wallGeometry._minimumHeights;
const maximumHeights = wallGeometry._maximumHeights;
const granularity = wallGeometry._granularity;
const ellipsoid = wallGeometry._ellipsoid;
const pos = WallGeometryLibrary_default.computePositions(
ellipsoid,
wallPositions,
maximumHeights,
minimumHeights,
granularity,
false
);
if (!defined_default(pos)) {
return;
}
const bottomPositions = pos.bottomPositions;
const topPositions = pos.topPositions;
let length = topPositions.length;
let size = length * 2;
const positions = new Float64Array(size);
let positionIndex = 0;
length /= 3;
let i;
for (i = 0; i < length; ++i) {
const i3 = i * 3;
const topPosition = Cartesian3_default.fromArray(
topPositions,
i3,
scratchCartesian3Position1
);
const bottomPosition = Cartesian3_default.fromArray(
bottomPositions,
i3,
scratchCartesian3Position2
);
positions[positionIndex++] = bottomPosition.x;
positions[positionIndex++] = bottomPosition.y;
positions[positionIndex++] = bottomPosition.z;
positions[positionIndex++] = topPosition.x;
positions[positionIndex++] = topPosition.y;
positions[positionIndex++] = topPosition.z;
}
const attributes = new GeometryAttributes_default({
position: new GeometryAttribute_default({
componentDatatype: ComponentDatatype_default.DOUBLE,
componentsPerAttribute: 3,
values: positions
})
});
const numVertices = size / 3;
size = 2 * numVertices - 4 + numVertices;
const indices = IndexDatatype_default.createTypedArray(numVertices, size);
let edgeIndex = 0;
for (i = 0; i < numVertices - 2; i += 2) {
const LL = i;
const LR = i + 2;
const pl = Cartesian3_default.fromArray(
positions,
LL * 3,
scratchCartesian3Position1
);
const pr = Cartesian3_default.fromArray(
positions,
LR * 3,
scratchCartesian3Position2
);
if (Cartesian3_default.equalsEpsilon(pl, pr, Math_default.EPSILON10)) {
continue;
}
const UL = i + 1;
const UR = i + 3;
indices[edgeIndex++] = UL;
indices[edgeIndex++] = LL;
indices[edgeIndex++] = UL;
indices[edgeIndex++] = UR;
indices[edgeIndex++] = LL;
indices[edgeIndex++] = LR;
}
indices[edgeIndex++] = numVertices - 2;
indices[edgeIndex++] = numVertices - 1;
return new Geometry_default({
attributes,
indices,
primitiveType: PrimitiveType_default.LINES,
boundingSphere: new BoundingSphere_default.fromVertices(positions)
});
};
var WallOutlineGeometry_default = WallOutlineGeometry;
// packages/engine/Source/Workers/createWallOutlineGeometry.js
function createWallOutlineGeometry(wallGeometry, offset) {
if (defined_default(offset)) {
wallGeometry = WallOutlineGeometry_default.unpack(wallGeometry, offset);
}
wallGeometry._ellipsoid = Ellipsoid_default.clone(wallGeometry._ellipsoid);
return WallOutlineGeometry_default.createGeometry(wallGeometry);
}
var createWallOutlineGeometry_default = createWallOutlineGeometry;
export {
createWallOutlineGeometry_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
require_draco_decoder_nodejs
} from "./chunk-M24KHENR.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
IndexDatatype_default
} from "./chunk-C4WPMOKT.js";
import {
ComponentDatatype_default
} from "./chunk-XIUSRWL6.js";
import "./chunk-WGDFYAGC.js";
import "./chunk-3HQMMUPU.js";
import {
RuntimeError_default
} from "./chunk-LLAF3CPH.js";
import "./chunk-U5HSOKPQ.js";
import "./chunk-P6TRGU3S.js";
import {
__toESM,
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Workers/decodeDraco.js
var import_draco_decoder_nodejs = __toESM(require_draco_decoder_nodejs(), 1);
var draco;
function decodeIndexArray(dracoGeometry, dracoDecoder) {
const numPoints = dracoGeometry.num_points();
const numFaces = dracoGeometry.num_faces();
const faceIndices = new draco.DracoInt32Array();
const numIndices = numFaces * 3;
const indexArray = IndexDatatype_default.createTypedArray(numPoints, numIndices);
let offset = 0;
for (let i = 0; i < numFaces; ++i) {
dracoDecoder.GetFaceFromMesh(dracoGeometry, i, faceIndices);
indexArray[offset + 0] = faceIndices.GetValue(0);
indexArray[offset + 1] = faceIndices.GetValue(1);
indexArray[offset + 2] = faceIndices.GetValue(2);
offset += 3;
}
draco.destroy(faceIndices);
return {
typedArray: indexArray,
numberOfIndices: numIndices
};
}
function decodeQuantizedDracoTypedArray(dracoGeometry, dracoDecoder, dracoAttribute, quantization, vertexArrayLength) {
let vertexArray;
let attributeData;
if (quantization.quantizationBits <= 8) {
attributeData = new draco.DracoUInt8Array();
vertexArray = new Uint8Array(vertexArrayLength);
dracoDecoder.GetAttributeUInt8ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
} else if (quantization.quantizationBits <= 16) {
attributeData = new draco.DracoUInt16Array();
vertexArray = new Uint16Array(vertexArrayLength);
dracoDecoder.GetAttributeUInt16ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
} else {
attributeData = new draco.DracoFloat32Array();
vertexArray = new Float32Array(vertexArrayLength);
dracoDecoder.GetAttributeFloatForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
}
for (let i = 0; i < vertexArrayLength; ++i) {
vertexArray[i] = attributeData.GetValue(i);
}
draco.destroy(attributeData);
return vertexArray;
}
function decodeDracoTypedArray(dracoGeometry, dracoDecoder, dracoAttribute, vertexArrayLength) {
let vertexArray;
let attributeData;
switch (dracoAttribute.data_type()) {
case 1:
case 11:
attributeData = new draco.DracoInt8Array();
vertexArray = new Int8Array(vertexArrayLength);
dracoDecoder.GetAttributeInt8ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
case 2:
attributeData = new draco.DracoUInt8Array();
vertexArray = new Uint8Array(vertexArrayLength);
dracoDecoder.GetAttributeUInt8ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
case 3:
attributeData = new draco.DracoInt16Array();
vertexArray = new Int16Array(vertexArrayLength);
dracoDecoder.GetAttributeInt16ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
case 4:
attributeData = new draco.DracoUInt16Array();
vertexArray = new Uint16Array(vertexArrayLength);
dracoDecoder.GetAttributeUInt16ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
case 5:
case 7:
attributeData = new draco.DracoInt32Array();
vertexArray = new Int32Array(vertexArrayLength);
dracoDecoder.GetAttributeInt32ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
case 6:
case 8:
attributeData = new draco.DracoUInt32Array();
vertexArray = new Uint32Array(vertexArrayLength);
dracoDecoder.GetAttributeUInt32ForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
case 9:
case 10:
attributeData = new draco.DracoFloat32Array();
vertexArray = new Float32Array(vertexArrayLength);
dracoDecoder.GetAttributeFloatForAllPoints(
dracoGeometry,
dracoAttribute,
attributeData
);
break;
}
for (let i = 0; i < vertexArrayLength; ++i) {
vertexArray[i] = attributeData.GetValue(i);
}
draco.destroy(attributeData);
return vertexArray;
}
function decodeAttribute(dracoGeometry, dracoDecoder, dracoAttribute) {
const numPoints = dracoGeometry.num_points();
const numComponents = dracoAttribute.num_components();
let quantization;
let transform = new draco.AttributeQuantizationTransform();
if (transform.InitFromAttribute(dracoAttribute)) {
const minValues = new Array(numComponents);
for (let i = 0; i < numComponents; ++i) {
minValues[i] = transform.min_value(i);
}
quantization = {
quantizationBits: transform.quantization_bits(),
minValues,
range: transform.range(),
octEncoded: false
};
}
draco.destroy(transform);
transform = new draco.AttributeOctahedronTransform();
if (transform.InitFromAttribute(dracoAttribute)) {
quantization = {
quantizationBits: transform.quantization_bits(),
octEncoded: true
};
}
draco.destroy(transform);
const vertexArrayLength = numPoints * numComponents;
let vertexArray;
if (defined_default(quantization)) {
vertexArray = decodeQuantizedDracoTypedArray(
dracoGeometry,
dracoDecoder,
dracoAttribute,
quantization,
vertexArrayLength
);
} else {
vertexArray = decodeDracoTypedArray(
dracoGeometry,
dracoDecoder,
dracoAttribute,
vertexArrayLength
);
}
const componentDatatype = ComponentDatatype_default.fromTypedArray(vertexArray);
return {
array: vertexArray,
data: {
componentsPerAttribute: numComponents,
componentDatatype,
byteOffset: dracoAttribute.byte_offset(),
byteStride: ComponentDatatype_default.getSizeInBytes(componentDatatype) * numComponents,
normalized: dracoAttribute.normalized(),
quantization
}
};
}
function decodePointCloud(parameters) {
const dracoDecoder = new draco.Decoder();
if (parameters.dequantizeInShader) {
dracoDecoder.SkipAttributeTransform(draco.POSITION);
dracoDecoder.SkipAttributeTransform(draco.NORMAL);
}
const buffer = new draco.DecoderBuffer();
buffer.Init(parameters.buffer, parameters.buffer.length);
const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
if (geometryType !== draco.POINT_CLOUD) {
throw new RuntimeError_default("Draco geometry type must be POINT_CLOUD.");
}
const dracoPointCloud = new draco.PointCloud();
const decodingStatus = dracoDecoder.DecodeBufferToPointCloud(
buffer,
dracoPointCloud
);
if (!decodingStatus.ok() || dracoPointCloud.ptr === 0) {
throw new RuntimeError_default(
`Error decoding draco point cloud: ${decodingStatus.error_msg()}`
);
}
draco.destroy(buffer);
const result = {};
const properties = parameters.properties;
for (const propertyName in properties) {
if (properties.hasOwnProperty(propertyName)) {
let dracoAttribute;
if (propertyName === "POSITION" || propertyName === "NORMAL") {
const dracoAttributeId = dracoDecoder.GetAttributeId(
dracoPointCloud,
draco[propertyName]
);
dracoAttribute = dracoDecoder.GetAttribute(
dracoPointCloud,
dracoAttributeId
);
} else {
const attributeId = properties[propertyName];
dracoAttribute = dracoDecoder.GetAttributeByUniqueId(
dracoPointCloud,
attributeId
);
}
result[propertyName] = decodeAttribute(
dracoPointCloud,
dracoDecoder,
dracoAttribute
);
}
}
draco.destroy(dracoPointCloud);
draco.destroy(dracoDecoder);
return result;
}
function decodePrimitive(parameters) {
const dracoDecoder = new draco.Decoder();
const attributesToSkip = ["POSITION", "NORMAL", "COLOR", "TEX_COORD"];
if (parameters.dequantizeInShader) {
for (let i = 0; i < attributesToSkip.length; ++i) {
dracoDecoder.SkipAttributeTransform(draco[attributesToSkip[i]]);
}
}
const bufferView = parameters.bufferView;
const buffer = new draco.DecoderBuffer();
buffer.Init(parameters.array, bufferView.byteLength);
const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
if (geometryType !== draco.TRIANGULAR_MESH) {
throw new RuntimeError_default("Unsupported draco mesh geometry type.");
}
const dracoGeometry = new draco.Mesh();
const decodingStatus = dracoDecoder.DecodeBufferToMesh(buffer, dracoGeometry);
if (!decodingStatus.ok() || dracoGeometry.ptr === 0) {
throw new RuntimeError_default(
`Error decoding draco mesh geometry: ${decodingStatus.error_msg()}`
);
}
draco.destroy(buffer);
const attributeData = {};
const compressedAttributes = parameters.compressedAttributes;
for (const attributeName in compressedAttributes) {
if (compressedAttributes.hasOwnProperty(attributeName)) {
const compressedAttribute = compressedAttributes[attributeName];
const dracoAttribute = dracoDecoder.GetAttributeByUniqueId(
dracoGeometry,
compressedAttribute
);
attributeData[attributeName] = decodeAttribute(
dracoGeometry,
dracoDecoder,
dracoAttribute
);
}
}
const result = {
indexArray: decodeIndexArray(dracoGeometry, dracoDecoder),
attributeData
};
draco.destroy(dracoGeometry);
draco.destroy(dracoDecoder);
return result;
}
async function decode(parameters, transferableObjects) {
if (defined_default(parameters.bufferView)) {
return decodePrimitive(parameters);
}
return decodePointCloud(parameters);
}
async function initWorker(parameters, transferableObjects) {
const wasmConfig = parameters.webAssemblyConfig;
if (defined_default(wasmConfig) && defined_default(wasmConfig.wasmBinaryFile)) {
draco = await (0, import_draco_decoder_nodejs.default)(wasmConfig);
} else {
draco = await (0, import_draco_decoder_nodejs.default)();
}
return true;
}
async function decodeDraco(parameters, transferableObjects) {
const wasmConfig = parameters.webAssemblyConfig;
if (defined_default(wasmConfig)) {
return initWorker(parameters, transferableObjects);
}
return decode(parameters, transferableObjects);
}
var decodeDraco_default = createTaskProcessorWorker_default(decodeDraco);
export {
decodeDraco_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
RuntimeError_default
} from "./chunk-LLAF3CPH.js";
import {
Check_default
} from "./chunk-P6TRGU3S.js";
import {
__commonJS,
__toESM,
defined_default
} from "./chunk-YCDZX5LS.js";
// node_modules/pako/lib/zlib/adler32.js
var require_adler32 = __commonJS({
"node_modules/pako/lib/zlib/adler32.js"(exports, module) {
"use strict";
var adler32 = (adler, buf, len, pos) => {
let s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n = 0;
while (len !== 0) {
n = len > 2e3 ? 2e3 : len;
len -= n;
do {
s1 = s1 + buf[pos++] | 0;
s2 = s2 + s1 | 0;
} while (--n);
s1 %= 65521;
s2 %= 65521;
}
return s1 | s2 << 16 | 0;
};
module.exports = adler32;
}
});
// node_modules/pako/lib/zlib/crc32.js
var require_crc32 = __commonJS({
"node_modules/pako/lib/zlib/crc32.js"(exports, module) {
"use strict";
var makeTable = () => {
let c, table = [];
for (var n = 0; n < 256; n++) {
c = n;
for (var k = 0; k < 8; k++) {
c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
}
table[n] = c;
}
return table;
};
var crcTable = new Uint32Array(makeTable());
var crc32 = (crc, buf, len, pos) => {
const t = crcTable;
const end = pos + len;
crc ^= -1;
for (let i = pos; i < end; i++) {
crc = crc >>> 8 ^ t[(crc ^ buf[i]) & 255];
}
return crc ^ -1;
};
module.exports = crc32;
}
});
// node_modules/pako/lib/zlib/inffast.js
var require_inffast = __commonJS({
"node_modules/pako/lib/zlib/inffast.js"(exports, module) {
"use strict";
var BAD = 16209;
var TYPE = 16191;
module.exports = function inflate_fast(strm, start) {
let _in;
let last;
let _out;
let beg;
let end;
let dmax;
let wsize;
let whave;
let wnext;
let s_window;
let hold;
let bits;
let lcode;
let dcode;
let lmask;
let dmask;
let here;
let op;
let len;
let dist;
let from;
let from_source;
let input, output;
const state = strm.state;
_in = strm.next_in;
input = strm.input;
last = _in + (strm.avail_in - 5);
_out = strm.next_out;
output = strm.output;
beg = _out - (start - strm.avail_out);
end = _out + (strm.avail_out - 257);
dmax = state.dmax;
wsize = state.wsize;
whave = state.whave;
wnext = state.wnext;
s_window = state.window;
hold = state.hold;
bits = state.bits;
lcode = state.lencode;
dcode = state.distcode;
lmask = (1 << state.lenbits) - 1;
dmask = (1 << state.distbits) - 1;
top:
do {
if (bits < 15) {
hold += input[_in++] << bits;
bits += 8;
hold += input[_in++] << bits;
bits += 8;
}
here = lcode[hold & lmask];
dolen:
for (; ; ) {
op = here >>> 24;
hold >>>= op;
bits -= op;
op = here >>> 16 & 255;
if (op === 0) {
output[_out++] = here & 65535;
} else if (op & 16) {
len = here & 65535;
op &= 15;
if (op) {
if (bits < op) {
hold += input[_in++] << bits;
bits += 8;
}
len += hold & (1 << op) - 1;
hold >>>= op;
bits -= op;
}
if (bits < 15) {
hold += input[_in++] << bits;
bits += 8;
hold += input[_in++] << bits;
bits += 8;
}
here = dcode[hold & dmask];
dodist:
for (; ; ) {
op = here >>> 24;
hold >>>= op;
bits -= op;
op = here >>> 16 & 255;
if (op & 16) {
dist = here & 65535;
op &= 15;
if (bits < op) {
hold += input[_in++] << bits;
bits += 8;
if (bits < op) {
hold += input[_in++] << bits;
bits += 8;
}
}
dist += hold & (1 << op) - 1;
if (dist > dmax) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break top;
}
hold >>>= op;
bits -= op;
op = _out - beg;
if (dist > op) {
op = dist - op;
if (op > whave) {
if (state.sane) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break top;
}
}
from = 0;
from_source = s_window;
if (wnext === 0) {
from += wsize - op;
if (op < len) {
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = _out - dist;
from_source = output;
}
} else if (wnext < op) {
from += wsize + wnext - op;
op -= wnext;
if (op < len) {
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = 0;
if (wnext < len) {
op = wnext;
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = _out - dist;
from_source = output;
}
}
} else {
from += wnext - op;
if (op < len) {
len -= op;
do {
output[_out++] = s_window[from++];
} while (--op);
from = _out - dist;
from_source = output;
}
}
while (len > 2) {
output[_out++] = from_source[from++];
output[_out++] = from_source[from++];
output[_out++] = from_source[from++];
len -= 3;
}
if (len) {
output[_out++] = from_source[from++];
if (len > 1) {
output[_out++] = from_source[from++];
}
}
} else {
from = _out - dist;
do {
output[_out++] = output[from++];
output[_out++] = output[from++];
output[_out++] = output[from++];
len -= 3;
} while (len > 2);
if (len) {
output[_out++] = output[from++];
if (len > 1) {
output[_out++] = output[from++];
}
}
}
} else if ((op & 64) === 0) {
here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
continue dodist;
} else {
strm.msg = "invalid distance code";
state.mode = BAD;
break top;
}
break;
}
} else if ((op & 64) === 0) {
here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
continue dolen;
} else if (op & 32) {
state.mode = TYPE;
break top;
} else {
strm.msg = "invalid literal/length code";
state.mode = BAD;
break top;
}
break;
}
} while (_in < last && _out < end);
len = bits >> 3;
_in -= len;
bits -= len << 3;
hold &= (1 << bits) - 1;
strm.next_in = _in;
strm.next_out = _out;
strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
state.hold = hold;
state.bits = bits;
return;
};
}
});
// node_modules/pako/lib/zlib/inftrees.js
var require_inftrees = __commonJS({
"node_modules/pako/lib/zlib/inftrees.js"(exports, module) {
"use strict";
var MAXBITS = 15;
var ENOUGH_LENS = 852;
var ENOUGH_DISTS = 592;
var CODES = 0;
var LENS = 1;
var DISTS = 2;
var lbase = new Uint16Array([
/* Length codes 257..285 base */
3,
4,
5,
6,
7,
8,
9,
10,
11,
13,
15,
17,
19,
23,
27,
31,
35,
43,
51,
59,
67,
83,
99,
115,
131,
163,
195,
227,
258,
0,
0
]);
var lext = new Uint8Array([
/* Length codes 257..285 extra */
16,
16,
16,
16,
16,
16,
16,
16,
17,
17,
17,
17,
18,
18,
18,
18,
19,
19,
19,
19,
20,
20,
20,
20,
21,
21,
21,
21,
16,
72,
78
]);
var dbase = new Uint16Array([
/* Distance codes 0..29 base */
1,
2,
3,
4,
5,
7,
9,
13,
17,
25,
33,
49,
65,
97,
129,
193,
257,
385,
513,
769,
1025,
1537,
2049,
3073,
4097,
6145,
8193,
12289,
16385,
24577,
0,
0
]);
var dext = new Uint8Array([
/* Distance codes 0..29 extra */
16,
16,
16,
16,
17,
17,
18,
18,
19,
19,
20,
20,
21,
21,
22,
22,
23,
23,
24,
24,
25,
25,
26,
26,
27,
27,
28,
28,
29,
29,
64,
64
]);
var inflate_table = (type, lens, lens_index, codes, table, table_index, work, opts) => {
const bits = opts.bits;
let len = 0;
let sym = 0;
let min = 0, max = 0;
let root = 0;
let curr = 0;
let drop = 0;
let left = 0;
let used = 0;
let huff = 0;
let incr;
let fill;
let low;
let mask;
let next;
let base = null;
let match;
const count = new Uint16Array(MAXBITS + 1);
const offs = new Uint16Array(MAXBITS + 1);
let extra = null;
let here_bits, here_op, here_val;
for (len = 0; len <= MAXBITS; len++) {
count[len] = 0;
}
for (sym = 0; sym < codes; sym++) {
count[lens[lens_index + sym]]++;
}
root = bits;
for (max = MAXBITS; max >= 1; max--) {
if (count[max] !== 0) {
break;
}
}
if (root > max) {
root = max;
}
if (max === 0) {
table[table_index++] = 1 << 24 | 64 << 16 | 0;
table[table_index++] = 1 << 24 | 64 << 16 | 0;
opts.bits = 1;
return 0;
}
for (min = 1; min < max; min++) {
if (count[min] !== 0) {
break;
}
}
if (root < min) {
root = min;
}
left = 1;
for (len = 1; len <= MAXBITS; len++) {
left <<= 1;
left -= count[len];
if (left < 0) {
return -1;
}
}
if (left > 0 && (type === CODES || max !== 1)) {
return -1;
}
offs[1] = 0;
for (len = 1; len < MAXBITS; len++) {
offs[len + 1] = offs[len] + count[len];
}
for (sym = 0; sym < codes; sym++) {
if (lens[lens_index + sym] !== 0) {
work[offs[lens[lens_index + sym]]++] = sym;
}
}
if (type === CODES) {
base = extra = work;
match = 20;
} else if (type === LENS) {
base = lbase;
extra = lext;
match = 257;
} else {
base = dbase;
extra = dext;
match = 0;
}
huff = 0;
sym = 0;
len = min;
next = table_index;
curr = root;
drop = 0;
low = -1;
used = 1 << root;
mask = used - 1;
if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
return 1;
}
for (; ; ) {
here_bits = len - drop;
if (work[sym] + 1 < match) {
here_op = 0;
here_val = work[sym];
} else if (work[sym] >= match) {
here_op = extra[work[sym] - match];
here_val = base[work[sym] - match];
} else {
here_op = 32 + 64;
here_val = 0;
}
incr = 1 << len - drop;
fill = 1 << curr;
min = fill;
do {
fill -= incr;
table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
} while (fill !== 0);
incr = 1 << len - 1;
while (huff & incr) {
incr >>= 1;
}
if (incr !== 0) {
huff &= incr - 1;
huff += incr;
} else {
huff = 0;
}
sym++;
if (--count[len] === 0) {
if (len === max) {
break;
}
len = lens[lens_index + work[sym]];
}
if (len > root && (huff & mask) !== low) {
if (drop === 0) {
drop = root;
}
next += min;
curr = len - drop;
left = 1 << curr;
while (curr + drop < max) {
left -= count[curr + drop];
if (left <= 0) {
break;
}
curr++;
left <<= 1;
}
used += 1 << curr;
if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
return 1;
}
low = huff & mask;
table[low] = root << 24 | curr << 16 | next - table_index | 0;
}
}
if (huff !== 0) {
table[next + huff] = len - drop << 24 | 64 << 16 | 0;
}
opts.bits = root;
return 0;
};
module.exports = inflate_table;
}
});
// node_modules/pako/lib/zlib/constants.js
var require_constants = __commonJS({
"node_modules/pako/lib/zlib/constants.js"(exports, module) {
"use strict";
module.exports = {
/* Allowed flush values; see deflate() and inflate() below for details */
Z_NO_FLUSH: 0,
Z_PARTIAL_FLUSH: 1,
Z_SYNC_FLUSH: 2,
Z_FULL_FLUSH: 3,
Z_FINISH: 4,
Z_BLOCK: 5,
Z_TREES: 6,
/* Return codes for the compression/decompression functions. Negative values
* are errors, positive values are used for special but normal events.
*/
Z_OK: 0,
Z_STREAM_END: 1,
Z_NEED_DICT: 2,
Z_ERRNO: -1,
Z_STREAM_ERROR: -2,
Z_DATA_ERROR: -3,
Z_MEM_ERROR: -4,
Z_BUF_ERROR: -5,
//Z_VERSION_ERROR: -6,
/* compression levels */
Z_NO_COMPRESSION: 0,
Z_BEST_SPEED: 1,
Z_BEST_COMPRESSION: 9,
Z_DEFAULT_COMPRESSION: -1,
Z_FILTERED: 1,
Z_HUFFMAN_ONLY: 2,
Z_RLE: 3,
Z_FIXED: 4,
Z_DEFAULT_STRATEGY: 0,
/* Possible values of the data_type field (though see inflate()) */
Z_BINARY: 0,
Z_TEXT: 1,
//Z_ASCII: 1, // = Z_TEXT (deprecated)
Z_UNKNOWN: 2,
/* The deflate compression method */
Z_DEFLATED: 8
//Z_NULL: null // Use -1 or null inline, depending on var type
};
}
});
// node_modules/pako/lib/zlib/inflate.js
var require_inflate = __commonJS({
"node_modules/pako/lib/zlib/inflate.js"(exports, module) {
"use strict";
var adler32 = require_adler32();
var crc32 = require_crc32();
var inflate_fast = require_inffast();
var inflate_table = require_inftrees();
var CODES = 0;
var LENS = 1;
var DISTS = 2;
var {
Z_FINISH,
Z_BLOCK,
Z_TREES,
Z_OK,
Z_STREAM_END,
Z_NEED_DICT,
Z_STREAM_ERROR,
Z_DATA_ERROR,
Z_MEM_ERROR,
Z_BUF_ERROR,
Z_DEFLATED
} = require_constants();
var HEAD = 16180;
var FLAGS = 16181;
var TIME = 16182;
var OS = 16183;
var EXLEN = 16184;
var EXTRA = 16185;
var NAME = 16186;
var COMMENT = 16187;
var HCRC = 16188;
var DICTID = 16189;
var DICT = 16190;
var TYPE = 16191;
var TYPEDO = 16192;
var STORED = 16193;
var COPY_ = 16194;
var COPY = 16195;
var TABLE = 16196;
var LENLENS = 16197;
var CODELENS = 16198;
var LEN_ = 16199;
var LEN = 16200;
var LENEXT = 16201;
var DIST = 16202;
var DISTEXT = 16203;
var MATCH = 16204;
var LIT = 16205;
var CHECK = 16206;
var LENGTH = 16207;
var DONE = 16208;
var BAD = 16209;
var MEM = 16210;
var SYNC = 16211;
var ENOUGH_LENS = 852;
var ENOUGH_DISTS = 592;
var MAX_WBITS = 15;
var DEF_WBITS = MAX_WBITS;
var zswap32 = (q) => {
return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
};
function InflateState() {
this.strm = null;
this.mode = 0;
this.last = false;
this.wrap = 0;
this.havedict = false;
this.flags = 0;
this.dmax = 0;
this.check = 0;
this.total = 0;
this.head = null;
this.wbits = 0;
this.wsize = 0;
this.whave = 0;
this.wnext = 0;
this.window = null;
this.hold = 0;
this.bits = 0;
this.length = 0;
this.offset = 0;
this.extra = 0;
this.lencode = null;
this.distcode = null;
this.lenbits = 0;
this.distbits = 0;
this.ncode = 0;
this.nlen = 0;
this.ndist = 0;
this.have = 0;
this.next = null;
this.lens = new Uint16Array(320);
this.work = new Uint16Array(288);
this.lendyn = null;
this.distdyn = null;
this.sane = 0;
this.back = 0;
this.was = 0;
}
var inflateStateCheck = (strm) => {
if (!strm) {
return 1;
}
const state = strm.state;
if (!state || state.strm !== strm || state.mode < HEAD || state.mode > SYNC) {
return 1;
}
return 0;
};
var inflateResetKeep = (strm) => {
if (inflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
const state = strm.state;
strm.total_in = strm.total_out = state.total = 0;
strm.msg = "";
if (state.wrap) {
strm.adler = state.wrap & 1;
}
state.mode = HEAD;
state.last = 0;
state.havedict = 0;
state.flags = -1;
state.dmax = 32768;
state.head = null;
state.hold = 0;
state.bits = 0;
state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);
state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);
state.sane = 1;
state.back = -1;
return Z_OK;
};
var inflateReset = (strm) => {
if (inflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
const state = strm.state;
state.wsize = 0;
state.whave = 0;
state.wnext = 0;
return inflateResetKeep(strm);
};
var inflateReset2 = (strm, windowBits) => {
let wrap;
if (inflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
const state = strm.state;
if (windowBits < 0) {
wrap = 0;
windowBits = -windowBits;
} else {
wrap = (windowBits >> 4) + 5;
if (windowBits < 48) {
windowBits &= 15;
}
}
if (windowBits && (windowBits < 8 || windowBits > 15)) {
return Z_STREAM_ERROR;
}
if (state.window !== null && state.wbits !== windowBits) {
state.window = null;
}
state.wrap = wrap;
state.wbits = windowBits;
return inflateReset(strm);
};
var inflateInit2 = (strm, windowBits) => {
if (!strm) {
return Z_STREAM_ERROR;
}
const state = new InflateState();
strm.state = state;
state.strm = strm;
state.window = null;
state.mode = HEAD;
const ret = inflateReset2(strm, windowBits);
if (ret !== Z_OK) {
strm.state = null;
}
return ret;
};
var inflateInit = (strm) => {
return inflateInit2(strm, DEF_WBITS);
};
var virgin = true;
var lenfix;
var distfix;
var fixedtables = (state) => {
if (virgin) {
lenfix = new Int32Array(512);
distfix = new Int32Array(32);
let sym = 0;
while (sym < 144) {
state.lens[sym++] = 8;
}
while (sym < 256) {
state.lens[sym++] = 9;
}
while (sym < 280) {
state.lens[sym++] = 7;
}
while (sym < 288) {
state.lens[sym++] = 8;
}
inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
sym = 0;
while (sym < 32) {
state.lens[sym++] = 5;
}
inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
virgin = false;
}
state.lencode = lenfix;
state.lenbits = 9;
state.distcode = distfix;
state.distbits = 5;
};
var updatewindow = (strm, src, end, copy) => {
let dist;
const state = strm.state;
if (state.window === null) {
state.wsize = 1 << state.wbits;
state.wnext = 0;
state.whave = 0;
state.window = new Uint8Array(state.wsize);
}
if (copy >= state.wsize) {
state.window.set(src.subarray(end - state.wsize, end), 0);
state.wnext = 0;
state.whave = state.wsize;
} else {
dist = state.wsize - state.wnext;
if (dist > copy) {
dist = copy;
}
state.window.set(src.subarray(end - copy, end - copy + dist), state.wnext);
copy -= dist;
if (copy) {
state.window.set(src.subarray(end - copy, end), 0);
state.wnext = copy;
state.whave = state.wsize;
} else {
state.wnext += dist;
if (state.wnext === state.wsize) {
state.wnext = 0;
}
if (state.whave < state.wsize) {
state.whave += dist;
}
}
}
return 0;
};
var inflate = (strm, flush) => {
let state;
let input, output;
let next;
let put;
let have, left;
let hold;
let bits;
let _in, _out;
let copy;
let from;
let from_source;
let here = 0;
let here_bits, here_op, here_val;
let last_bits, last_op, last_val;
let len;
let ret;
const hbuf = new Uint8Array(4);
let opts;
let n;
const order = (
/* permutation of code lengths */
new Uint8Array([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15])
);
if (inflateStateCheck(strm) || !strm.output || !strm.input && strm.avail_in !== 0) {
return Z_STREAM_ERROR;
}
state = strm.state;
if (state.mode === TYPE) {
state.mode = TYPEDO;
}
put = strm.next_out;
output = strm.output;
left = strm.avail_out;
next = strm.next_in;
input = strm.input;
have = strm.avail_in;
hold = state.hold;
bits = state.bits;
_in = have;
_out = left;
ret = Z_OK;
inf_leave:
for (; ; ) {
switch (state.mode) {
case HEAD:
if (state.wrap === 0) {
state.mode = TYPEDO;
break;
}
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.wrap & 2 && hold === 35615) {
if (state.wbits === 0) {
state.wbits = 15;
}
state.check = 0;
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
hold = 0;
bits = 0;
state.mode = FLAGS;
break;
}
if (state.head) {
state.head.done = false;
}
if (!(state.wrap & 1) || /* check if zlib header allowed */
(((hold & 255) << 8) + (hold >> 8)) % 31) {
strm.msg = "incorrect header check";
state.mode = BAD;
break;
}
if ((hold & 15) !== Z_DEFLATED) {
strm.msg = "unknown compression method";
state.mode = BAD;
break;
}
hold >>>= 4;
bits -= 4;
len = (hold & 15) + 8;
if (state.wbits === 0) {
state.wbits = len;
}
if (len > 15 || len > state.wbits) {
strm.msg = "invalid window size";
state.mode = BAD;
break;
}
state.dmax = 1 << state.wbits;
state.flags = 0;
strm.adler = state.check = 1;
state.mode = hold & 512 ? DICTID : TYPE;
hold = 0;
bits = 0;
break;
case FLAGS:
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.flags = hold;
if ((state.flags & 255) !== Z_DEFLATED) {
strm.msg = "unknown compression method";
state.mode = BAD;
break;
}
if (state.flags & 57344) {
strm.msg = "unknown header flags set";
state.mode = BAD;
break;
}
if (state.head) {
state.head.text = hold >> 8 & 1;
}
if (state.flags & 512 && state.wrap & 4) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
}
hold = 0;
bits = 0;
state.mode = TIME;
/* falls through */
case TIME:
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.head) {
state.head.time = hold;
}
if (state.flags & 512 && state.wrap & 4) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
hbuf[2] = hold >>> 16 & 255;
hbuf[3] = hold >>> 24 & 255;
state.check = crc32(state.check, hbuf, 4, 0);
}
hold = 0;
bits = 0;
state.mode = OS;
/* falls through */
case OS:
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.head) {
state.head.xflags = hold & 255;
state.head.os = hold >> 8;
}
if (state.flags & 512 && state.wrap & 4) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
}
hold = 0;
bits = 0;
state.mode = EXLEN;
/* falls through */
case EXLEN:
if (state.flags & 1024) {
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.length = hold;
if (state.head) {
state.head.extra_len = hold;
}
if (state.flags & 512 && state.wrap & 4) {
hbuf[0] = hold & 255;
hbuf[1] = hold >>> 8 & 255;
state.check = crc32(state.check, hbuf, 2, 0);
}
hold = 0;
bits = 0;
} else if (state.head) {
state.head.extra = null;
}
state.mode = EXTRA;
/* falls through */
case EXTRA:
if (state.flags & 1024) {
copy = state.length;
if (copy > have) {
copy = have;
}
if (copy) {
if (state.head) {
len = state.head.extra_len - state.length;
if (!state.head.extra) {
state.head.extra = new Uint8Array(state.head.extra_len);
}
state.head.extra.set(
input.subarray(
next,
// extra field is limited to 65536 bytes
// - no need for additional size check
next + copy
),
/*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
len
);
}
if (state.flags & 512 && state.wrap & 4) {
state.check = crc32(state.check, input, copy, next);
}
have -= copy;
next += copy;
state.length -= copy;
}
if (state.length) {
break inf_leave;
}
}
state.length = 0;
state.mode = NAME;
/* falls through */
case NAME:
if (state.flags & 2048) {
if (have === 0) {
break inf_leave;
}
copy = 0;
do {
len = input[next + copy++];
if (state.head && len && state.length < 65536) {
state.head.name += String.fromCharCode(len);
}
} while (len && copy < have);
if (state.flags & 512 && state.wrap & 4) {
state.check = crc32(state.check, input, copy, next);
}
have -= copy;
next += copy;
if (len) {
break inf_leave;
}
} else if (state.head) {
state.head.name = null;
}
state.length = 0;
state.mode = COMMENT;
/* falls through */
case COMMENT:
if (state.flags & 4096) {
if (have === 0) {
break inf_leave;
}
copy = 0;
do {
len = input[next + copy++];
if (state.head && len && state.length < 65536) {
state.head.comment += String.fromCharCode(len);
}
} while (len && copy < have);
if (state.flags & 512 && state.wrap & 4) {
state.check = crc32(state.check, input, copy, next);
}
have -= copy;
next += copy;
if (len) {
break inf_leave;
}
} else if (state.head) {
state.head.comment = null;
}
state.mode = HCRC;
/* falls through */
case HCRC:
if (state.flags & 512) {
while (bits < 16) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.wrap & 4 && hold !== (state.check & 65535)) {
strm.msg = "header crc mismatch";
state.mode = BAD;
break;
}
hold = 0;
bits = 0;
}
if (state.head) {
state.head.hcrc = state.flags >> 9 & 1;
state.head.done = true;
}
strm.adler = state.check = 0;
state.mode = TYPE;
break;
case DICTID:
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
strm.adler = state.check = zswap32(hold);
hold = 0;
bits = 0;
state.mode = DICT;
/* falls through */
case DICT:
if (state.havedict === 0) {
strm.next_out = put;
strm.avail_out = left;
strm.next_in = next;
strm.avail_in = have;
state.hold = hold;
state.bits = bits;
return Z_NEED_DICT;
}
strm.adler = state.check = 1;
state.mode = TYPE;
/* falls through */
case TYPE:
if (flush === Z_BLOCK || flush === Z_TREES) {
break inf_leave;
}
/* falls through */
case TYPEDO:
if (state.last) {
hold >>>= bits & 7;
bits -= bits & 7;
state.mode = CHECK;
break;
}
while (bits < 3) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.last = hold & 1;
hold >>>= 1;
bits -= 1;
switch (hold & 3) {
case 0:
state.mode = STORED;
break;
case 1:
fixedtables(state);
state.mode = LEN_;
if (flush === Z_TREES) {
hold >>>= 2;
bits -= 2;
break inf_leave;
}
break;
case 2:
state.mode = TABLE;
break;
case 3:
strm.msg = "invalid block type";
state.mode = BAD;
}
hold >>>= 2;
bits -= 2;
break;
case STORED:
hold >>>= bits & 7;
bits -= bits & 7;
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
strm.msg = "invalid stored block lengths";
state.mode = BAD;
break;
}
state.length = hold & 65535;
hold = 0;
bits = 0;
state.mode = COPY_;
if (flush === Z_TREES) {
break inf_leave;
}
/* falls through */
case COPY_:
state.mode = COPY;
/* falls through */
case COPY:
copy = state.length;
if (copy) {
if (copy > have) {
copy = have;
}
if (copy > left) {
copy = left;
}
if (copy === 0) {
break inf_leave;
}
output.set(input.subarray(next, next + copy), put);
have -= copy;
next += copy;
left -= copy;
put += copy;
state.length -= copy;
break;
}
state.mode = TYPE;
break;
case TABLE:
while (bits < 14) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.nlen = (hold & 31) + 257;
hold >>>= 5;
bits -= 5;
state.ndist = (hold & 31) + 1;
hold >>>= 5;
bits -= 5;
state.ncode = (hold & 15) + 4;
hold >>>= 4;
bits -= 4;
if (state.nlen > 286 || state.ndist > 30) {
strm.msg = "too many length or distance symbols";
state.mode = BAD;
break;
}
state.have = 0;
state.mode = LENLENS;
/* falls through */
case LENLENS:
while (state.have < state.ncode) {
while (bits < 3) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.lens[order[state.have++]] = hold & 7;
hold >>>= 3;
bits -= 3;
}
while (state.have < 19) {
state.lens[order[state.have++]] = 0;
}
state.lencode = state.lendyn;
state.lenbits = 7;
opts = { bits: state.lenbits };
ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
state.lenbits = opts.bits;
if (ret) {
strm.msg = "invalid code lengths set";
state.mode = BAD;
break;
}
state.have = 0;
state.mode = CODELENS;
/* falls through */
case CODELENS:
while (state.have < state.nlen + state.ndist) {
for (; ; ) {
here = state.lencode[hold & (1 << state.lenbits) - 1];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (here_val < 16) {
hold >>>= here_bits;
bits -= here_bits;
state.lens[state.have++] = here_val;
} else {
if (here_val === 16) {
n = here_bits + 2;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= here_bits;
bits -= here_bits;
if (state.have === 0) {
strm.msg = "invalid bit length repeat";
state.mode = BAD;
break;
}
len = state.lens[state.have - 1];
copy = 3 + (hold & 3);
hold >>>= 2;
bits -= 2;
} else if (here_val === 17) {
n = here_bits + 3;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= here_bits;
bits -= here_bits;
len = 0;
copy = 3 + (hold & 7);
hold >>>= 3;
bits -= 3;
} else {
n = here_bits + 7;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= here_bits;
bits -= here_bits;
len = 0;
copy = 11 + (hold & 127);
hold >>>= 7;
bits -= 7;
}
if (state.have + copy > state.nlen + state.ndist) {
strm.msg = "invalid bit length repeat";
state.mode = BAD;
break;
}
while (copy--) {
state.lens[state.have++] = len;
}
}
}
if (state.mode === BAD) {
break;
}
if (state.lens[256] === 0) {
strm.msg = "invalid code -- missing end-of-block";
state.mode = BAD;
break;
}
state.lenbits = 9;
opts = { bits: state.lenbits };
ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
state.lenbits = opts.bits;
if (ret) {
strm.msg = "invalid literal/lengths set";
state.mode = BAD;
break;
}
state.distbits = 6;
state.distcode = state.distdyn;
opts = { bits: state.distbits };
ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
state.distbits = opts.bits;
if (ret) {
strm.msg = "invalid distances set";
state.mode = BAD;
break;
}
state.mode = LEN_;
if (flush === Z_TREES) {
break inf_leave;
}
/* falls through */
case LEN_:
state.mode = LEN;
/* falls through */
case LEN:
if (have >= 6 && left >= 258) {
strm.next_out = put;
strm.avail_out = left;
strm.next_in = next;
strm.avail_in = have;
state.hold = hold;
state.bits = bits;
inflate_fast(strm, _out);
put = strm.next_out;
output = strm.output;
left = strm.avail_out;
next = strm.next_in;
input = strm.input;
have = strm.avail_in;
hold = state.hold;
bits = state.bits;
if (state.mode === TYPE) {
state.back = -1;
}
break;
}
state.back = 0;
for (; ; ) {
here = state.lencode[hold & (1 << state.lenbits) - 1];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (here_op && (here_op & 240) === 0) {
last_bits = here_bits;
last_op = here_op;
last_val = here_val;
for (; ; ) {
here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (last_bits + here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= last_bits;
bits -= last_bits;
state.back += last_bits;
}
hold >>>= here_bits;
bits -= here_bits;
state.back += here_bits;
state.length = here_val;
if (here_op === 0) {
state.mode = LIT;
break;
}
if (here_op & 32) {
state.back = -1;
state.mode = TYPE;
break;
}
if (here_op & 64) {
strm.msg = "invalid literal/length code";
state.mode = BAD;
break;
}
state.extra = here_op & 15;
state.mode = LENEXT;
/* falls through */
case LENEXT:
if (state.extra) {
n = state.extra;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.length += hold & (1 << state.extra) - 1;
hold >>>= state.extra;
bits -= state.extra;
state.back += state.extra;
}
state.was = state.length;
state.mode = DIST;
/* falls through */
case DIST:
for (; ; ) {
here = state.distcode[hold & (1 << state.distbits) - 1];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if ((here_op & 240) === 0) {
last_bits = here_bits;
last_op = here_op;
last_val = here_val;
for (; ; ) {
here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
here_bits = here >>> 24;
here_op = here >>> 16 & 255;
here_val = here & 65535;
if (last_bits + here_bits <= bits) {
break;
}
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
hold >>>= last_bits;
bits -= last_bits;
state.back += last_bits;
}
hold >>>= here_bits;
bits -= here_bits;
state.back += here_bits;
if (here_op & 64) {
strm.msg = "invalid distance code";
state.mode = BAD;
break;
}
state.offset = here_val;
state.extra = here_op & 15;
state.mode = DISTEXT;
/* falls through */
case DISTEXT:
if (state.extra) {
n = state.extra;
while (bits < n) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
state.offset += hold & (1 << state.extra) - 1;
hold >>>= state.extra;
bits -= state.extra;
state.back += state.extra;
}
if (state.offset > state.dmax) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break;
}
state.mode = MATCH;
/* falls through */
case MATCH:
if (left === 0) {
break inf_leave;
}
copy = _out - left;
if (state.offset > copy) {
copy = state.offset - copy;
if (copy > state.whave) {
if (state.sane) {
strm.msg = "invalid distance too far back";
state.mode = BAD;
break;
}
}
if (copy > state.wnext) {
copy -= state.wnext;
from = state.wsize - copy;
} else {
from = state.wnext - copy;
}
if (copy > state.length) {
copy = state.length;
}
from_source = state.window;
} else {
from_source = output;
from = put - state.offset;
copy = state.length;
}
if (copy > left) {
copy = left;
}
left -= copy;
state.length -= copy;
do {
output[put++] = from_source[from++];
} while (--copy);
if (state.length === 0) {
state.mode = LEN;
}
break;
case LIT:
if (left === 0) {
break inf_leave;
}
output[put++] = state.length;
left--;
state.mode = LEN;
break;
case CHECK:
if (state.wrap) {
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold |= input[next++] << bits;
bits += 8;
}
_out -= left;
strm.total_out += _out;
state.total += _out;
if (state.wrap & 4 && _out) {
strm.adler = state.check = /*UPDATE_CHECK(state.check, put - _out, _out);*/
state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out);
}
_out = left;
if (state.wrap & 4 && (state.flags ? hold : zswap32(hold)) !== state.check) {
strm.msg = "incorrect data check";
state.mode = BAD;
break;
}
hold = 0;
bits = 0;
}
state.mode = LENGTH;
/* falls through */
case LENGTH:
if (state.wrap && state.flags) {
while (bits < 32) {
if (have === 0) {
break inf_leave;
}
have--;
hold += input[next++] << bits;
bits += 8;
}
if (state.wrap & 4 && hold !== (state.total & 4294967295)) {
strm.msg = "incorrect length check";
state.mode = BAD;
break;
}
hold = 0;
bits = 0;
}
state.mode = DONE;
/* falls through */
case DONE:
ret = Z_STREAM_END;
break inf_leave;
case BAD:
ret = Z_DATA_ERROR;
break inf_leave;
case MEM:
return Z_MEM_ERROR;
case SYNC:
/* falls through */
default:
return Z_STREAM_ERROR;
}
}
strm.next_out = put;
strm.avail_out = left;
strm.next_in = next;
strm.avail_in = have;
state.hold = hold;
state.bits = bits;
if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
state.mode = MEM;
return Z_MEM_ERROR;
}
}
_in -= strm.avail_in;
_out -= strm.avail_out;
strm.total_in += _in;
strm.total_out += _out;
state.total += _out;
if (state.wrap & 4 && _out) {
strm.adler = state.check = /*UPDATE_CHECK(state.check, strm.next_out - _out, _out);*/
state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out);
}
strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
ret = Z_BUF_ERROR;
}
return ret;
};
var inflateEnd = (strm) => {
if (inflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
let state = strm.state;
if (state.window) {
state.window = null;
}
strm.state = null;
return Z_OK;
};
var inflateGetHeader = (strm, head) => {
if (inflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
const state = strm.state;
if ((state.wrap & 2) === 0) {
return Z_STREAM_ERROR;
}
state.head = head;
head.done = false;
return Z_OK;
};
var inflateSetDictionary = (strm, dictionary) => {
const dictLength = dictionary.length;
let state;
let dictid;
let ret;
if (inflateStateCheck(strm)) {
return Z_STREAM_ERROR;
}
state = strm.state;
if (state.wrap !== 0 && state.mode !== DICT) {
return Z_STREAM_ERROR;
}
if (state.mode === DICT) {
dictid = 1;
dictid = adler32(dictid, dictionary, dictLength, 0);
if (dictid !== state.check) {
return Z_DATA_ERROR;
}
}
ret = updatewindow(strm, dictionary, dictLength, dictLength);
if (ret) {
state.mode = MEM;
return Z_MEM_ERROR;
}
state.havedict = 1;
return Z_OK;
};
module.exports.inflateReset = inflateReset;
module.exports.inflateReset2 = inflateReset2;
module.exports.inflateResetKeep = inflateResetKeep;
module.exports.inflateInit = inflateInit;
module.exports.inflateInit2 = inflateInit2;
module.exports.inflate = inflate;
module.exports.inflateEnd = inflateEnd;
module.exports.inflateGetHeader = inflateGetHeader;
module.exports.inflateSetDictionary = inflateSetDictionary;
module.exports.inflateInfo = "pako inflate (from Nodeca project)";
}
});
// node_modules/pako/lib/utils/common.js
var require_common = __commonJS({
"node_modules/pako/lib/utils/common.js"(exports, module) {
"use strict";
var _has = (obj, key) => {
return Object.prototype.hasOwnProperty.call(obj, key);
};
module.exports.assign = function(obj) {
const sources = Array.prototype.slice.call(arguments, 1);
while (sources.length) {
const source = sources.shift();
if (!source) {
continue;
}
if (typeof source !== "object") {
throw new TypeError(source + "must be non-object");
}
for (const p in source) {
if (_has(source, p)) {
obj[p] = source[p];
}
}
}
return obj;
};
module.exports.flattenChunks = (chunks) => {
let len = 0;
for (let i = 0, l = chunks.length; i < l; i++) {
len += chunks[i].length;
}
const result = new Uint8Array(len);
for (let i = 0, pos = 0, l = chunks.length; i < l; i++) {
let chunk = chunks[i];
result.set(chunk, pos);
pos += chunk.length;
}
return result;
};
}
});
// node_modules/pako/lib/utils/strings.js
var require_strings = __commonJS({
"node_modules/pako/lib/utils/strings.js"(exports, module) {
"use strict";
var STR_APPLY_UIA_OK = true;
try {
String.fromCharCode.apply(null, new Uint8Array(1));
} catch (__) {
STR_APPLY_UIA_OK = false;
}
var _utf8len = new Uint8Array(256);
for (let q = 0; q < 256; q++) {
_utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
}
_utf8len[254] = _utf8len[254] = 1;
module.exports.string2buf = (str) => {
if (typeof TextEncoder === "function" && TextEncoder.prototype.encode) {
return new TextEncoder().encode(str);
}
let buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
for (m_pos = 0; m_pos < str_len; m_pos++) {
c = str.charCodeAt(m_pos);
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
c2 = str.charCodeAt(m_pos + 1);
if ((c2 & 64512) === 56320) {
c = 65536 + (c - 55296 << 10) + (c2 - 56320);
m_pos++;
}
}
buf_len += c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;
}
buf = new Uint8Array(buf_len);
for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
c = str.charCodeAt(m_pos);
if ((c & 64512) === 55296 && m_pos + 1 < str_len) {
c2 = str.charCodeAt(m_pos + 1);
if ((c2 & 64512) === 56320) {
c = 65536 + (c - 55296 << 10) + (c2 - 56320);
m_pos++;
}
}
if (c < 128) {
buf[i++] = c;
} else if (c < 2048) {
buf[i++] = 192 | c >>> 6;
buf[i++] = 128 | c & 63;
} else if (c < 65536) {
buf[i++] = 224 | c >>> 12;
buf[i++] = 128 | c >>> 6 & 63;
buf[i++] = 128 | c & 63;
} else {
buf[i++] = 240 | c >>> 18;
buf[i++] = 128 | c >>> 12 & 63;
buf[i++] = 128 | c >>> 6 & 63;
buf[i++] = 128 | c & 63;
}
}
return buf;
};
var buf2binstring = (buf, len) => {
if (len < 65534) {
if (buf.subarray && STR_APPLY_UIA_OK) {
return String.fromCharCode.apply(null, buf.length === len ? buf : buf.subarray(0, len));
}
}
let result = "";
for (let i = 0; i < len; i++) {
result += String.fromCharCode(buf[i]);
}
return result;
};
module.exports.buf2string = (buf, max) => {
const len = max || buf.length;
if (typeof TextDecoder === "function" && TextDecoder.prototype.decode) {
return new TextDecoder().decode(buf.subarray(0, max));
}
let i, out;
const utf16buf = new Array(len * 2);
for (out = 0, i = 0; i < len; ) {
let c = buf[i++];
if (c < 128) {
utf16buf[out++] = c;
continue;
}
let c_len = _utf8len[c];
if (c_len > 4) {
utf16buf[out++] = 65533;
i += c_len - 1;
continue;
}
c &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
while (c_len > 1 && i < len) {
c = c << 6 | buf[i++] & 63;
c_len--;
}
if (c_len > 1) {
utf16buf[out++] = 65533;
continue;
}
if (c < 65536) {
utf16buf[out++] = c;
} else {
c -= 65536;
utf16buf[out++] = 55296 | c >> 10 & 1023;
utf16buf[out++] = 56320 | c & 1023;
}
}
return buf2binstring(utf16buf, out);
};
module.exports.utf8border = (buf, max) => {
max = max || buf.length;
if (max > buf.length) {
max = buf.length;
}
let pos = max - 1;
while (pos >= 0 && (buf[pos] & 192) === 128) {
pos--;
}
if (pos < 0) {
return max;
}
if (pos === 0) {
return max;
}
return pos + _utf8len[buf[pos]] > max ? pos : max;
};
}
});
// node_modules/pako/lib/zlib/messages.js
var require_messages = __commonJS({
"node_modules/pako/lib/zlib/messages.js"(exports, module) {
"use strict";
module.exports = {
2: "need dictionary",
/* Z_NEED_DICT 2 */
1: "stream end",
/* Z_STREAM_END 1 */
0: "",
/* Z_OK 0 */
"-1": "file error",
/* Z_ERRNO (-1) */
"-2": "stream error",
/* Z_STREAM_ERROR (-2) */
"-3": "data error",
/* Z_DATA_ERROR (-3) */
"-4": "insufficient memory",
/* Z_MEM_ERROR (-4) */
"-5": "buffer error",
/* Z_BUF_ERROR (-5) */
"-6": "incompatible version"
/* Z_VERSION_ERROR (-6) */
};
}
});
// node_modules/pako/lib/zlib/zstream.js
var require_zstream = __commonJS({
"node_modules/pako/lib/zlib/zstream.js"(exports, module) {
"use strict";
function ZStream() {
this.input = null;
this.next_in = 0;
this.avail_in = 0;
this.total_in = 0;
this.output = null;
this.next_out = 0;
this.avail_out = 0;
this.total_out = 0;
this.msg = "";
this.state = null;
this.data_type = 2;
this.adler = 0;
}
module.exports = ZStream;
}
});
// node_modules/pako/lib/zlib/gzheader.js
var require_gzheader = __commonJS({
"node_modules/pako/lib/zlib/gzheader.js"(exports, module) {
"use strict";
function GZheader() {
this.text = 0;
this.time = 0;
this.xflags = 0;
this.os = 0;
this.extra = null;
this.extra_len = 0;
this.name = "";
this.comment = "";
this.hcrc = 0;
this.done = false;
}
module.exports = GZheader;
}
});
// node_modules/pako/lib/inflate.js
var require_inflate2 = __commonJS({
"node_modules/pako/lib/inflate.js"(exports, module) {
"use strict";
var zlib_inflate = require_inflate();
var utils = require_common();
var strings = require_strings();
var msg = require_messages();
var ZStream = require_zstream();
var GZheader = require_gzheader();
var toString = Object.prototype.toString;
var {
Z_NO_FLUSH,
Z_FINISH,
Z_OK,
Z_STREAM_END,
Z_NEED_DICT,
Z_STREAM_ERROR,
Z_DATA_ERROR,
Z_MEM_ERROR
} = require_constants();
function Inflate(options) {
this.options = utils.assign({
chunkSize: 1024 * 64,
windowBits: 15,
to: ""
}, options || {});
const opt = this.options;
if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
opt.windowBits = -opt.windowBits;
if (opt.windowBits === 0) {
opt.windowBits = -15;
}
}
if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
opt.windowBits += 32;
}
if (opt.windowBits > 15 && opt.windowBits < 48) {
if ((opt.windowBits & 15) === 0) {
opt.windowBits |= 15;
}
}
this.err = 0;
this.msg = "";
this.ended = false;
this.chunks = [];
this.strm = new ZStream();
this.strm.avail_out = 0;
let status = zlib_inflate.inflateInit2(
this.strm,
opt.windowBits
);
if (status !== Z_OK) {
throw new Error(msg[status]);
}
this.header = new GZheader();
zlib_inflate.inflateGetHeader(this.strm, this.header);
if (opt.dictionary) {
if (typeof opt.dictionary === "string") {
opt.dictionary = strings.string2buf(opt.dictionary);
} else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
opt.dictionary = new Uint8Array(opt.dictionary);
}
if (opt.raw) {
status = zlib_inflate.inflateSetDictionary(this.strm, opt.dictionary);
if (status !== Z_OK) {
throw new Error(msg[status]);
}
}
}
}
Inflate.prototype.push = function(data, flush_mode) {
const strm = this.strm;
const chunkSize = this.options.chunkSize;
const dictionary = this.options.dictionary;
let status, _flush_mode, last_avail_out;
if (this.ended) return false;
if (flush_mode === ~~flush_mode) _flush_mode = flush_mode;
else _flush_mode = flush_mode === true ? Z_FINISH : Z_NO_FLUSH;
if (toString.call(data) === "[object ArrayBuffer]") {
strm.input = new Uint8Array(data);
} else {
strm.input = data;
}
strm.next_in = 0;
strm.avail_in = strm.input.length;
for (; ; ) {
if (strm.avail_out === 0) {
strm.output = new Uint8Array(chunkSize);
strm.next_out = 0;
strm.avail_out = chunkSize;
}
status = zlib_inflate.inflate(strm, _flush_mode);
if (status === Z_NEED_DICT && dictionary) {
status = zlib_inflate.inflateSetDictionary(strm, dictionary);
if (status === Z_OK) {
status = zlib_inflate.inflate(strm, _flush_mode);
} else if (status === Z_DATA_ERROR) {
status = Z_NEED_DICT;
}
}
while (strm.avail_in > 0 && status === Z_STREAM_END && strm.state.wrap > 0 && data[strm.next_in] !== 0) {
zlib_inflate.inflateReset(strm);
status = zlib_inflate.inflate(strm, _flush_mode);
}
switch (status) {
case Z_STREAM_ERROR:
case Z_DATA_ERROR:
case Z_NEED_DICT:
case Z_MEM_ERROR:
this.onEnd(status);
this.ended = true;
return false;
}
last_avail_out = strm.avail_out;
if (strm.next_out) {
if (strm.avail_out === 0 || status === Z_STREAM_END) {
if (this.options.to === "string") {
let next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
let tail = strm.next_out - next_out_utf8;
let utf8str = strings.buf2string(strm.output, next_out_utf8);
strm.next_out = tail;
strm.avail_out = chunkSize - tail;
if (tail) strm.output.set(strm.output.subarray(next_out_utf8, next_out_utf8 + tail), 0);
this.onData(utf8str);
} else {
this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));
}
}
}
if (status === Z_OK && last_avail_out === 0) continue;
if (status === Z_STREAM_END) {
status = zlib_inflate.inflateEnd(this.strm);
this.onEnd(status);
this.ended = true;
return true;
}
if (strm.avail_in === 0) break;
}
return true;
};
Inflate.prototype.onData = function(chunk) {
this.chunks.push(chunk);
};
Inflate.prototype.onEnd = function(status) {
if (status === Z_OK) {
if (this.options.to === "string") {
this.result = this.chunks.join("");
} else {
this.result = utils.flattenChunks(this.chunks);
}
}
this.chunks = [];
this.err = status;
this.msg = this.strm.msg;
};
function inflate(input, options) {
const inflator = new Inflate(options);
inflator.push(input);
if (inflator.err) throw inflator.msg || msg[inflator.err];
return inflator.result;
}
function inflateRaw(input, options) {
options = options || {};
options.raw = true;
return inflate(input, options);
}
module.exports.Inflate = Inflate;
module.exports.inflate = inflate;
module.exports.inflateRaw = inflateRaw;
module.exports.ungzip = inflate;
module.exports.constants = require_constants();
}
});
// packages/engine/Source/Core/decodeGoogleEarthEnterpriseData.js
var compressedMagic = 1953029805;
var compressedMagicSwap = 2917034100;
function decodeGoogleEarthEnterpriseData(key, data) {
if (decodeGoogleEarthEnterpriseData.passThroughDataForTesting) {
return data;
}
Check_default.typeOf.object("key", key);
Check_default.typeOf.object("data", data);
const keyLength = key.byteLength;
if (keyLength === 0 || keyLength % 4 !== 0) {
throw new RuntimeError_default(
"The length of key must be greater than 0 and a multiple of 4."
);
}
const dataView = new DataView(data);
const magic = dataView.getUint32(0, true);
if (magic === compressedMagic || magic === compressedMagicSwap) {
return data;
}
const keyView = new DataView(key);
let dp = 0;
const dpend = data.byteLength;
const dpend64 = dpend - dpend % 8;
const kpend = keyLength;
let kp;
let off = 8;
while (dp < dpend64) {
off = (off + 8) % 24;
kp = off;
while (dp < dpend64 && kp < kpend) {
dataView.setUint32(
dp,
dataView.getUint32(dp, true) ^ keyView.getUint32(kp, true),
true
);
dataView.setUint32(
dp + 4,
dataView.getUint32(dp + 4, true) ^ keyView.getUint32(kp + 4, true),
true
);
dp += 8;
kp += 24;
}
}
if (dp < dpend) {
if (kp >= kpend) {
off = (off + 8) % 24;
kp = off;
}
while (dp < dpend) {
dataView.setUint8(dp, dataView.getUint8(dp) ^ keyView.getUint8(kp));
dp++;
kp++;
}
}
}
decodeGoogleEarthEnterpriseData.passThroughDataForTesting = false;
var decodeGoogleEarthEnterpriseData_default = decodeGoogleEarthEnterpriseData;
// packages/engine/Source/Core/isBitSet.js
function isBitSet(bits, mask) {
return (bits & mask) !== 0;
}
var isBitSet_default = isBitSet;
// packages/engine/Source/Core/GoogleEarthEnterpriseTileInformation.js
var childrenBitmasks = [1, 2, 4, 8];
var anyChildBitmask = 15;
var cacheFlagBitmask = 16;
var imageBitmask = 64;
var terrainBitmask = 128;
function GoogleEarthEnterpriseTileInformation(bits, cnodeVersion, imageryVersion, terrainVersion, imageryProvider, terrainProvider) {
this._bits = bits;
this.cnodeVersion = cnodeVersion;
this.imageryVersion = imageryVersion;
this.terrainVersion = terrainVersion;
this.imageryProvider = imageryProvider;
this.terrainProvider = terrainProvider;
this.ancestorHasTerrain = false;
this.terrainState = void 0;
}
GoogleEarthEnterpriseTileInformation.clone = function(info, result) {
if (!defined_default(result)) {
result = new GoogleEarthEnterpriseTileInformation(
info._bits,
info.cnodeVersion,
info.imageryVersion,
info.terrainVersion,
info.imageryProvider,
info.terrainProvider
);
} else {
result._bits = info._bits;
result.cnodeVersion = info.cnodeVersion;
result.imageryVersion = info.imageryVersion;
result.terrainVersion = info.terrainVersion;
result.imageryProvider = info.imageryProvider;
result.terrainProvider = info.terrainProvider;
}
result.ancestorHasTerrain = info.ancestorHasTerrain;
result.terrainState = info.terrainState;
return result;
};
GoogleEarthEnterpriseTileInformation.prototype.setParent = function(parent) {
this.ancestorHasTerrain = parent.ancestorHasTerrain || this.hasTerrain();
};
GoogleEarthEnterpriseTileInformation.prototype.hasSubtree = function() {
return isBitSet_default(this._bits, cacheFlagBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasImagery = function() {
return isBitSet_default(this._bits, imageBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasTerrain = function() {
return isBitSet_default(this._bits, terrainBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasChildren = function() {
return isBitSet_default(this._bits, anyChildBitmask);
};
GoogleEarthEnterpriseTileInformation.prototype.hasChild = function(index) {
return isBitSet_default(this._bits, childrenBitmasks[index]);
};
GoogleEarthEnterpriseTileInformation.prototype.getChildBitmask = function() {
return this._bits & anyChildBitmask;
};
var GoogleEarthEnterpriseTileInformation_default = GoogleEarthEnterpriseTileInformation;
// packages/engine/Source/Workers/decodeGoogleEarthEnterprisePacket.js
var import_inflate = __toESM(require_inflate2(), 1);
var sizeOfUint16 = Uint16Array.BYTES_PER_ELEMENT;
var sizeOfInt32 = Int32Array.BYTES_PER_ELEMENT;
var sizeOfUint32 = Uint32Array.BYTES_PER_ELEMENT;
var Types = {
METADATA: 0,
TERRAIN: 1,
DBROOT: 2
};
Types.fromString = function(s) {
if (s === "Metadata") {
return Types.METADATA;
} else if (s === "Terrain") {
return Types.TERRAIN;
} else if (s === "DbRoot") {
return Types.DBROOT;
}
};
function decodeGoogleEarthEnterprisePacket(parameters, transferableObjects) {
const type = Types.fromString(parameters.type);
let buffer = parameters.buffer;
decodeGoogleEarthEnterpriseData_default(parameters.key, buffer);
const uncompressedTerrain = uncompressPacket(buffer);
buffer = uncompressedTerrain.buffer;
const length = uncompressedTerrain.length;
switch (type) {
case Types.METADATA:
return processMetadata(buffer, length, parameters.quadKey);
case Types.TERRAIN:
return processTerrain(buffer, length, transferableObjects);
case Types.DBROOT:
transferableObjects.push(buffer);
return {
buffer
};
}
}
var qtMagic = 32301;
function processMetadata(buffer, totalSize, quadKey) {
const dv = new DataView(buffer);
let offset = 0;
const magic = dv.getUint32(offset, true);
offset += sizeOfUint32;
if (magic !== qtMagic) {
throw new RuntimeError_default("Invalid magic");
}
const dataTypeId = dv.getUint32(offset, true);
offset += sizeOfUint32;
if (dataTypeId !== 1) {
throw new RuntimeError_default("Invalid data type. Must be 1 for QuadTreePacket");
}
const quadVersion = dv.getUint32(offset, true);
offset += sizeOfUint32;
if (quadVersion !== 2) {
throw new RuntimeError_default(
"Invalid QuadTreePacket version. Only version 2 is supported."
);
}
const numInstances = dv.getInt32(offset, true);
offset += sizeOfInt32;
const dataInstanceSize = dv.getInt32(offset, true);
offset += sizeOfInt32;
if (dataInstanceSize !== 32) {
throw new RuntimeError_default("Invalid instance size.");
}
const dataBufferOffset = dv.getInt32(offset, true);
offset += sizeOfInt32;
const dataBufferSize = dv.getInt32(offset, true);
offset += sizeOfInt32;
const metaBufferSize = dv.getInt32(offset, true);
offset += sizeOfInt32;
if (dataBufferOffset !== numInstances * dataInstanceSize + offset) {
throw new RuntimeError_default("Invalid dataBufferOffset");
}
if (dataBufferOffset + dataBufferSize + metaBufferSize !== totalSize) {
throw new RuntimeError_default("Invalid packet offsets");
}
const instances = [];
for (let i = 0; i < numInstances; ++i) {
const bitfield = dv.getUint8(offset);
++offset;
++offset;
const cnodeVersion = dv.getUint16(offset, true);
offset += sizeOfUint16;
const imageVersion = dv.getUint16(offset, true);
offset += sizeOfUint16;
const terrainVersion = dv.getUint16(offset, true);
offset += sizeOfUint16;
offset += sizeOfUint16;
offset += sizeOfUint16;
offset += sizeOfInt32;
offset += sizeOfInt32;
offset += 8;
const imageProvider = dv.getUint8(offset++);
const terrainProvider = dv.getUint8(offset++);
offset += sizeOfUint16;
instances.push(
new GoogleEarthEnterpriseTileInformation_default(
bitfield,
cnodeVersion,
imageVersion,
terrainVersion,
imageProvider,
terrainProvider
)
);
}
const tileInfo = [];
let index = 0;
function populateTiles(parentKey, parent, level2) {
let isLeaf = false;
if (level2 === 4) {
if (parent.hasSubtree()) {
return;
}
isLeaf = true;
}
for (let i = 0; i < 4; ++i) {
const childKey = parentKey + i.toString();
if (isLeaf) {
tileInfo[childKey] = null;
} else if (level2 < 4) {
if (!parent.hasChild(i)) {
tileInfo[childKey] = null;
} else {
if (index === numInstances) {
console.log("Incorrect number of instances");
return;
}
const instance = instances[index++];
tileInfo[childKey] = instance;
populateTiles(childKey, instance, level2 + 1);
}
}
}
}
let level = 0;
const root = instances[index++];
if (quadKey === "") {
++level;
} else {
tileInfo[quadKey] = root;
}
populateTiles(quadKey, root, level);
return tileInfo;
}
var numMeshesPerPacket = 5;
var numSubMeshesPerMesh = 4;
function processTerrain(buffer, totalSize, transferableObjects) {
const dv = new DataView(buffer);
const advanceMesh = function(pos) {
for (let sub = 0; sub < numSubMeshesPerMesh; ++sub) {
const size = dv.getUint32(pos, true);
pos += sizeOfUint32;
pos += size;
if (pos > totalSize) {
throw new RuntimeError_default("Malformed terrain packet found.");
}
}
return pos;
};
let offset = 0;
const terrainMeshes = [];
while (terrainMeshes.length < numMeshesPerPacket) {
const start = offset;
offset = advanceMesh(offset);
const mesh = buffer.slice(start, offset);
transferableObjects.push(mesh);
terrainMeshes.push(mesh);
}
return terrainMeshes;
}
var compressedMagic2 = 1953029805;
var compressedMagicSwap2 = 2917034100;
function uncompressPacket(data) {
const dv = new DataView(data);
let offset = 0;
const magic = dv.getUint32(offset, true);
offset += sizeOfUint32;
if (magic !== compressedMagic2 && magic !== compressedMagicSwap2) {
throw new RuntimeError_default("Invalid magic");
}
const size = dv.getUint32(offset, magic === compressedMagic2);
offset += sizeOfUint32;
const compressedPacket = new Uint8Array(data, offset);
const uncompressedPacket = import_inflate.default.inflate(compressedPacket);
if (uncompressedPacket.length !== size) {
throw new RuntimeError_default("Size of packet doesn't match header");
}
return uncompressedPacket;
}
var decodeGoogleEarthEnterprisePacket_default = createTaskProcessorWorker_default(decodeGoogleEarthEnterprisePacket);
export {
decodeGoogleEarthEnterprisePacket_default as default
};
/**
* @license
* Cesium - https://github.com/CesiumGS/cesium
* Version 1.121.2
*
* Copyright 2011-2022 Cesium Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Columbus View (Pat. Pend.)
*
* Portions licensed separately.
* See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
*/
import {
require_draco_decoder_nodejs
} from "./chunk-M24KHENR.js";
import {
Color_default
} from "./chunk-HP5XLODI.js";
import {
createTaskProcessorWorker_default
} from "./chunk-Z2QP3CXW.js";
import {
WebMercatorProjection_default
} from "./chunk-RJM36CNY.js";
import {
Cartesian3_default,
Cartographic_default,
Ellipsoid_default,
Matrix3_default
} from "./chunk-FFLMY4TE.js";
import {
Math_default
} from "./chunk-WGDFYAGC.js";
import {
defaultValue_default
} from "./chunk-U5HSOKPQ.js";
import {
Check_default
} from "./chunk-P6TRGU3S.js";
import {
__toESM,
defined_default
} from "./chunk-YCDZX5LS.js";
// packages/engine/Source/Workers/decodeI3S.js
var import_draco_decoder_nodejs = __toESM(require_draco_decoder_nodejs(), 1);
// packages/engine/Source/Core/srgbToLinear.js
function srgbToLinear(value) {
Check_default.defined("value", value);
if (value <= 0.04045) {
return value * 0.07739938080495357;
}
return Math.pow(
// eslint-disable-next-line no-loss-of-precision
(value + 0.055) * 0.9478672985781991,
2.4
);
}
var srgbToLinear_default = srgbToLinear;
// packages/engine/Source/Workers/decodeI3S.js
var draco;
function bilinearInterpolate(tx, ty, h00, h10, h01, h11) {
const a = h00 * (1 - tx) + h10 * tx;
const b = h01 * (1 - tx) + h11 * tx;
return a * (1 - ty) + b * ty;
}
function sampleMap(u, v, width, data) {
const address = u + v * width;
return data[address];
}
function sampleGeoid(sampleX, sampleY, geoidData) {
const extent = geoidData.nativeExtent;
let x = (sampleX - extent.west) / (extent.east - extent.west) * (geoidData.width - 1);
let y = (sampleY - extent.south) / (extent.north - extent.south) * (geoidData.height - 1);
const xi = Math.floor(x);
let yi = Math.floor(y);
x -= xi;
y -= yi;
const xNext = xi < geoidData.width ? xi + 1 : xi;
let yNext = yi < geoidData.height ? yi + 1 : yi;
yi = geoidData.height - 1 - yi;
yNext = geoidData.height - 1 - yNext;
const h00 = sampleMap(xi, yi, geoidData.width, geoidData.buffer);
const h10 = sampleMap(xNext, yi, geoidData.width, geoidData.buffer);
const h01 = sampleMap(xi, yNext, geoidData.width, geoidData.buffer);
const h11 = sampleMap(xNext, yNext, geoidData.width, geoidData.buffer);
let finalHeight = bilinearInterpolate(x, y, h00, h10, h01, h11);
finalHeight = finalHeight * geoidData.scale + geoidData.offset;
return finalHeight;
}
function sampleGeoidFromList(lon, lat, geoidDataList) {
for (let i = 0; i < geoidDataList.length; i++) {
const localExtent = geoidDataList[i].nativeExtent;
let localPt = new Cartesian3_default();
if (geoidDataList[i].projectionType === "WebMercator") {
const radii = geoidDataList[i].projection._ellipsoid._radii;
const webMercatorProj = new WebMercatorProjection_default(
new Ellipsoid_default(radii.x, radii.y, radii.z)
);
localPt = webMercatorProj.project(new Cartographic_default(lon, lat, 0));
} else {
localPt.x = lon;
localPt.y = lat;
}
if (localPt.x > localExtent.west && localPt.x < localExtent.east && localPt.y > localExtent.south && localPt.y < localExtent.north) {
return sampleGeoid(localPt.x, localPt.y, geoidDataList[i]);
}
}
return 0;
}
function orthometricToEllipsoidal(vertexCount, position, scale_x, scale_y, center, geoidDataList, fast) {
if (fast) {
return;
}
const centerHeight = sampleGeoidFromList(
center.longitude,
center.latitude,
geoidDataList
);
for (let i = 0; i < vertexCount; ++i) {
const height = sampleGeoidFromList(
center.longitude + Math_default.toRadians(scale_x * position[i * 3]),
center.latitude + Math_default.toRadians(scale_y * position[i * 3 + 1]),
geoidDataList
);
position[i * 3 + 2] += height - centerHeight;
}
}
function transformToLocal(vertexCount, positions, normals, cartographicCenter, cartesianCenter, parentRotation, ellipsoidRadiiSquare, scale_x, scale_y) {
if (vertexCount === 0 || !defined_default(positions) || positions.length === 0) {
return;
}
const ellipsoid = new Ellipsoid_default(
Math.sqrt(ellipsoidRadiiSquare.x),
Math.sqrt(ellipsoidRadiiSquare.y),
Math.sqrt(ellipsoidRadiiSquare.z)
);
for (let i = 0; i < vertexCount; ++i) {
const indexOffset = i * 3;
const indexOffset1 = indexOffset + 1;
const indexOffset2 = indexOffset + 2;
const cartographic = new Cartographic_default();
cartographic.longitude = cartographicCenter.longitude + Math_default.toRadians(scale_x * positions[indexOffset]);
cartographic.latitude = cartographicCenter.latitude + Math_default.toRadians(scale_y * positions[indexOffset1]);
cartographic.height = cartographicCenter.height + positions[indexOffset2];
const position = {};
ellipsoid.cartographicToCartesian(cartographic, position);
position.x -= cartesianCenter.x;
position.y -= cartesianCenter.y;
position.z -= cartesianCenter.z;
const rotatedPosition = {};
Matrix3_default.multiplyByVector(parentRotation, position, rotatedPosition);
positions[indexOffset] = rotatedPosition.x;
positions[indexOffset1] = rotatedPosition.y;
positions[indexOffset2] = rotatedPosition.z;
if (defined_default(normals)) {
const normal = new Cartesian3_default(
normals[indexOffset],
normals[indexOffset1],
normals[indexOffset2]
);
const rotatedNormal = {};
Matrix3_default.multiplyByVector(parentRotation, normal, rotatedNormal);
normals[indexOffset] = rotatedNormal.x;
normals[indexOffset1] = rotatedNormal.y;
normals[indexOffset2] = rotatedNormal.z;
}
}
}
function cropUVs(vertexCount, uv0s, uvRegions) {
for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
const minU = uvRegions[vertexIndex * 4] / 65535;
const minV = uvRegions[vertexIndex * 4 + 1] / 65535;
const scaleU = (uvRegions[vertexIndex * 4 + 2] - uvRegions[vertexIndex * 4]) / 65535;
const scaleV = (uvRegions[vertexIndex * 4 + 3] - uvRegions[vertexIndex * 4 + 1]) / 65535;
uv0s[vertexIndex * 2] *= scaleU;
uv0s[vertexIndex * 2] += minU;
uv0s[vertexIndex * 2 + 1] *= scaleV;
uv0s[vertexIndex * 2 + 1] += minV;
}
}
function generateIndexArray(vertexCount, indices, colors, splitGeometryByColorTransparency) {
const indexArray = new Uint32Array(vertexCount);
const vertexIndexFn = defined_default(indices) ? (vertexIndex) => indices[vertexIndex] : (vertexIndex) => vertexIndex;
let transparentVertexOffset = 0;
if (splitGeometryByColorTransparency && defined_default(colors)) {
const isVertexTransparentFn = (vertexIndex) => colors[vertexIndexFn(vertexIndex) * 4 + 3] < 255;
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex += 3) {
if (!isVertexTransparentFn(vertexIndex) && !isVertexTransparentFn(vertexIndex + 1) && !isVertexTransparentFn(vertexIndex + 2)) {
indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex);
indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex + 1);
indexArray[transparentVertexOffset++] = vertexIndexFn(vertexIndex + 2);
}
}
if (transparentVertexOffset > 0) {
let offset = transparentVertexOffset;
for (let vertexIndex = 0; vertexIndex < vertexCount; vertexIndex += 3) {
if (isVertexTransparentFn(vertexIndex) || isVertexTransparentFn(vertexIndex + 1) || isVertexTransparentFn(vertexIndex + 2)) {
indexArray[offset++] = vertexIndexFn(vertexIndex);
indexArray[offset++] = vertexIndexFn(vertexIndex + 1);
indexArray[offset++] = vertexIndexFn(vertexIndex + 2);
}
}
} else {
for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
indexArray[vertexIndex] = vertexIndexFn(vertexIndex);
}
}
} else {
transparentVertexOffset = vertexCount;
for (let vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex) {
indexArray[vertexIndex] = vertexIndexFn(vertexIndex);
}
}
return {
indexArray,
transparentVertexOffset
};
}
function getFeatureHash(symbologyData, outlinesHash, featureIndex) {
const featureHash = outlinesHash[featureIndex];
if (defined_default(featureHash)) {
return featureHash;
}
const newFeatureHash = outlinesHash[featureIndex] = {
positions: {},
indices: {},
edges: {}
};
const featureSymbology = defaultValue_default(
symbologyData[featureIndex],
symbologyData.default
);
newFeatureHash.hasOutline = defined_default(featureSymbology?.edges);
return newFeatureHash;
}
function addVertexToHash(indexHash, positionHash, vertexIndex, positions) {
if (!defined_default(indexHash[vertexIndex])) {
const startPositionIndex = vertexIndex * 3;
let coordinateHash = positionHash;
for (let index = 0; index < 3; index++) {
const coordinate = positions[startPositionIndex + index];
if (!defined_default(coordinateHash[coordinate])) {
coordinateHash[coordinate] = {};
}
coordinateHash = coordinateHash[coordinate];
}
if (!defined_default(coordinateHash.index)) {
coordinateHash.index = vertexIndex;
}
indexHash[vertexIndex] = coordinateHash.index;
}
}
function addEdgeToHash(edgeHash, vertexAIndex, vertexBIndex, vertexAIndexUnique, vertexBIndexUnique, normalIndex) {
let startVertexIndex;
let endVertexIndex;
if (vertexAIndexUnique < vertexBIndexUnique) {
startVertexIndex = vertexAIndexUnique;
endVertexIndex = vertexBIndexUnique;
} else {
startVertexIndex = vertexBIndexUnique;
endVertexIndex = vertexAIndexUnique;
}
let edgeStart = edgeHash[startVertexIndex];
if (!defined_default(edgeStart)) {
edgeStart = edgeHash[startVertexIndex] = {};
}
let edgeEnd = edgeStart[endVertexIndex];
if (!defined_default(edgeEnd)) {
edgeEnd = edgeStart[endVertexIndex] = {
normalsIndex: [],
outlines: []
};
}
edgeEnd.normalsIndex.push(normalIndex);
if (edgeEnd.outlines.length === 0 || vertexAIndex !== vertexAIndexUnique || vertexBIndex !== vertexBIndexUnique) {
edgeEnd.outlines.push(vertexAIndex, vertexBIndex);
}
}
function generateOutlinesHash(symbologyData, featureIndexArray, indexArray, positions) {
const outlinesHash = [];
for (let i = 0; i < indexArray.length; i += 3) {
const featureIndex = defined_default(featureIndexArray) ? featureIndexArray[indexArray[i]] : "default";
const featureHash = getFeatureHash(
symbologyData,
outlinesHash,
featureIndex
);
if (!featureHash.hasOutline) {
continue;
}
const indexHash = featureHash.indices;
const positionHash = featureHash.positions;
for (let vertex = 0; vertex < 3; vertex++) {
const vertexIndex = indexArray[i + vertex];
addVertexToHash(indexHash, positionHash, vertexIndex, positions);
}
const edgeHash = featureHash.edges;
for (let vertex = 0; vertex < 3; vertex++) {
const vertexIndex = indexArray[i + vertex];
const nextVertexIndex = indexArray[i + (vertex + 1) % 3];
const uniqueVertexIndex = indexHash[vertexIndex];
const uniqueNextVertexIndex = indexHash[nextVertexIndex];
addEdgeToHash(
edgeHash,
vertexIndex,
nextVertexIndex,
uniqueVertexIndex,
uniqueNextVertexIndex,
i
);
}
}
return outlinesHash;
}
var calculateFaceNormalA = new Cartesian3_default();
var calculateFaceNormalB = new Cartesian3_default();
var calculateFaceNormalC = new Cartesian3_default();
function calculateFaceNormal(normals, vertexAIndex, indexArray, positions) {
const positionAIndex = indexArray[vertexAIndex] * 3;
const positionBIndex = indexArray[vertexAIndex + 1] * 3;
const positionCIndex = indexArray[vertexAIndex + 2] * 3;
Cartesian3_default.fromArray(positions, positionAIndex, calculateFaceNormalA);
Cartesian3_default.fromArray(positions, positionBIndex, calculateFaceNormalB);
Cartesian3_default.fromArray(positions, positionCIndex, calculateFaceNormalC);
Cartesian3_default.subtract(
calculateFaceNormalB,
calculateFaceNormalA,
calculateFaceNormalB
);
Cartesian3_default.subtract(
calculateFaceNormalC,
calculateFaceNormalA,
calculateFaceNormalC
);
Cartesian3_default.cross(
calculateFaceNormalB,
calculateFaceNormalC,
calculateFaceNormalA
);
const magnitude = Cartesian3_default.magnitude(calculateFaceNormalA);
if (magnitude !== 0) {
Cartesian3_default.divideByScalar(
calculateFaceNormalA,
magnitude,
calculateFaceNormalA
);
}
const normalAIndex = vertexAIndex * 3;
const normalBIndex = (vertexAIndex + 1) * 3;
const normalCIndex = (vertexAIndex + 2) * 3;
Cartesian3_default.pack(calculateFaceNormalA, normals, normalAIndex);
Cartesian3_default.pack(calculateFaceNormalA, normals, normalBIndex);
Cartesian3_default.pack(calculateFaceNormalA, normals, normalCIndex);
}
var isEdgeSmoothA = new Cartesian3_default();
var isEdgeSmoothB = new Cartesian3_default();
function isEdgeSmooth(normals, normalAIndex, normalBIndex) {
Cartesian3_default.fromArray(normals, normalAIndex, isEdgeSmoothA);
Cartesian3_default.fromArray(normals, normalBIndex, isEdgeSmoothB);
const cosine = Cartesian3_default.dot(isEdgeSmoothA, isEdgeSmoothB);
const sine = Cartesian3_default.magnitude(
Cartesian3_default.cross(isEdgeSmoothA, isEdgeSmoothB, isEdgeSmoothA)
);
return Math.atan2(sine, cosine) < 0.25;
}
function addOutlinesForEdge(outlines, edgeData, indexArray, positions, normals) {
if (edgeData.normalsIndex.length > 1) {
const normalsByIndex = positions.length === normals.length;
for (let indexA = 0; indexA < edgeData.normalsIndex.length; indexA++) {
const vertexAIndex = edgeData.normalsIndex[indexA];
if (!defined_default(normals[vertexAIndex * 3])) {
calculateFaceNormal(normals, vertexAIndex, indexArray, positions);
}
if (indexA === 0) {
continue;
}
for (let indexB = 0; indexB < indexA; indexB++) {
const vertexBIndex = edgeData.normalsIndex[indexB];
const normalAIndex = normalsByIndex ? indexArray[vertexAIndex] * 3 : vertexAIndex * 3;
const normalBIndex = normalsByIndex ? indexArray[vertexBIndex] * 3 : vertexBIndex * 3;
if (isEdgeSmooth(normals, normalAIndex, normalBIndex)) {
return;
}
}
}
}
outlines.push(...edgeData.outlines);
}
function addOutlinesForFeature(outlines, edgeHash, indexArray, positions, normals) {
const edgeStartKeys = Object.keys(edgeHash);
for (let startIndex = 0; startIndex < edgeStartKeys.length; startIndex++) {
const edgeEnds = edgeHash[edgeStartKeys[startIndex]];
const edgeEndKeys = Object.keys(edgeEnds);
for (let endIndex = 0; endIndex < edgeEndKeys.length; endIndex++) {
const edgeData = edgeEnds[edgeEndKeys[endIndex]];
addOutlinesForEdge(outlines, edgeData, indexArray, positions, normals);
}
}
}
function generateOutlinesFromHash(outlinesHash, indexArray, positions, normals) {
const outlines = [];
const features = Object.keys(outlinesHash);
for (let featureIndex = 0; featureIndex < features.length; featureIndex++) {
const edgeHash = outlinesHash[features[featureIndex]].edges;
addOutlinesForFeature(outlines, edgeHash, indexArray, positions, normals);
}
return outlines;
}
function generateOutlinesIndexArray(symbologyData, featureIndexArray, indexArray, positions, normals) {
if (!defined_default(symbologyData) || Object.keys(symbologyData).length === 0) {
return void 0;
}
const outlinesHash = generateOutlinesHash(
symbologyData,
featureIndexArray,
indexArray,
positions
);
if (!defined_default(normals) || indexArray.length * 3 !== normals.length) {
normals = [];
}
const outlines = generateOutlinesFromHash(
outlinesHash,
indexArray,
positions,
normals
);
const outlinesIndexArray = outlines.length > 0 ? new Uint32Array(outlines) : void 0;
return outlinesIndexArray;
}
function convertColorsArray(colors) {
const colorsArray = new Float32Array(colors.length);
for (let index = 0; index < colors.length; index += 4) {
colorsArray[index] = srgbToLinear_default(Color_default.byteToFloat(colors[index]));
colorsArray[index + 1] = srgbToLinear_default(Color_default.byteToFloat(colors[index + 1]));
colorsArray[index + 2] = srgbToLinear_default(Color_default.byteToFloat(colors[index + 2]));
colorsArray[index + 3] = Color_default.byteToFloat(colors[index + 3]);
}
return colorsArray;
}
function generateNormals(vertexCount, indices, positions, normals, uv0s, colors, featureIndex) {
const result = {
normals: void 0,
positions: void 0,
uv0s: void 0,
colors: void 0,
featureIndex: void 0,
vertexCount: void 0
};
if (vertexCount === 0 || !defined_default(positions) || positions.length === 0 || defined_default(normals)) {
return result;
}
if (defined_default(indices)) {
result.vertexCount = indices.length;
result.positions = new Float32Array(indices.length * 3);
result.uv0s = defined_default(uv0s) ? new Float32Array(indices.length * 2) : void 0;
result.colors = defined_default(colors) ? new Uint8Array(indices.length * 4) : void 0;
result.featureIndex = defined_default(featureIndex) ? new Array(indices.length) : void 0;
for (let i = 0; i < indices.length; i++) {
const index = indices[i];
result.positions[i * 3] = positions[index * 3];
result.positions[i * 3 + 1] = positions[index * 3 + 1];
result.positions[i * 3 + 2] = positions[index * 3 + 2];
if (defined_default(result.uv0s)) {
result.uv0s[i * 2] = uv0s[index * 2];
result.uv0s[i * 2 + 1] = uv0s[index * 2 + 1];
}
if (defined_default(result.colors)) {
result.colors[i * 4] = colors[index * 4];
result.colors[i * 4 + 1] = colors[index * 4 + 1];
result.colors[i * 4 + 2] = colors[index * 4 + 2];
result.colors[i * 4 + 3] = colors[index * 4 + 3];
}
if (defined_default(result.featureIndex)) {
result.featureIndex[i] = featureIndex[index];
}
}
vertexCount = indices.length;
positions = result.positions;
}
indices = new Array(vertexCount);
for (let i = 0; i < vertexCount; i++) {
indices[i] = i;
}
result.normals = new Float32Array(indices.length * 3);
for (let i = 0; i < indices.length; i += 3) {
calculateFaceNormal(result.normals, i, indices, positions);
}
return result;
}
function generateGltfBuffer(vertexCount, indices, positions, normals, uv0s, colors, featureIndex, parameters) {
if (vertexCount === 0 || !defined_default(positions) || positions.length === 0) {
return {
buffers: [],
bufferViews: [],
accessors: [],
meshes: [],
nodes: [],
nodesInScene: []
};
}
const buffers = [];
const bufferViews = [];
const accessors = [];
const meshes = [];
const nodes = [];
const nodesInScene = [];
const rootExtensions = {};
const extensionsUsed = [];
if (defined_default(indices)) {
vertexCount = indices.length;
}
const { indexArray, transparentVertexOffset } = generateIndexArray(
vertexCount,
indices,
colors,
parameters.splitGeometryByColorTransparency
);
const indicesBlob = new Blob([indexArray], { type: "application/binary" });
const indicesURL = URL.createObjectURL(indicesBlob);
const endIndex = vertexCount;
const featureIndexArray = parameters.enableFeatures && defined_default(featureIndex) ? new Float32Array(featureIndex.length) : void 0;
let featureCount = 0;
if (defined_default(featureIndexArray)) {
for (let index = 0; index < featureIndex.length; ++index) {
featureIndexArray[index] = featureIndex[index];
const countByIndex = featureIndex[index] + 1;
if (featureCount < countByIndex) {
featureCount = countByIndex;
}
}
}
let outlinesIndicesURL;
const outlinesIndexArray = generateOutlinesIndexArray(
parameters.symbologyData,
featureIndex,
indexArray,
positions,
normals
);
if (defined_default(outlinesIndexArray)) {
const outlinesIndicesBlob = new Blob([outlinesIndexArray], {
type: "application/binary"
});
outlinesIndicesURL = URL.createObjectURL(outlinesIndicesBlob);
}
const meshPositions = positions.subarray(0, endIndex * 3);
const positionsBlob = new Blob([meshPositions], {
type: "application/binary"
});
const positionsURL = URL.createObjectURL(positionsBlob);
let minX = Number.POSITIVE_INFINITY;
let maxX = Number.NEGATIVE_INFINITY;
let minY = Number.POSITIVE_INFINITY;
let maxY = Number.NEGATIVE_INFINITY;
let minZ = Number.POSITIVE_INFINITY;
let maxZ = Number.NEGATIVE_INFINITY;
for (let i = 0; i < meshPositions.length / 3; i++) {
minX = Math.min(minX, meshPositions[i * 3 + 0]);
maxX = Math.max(maxX, meshPositions[i * 3 + 0]);
minY = Math.min(minY, meshPositions[i * 3 + 1]);
maxY = Math.max(maxY, meshPositions[i * 3 + 1]);
minZ = Math.min(minZ, meshPositions[i * 3 + 2]);
maxZ = Math.max(maxZ, meshPositions[i * 3 + 2]);
}
const meshNormals = normals ? normals.subarray(0, endIndex * 3) : void 0;
let normalsURL;
if (defined_default(meshNormals)) {
const normalsBlob = new Blob([meshNormals], {
type: "application/binary"
});
normalsURL = URL.createObjectURL(normalsBlob);
}
const meshUv0s = uv0s ? uv0s.subarray(0, endIndex * 2) : void 0;
let uv0URL;
if (defined_default(meshUv0s)) {
const uv0Blob = new Blob([meshUv0s], { type: "application/binary" });
uv0URL = URL.createObjectURL(uv0Blob);
}
const meshColorsInBytes = defined_default(colors) ? convertColorsArray(colors.subarray(0, endIndex * 4)) : void 0;
let colorsURL;
if (defined_default(meshColorsInBytes)) {
const colorsBlob = new Blob([meshColorsInBytes], {
type: "application/binary"
});
colorsURL = URL.createObjectURL(colorsBlob);
}
const meshFeatureId0 = defined_default(featureIndexArray) ? featureIndexArray.subarray(0, endIndex) : void 0;
let featureId0URL;
if (defined_default(meshFeatureId0)) {
const featureId0Blob = new Blob([meshFeatureId0], {
type: "application/binary"
});
featureId0URL = URL.createObjectURL(featureId0Blob);
}
const meshPropertyTable0 = defined_default(featureIndexArray) ? new Float32Array(featureCount) : void 0;
let propertyTable0URL;
if (defined_default(meshPropertyTable0)) {
for (let index = 0; index < meshPropertyTable0.length; ++index) {
meshPropertyTable0[index] = index;
}
const propertyTable0Blob = new Blob([meshPropertyTable0], {
type: "application/binary"
});
propertyTable0URL = URL.createObjectURL(propertyTable0Blob);
}
const attributes = {};
const extensions = {};
attributes.POSITION = accessors.length;
buffers.push({
uri: positionsURL,
byteLength: meshPositions.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: meshPositions.byteLength,
target: 34962
});
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5126,
count: meshPositions.length / 3,
type: "VEC3",
max: [minX, minY, minZ],
min: [maxX, maxY, maxZ]
});
if (defined_default(normalsURL)) {
attributes.NORMAL = accessors.length;
buffers.push({
uri: normalsURL,
byteLength: meshNormals.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: meshNormals.byteLength,
target: 34962
});
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5126,
count: meshNormals.length / 3,
type: "VEC3"
});
}
if (defined_default(uv0URL)) {
attributes.TEXCOORD_0 = accessors.length;
buffers.push({
uri: uv0URL,
byteLength: meshUv0s.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: meshUv0s.byteLength,
target: 34962
});
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5126,
count: meshUv0s.length / 2,
type: "VEC2"
});
}
if (defined_default(colorsURL)) {
attributes.COLOR_0 = accessors.length;
buffers.push({
uri: colorsURL,
byteLength: meshColorsInBytes.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: meshColorsInBytes.byteLength,
target: 34962
});
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5126,
count: meshColorsInBytes.length / 4,
type: "VEC4"
});
}
if (defined_default(featureId0URL)) {
attributes._FEATURE_ID_0 = accessors.length;
buffers.push({
uri: featureId0URL,
byteLength: meshFeatureId0.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: meshFeatureId0.byteLength,
target: 34963
});
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5126,
count: meshFeatureId0.length,
type: "SCALAR"
});
extensions.EXT_mesh_features = {
featureIds: [
{
attribute: 0,
propertyTable: 0,
featureCount
}
]
};
extensionsUsed.push("EXT_mesh_features");
}
if (defined_default(propertyTable0URL)) {
buffers.push({
uri: propertyTable0URL,
byteLength: meshPropertyTable0.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: meshPropertyTable0.byteLength,
target: 34963
});
rootExtensions.EXT_structural_metadata = {
schema: {
id: "i3s-metadata-schema-001",
name: "I3S metadata schema 001",
description: "The schema for I3S metadata",
version: "1.0",
classes: {
feature: {
name: "feature",
description: "Feature metadata",
properties: {
index: {
description: "The feature index",
type: "SCALAR",
componentType: "FLOAT32",
required: true
}
}
}
}
},
propertyTables: [
{
name: "feature-indices-mapping",
class: "feature",
count: featureCount,
properties: {
index: {
values: bufferViews.length - 1
}
}
}
]
};
extensionsUsed.push("EXT_structural_metadata");
}
if (defined_default(outlinesIndicesURL)) {
buffers.push({
uri: outlinesIndicesURL,
byteLength: outlinesIndexArray.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: outlinesIndexArray.byteLength,
target: 34963
});
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5125,
count: outlinesIndexArray.length,
type: "SCALAR"
});
extensions.CESIUM_primitive_outline = {
indices: accessors.length - 1
};
extensionsUsed.push("CESIUM_primitive_outline");
}
buffers.push({
uri: indicesURL,
byteLength: indexArray.byteLength
});
bufferViews.push({
buffer: buffers.length - 1,
byteOffset: 0,
byteLength: indexArray.byteLength,
target: 34963
});
const meshPrimitives = [];
if (transparentVertexOffset > 0) {
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 0,
componentType: 5125,
count: transparentVertexOffset,
type: "SCALAR"
});
meshPrimitives.push({
attributes,
indices: accessors.length - 1,
material: meshPrimitives.length,
extensions
});
}
if (transparentVertexOffset < vertexCount) {
accessors.push({
bufferView: bufferViews.length - 1,
byteOffset: 4 * transparentVertexOffset,
// skip 4 bytes for each opaque vertex
componentType: 5125,
count: vertexCount - transparentVertexOffset,
type: "SCALAR"
});
meshPrimitives.push({
attributes,
indices: accessors.length - 1,
material: meshPrimitives.length,
extensions,
extra: {
isTransparent: true
}
});
}
meshes.push({
primitives: meshPrimitives
});
nodesInScene.push(0);
nodes.push({ mesh: 0 });
return {
buffers,
bufferViews,
accessors,
meshes,
nodes,
nodesInScene,
rootExtensions,
extensionsUsed
};
}
function decode(data, schema, bufferInfo, featureData) {
const magicNumber = new Uint8Array(data, 0, 5);
if (magicNumber[0] === "D".charCodeAt() && magicNumber[1] === "R".charCodeAt() && magicNumber[2] === "A".charCodeAt() && magicNumber[3] === "C".charCodeAt() && magicNumber[4] === "O".charCodeAt()) {
return decodeDracoEncodedGeometry(data, bufferInfo);
}
return decodeBinaryGeometry(data, schema, bufferInfo, featureData);
}
function decodeDracoEncodedGeometry(data) {
const dracoDecoderModule = draco;
const buffer = new dracoDecoderModule.DecoderBuffer();
const byteArray = new Uint8Array(data);
buffer.Init(byteArray, byteArray.length);
const dracoDecoder = new dracoDecoderModule.Decoder();
const geometryType = dracoDecoder.GetEncodedGeometryType(buffer);
const metadataQuerier = new dracoDecoderModule.MetadataQuerier();
let dracoGeometry;
let status;
if (geometryType === dracoDecoderModule.TRIANGULAR_MESH) {
dracoGeometry = new dracoDecoderModule.Mesh();
status = dracoDecoder.DecodeBufferToMesh(buffer, dracoGeometry);
}
const decodedGeometry = {
vertexCount: [0],
featureCount: 0
};
if (defined_default(status) && status.ok() && dracoGeometry.ptr !== 0) {
const faceCount = dracoGeometry.num_faces();
const attributesCount = dracoGeometry.num_attributes();
const vertexCount = dracoGeometry.num_points();
decodedGeometry.indices = new Uint32Array(faceCount * 3);
const faces = decodedGeometry.indices;
decodedGeometry.vertexCount[0] = vertexCount;
decodedGeometry.scale_x = 1;
decodedGeometry.scale_y = 1;
const face = new dracoDecoderModule.DracoInt32Array(3);
for (let faceIndex = 0; faceIndex < faceCount; ++faceIndex) {
dracoDecoder.GetFaceFromMesh(dracoGeometry, faceIndex, face);
faces[faceIndex * 3] = face.GetValue(0);
faces[faceIndex * 3 + 1] = face.GetValue(1);
faces[faceIndex * 3 + 2] = face.GetValue(2);
}
dracoDecoderModule.destroy(face);
for (let attrIndex = 0; attrIndex < attributesCount; ++attrIndex) {
const dracoAttribute = dracoDecoder.GetAttribute(
dracoGeometry,
attrIndex
);
const attributeData = decodeDracoAttribute(
dracoDecoderModule,
dracoDecoder,
dracoGeometry,
dracoAttribute,
vertexCount
);
const dracoAttributeType = dracoAttribute.attribute_type();
let attributei3sName = "unknown";
if (dracoAttributeType === dracoDecoderModule.POSITION) {
attributei3sName = "positions";
} else if (dracoAttributeType === dracoDecoderModule.NORMAL) {
attributei3sName = "normals";
} else if (dracoAttributeType === dracoDecoderModule.COLOR) {
attributei3sName = "colors";
} else if (dracoAttributeType === dracoDecoderModule.TEX_COORD) {
attributei3sName = "uv0s";
}
const metadata = dracoDecoder.GetAttributeMetadata(
dracoGeometry,
attrIndex
);
if (metadata.ptr !== 0) {
const numEntries = metadataQuerier.NumEntries(metadata);
for (let entry = 0; entry < numEntries; ++entry) {
const entryName = metadataQuerier.GetEntryName(metadata, entry);
if (entryName === "i3s-scale_x") {
decodedGeometry.scale_x = metadataQuerier.GetDoubleEntry(
metadata,
"i3s-scale_x"
);
} else if (entryName === "i3s-scale_y") {
decodedGeometry.scale_y = metadataQuerier.GetDoubleEntry(
metadata,
"i3s-scale_y"
);
} else if (entryName === "i3s-attribute-type") {
attributei3sName = metadataQuerier.GetStringEntry(
metadata,
"i3s-attribute-type"
);
}
}
}
if (defined_default(decodedGeometry[attributei3sName])) {
console.log("Attribute already exists", attributei3sName);
}
decodedGeometry[attributei3sName] = attributeData;
if (attributei3sName === "feature-index") {
decodedGeometry.featureCount++;
}
}
dracoDecoderModule.destroy(dracoGeometry);
}
dracoDecoderModule.destroy(metadataQuerier);
dracoDecoderModule.destroy(dracoDecoder);
return decodedGeometry;
}
function decodeDracoAttribute(dracoDecoderModule, dracoDecoder, dracoGeometry, dracoAttribute, vertexCount) {
const bufferSize = dracoAttribute.num_components() * vertexCount;
let dracoAttributeData;
const handlers = [
function() {
},
// DT_INVALID - 0
function() {
dracoAttributeData = new dracoDecoderModule.DracoInt8Array(bufferSize);
const success = dracoDecoder.GetAttributeInt8ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Int8Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoInt8Array(bufferSize);
const success = dracoDecoder.GetAttributeUInt8ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Uint8Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoInt16Array(bufferSize);
const success = dracoDecoder.GetAttributeInt16ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Int16Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoInt16Array(bufferSize);
const success = dracoDecoder.GetAttributeUInt16ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Uint16Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoInt32Array(bufferSize);
const success = dracoDecoder.GetAttributeInt32ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Int32Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoInt32Array(bufferSize);
const success = dracoDecoder.GetAttributeUInt32ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Uint32Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
},
function() {
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoFloat32Array(bufferSize);
const success = dracoDecoder.GetAttributeFloatForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Float32Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
},
function() {
},
function() {
dracoAttributeData = new dracoDecoderModule.DracoUInt8Array(bufferSize);
const success = dracoDecoder.GetAttributeUInt8ForAllPoints(
dracoGeometry,
dracoAttribute,
dracoAttributeData
);
if (!success) {
console.error("Bad stream");
}
const attributeData2 = new Uint8Array(bufferSize);
for (let i = 0; i < bufferSize; ++i) {
attributeData2[i] = dracoAttributeData.GetValue(i);
}
return attributeData2;
}
];
const attributeData = handlers[dracoAttribute.data_type()]();
if (defined_default(dracoAttributeData)) {
dracoDecoderModule.destroy(dracoAttributeData);
}
return attributeData;
}
var binaryAttributeDecoders = {
position: function(decodedGeometry, data, offset) {
const count = decodedGeometry.vertexCount * 3;
decodedGeometry.positions = new Float32Array(data, offset, count);
offset += count * 4;
return offset;
},
normal: function(decodedGeometry, data, offset) {
const count = decodedGeometry.vertexCount * 3;
decodedGeometry.normals = new Float32Array(data, offset, count);
offset += count * 4;
return offset;
},
uv0: function(decodedGeometry, data, offset) {
const count = decodedGeometry.vertexCount * 2;
decodedGeometry.uv0s = new Float32Array(data, offset, count);
offset += count * 4;
return offset;
},
color: function(decodedGeometry, data, offset) {
const count = decodedGeometry.vertexCount * 4;
decodedGeometry.colors = new Uint8Array(data, offset, count);
offset += count;
return offset;
},
featureId: function(decodedGeometry, data, offset) {
const count = decodedGeometry.featureCount;
offset += count * 8;
return offset;
},
id: function(decodedGeometry, data, offset) {
const count = decodedGeometry.featureCount;
offset += count * 8;
return offset;
},
faceRange: function(decodedGeometry, data, offset) {
const count = decodedGeometry.featureCount * 2;
decodedGeometry.faceRange = new Uint32Array(data, offset, count);
offset += count * 4;
return offset;
},
uvRegion: function(decodedGeometry, data, offset) {
const count = decodedGeometry.vertexCount * 4;
decodedGeometry["uv-region"] = new Uint16Array(data, offset, count);
offset += count * 2;
return offset;
},
region: function(decodedGeometry, data, offset) {
const count = decodedGeometry.vertexCount * 4;
decodedGeometry["uv-region"] = new Uint16Array(data, offset, count);
offset += count * 2;
return offset;
}
};
function decodeBinaryGeometry(data, schema, bufferInfo, featureData) {
const decodedGeometry = {
vertexCount: 0
};
const dataView = new DataView(data);
try {
let offset = 0;
decodedGeometry.vertexCount = dataView.getUint32(offset, 1);
offset += 4;
decodedGeometry.featureCount = dataView.getUint32(offset, 1);
offset += 4;
if (defined_default(bufferInfo)) {
for (let attrIndex = 0; attrIndex < bufferInfo.attributes.length; attrIndex++) {
if (defined_default(binaryAttributeDecoders[bufferInfo.attributes[attrIndex]])) {
offset = binaryAttributeDecoders[bufferInfo.attributes[attrIndex]](
decodedGeometry,
data,
offset
);
} else {
console.error(
"Unknown decoder for",
bufferInfo.attributes[attrIndex]
);
}
}
} else {
let ordering = schema.ordering;
let featureAttributeOrder = schema.featureAttributeOrder;
if (defined_default(featureData) && defined_default(featureData.geometryData) && defined_default(featureData.geometryData[0]) && defined_default(featureData.geometryData[0].params)) {
ordering = Object.keys(
featureData.geometryData[0].params.vertexAttributes
);
featureAttributeOrder = Object.keys(
featureData.geometryData[0].params.featureAttributes
);
}
for (let i = 0; i < ordering.length; i++) {
const decoder = binaryAttributeDecoders[ordering[i]];
offset = decoder(decodedGeometry, data, offset);
}
for (let j = 0; j < featureAttributeOrder.length; j++) {
const curDecoder = binaryAttributeDecoders[featureAttributeOrder[j]];
offset = curDecoder(decodedGeometry, data, offset);
}
}
} catch (e) {
console.error(e);
}
decodedGeometry.scale_x = 1;
decodedGeometry.scale_y = 1;
return decodedGeometry;
}
function decodeAndCreateGltf(parameters) {
const geometryData = decode(
parameters.binaryData,
parameters.schema,
parameters.bufferInfo,
parameters.featureData
);
if (defined_default(parameters.geoidDataList) && parameters.geoidDataList.length > 0) {
orthometricToEllipsoidal(
geometryData.vertexCount,
geometryData.positions,
geometryData.scale_x,
geometryData.scale_y,
parameters.cartographicCenter,
parameters.geoidDataList,
false
);
}
transformToLocal(
geometryData.vertexCount,
geometryData.positions,
geometryData.normals,
parameters.cartographicCenter,
parameters.cartesianCenter,
parameters.parentRotation,
parameters.ellipsoidRadiiSquare,
geometryData.scale_x,
geometryData.scale_y
);
if (defined_default(geometryData.uv0s) && defined_default(geometryData["uv-region"])) {
cropUVs(
geometryData.vertexCount,
geometryData.uv0s,
geometryData["uv-region"]
);
}
let featureIndex;
if (defined_default(geometryData["feature-index"])) {
featureIndex = geometryData["feature-index"];
} else if (defined_default(geometryData["faceRange"])) {
featureIndex = new Array(geometryData.vertexCount);
for (let range = 0; range < geometryData["faceRange"].length - 1; range += 2) {
const curIndex = range / 2;
const rangeStart = geometryData["faceRange"][range];
const rangeEnd = geometryData["faceRange"][range + 1];
for (let i = rangeStart; i <= rangeEnd; i++) {
featureIndex[i * 3] = curIndex;
featureIndex[i * 3 + 1] = curIndex;
featureIndex[i * 3 + 2] = curIndex;
}
}
}
if (parameters.calculateNormals) {
const data = generateNormals(
geometryData.vertexCount,
geometryData.indices,
geometryData.positions,
geometryData.normals,
geometryData.uv0s,
geometryData.colors,
featureIndex
);
if (defined_default(data.normals)) {
geometryData.normals = data.normals;
if (defined_default(data.vertexCount)) {
geometryData.vertexCount = data.vertexCount;
geometryData.indices = data.indices;
geometryData.positions = data.positions;
geometryData.uv0s = data.uv0s;
geometryData.colors = data.colors;
featureIndex = data.featureIndex;
}
}
}
const meshData = generateGltfBuffer(
geometryData.vertexCount,
geometryData.indices,
geometryData.positions,
geometryData.normals,
geometryData.uv0s,
geometryData.colors,
featureIndex,
parameters
);
const customAttributes = {
positions: geometryData.positions,
indices: geometryData.indices,
featureIndex,
sourceURL: parameters.url,
cartesianCenter: parameters.cartesianCenter,
parentRotation: parameters.parentRotation
};
meshData._customAttributes = customAttributes;
const results = {
meshData
};
return results;
}
async function initWorker(parameters, transferableObjects) {
const wasmConfig = parameters.webAssemblyConfig;
if (defined_default(wasmConfig) && defined_default(wasmConfig.wasmBinaryFile)) {
draco = await (0, import_draco_decoder_nodejs.default)(wasmConfig);
} else {
draco = await (0, import_draco_decoder_nodejs.default)();
}
return true;
}
function decodeI3S(parameters, transferableObjects) {
const wasmConfig = parameters.webAssemblyConfig;
if (defined_default(wasmConfig)) {
return initWorker(parameters, transferableObjects);
}
return decodeAndCreateGltf(parameters, transferableObjects);
}
var decodeI3S_default = createTaskProcessorWorker_default(decodeI3S);
export {
decodeI3S_default as default
};