@@ -19,7 +19,7 @@ const XKT_INFO = {
19
19
* @property xktVersion
20
20
* @type {number}
21
21
*/
22
- xktVersion: 11
22
+ xktVersion: 12
23
23
};
24
24
25
25
// Some temporary vars to help avoid garbage collection
@@ -4395,6 +4395,7 @@ class XKTGeometry {
4395
4395
* @param {*} cfg Configuration for the XKTGeometry.
4396
4396
* @param {Number} cfg.geometryId Unique ID of the geometry in {@link XKTModel#geometries}.
4397
4397
* @param {String} cfg.primitiveType Type of this geometry - "triangles", "points" or "lines" so far.
4398
+ * @param {String} cfg.axisLabel Text label of this geometry - "A", "B1"
4398
4399
* @param {Number} cfg.geometryIndex Index of this XKTGeometry in {@link XKTModel#geometriesList}.
4399
4400
* @param {Float64Array} cfg.positions Non-quantized 3D vertex positions.
4400
4401
* @param {Float32Array} cfg.normals Non-compressed vertex normals.
@@ -4419,6 +4420,13 @@ class XKTGeometry {
4419
4420
*/
4420
4421
this.primitiveType = cfg.primitiveType;
4421
4422
4423
+ /**
4424
+ * The text label - "A", "B1".
4425
+ *
4426
+ * @type {String}
4427
+ */
4428
+ this.axisLabel = cfg.axisLabel;
4429
+
4422
4430
/**
4423
4431
* Index of this XKTGeometry in {@link XKTModel#geometriesList}.
4424
4432
*
@@ -9217,13 +9225,14 @@ class XKTModel {
9217
9225
9218
9226
const triangles = params.primitiveType === "triangles";
9219
9227
const points = params.primitiveType === "points";
9228
+ const axis_label = params.primitiveType === "axis-label";
9220
9229
const lines = params.primitiveType === "lines";
9221
9230
const line_strip = params.primitiveType === "line-strip";
9222
9231
const line_loop = params.primitiveType === "line-loop";
9223
9232
params.primitiveType === "triangle-strip";
9224
9233
params.primitiveType === "triangle-fan";
9225
9234
9226
- if (!triangles && !points && !lines && !line_strip && !line_loop) {
9235
+ if (!triangles && !points && !lines && !line_strip && !line_loop && !axis_label ) {
9227
9236
throw "[XKTModel.createGeometry] Unsupported value for params.primitiveType: "
9228
9237
+ params.primitiveType
9229
9238
+ "' - supported values are 'triangles', 'points', 'lines', 'line-strip', 'triangle-strip' and 'triangle-fan";
@@ -9261,12 +9270,14 @@ class XKTModel {
9261
9270
9262
9271
const geometryId = params.geometryId;
9263
9272
const primitiveType = params.primitiveType;
9273
+ const axisLabel = params.axisLabel;
9264
9274
const positions = new Float64Array(params.positions); // May modify in #finalize
9265
9275
9266
9276
const xktGeometryCfg = {
9267
9277
geometryId: geometryId,
9268
9278
geometryIndex: this.geometriesList.length,
9269
9279
primitiveType: primitiveType,
9280
+ axisLabel,
9270
9281
positions: positions,
9271
9282
uvs: params.uvs || params.uv
9272
9283
};
@@ -16648,11 +16659,17 @@ function parseNodeMesh(node, ctx, matrix, meshIds) {
16648
16659
const geometryId = createPrimitiveHash(primitive);
16649
16660
if (!ctx.geometriesCreated[geometryId]) {
16650
16661
const geometryCfg = {
16651
- geometryId
16662
+ geometryId,
16663
+ axisLabel: "",
16652
16664
};
16653
16665
switch (primitive.mode) {
16654
16666
case 0: // POINTS
16655
- geometryCfg.primitiveType = "points";
16667
+ if(primitive.extras?.IfcAxisLabel){
16668
+ geometryCfg.primitiveType = "axis-label";
16669
+ geometryCfg.axisLabel = primitive.extras.IfcAxisLabel;
16670
+ }
16671
+ else
16672
+ geometryCfg.primitiveType = "points";
16656
16673
break;
16657
16674
case 1: // LINES
16658
16675
geometryCfg.primitiveType = "lines";
@@ -26297,6 +26314,7 @@ function writeXKTModelToArrayBufferUncompressed(xktModel, metaModelJSON, stats)
26297
26314
data.matrices,
26298
26315
data.reusedGeometriesDecodeMatrix,
26299
26316
data.eachGeometryPrimitiveType,
26317
+ object2Array(data.eachGeometryAxisLabel),
26300
26318
data.eachGeometryPositionsPortion,
26301
26319
data.eachGeometryNormalsPortion,
26302
26320
data.eachGeometryColorsPortion,
@@ -26316,7 +26334,7 @@ function writeXKTModelToArrayBufferUncompressed(xktModel, metaModelJSON, stats)
26316
26334
const arraysCnt = arrays.length;
26317
26335
const dataView = new DataView(new ArrayBuffer((1 + 2 * arraysCnt) * 4));
26318
26336
26319
- dataView.setUint32(0, XKT_VERSION, true);
26337
+ dataView.setUint32(0, 0 << 31 | XKT_VERSION, true);
26320
26338
26321
26339
let byteOffset = dataView.byteLength;
26322
26340
const offsets = [ ];
@@ -26460,6 +26478,7 @@ function getModelData(xktModel, metaModelDataStr, stats) {
26460
26478
matrices: new Float32Array(lenMatrices), // Modeling matrices for entities that share geometries. Each entity either shares all it's geometries, or owns all its geometries exclusively. Exclusively-owned geometries are pre-transformed into World-space, and so their entities don't have modeling matrices in this array.
26461
26479
reusedGeometriesDecodeMatrix: new Float32Array(xktModel.reusedGeometriesDecodeMatrix), // A single, global vertex position de-quantization matrix for all reused geometries. Reused geometries are quantized to their collective Local-space AABB, and this matrix is derived from that AABB.
26462
26480
eachGeometryPrimitiveType: new Uint8Array(numGeometries), // Primitive type for each geometry (0=solid triangles, 1=surface triangles, 2=lines, 3=points, 4=line-strip)
26481
+ eachGeometryAxisLabel: [], //for each primitive, an axis label
26463
26482
eachGeometryPositionsPortion: new Uint32Array(numGeometries), // For each geometry, an index to its first element in data.positions. Every primitive type has positions.
26464
26483
eachGeometryNormalsPortion: new Uint32Array(numGeometries), // For each geometry, an index to its first element in data.normals. If the next geometry has the same index, then this geometry has no normals.
26465
26484
eachGeometryColorsPortion: new Uint32Array(numGeometries), // For each geometry, an index to its first element in data.colors. If the next geometry has the same index, then this geometry has no colors.
@@ -26558,10 +26577,14 @@ function getModelData(xktModel, metaModelDataStr, stats) {
26558
26577
case "triangle-fan":
26559
26578
primitiveType = 6;
26560
26579
break;
26580
+ case "axis-label":
26581
+ primitiveType = 7;
26582
+ break;
26561
26583
default:
26562
26584
primitiveType = 1;
26563
26585
}
26564
26586
data.eachGeometryPrimitiveType [geometryIndex] = primitiveType;
26587
+ data.eachGeometryAxisLabel [geometryIndex] = geometry.axisLabel;
26565
26588
data.eachGeometryPositionsPortion [geometryIndex] = countPositions;
26566
26589
data.eachGeometryNormalsPortion [geometryIndex] = countNormals;
26567
26590
data.eachGeometryColorsPortion [geometryIndex] = countColors;
@@ -26726,6 +26749,10 @@ function deflateData(data, metaModelJSON, options) {
26726
26749
matrices: deflate(data.matrices.buffer),
26727
26750
reusedGeometriesDecodeMatrix: deflate(data.reusedGeometriesDecodeMatrix.buffer),
26728
26751
eachGeometryPrimitiveType: deflate(data.eachGeometryPrimitiveType.buffer),
26752
+ eachGeometryAxisLabel: deflate(JSON.stringify(data.eachGeometryAxisLabel)
26753
+ .replace(/[\u007F-\uFFFF]/g, function (chr) { // Produce only ASCII-chars, so that the data can be inflated later
26754
+ return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
26755
+ })),
26729
26756
eachGeometryPositionsPortion: deflate(data.eachGeometryPositionsPortion.buffer),
26730
26757
eachGeometryNormalsPortion: deflate(data.eachGeometryNormalsPortion.buffer),
26731
26758
eachGeometryColorsPortion: deflate(data.eachGeometryColorsPortion.buffer),
@@ -26769,6 +26796,7 @@ function createArrayBuffer(deflatedData) {
26769
26796
deflatedData.matrices,
26770
26797
deflatedData.reusedGeometriesDecodeMatrix,
26771
26798
deflatedData.eachGeometryPrimitiveType,
26799
+ deflatedData.eachGeometryAxisLabel,
26772
26800
deflatedData.eachGeometryPositionsPortion,
26773
26801
deflatedData.eachGeometryNormalsPortion,
26774
26802
deflatedData.eachGeometryColorsPortion,
@@ -26787,21 +26815,24 @@ function createArrayBuffer(deflatedData) {
26787
26815
}
26788
26816
26789
26817
function toArrayBuffer$1(elements) {
26790
- const indexData = new Uint32Array(elements.length + 2);
26791
- indexData[0] = 10; // XKT_VERSION for legacy v10 mode
26792
- indexData [1] = elements.length; // Stored Data 1.1: number of stored elements
26793
- let dataLen = 0; // Stored Data 1.2: length of stored elements
26794
- for (let i = 0, len = elements.length; i < len; i++) {
26795
- const element = elements[i];
26796
- const elementsize = element.length;
26797
- indexData[i + 2] = elementsize;
26798
- dataLen += elementsize;
26799
- }
26800
- const indexBuf = new Uint8Array(indexData.buffer);
26801
- const dataArray = new Uint8Array(indexBuf.length + dataLen);
26802
- dataArray.set(indexBuf);
26803
- let offset = indexBuf.length;
26804
- for (let i = 0, len = elements.length; i < len; i++) { // Stored Data 2: the elements themselves
26818
+ const headerSize = (2 + elements.length) * 4;
26819
+
26820
+ const dataView = new DataView(new ArrayBuffer(headerSize));
26821
+ dataView.setUint32(0, 1 << 31 | XKT_VERSION, true);
26822
+ dataView.setUint32(4, elements.length, true);
26823
+
26824
+ let dataLen = 0;
26825
+ for(let i=0;i<elements.length;i++){
26826
+ const elementSize = elements[i].length;
26827
+ dataView.setUint32((i+2)*4, elementSize, true);
26828
+ dataLen += elementSize;
26829
+ }
26830
+
26831
+ const dataArray = new Uint8Array(headerSize + dataLen);
26832
+ dataArray.set(new Uint8Array(dataView.buffer));
26833
+
26834
+ let offset = headerSize;
26835
+ for(let i=0; i < elements.length;i++) {
26805
26836
const element = elements[i];
26806
26837
dataArray.set(element, offset);
26807
26838
offset += element.length;
@@ -26905,7 +26936,7 @@ function convert2xkt({
26905
26936
rotateX = false,
26906
26937
includeTextures = true,
26907
26938
includeNormals = true,
26908
- zip = true ,
26939
+ zip = false ,
26909
26940
log = function (msg) {
26910
26941
}
26911
26942
}) {
@@ -27203,7 +27234,7 @@ function convert2xkt({
27203
27234
stats.minTileSize = minTileSize || 200;
27204
27235
stats.sourceSize = (sourceFileSizeBytes / 1000).toFixed(2);
27205
27236
stats.xktSize = (targetFileSizeBytes / 1000).toFixed(2);
27206
- stats.xktVersion = zip ? 10 : XKT_INFO.xktVersion;
27237
+ stats.xktVersion = XKT_INFO.xktVersion;
27207
27238
stats.compressionRatio = (sourceFileSizeBytes / targetFileSizeBytes).toFixed(2);
27208
27239
stats.conversionTime = ((new Date() - startTime) / 1000.0).toFixed(2);
27209
27240
stats.aabb = xktModel.aabb;
0 commit comments