@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.
@@ -35,7 +35,7 @@ export declare class Viewpoint implements BCFViewpoint {
35
35
  * A map of colors and components GUIDs that should be colorized when displaying a viewpoint.
36
36
  * For this to work, call viewpoint.colorize()
37
37
  */
38
- readonly componentColors: DataMap<string, string[]>;
38
+ readonly componentColors: DataMap<THREE.Color, string[]>;
39
39
  /**
40
40
  * Boolean flags to allow fine control over the visibility of spaces.
41
41
  * A typical use of these flags is when DefaultVisibility=true but spaces should remain hidden.
@@ -163,6 +163,7 @@ export declare class Viewpoint implements BCFViewpoint {
163
163
  * @throws An error if the world's renderer is not available.
164
164
  */
165
165
  updateCamera(): void;
166
+ applyVisibility(): void;
166
167
  /**
167
168
  * Applies color to the components in the viewpoint based on their GUIDs.
168
169
  *
@@ -173,14 +174,13 @@ export declare class Viewpoint implements BCFViewpoint {
173
174
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
174
175
  * The color is provided as a hexadecimal string, prefixed with a '#'.
175
176
  */
176
- colorize(): void;
177
+ applyColors(): void;
177
178
  /**
178
179
  * Resets the colors of all components in the viewpoint to their original color.
179
- * This method iterates through the `componentColors` map, retrieves the fragment IDs
180
- * corresponding to each color, and then uses the `Classifier` to reset the color of those fragments.
181
180
  */
182
181
  resetColors(): void;
183
182
  private createComponentTags;
183
+ private createColorTags;
184
184
  /**
185
185
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
186
186
  *
package/dist/index.cjs CHANGED
@@ -24443,6 +24443,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24443
24443
  this.webIfc.SetLogLevel(logLevel);
24444
24444
  }
24445
24445
  this.webIfc.OpenModelFromCallback(loadCallback, this.settings.webIfc);
24446
+ this._nextAvailableID = this.webIfc.GetMaxExpressID(0);
24446
24447
  }
24447
24448
  async streamAllGeometries() {
24448
24449
  console.log("Converting geometries to tiles...");
@@ -24552,7 +24553,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24552
24553
  const factor = isOpaque ? 1 : -1;
24553
24554
  const transpGeometryID = geometryID * factor;
24554
24555
  if (!this._visitedGeometries.has(transpGeometryID)) {
24555
- this.getGeometry(webIfc, geometryID, transpGeometryID);
24556
+ this.getGeometry(webIfc, geometryID, isOpaque);
24556
24557
  }
24557
24558
  this.registerGeometryData(
24558
24559
  group,
@@ -24571,7 +24572,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24571
24572
  }
24572
24573
  this._assets.push(asset);
24573
24574
  }
24574
- getGeometry(webIfc, id, transpGeometryID) {
24575
+ getGeometry(webIfc, id, isOpaque) {
24575
24576
  const geometry = webIfc.GetGeometry(0, id);
24576
24577
  const index = webIfc.GetIndexArray(
24577
24578
  geometry.GetIndexData(),
@@ -24591,6 +24592,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24591
24592
  normal[i / 2 + 1] = vertexData[i + 4];
24592
24593
  normal[i / 2 + 2] = vertexData[i + 5];
24593
24594
  }
24595
+ const factor = isOpaque ? 1 : -1;
24594
24596
  if (index.length === 0) {
24595
24597
  const boundingBox2 = new Float32Array([
24596
24598
  0,
@@ -24619,6 +24621,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24619
24621
  });
24620
24622
  const geomIndex = this._visitedGeometries.size;
24621
24623
  const uuid = THREE__namespace.MathUtils.generateUUID();
24624
+ const transpGeometryID = id * factor;
24622
24625
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24623
24626
  this._geometryCount++;
24624
24627
  geometry.delete();
@@ -24668,6 +24671,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24668
24671
  }
24669
24672
  const geomIndex = this._visitedGeometries.size;
24670
24673
  const uuid = THREE__namespace.MathUtils.generateUUID();
24674
+ const transpGeometryID = geometryID * factor;
24671
24675
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24672
24676
  this._geometryCount++;
24673
24677
  firstSplit = false;
@@ -24887,9 +24891,9 @@ class Viewpoint {
24887
24891
  */
24888
24892
  __publicField(this, "clippingPlanes", new DataSet());
24889
24893
  __publicField(this, "camera", {
24890
- aspectRatio: 0,
24891
- fov: 0,
24892
- direction: { x: 0, y: 0, z: 80 },
24894
+ aspectRatio: 1,
24895
+ fov: 60,
24896
+ direction: { x: 0, y: 0, z: 0 },
24893
24897
  position: { x: 0, y: 0, z: 0 }
24894
24898
  });
24895
24899
  /**
@@ -25129,6 +25133,19 @@ class Viewpoint {
25129
25133
  if (camera instanceof OrthoPerspectiveCamera) {
25130
25134
  camera.projection.set(this.projection);
25131
25135
  }
25136
+ const basePosition = new THREE__namespace.Vector3(
25137
+ this.camera.position.x,
25138
+ this.camera.position.y,
25139
+ this.camera.position.z
25140
+ );
25141
+ const baseTarget = new THREE__namespace.Vector3(
25142
+ this.camera.direction.x,
25143
+ this.camera.direction.y,
25144
+ this.camera.direction.z
25145
+ );
25146
+ if (basePosition.equals(new THREE__namespace.Vector3()) && baseTarget.equals(new THREE__namespace.Vector3())) {
25147
+ return;
25148
+ }
25132
25149
  const position = this.position;
25133
25150
  const direction = this.direction;
25134
25151
  let target = {
@@ -25150,10 +25167,6 @@ class Viewpoint {
25150
25167
  target = bb.getSphere().center;
25151
25168
  bb.reset();
25152
25169
  }
25153
- const hider = this._components.get(Hider);
25154
- hider.set(this.defaultVisibility);
25155
- hider.set(!this.defaultVisibility, this.exception);
25156
- hider.set(true, selection);
25157
25170
  await camera.controls.setLookAt(
25158
25171
  position.x,
25159
25172
  position.y,
@@ -25214,6 +25227,12 @@ class Viewpoint {
25214
25227
  const manager = this._components.get(Viewpoints);
25215
25228
  manager.list.set(this.guid, this);
25216
25229
  }
25230
+ applyVisibility() {
25231
+ const hider = this._components.get(Hider);
25232
+ hider.set(this.defaultVisibility);
25233
+ hider.set(!this.defaultVisibility, this.exception);
25234
+ hider.set(true, this.selection);
25235
+ }
25217
25236
  /**
25218
25237
  * Applies color to the components in the viewpoint based on their GUIDs.
25219
25238
  *
@@ -25224,24 +25243,17 @@ class Viewpoint {
25224
25243
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
25225
25244
  * The color is provided as a hexadecimal string, prefixed with a '#'.
25226
25245
  */
25227
- colorize() {
25246
+ applyColors() {
25228
25247
  const manager = this._components.get(Viewpoints);
25229
25248
  const fragments = this._components.get(FragmentsManager);
25230
25249
  const classifier = this._components.get(Classifier);
25231
25250
  for (const [color, guids] of this.componentColors) {
25232
25251
  const fragmentIdMap = fragments.guidToFragmentIdMap(guids);
25233
- const threeColor = new THREE__namespace.Color(`#${color}`);
25234
- classifier.setColor(
25235
- fragmentIdMap,
25236
- threeColor,
25237
- manager.config.overwriteColors
25238
- );
25252
+ classifier.setColor(fragmentIdMap, color, manager.config.overwriteColors);
25239
25253
  }
25240
25254
  }
25241
25255
  /**
25242
25256
  * Resets the colors of all components in the viewpoint to their original color.
25243
- * This method iterates through the `componentColors` map, retrieves the fragment IDs
25244
- * corresponding to each color, and then uses the `Classifier` to reset the color of those fragments.
25245
25257
  */
25246
25258
  resetColors() {
25247
25259
  const fragments = this._components.get(FragmentsManager);
@@ -25284,6 +25296,23 @@ class Viewpoint {
25284
25296
  }
25285
25297
  return tags;
25286
25298
  }
25299
+ createColorTags() {
25300
+ let colorTags = "";
25301
+ for (const [color, components] of this.componentColors.entries()) {
25302
+ const hex = `#${color.getHexString()}`;
25303
+ const tags = components.map((globalId) => `
25304
+ <Component IfcGuid="${globalId}" />`).join("\n");
25305
+ colorTags += `<Color Color="${hex}">
25306
+ ${tags}
25307
+ </Color>`;
25308
+ }
25309
+ if (colorTags.length !== 0) {
25310
+ return `<Coloring>
25311
+ ${colorTags}
25312
+ </Coloring>`;
25313
+ }
25314
+ return `<Coloring />`;
25315
+ }
25287
25316
  /**
25288
25317
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
25289
25318
  *
@@ -25342,6 +25371,7 @@ class Viewpoint {
25342
25371
  const viewSetupHints = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? false}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? false}" OpeningsVisible="${this.openingsVisible ?? false}" />`;
25343
25372
  const selectionTags = (await this.createComponentTags("selection")).trim();
25344
25373
  const exceptionTags = (await this.createComponentTags("exception")).trim();
25374
+ const colorTags = this.createColorTags();
25345
25375
  return `<?xml version="1.0" encoding="UTF-8"?>
25346
25376
  <VisualizationInfo Guid="${this.guid}">
25347
25377
  <Components>
@@ -25351,6 +25381,7 @@ class Viewpoint {
25351
25381
  ${version === "3" ? viewSetupHints : ""}
25352
25382
  ${exceptionTags.length !== 0 ? `<Exceptions>${exceptionTags}</Exceptions>` : ""}
25353
25383
  </Visibility>
25384
+ ${colorTags}
25354
25385
  </Components>
25355
25386
  ${cameraXML}
25356
25387
  </VisualizationInfo>`;
@@ -27303,6 +27334,7 @@ const createEntityFacets = (components, elements) => {
27303
27334
  if (element.cardinality)
27304
27335
  facet.cardinality = element.cardinality;
27305
27336
  facet.predefinedType = getParameterValue(element.predefinedType);
27337
+ facet.instructions = element.instructions;
27306
27338
  facets.push(facet);
27307
27339
  }
27308
27340
  return facets;
@@ -27318,6 +27350,7 @@ const createAttributeFacets = (components, elements) => {
27318
27350
  if (element.cardinality)
27319
27351
  facet.cardinality = element.cardinality;
27320
27352
  facet.value = getParameterValue(element.value);
27353
+ facet.instructions = element.instructions;
27321
27354
  facets.push(facet);
27322
27355
  }
27323
27356
  return facets;
@@ -27341,6 +27374,7 @@ const createClassificationFacets = (components, elements) => {
27341
27374
  }
27342
27375
  facet.value = value;
27343
27376
  facet.uri = element.uri;
27377
+ facet.instructions = element.instructions;
27344
27378
  facets.push(facet);
27345
27379
  }
27346
27380
  return facets;
@@ -27364,6 +27398,7 @@ const createPropertyFacets = (components, elements) => {
27364
27398
  facet.value = value;
27365
27399
  facet.dataType = element.dataType;
27366
27400
  facet.uri = element.uri;
27401
+ facet.instructions = element.instructions;
27367
27402
  facets.push(facet);
27368
27403
  }
27369
27404
  return facets;
@@ -27403,12 +27438,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27403
27438
  *
27404
27439
  * @returns The newly created IDSSpecification instance.
27405
27440
  */
27406
- create(name, ifcVersion) {
27441
+ create(name, ifcVersion, identifier) {
27407
27442
  const specification = new IDSSpecification(
27408
27443
  this.components,
27409
27444
  name,
27410
27445
  ifcVersion
27411
27446
  );
27447
+ if (identifier)
27448
+ specification.identifier = identifier;
27412
27449
  this.list.set(specification.identifier, specification);
27413
27450
  return specification;
27414
27451
  }
@@ -27428,7 +27465,7 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27428
27465
  if (specifications && specifications.specification) {
27429
27466
  const specs = Array.isArray(specifications.specification) ? specifications.specification : [specifications.specification];
27430
27467
  for (const spec of specs) {
27431
- const { name, ifcVersion } = spec;
27468
+ const { name, ifcVersion, description, instructions, identifier } = spec;
27432
27469
  if (!(name && ifcVersion))
27433
27470
  continue;
27434
27471
  const applicabilities = [];
@@ -27447,8 +27484,10 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27447
27484
  }
27448
27485
  }
27449
27486
  }
27487
+ let requirementsDescription;
27450
27488
  if (requirements) {
27451
27489
  const { maxOccurs, ...rest } = requirements;
27490
+ requirementsDescription = requirements.description;
27452
27491
  const facets = Array.isArray(rest) ? rest : [rest];
27453
27492
  for (const facet of facets) {
27454
27493
  for (const facetName in facet) {
@@ -27476,7 +27515,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27476
27515
  }
27477
27516
  }
27478
27517
  if (applicabilities.length > 0 && reqs.length > 0) {
27479
- const specification = this.create(name, ifcVersion.split(/\s+/));
27518
+ const specification = this.create(
27519
+ name,
27520
+ ifcVersion.split(/\s+/),
27521
+ identifier
27522
+ );
27523
+ specification.description = description;
27524
+ specification.instructions = instructions;
27525
+ specification.requirementsDescription = requirementsDescription;
27480
27526
  specification.applicability.add(...applicabilities);
27481
27527
  specification.requirements.add(...reqs);
27482
27528
  result.push(specification);