Skip to content

Commit 3dab3f3

Browse files
committed
Rebuild
1 parent 81eac62 commit 3dab3f3

15 files changed

+61529
-53548
lines changed

dist/convert2xkt.cjs.js

Lines changed: 99 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -17673,7 +17673,7 @@ function parseLASIntoXKTModel({
1767317673
transform = null,
1767417674
colorDepth = "auto",
1767517675
fp64 = false,
17676-
skip = 10,
17676+
skip = 1,
1767717677
stats,
1767817678
log = () => {
1767917679
}
@@ -17708,8 +17708,7 @@ function parseLASIntoXKTModel({
1770817708
parse$2(data, LASLoader, {
1770917709
las: {
1771017710
colorDepth,
17711-
fp64,
17712-
skip
17711+
fp64
1771317712
}
1771417713
}).then((parsedData) => {
1771517714

@@ -17723,46 +17722,43 @@ function parseLASIntoXKTModel({
1772317722
return;
1772417723
}
1772517724

17726-
let positionsValue;
17727-
let colorsCompressed;
17725+
let readAttributes = {};
1772817726

1772917727
switch (pointsFormatId) {
1773017728
case 0:
1773117729
if (!attributes.intensity) {
1773217730
log("No intensities found in file (expected for LAS point format 0)");
1773317731
return;
1773417732
}
17735-
positionsValue = readPositions(attributes.POSITION);
17736-
colorsCompressed = readIntensities(attributes.intensity);
17733+
17734+
readAttributes = readIntensities(attributes.POSITION, attributes.intensity);
1773717735
break;
1773817736
case 1:
1773917737
if (!attributes.intensity) {
1774017738
log("No intensities found in file (expected for LAS point format 1)");
1774117739
return;
1774217740
}
17743-
positionsValue = readPositions(attributes.POSITION);
17744-
colorsCompressed = readIntensities(attributes.intensity);
17741+
readAttributes = readIntensities(attributes.POSITION, attributes.intensity);
1774517742
break;
1774617743
case 2:
1774717744
if (!attributes.intensity) {
1774817745
log("No intensities found in file (expected for LAS point format 2)");
1774917746
return;
1775017747
}
17751-
positionsValue = readPositions(attributes.POSITION);
17752-
colorsCompressed = readColorsAndIntensities(attributes.COLOR_0, attributes.intensity);
17748+
17749+
readAttributes = readColorsAndIntensities(attributes.POSITION, attributes.COLOR_0, attributes.intensity);
1775317750
break;
1775417751
case 3:
1775517752
if (!attributes.intensity) {
1775617753
log("No intensities found in file (expected for LAS point format 3)");
1775717754
return;
1775817755
}
17759-
positionsValue = readPositions(attributes.POSITION);
17760-
colorsCompressed = readColorsAndIntensities(attributes.COLOR_0, attributes.intensity);
17756+
readAttributes = readColorsAndIntensities(attributes.POSITION, attributes.COLOR_0, attributes.intensity);
1776117757
break;
1776217758
}
1776317759

17764-
const pointsChunks = chunkArray(positionsValue, MAX_VERTICES * 3);
17765-
const colorsChunks = chunkArray(colorsCompressed, MAX_VERTICES * 4);
17760+
const pointsChunks = chunkArray(readPositions(readAttributes.positions), MAX_VERTICES * 3);
17761+
const colorsChunks = chunkArray(readAttributes.colors, MAX_VERTICES * 4);
1776617762

1776717763
const meshIds = [];
1776817764

@@ -17818,7 +17814,7 @@ function parseLASIntoXKTModel({
1781817814
stats.numPropertySets = 0;
1781917815
stats.numObjects = 1;
1782017816
stats.numGeometries = 1;
17821-
stats.numVertices = positionsValue.length / 3;
17817+
stats.numVertices = readAttributes.positions.length / 3;
1782217818
}
1782317819

1782417820
resolve();
@@ -17828,11 +17824,9 @@ function parseLASIntoXKTModel({
1782817824
});
1782917825
});
1783017826

17831-
function readPositions(attributesPosition) {
17832-
const positionsValue = attributesPosition.value;
17827+
function readPositions(positionsValue) {
1783317828
if (positionsValue) {
1783417829
if (center) {
17835-
1783617830
const centerPos = math.vec3();
1783717831
const numPoints = positionsValue.length;
1783817832
for (let i = 0, len = positionsValue.length; i < len; i += 3) {
@@ -17866,32 +17860,60 @@ function parseLASIntoXKTModel({
1786617860
return positionsValue;
1786717861
}
1786817862

17869-
function readColorsAndIntensities(attributesColor, attributesIntensity) {
17863+
function readColorsAndIntensities(attributesPosition, attributesColor, attributesIntensity) {
17864+
const positionsValue = attributesPosition.value;
1787017865
const colors = attributesColor.value;
1787117866
const colorSize = attributesColor.size;
1787217867
const intensities = attributesIntensity.value;
1787317868
const colorsCompressedSize = intensities.length * 4;
17874-
const colorsCompressed = new Uint8Array(colorsCompressedSize);
17875-
for (let i = 0, j = 0, k = 0, len = intensities.length; i < len; i++, k += colorSize, j += 4) {
17876-
colorsCompressed[j + 0] = colors[k + 0];
17877-
colorsCompressed[j + 1] = colors[k + 1];
17878-
colorsCompressed[j + 2] = colors[k + 2];
17879-
colorsCompressed[j + 3] = Math.round((intensities[i] / 65536) * 255);
17869+
const positions = [];
17870+
const colorsCompressed = new Uint8Array(colorsCompressedSize / skip);
17871+
let count = skip;
17872+
for (let i = 0, j = 0, k = 0, l = 0, m = 0, n=0,len = intensities.length; i < len; i++, k += colorSize, j += 4, l += 3) {
17873+
if (count <= 0) {
17874+
colorsCompressed[m++] = colors[k + 0];
17875+
colorsCompressed[m++] = colors[k + 1];
17876+
colorsCompressed[m++] = colors[k + 2];
17877+
colorsCompressed[m++] = Math.round((intensities[i] / 65536) * 255);
17878+
positions[n++] = positionsValue[l + 0];
17879+
positions[n++] = positionsValue[l + 1];
17880+
positions[n++] = positionsValue[l + 2];
17881+
count = skip;
17882+
} else {
17883+
count--;
17884+
}
1788017885
}
17881-
return colorsCompressed;
17886+
return {
17887+
positions,
17888+
colors: colorsCompressed
17889+
};
1788217890
}
1788317891

17884-
function readIntensities(attributesIntensity) {
17892+
function readIntensities(attributesPosition, attributesIntensity) {
17893+
const positionsValue = attributesPosition.value;
1788517894
const intensities = attributesIntensity.intensity;
1788617895
const colorsCompressedSize = intensities.length * 4;
17887-
const colorsCompressed = new Uint8Array(colorsCompressedSize);
17888-
for (let i = 0, j = 0, k = 0, len = intensities.length; i < len; i++, k += 3, j += 4) {
17889-
colorsCompressed[j + 0] = 0;
17890-
colorsCompressed[j + 1] = 0;
17891-
colorsCompressed[j + 2] = 0;
17892-
colorsCompressed[j + 3] = Math.round((intensities[i] / 65536) * 255);
17896+
const positions = [];
17897+
const colorsCompressed = new Uint8Array(colorsCompressedSize / skip);
17898+
let count = skip;
17899+
for (let i = 0, j = 0, k = 0, l = 0, m = 0, n = 0, len = intensities.length; i < len; i++, k += 3, j += 4, l += 3) {
17900+
if (count <= 0) {
17901+
colorsCompressed[m++] = 0;
17902+
colorsCompressed[m++] = 0;
17903+
colorsCompressed[m++] = 0;
17904+
colorsCompressed[m++] = Math.round((intensities[i] / 65536) * 255);
17905+
positions[n++] = positionsValue[l + 0];
17906+
positions[n++] = positionsValue[l + 1];
17907+
positions[n++] = positionsValue[l + 2];
17908+
count = skip;
17909+
} else {
17910+
count--;
17911+
}
1789317912
}
17894-
return colorsCompressed;
17913+
return {
17914+
positions,
17915+
colors: colorsCompressed
17916+
};
1789517917
}
1789617918

1789717919
function chunkArray(array, chunkSize) {
@@ -26149,13 +26171,15 @@ const NUM_MATERIAL_ATTRIBUTES = 6;
2614926171
* Writes an {@link XKTModel} to an {@link ArrayBuffer}.
2615026172
*
2615126173
* @param {XKTModel} xktModel The {@link XKTModel}.
26152-
* @param {String} metaModelJSON The metamodel JSON in an string.
26174+
* @param {String} metaModelJSON The metamodel JSON in a string.
2615326175
* @param {Object} [stats] Collects statistics.
26176+
* @param {Object} options Options for how the XKT is written.
26177+
* @param {Boolean} [options.zip=true] ZIP the contents?
2615426178
* @returns {ArrayBuffer} The {@link ArrayBuffer}.
2615526179
*/
26156-
function writeXKTModelToArrayBuffer(xktModel, metaModelJSON, stats = {}) {
26180+
function writeXKTModelToArrayBuffer(xktModel, metaModelJSON, stats, options) {
2615726181
const data = getModelData(xktModel, metaModelJSON, stats);
26158-
const deflatedData = deflateData(data, metaModelJSON);
26182+
const deflatedData = deflateData(data, metaModelJSON, options);
2615926183
stats.texturesSize += deflatedData.textureData.byteLength;
2616026184
const arrayBuffer = createArrayBuffer(deflatedData);
2616126185
return arrayBuffer;
@@ -26483,47 +26507,53 @@ function getModelData(xktModel, metaModelDataStr, stats) {
2648326507
return data;
2648426508
}
2648526509

26486-
function deflateData(data, metaModelJSON) {
26510+
function deflateData(data, metaModelJSON, options) {
26511+
26512+
function deflate(buffer) {
26513+
return (options.zip !== false) ? deflate_1(buffer) : buffer;
26514+
}
26515+
2648726516
let metaModelBytes;
2648826517
if (metaModelJSON) {
2648926518
const deflatedJSON = deflateJSON(metaModelJSON);
26490-
metaModelBytes = deflate_1(deflatedJSON);
26519+
metaModelBytes = deflate(deflatedJSON);
2649126520
} else {
2649226521
const deflatedJSON = deflateJSON(data.metadata);
26493-
metaModelBytes = deflate_1(deflatedJSON);
26522+
metaModelBytes = deflate(deflatedJSON);
2649426523
}
26524+
2649526525
return {
2649626526
metadata: metaModelBytes,
26497-
textureData: deflate_1(data.textureData.buffer),
26498-
eachTextureDataPortion: deflate_1(data.eachTextureDataPortion.buffer),
26499-
eachTextureAttributes: deflate_1(data.eachTextureAttributes.buffer),
26500-
positions: deflate_1(data.positions.buffer),
26501-
normals: deflate_1(data.normals.buffer),
26502-
colors: deflate_1(data.colors.buffer),
26503-
uvs: deflate_1(data.uvs.buffer),
26504-
indices: deflate_1(data.indices.buffer),
26505-
edgeIndices: deflate_1(data.edgeIndices.buffer),
26506-
eachTextureSetTextures: deflate_1(data.eachTextureSetTextures.buffer),
26507-
matrices: deflate_1(data.matrices.buffer),
26508-
reusedGeometriesDecodeMatrix: deflate_1(data.reusedGeometriesDecodeMatrix.buffer),
26509-
eachGeometryPrimitiveType: deflate_1(data.eachGeometryPrimitiveType.buffer),
26510-
eachGeometryPositionsPortion: deflate_1(data.eachGeometryPositionsPortion.buffer),
26511-
eachGeometryNormalsPortion: deflate_1(data.eachGeometryNormalsPortion.buffer),
26512-
eachGeometryColorsPortion: deflate_1(data.eachGeometryColorsPortion.buffer),
26513-
eachGeometryUVsPortion: deflate_1(data.eachGeometryUVsPortion.buffer),
26514-
eachGeometryIndicesPortion: deflate_1(data.eachGeometryIndicesPortion.buffer),
26515-
eachGeometryEdgeIndicesPortion: deflate_1(data.eachGeometryEdgeIndicesPortion.buffer),
26516-
eachMeshGeometriesPortion: deflate_1(data.eachMeshGeometriesPortion.buffer),
26517-
eachMeshMatricesPortion: deflate_1(data.eachMeshMatricesPortion.buffer),
26518-
eachMeshTextureSet: deflate_1(data.eachMeshTextureSet.buffer),
26519-
eachMeshMaterialAttributes: deflate_1(data.eachMeshMaterialAttributes.buffer),
26520-
eachEntityId: deflate_1(JSON.stringify(data.eachEntityId)
26527+
textureData: deflate(data.textureData.buffer),
26528+
eachTextureDataPortion: deflate(data.eachTextureDataPortion.buffer),
26529+
eachTextureAttributes: deflate(data.eachTextureAttributes.buffer),
26530+
positions: deflate(data.positions.buffer),
26531+
normals: deflate(data.normals.buffer),
26532+
colors: deflate(data.colors.buffer),
26533+
uvs: deflate(data.uvs.buffer),
26534+
indices: deflate(data.indices.buffer),
26535+
edgeIndices: deflate(data.edgeIndices.buffer),
26536+
eachTextureSetTextures: deflate(data.eachTextureSetTextures.buffer),
26537+
matrices: deflate(data.matrices.buffer),
26538+
reusedGeometriesDecodeMatrix: deflate(data.reusedGeometriesDecodeMatrix.buffer),
26539+
eachGeometryPrimitiveType: deflate(data.eachGeometryPrimitiveType.buffer),
26540+
eachGeometryPositionsPortion: deflate(data.eachGeometryPositionsPortion.buffer),
26541+
eachGeometryNormalsPortion: deflate(data.eachGeometryNormalsPortion.buffer),
26542+
eachGeometryColorsPortion: deflate(data.eachGeometryColorsPortion.buffer),
26543+
eachGeometryUVsPortion: deflate(data.eachGeometryUVsPortion.buffer),
26544+
eachGeometryIndicesPortion: deflate(data.eachGeometryIndicesPortion.buffer),
26545+
eachGeometryEdgeIndicesPortion: deflate(data.eachGeometryEdgeIndicesPortion.buffer),
26546+
eachMeshGeometriesPortion: deflate(data.eachMeshGeometriesPortion.buffer),
26547+
eachMeshMatricesPortion: deflate(data.eachMeshMatricesPortion.buffer),
26548+
eachMeshTextureSet: deflate(data.eachMeshTextureSet.buffer),
26549+
eachMeshMaterialAttributes: deflate(data.eachMeshMaterialAttributes.buffer),
26550+
eachEntityId: deflate(JSON.stringify(data.eachEntityId)
2652126551
.replace(/[\u007F-\uFFFF]/g, function (chr) { // Produce only ASCII-chars, so that the data can be inflated later
2652226552
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
2652326553
})),
26524-
eachEntityMeshesPortion: deflate_1(data.eachEntityMeshesPortion.buffer),
26525-
eachTileAABB: deflate_1(data.eachTileAABB.buffer),
26526-
eachTileEntitiesPortion: deflate_1(data.eachTileEntitiesPortion.buffer)
26554+
eachEntityMeshesPortion: deflate(data.eachEntityMeshesPortion.buffer),
26555+
eachTileAABB: deflate(data.eachTileAABB.buffer),
26556+
eachTileEntitiesPortion: deflate(data.eachTileEntitiesPortion.buffer)
2652726557
};
2652826558
}
2652926559

@@ -27592,7 +27622,7 @@ function convert2xkt({
2759227622

2759327623
log("XKT document built OK. Writing to XKT file...");
2759427624

27595-
const xktArrayBuffer = writeXKTModelToArrayBuffer(xktModel, metaModelJSON, stats);
27625+
const xktArrayBuffer = writeXKTModelToArrayBuffer(xktModel, metaModelJSON, stats, {zip: true});
2759627626

2759727627
const xktContent = Buffer.from(xktArrayBuffer);
2759827628

dist/xeokit-convert.cjs.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/xeokit-convert.cjs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)