@thatopen/components 2.4.0-alpha.7 → 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
@@ -24424,6 +24424,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24424
24424
  this.webIfc.SetLogLevel(logLevel);
24425
24425
  }
24426
24426
  this.webIfc.OpenModelFromCallback(loadCallback, this.settings.webIfc);
24427
+ this._nextAvailableID = this.webIfc.GetMaxExpressID(0);
24427
24428
  }
24428
24429
  async streamAllGeometries() {
24429
24430
  console.log("Converting geometries to tiles...");
@@ -24533,7 +24534,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24533
24534
  const factor = isOpaque ? 1 : -1;
24534
24535
  const transpGeometryID = geometryID * factor;
24535
24536
  if (!this._visitedGeometries.has(transpGeometryID)) {
24536
- this.getGeometry(webIfc, geometryID, transpGeometryID);
24537
+ this.getGeometry(webIfc, geometryID, isOpaque);
24537
24538
  }
24538
24539
  this.registerGeometryData(
24539
24540
  group,
@@ -24552,7 +24553,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24552
24553
  }
24553
24554
  this._assets.push(asset);
24554
24555
  }
24555
- getGeometry(webIfc, id, transpGeometryID) {
24556
+ getGeometry(webIfc, id, isOpaque) {
24556
24557
  const geometry = webIfc.GetGeometry(0, id);
24557
24558
  const index = webIfc.GetIndexArray(
24558
24559
  geometry.GetIndexData(),
@@ -24572,6 +24573,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24572
24573
  normal[i / 2 + 1] = vertexData[i + 4];
24573
24574
  normal[i / 2 + 2] = vertexData[i + 5];
24574
24575
  }
24576
+ const factor = isOpaque ? 1 : -1;
24575
24577
  if (index.length === 0) {
24576
24578
  const boundingBox2 = new Float32Array([
24577
24579
  0,
@@ -24600,6 +24602,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24600
24602
  });
24601
24603
  const geomIndex = this._visitedGeometries.size;
24602
24604
  const uuid = THREE$1.MathUtils.generateUUID();
24605
+ const transpGeometryID = id * factor;
24603
24606
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24604
24607
  this._geometryCount++;
24605
24608
  geometry.delete();
@@ -24649,6 +24652,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24649
24652
  }
24650
24653
  const geomIndex = this._visitedGeometries.size;
24651
24654
  const uuid = THREE$1.MathUtils.generateUUID();
24655
+ const transpGeometryID = geometryID * factor;
24652
24656
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24653
24657
  this._geometryCount++;
24654
24658
  firstSplit = false;
@@ -24868,9 +24872,9 @@ class Viewpoint {
24868
24872
  */
24869
24873
  __publicField(this, "clippingPlanes", new DataSet());
24870
24874
  __publicField(this, "camera", {
24871
- aspectRatio: 0,
24872
- fov: 0,
24873
- direction: { x: 0, y: 0, z: 80 },
24875
+ aspectRatio: 1,
24876
+ fov: 60,
24877
+ direction: { x: 0, y: 0, z: 0 },
24874
24878
  position: { x: 0, y: 0, z: 0 }
24875
24879
  });
24876
24880
  /**
@@ -25110,6 +25114,19 @@ class Viewpoint {
25110
25114
  if (camera instanceof OrthoPerspectiveCamera) {
25111
25115
  camera.projection.set(this.projection);
25112
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
+ }
25113
25130
  const position = this.position;
25114
25131
  const direction = this.direction;
25115
25132
  let target = {
@@ -25131,10 +25148,6 @@ class Viewpoint {
25131
25148
  target = bb.getSphere().center;
25132
25149
  bb.reset();
25133
25150
  }
25134
- const hider = this._components.get(Hider);
25135
- hider.set(this.defaultVisibility);
25136
- hider.set(!this.defaultVisibility, this.exception);
25137
- hider.set(true, selection);
25138
25151
  await camera.controls.setLookAt(
25139
25152
  position.x,
25140
25153
  position.y,
@@ -25195,6 +25208,12 @@ class Viewpoint {
25195
25208
  const manager = this._components.get(Viewpoints);
25196
25209
  manager.list.set(this.guid, this);
25197
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
+ }
25198
25217
  /**
25199
25218
  * Applies color to the components in the viewpoint based on their GUIDs.
25200
25219
  *
@@ -25205,24 +25224,17 @@ class Viewpoint {
25205
25224
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
25206
25225
  * The color is provided as a hexadecimal string, prefixed with a '#'.
25207
25226
  */
25208
- colorize() {
25227
+ applyColors() {
25209
25228
  const manager = this._components.get(Viewpoints);
25210
25229
  const fragments = this._components.get(FragmentsManager);
25211
25230
  const classifier = this._components.get(Classifier);
25212
25231
  for (const [color, guids] of this.componentColors) {
25213
25232
  const fragmentIdMap = fragments.guidToFragmentIdMap(guids);
25214
- const threeColor = new THREE$1.Color(`#${color}`);
25215
- classifier.setColor(
25216
- fragmentIdMap,
25217
- threeColor,
25218
- manager.config.overwriteColors
25219
- );
25233
+ classifier.setColor(fragmentIdMap, color, manager.config.overwriteColors);
25220
25234
  }
25221
25235
  }
25222
25236
  /**
25223
25237
  * Resets the colors of all components in the viewpoint to their original color.
25224
- * This method iterates through the `componentColors` map, retrieves the fragment IDs
25225
- * corresponding to each color, and then uses the `Classifier` to reset the color of those fragments.
25226
25238
  */
25227
25239
  resetColors() {
25228
25240
  const fragments = this._components.get(FragmentsManager);
@@ -25265,6 +25277,23 @@ class Viewpoint {
25265
25277
  }
25266
25278
  return tags;
25267
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
+ }
25268
25297
  /**
25269
25298
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
25270
25299
  *
@@ -25323,6 +25352,7 @@ class Viewpoint {
25323
25352
  const viewSetupHints = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? false}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? false}" OpeningsVisible="${this.openingsVisible ?? false}" />`;
25324
25353
  const selectionTags = (await this.createComponentTags("selection")).trim();
25325
25354
  const exceptionTags = (await this.createComponentTags("exception")).trim();
25355
+ const colorTags = this.createColorTags();
25326
25356
  return `<?xml version="1.0" encoding="UTF-8"?>
25327
25357
  <VisualizationInfo Guid="${this.guid}">
25328
25358
  <Components>
@@ -25332,6 +25362,7 @@ class Viewpoint {
25332
25362
  ${version === "3" ? viewSetupHints : ""}
25333
25363
  ${exceptionTags.length !== 0 ? `<Exceptions>${exceptionTags}</Exceptions>` : ""}
25334
25364
  </Visibility>
25365
+ ${colorTags}
25335
25366
  </Components>
25336
25367
  ${cameraXML}
25337
25368
  </VisualizationInfo>`;
@@ -27284,6 +27315,7 @@ const createEntityFacets = (components, elements) => {
27284
27315
  if (element.cardinality)
27285
27316
  facet.cardinality = element.cardinality;
27286
27317
  facet.predefinedType = getParameterValue(element.predefinedType);
27318
+ facet.instructions = element.instructions;
27287
27319
  facets.push(facet);
27288
27320
  }
27289
27321
  return facets;
@@ -27299,6 +27331,7 @@ const createAttributeFacets = (components, elements) => {
27299
27331
  if (element.cardinality)
27300
27332
  facet.cardinality = element.cardinality;
27301
27333
  facet.value = getParameterValue(element.value);
27334
+ facet.instructions = element.instructions;
27302
27335
  facets.push(facet);
27303
27336
  }
27304
27337
  return facets;
@@ -27322,6 +27355,7 @@ const createClassificationFacets = (components, elements) => {
27322
27355
  }
27323
27356
  facet.value = value;
27324
27357
  facet.uri = element.uri;
27358
+ facet.instructions = element.instructions;
27325
27359
  facets.push(facet);
27326
27360
  }
27327
27361
  return facets;
@@ -27345,6 +27379,7 @@ const createPropertyFacets = (components, elements) => {
27345
27379
  facet.value = value;
27346
27380
  facet.dataType = element.dataType;
27347
27381
  facet.uri = element.uri;
27382
+ facet.instructions = element.instructions;
27348
27383
  facets.push(facet);
27349
27384
  }
27350
27385
  return facets;
@@ -27384,12 +27419,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27384
27419
  *
27385
27420
  * @returns The newly created IDSSpecification instance.
27386
27421
  */
27387
- create(name, ifcVersion) {
27422
+ create(name, ifcVersion, identifier) {
27388
27423
  const specification = new IDSSpecification(
27389
27424
  this.components,
27390
27425
  name,
27391
27426
  ifcVersion
27392
27427
  );
27428
+ if (identifier)
27429
+ specification.identifier = identifier;
27393
27430
  this.list.set(specification.identifier, specification);
27394
27431
  return specification;
27395
27432
  }
@@ -27409,7 +27446,7 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27409
27446
  if (specifications && specifications.specification) {
27410
27447
  const specs = Array.isArray(specifications.specification) ? specifications.specification : [specifications.specification];
27411
27448
  for (const spec of specs) {
27412
- const { name, ifcVersion } = spec;
27449
+ const { name, ifcVersion, description, instructions, identifier } = spec;
27413
27450
  if (!(name && ifcVersion))
27414
27451
  continue;
27415
27452
  const applicabilities = [];
@@ -27428,8 +27465,10 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27428
27465
  }
27429
27466
  }
27430
27467
  }
27468
+ let requirementsDescription;
27431
27469
  if (requirements) {
27432
27470
  const { maxOccurs, ...rest } = requirements;
27471
+ requirementsDescription = requirements.description;
27433
27472
  const facets = Array.isArray(rest) ? rest : [rest];
27434
27473
  for (const facet of facets) {
27435
27474
  for (const facetName in facet) {
@@ -27457,7 +27496,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27457
27496
  }
27458
27497
  }
27459
27498
  if (applicabilities.length > 0 && reqs.length > 0) {
27460
- 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;
27461
27507
  specification.applicability.add(...applicabilities);
27462
27508
  specification.requirements.add(...reqs);
27463
27509
  result.push(specification);