@thatopen/components 2.4.0-alpha.6 → 2.4.0-alpha.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -24071,6 +24071,47 @@ const _Classifier = class _Classifier extends Component {
24071
24071
  found.resetColor(ids);
24072
24072
  }
24073
24073
  }
24074
+ /**
24075
+ * Exports the computed classification to persists them and import them back
24076
+ * later for faster loading.
24077
+ */
24078
+ export() {
24079
+ const exported = {};
24080
+ for (const systemName in this.list) {
24081
+ exported[systemName] = {};
24082
+ const system = this.list[systemName];
24083
+ for (const groupName in system) {
24084
+ const group = system[groupName];
24085
+ exported[systemName][groupName] = {
24086
+ map: FRAGS.FragmentUtils.export(group.map),
24087
+ name: group.name,
24088
+ id: group.id
24089
+ };
24090
+ }
24091
+ }
24092
+ return JSON.stringify(exported);
24093
+ }
24094
+ /**
24095
+ * Imports a classification previously exported with .export().
24096
+ * @param data the serialized classification to import.
24097
+ */
24098
+ import(data) {
24099
+ const imported = JSON.parse(data);
24100
+ for (const systemName in imported) {
24101
+ if (!this.list[systemName]) {
24102
+ this.list[systemName] = {};
24103
+ }
24104
+ const system = imported[systemName];
24105
+ for (const groupName in system) {
24106
+ const group = system[groupName];
24107
+ this.list[systemName][groupName] = {
24108
+ map: FRAGS.FragmentUtils.import(group.map),
24109
+ name: group.name,
24110
+ id: group.id
24111
+ };
24112
+ }
24113
+ }
24114
+ }
24074
24115
  saveItem(group, systemName, className, expressID, parentID = null) {
24075
24116
  if (!this.list[systemName]) {
24076
24117
  this.list[systemName] = {};
@@ -24383,6 +24424,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24383
24424
  this.webIfc.SetLogLevel(logLevel);
24384
24425
  }
24385
24426
  this.webIfc.OpenModelFromCallback(loadCallback, this.settings.webIfc);
24427
+ this._nextAvailableID = this.webIfc.GetMaxExpressID(0);
24386
24428
  }
24387
24429
  async streamAllGeometries() {
24388
24430
  console.log("Converting geometries to tiles...");
@@ -24492,7 +24534,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24492
24534
  const factor = isOpaque ? 1 : -1;
24493
24535
  const transpGeometryID = geometryID * factor;
24494
24536
  if (!this._visitedGeometries.has(transpGeometryID)) {
24495
- this.getGeometry(webIfc, geometryID, transpGeometryID);
24537
+ this.getGeometry(webIfc, geometryID, isOpaque);
24496
24538
  }
24497
24539
  this.registerGeometryData(
24498
24540
  group,
@@ -24511,7 +24553,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24511
24553
  }
24512
24554
  this._assets.push(asset);
24513
24555
  }
24514
- getGeometry(webIfc, id, transpGeometryID) {
24556
+ getGeometry(webIfc, id, isOpaque) {
24515
24557
  const geometry = webIfc.GetGeometry(0, id);
24516
24558
  const index = webIfc.GetIndexArray(
24517
24559
  geometry.GetIndexData(),
@@ -24531,6 +24573,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24531
24573
  normal[i / 2 + 1] = vertexData[i + 4];
24532
24574
  normal[i / 2 + 2] = vertexData[i + 5];
24533
24575
  }
24576
+ const factor = isOpaque ? 1 : -1;
24534
24577
  if (index.length === 0) {
24535
24578
  const boundingBox2 = new Float32Array([
24536
24579
  0,
@@ -24559,6 +24602,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24559
24602
  });
24560
24603
  const geomIndex = this._visitedGeometries.size;
24561
24604
  const uuid = THREE$1.MathUtils.generateUUID();
24605
+ const transpGeometryID = id * factor;
24562
24606
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24563
24607
  this._geometryCount++;
24564
24608
  geometry.delete();
@@ -24608,6 +24652,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24608
24652
  }
24609
24653
  const geomIndex = this._visitedGeometries.size;
24610
24654
  const uuid = THREE$1.MathUtils.generateUUID();
24655
+ const transpGeometryID = geometryID * factor;
24611
24656
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24612
24657
  this._geometryCount++;
24613
24658
  firstSplit = false;
@@ -24827,9 +24872,9 @@ class Viewpoint {
24827
24872
  */
24828
24873
  __publicField(this, "clippingPlanes", new DataSet());
24829
24874
  __publicField(this, "camera", {
24830
- aspectRatio: 0,
24831
- fov: 0,
24832
- direction: { x: 0, y: 0, z: 80 },
24875
+ aspectRatio: 1,
24876
+ fov: 60,
24877
+ direction: { x: 0, y: 0, z: 0 },
24833
24878
  position: { x: 0, y: 0, z: 0 }
24834
24879
  });
24835
24880
  /**
@@ -25069,6 +25114,19 @@ class Viewpoint {
25069
25114
  if (camera instanceof OrthoPerspectiveCamera) {
25070
25115
  camera.projection.set(this.projection);
25071
25116
  }
25117
+ const basePosition = new THREE$1.Vector3(
25118
+ this.camera.position.x,
25119
+ this.camera.position.y,
25120
+ this.camera.position.z
25121
+ );
25122
+ const baseTarget = new THREE$1.Vector3(
25123
+ this.camera.direction.x,
25124
+ this.camera.direction.y,
25125
+ this.camera.direction.z
25126
+ );
25127
+ if (basePosition.equals(new THREE$1.Vector3()) && baseTarget.equals(new THREE$1.Vector3())) {
25128
+ return;
25129
+ }
25072
25130
  const position = this.position;
25073
25131
  const direction = this.direction;
25074
25132
  let target = {
@@ -25090,10 +25148,6 @@ class Viewpoint {
25090
25148
  target = bb.getSphere().center;
25091
25149
  bb.reset();
25092
25150
  }
25093
- const hider = this._components.get(Hider);
25094
- hider.set(this.defaultVisibility);
25095
- hider.set(!this.defaultVisibility, this.exception);
25096
- hider.set(true, selection);
25097
25151
  await camera.controls.setLookAt(
25098
25152
  position.x,
25099
25153
  position.y,
@@ -25154,6 +25208,12 @@ class Viewpoint {
25154
25208
  const manager = this._components.get(Viewpoints);
25155
25209
  manager.list.set(this.guid, this);
25156
25210
  }
25211
+ applyVisibility() {
25212
+ const hider = this._components.get(Hider);
25213
+ hider.set(this.defaultVisibility);
25214
+ hider.set(!this.defaultVisibility, this.exception);
25215
+ hider.set(true, this.selection);
25216
+ }
25157
25217
  /**
25158
25218
  * Applies color to the components in the viewpoint based on their GUIDs.
25159
25219
  *
@@ -25164,24 +25224,17 @@ class Viewpoint {
25164
25224
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
25165
25225
  * The color is provided as a hexadecimal string, prefixed with a '#'.
25166
25226
  */
25167
- colorize() {
25227
+ applyColors() {
25168
25228
  const manager = this._components.get(Viewpoints);
25169
25229
  const fragments = this._components.get(FragmentsManager);
25170
25230
  const classifier = this._components.get(Classifier);
25171
25231
  for (const [color, guids] of this.componentColors) {
25172
25232
  const fragmentIdMap = fragments.guidToFragmentIdMap(guids);
25173
- const threeColor = new THREE$1.Color(`#${color}`);
25174
- classifier.setColor(
25175
- fragmentIdMap,
25176
- threeColor,
25177
- manager.config.overwriteColors
25178
- );
25233
+ classifier.setColor(fragmentIdMap, color, manager.config.overwriteColors);
25179
25234
  }
25180
25235
  }
25181
25236
  /**
25182
25237
  * Resets the colors of all components in the viewpoint to their original color.
25183
- * This method iterates through the `componentColors` map, retrieves the fragment IDs
25184
- * corresponding to each color, and then uses the `Classifier` to reset the color of those fragments.
25185
25238
  */
25186
25239
  resetColors() {
25187
25240
  const fragments = this._components.get(FragmentsManager);
@@ -25224,6 +25277,23 @@ class Viewpoint {
25224
25277
  }
25225
25278
  return tags;
25226
25279
  }
25280
+ createColorTags() {
25281
+ let colorTags = "";
25282
+ for (const [color, components] of this.componentColors.entries()) {
25283
+ const hex = `#${color.getHexString()}`;
25284
+ const tags = components.map((globalId) => `
25285
+ <Component IfcGuid="${globalId}" />`).join("\n");
25286
+ colorTags += `<Color Color="${hex}">
25287
+ ${tags}
25288
+ </Color>`;
25289
+ }
25290
+ if (colorTags.length !== 0) {
25291
+ return `<Coloring>
25292
+ ${colorTags}
25293
+ </Coloring>`;
25294
+ }
25295
+ return `<Coloring />`;
25296
+ }
25227
25297
  /**
25228
25298
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
25229
25299
  *
@@ -25282,6 +25352,7 @@ class Viewpoint {
25282
25352
  const viewSetupHints = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? false}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? false}" OpeningsVisible="${this.openingsVisible ?? false}" />`;
25283
25353
  const selectionTags = (await this.createComponentTags("selection")).trim();
25284
25354
  const exceptionTags = (await this.createComponentTags("exception")).trim();
25355
+ const colorTags = this.createColorTags();
25285
25356
  return `<?xml version="1.0" encoding="UTF-8"?>
25286
25357
  <VisualizationInfo Guid="${this.guid}">
25287
25358
  <Components>
@@ -25291,6 +25362,7 @@ class Viewpoint {
25291
25362
  ${version === "3" ? viewSetupHints : ""}
25292
25363
  ${exceptionTags.length !== 0 ? `<Exceptions>${exceptionTags}</Exceptions>` : ""}
25293
25364
  </Visibility>
25365
+ ${colorTags}
25294
25366
  </Components>
25295
25367
  ${cameraXML}
25296
25368
  </VisualizationInfo>`;
@@ -27243,6 +27315,7 @@ const createEntityFacets = (components, elements) => {
27243
27315
  if (element.cardinality)
27244
27316
  facet.cardinality = element.cardinality;
27245
27317
  facet.predefinedType = getParameterValue(element.predefinedType);
27318
+ facet.instructions = element.instructions;
27246
27319
  facets.push(facet);
27247
27320
  }
27248
27321
  return facets;
@@ -27258,6 +27331,7 @@ const createAttributeFacets = (components, elements) => {
27258
27331
  if (element.cardinality)
27259
27332
  facet.cardinality = element.cardinality;
27260
27333
  facet.value = getParameterValue(element.value);
27334
+ facet.instructions = element.instructions;
27261
27335
  facets.push(facet);
27262
27336
  }
27263
27337
  return facets;
@@ -27281,6 +27355,7 @@ const createClassificationFacets = (components, elements) => {
27281
27355
  }
27282
27356
  facet.value = value;
27283
27357
  facet.uri = element.uri;
27358
+ facet.instructions = element.instructions;
27284
27359
  facets.push(facet);
27285
27360
  }
27286
27361
  return facets;
@@ -27304,6 +27379,7 @@ const createPropertyFacets = (components, elements) => {
27304
27379
  facet.value = value;
27305
27380
  facet.dataType = element.dataType;
27306
27381
  facet.uri = element.uri;
27382
+ facet.instructions = element.instructions;
27307
27383
  facets.push(facet);
27308
27384
  }
27309
27385
  return facets;
@@ -27343,12 +27419,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27343
27419
  *
27344
27420
  * @returns The newly created IDSSpecification instance.
27345
27421
  */
27346
- create(name, ifcVersion) {
27422
+ create(name, ifcVersion, identifier) {
27347
27423
  const specification = new IDSSpecification(
27348
27424
  this.components,
27349
27425
  name,
27350
27426
  ifcVersion
27351
27427
  );
27428
+ if (identifier)
27429
+ specification.identifier = identifier;
27352
27430
  this.list.set(specification.identifier, specification);
27353
27431
  return specification;
27354
27432
  }
@@ -27368,7 +27446,7 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27368
27446
  if (specifications && specifications.specification) {
27369
27447
  const specs = Array.isArray(specifications.specification) ? specifications.specification : [specifications.specification];
27370
27448
  for (const spec of specs) {
27371
- const { name, ifcVersion } = spec;
27449
+ const { name, ifcVersion, description, instructions, identifier } = spec;
27372
27450
  if (!(name && ifcVersion))
27373
27451
  continue;
27374
27452
  const applicabilities = [];
@@ -27387,8 +27465,10 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27387
27465
  }
27388
27466
  }
27389
27467
  }
27468
+ let requirementsDescription;
27390
27469
  if (requirements) {
27391
27470
  const { maxOccurs, ...rest } = requirements;
27471
+ requirementsDescription = requirements.description;
27392
27472
  const facets = Array.isArray(rest) ? rest : [rest];
27393
27473
  for (const facet of facets) {
27394
27474
  for (const facetName in facet) {
@@ -27416,7 +27496,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27416
27496
  }
27417
27497
  }
27418
27498
  if (applicabilities.length > 0 && reqs.length > 0) {
27419
- const specification = this.create(name, ifcVersion.split(/\s+/));
27499
+ const specification = this.create(
27500
+ name,
27501
+ ifcVersion.split(/\s+/),
27502
+ identifier
27503
+ );
27504
+ specification.description = description;
27505
+ specification.instructions = instructions;
27506
+ specification.requirementsDescription = requirementsDescription;
27420
27507
  specification.applicability.add(...applicabilities);
27421
27508
  specification.requirements.add(...reqs);
27422
27509
  result.push(specification);