@thatopen/components 2.4.0-alpha.7 → 2.4.0-alpha.9

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
@@ -9535,13 +9535,15 @@ class SimpleRaycaster {
9535
9535
  * @param items - the [meshes](https://threejs.org/docs/#api/en/objects/Mesh)
9536
9536
  * to query. If not provided, it will query all the meshes stored in
9537
9537
  * {@link Components.meshes}.
9538
+ * @param position - the screen position to use for raycasting. If not provided,
9539
+ * the last pointer (mouse/touch) position will be used.
9538
9540
  */
9539
- castRay(items = Array.from(this.world.meshes)) {
9541
+ castRay(items = Array.from(this.world.meshes), position = this.mouse.position) {
9540
9542
  if (!this.world) {
9541
9543
  throw new Error("A world is needed to cast rays!");
9542
9544
  }
9543
9545
  const camera = this.world.camera.three;
9544
- this.three.setFromCamera(this.mouse.position, camera);
9546
+ this.three.setFromCamera(position, camera);
9545
9547
  return this.intersect(items);
9546
9548
  }
9547
9549
  /**
@@ -24424,6 +24426,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24424
24426
  this.webIfc.SetLogLevel(logLevel);
24425
24427
  }
24426
24428
  this.webIfc.OpenModelFromCallback(loadCallback, this.settings.webIfc);
24429
+ this._nextAvailableID = this.webIfc.GetMaxExpressID(0);
24427
24430
  }
24428
24431
  async streamAllGeometries() {
24429
24432
  console.log("Converting geometries to tiles...");
@@ -24533,7 +24536,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24533
24536
  const factor = isOpaque ? 1 : -1;
24534
24537
  const transpGeometryID = geometryID * factor;
24535
24538
  if (!this._visitedGeometries.has(transpGeometryID)) {
24536
- this.getGeometry(webIfc, geometryID, transpGeometryID);
24539
+ this.getGeometry(webIfc, geometryID, isOpaque);
24537
24540
  }
24538
24541
  this.registerGeometryData(
24539
24542
  group,
@@ -24552,7 +24555,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24552
24555
  }
24553
24556
  this._assets.push(asset);
24554
24557
  }
24555
- getGeometry(webIfc, id, transpGeometryID) {
24558
+ getGeometry(webIfc, id, isOpaque) {
24556
24559
  const geometry = webIfc.GetGeometry(0, id);
24557
24560
  const index = webIfc.GetIndexArray(
24558
24561
  geometry.GetIndexData(),
@@ -24572,6 +24575,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24572
24575
  normal[i / 2 + 1] = vertexData[i + 4];
24573
24576
  normal[i / 2 + 2] = vertexData[i + 5];
24574
24577
  }
24578
+ const factor = isOpaque ? 1 : -1;
24575
24579
  if (index.length === 0) {
24576
24580
  const boundingBox2 = new Float32Array([
24577
24581
  0,
@@ -24600,6 +24604,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24600
24604
  });
24601
24605
  const geomIndex = this._visitedGeometries.size;
24602
24606
  const uuid = THREE$1.MathUtils.generateUUID();
24607
+ const transpGeometryID = id * factor;
24603
24608
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24604
24609
  this._geometryCount++;
24605
24610
  geometry.delete();
@@ -24649,6 +24654,7 @@ const _IfcGeometryTiler = class _IfcGeometryTiler extends Component {
24649
24654
  }
24650
24655
  const geomIndex = this._visitedGeometries.size;
24651
24656
  const uuid = THREE$1.MathUtils.generateUUID();
24657
+ const transpGeometryID = geometryID * factor;
24652
24658
  this._visitedGeometries.set(transpGeometryID, { uuid, index: geomIndex });
24653
24659
  this._geometryCount++;
24654
24660
  firstSplit = false;
@@ -24868,9 +24874,9 @@ class Viewpoint {
24868
24874
  */
24869
24875
  __publicField(this, "clippingPlanes", new DataSet());
24870
24876
  __publicField(this, "camera", {
24871
- aspectRatio: 0,
24872
- fov: 0,
24873
- direction: { x: 0, y: 0, z: 80 },
24877
+ aspectRatio: 1,
24878
+ fov: 60,
24879
+ direction: { x: 0, y: 0, z: 0 },
24874
24880
  position: { x: 0, y: 0, z: 0 }
24875
24881
  });
24876
24882
  /**
@@ -25110,6 +25116,19 @@ class Viewpoint {
25110
25116
  if (camera instanceof OrthoPerspectiveCamera) {
25111
25117
  camera.projection.set(this.projection);
25112
25118
  }
25119
+ const basePosition = new THREE$1.Vector3(
25120
+ this.camera.position.x,
25121
+ this.camera.position.y,
25122
+ this.camera.position.z
25123
+ );
25124
+ const baseTarget = new THREE$1.Vector3(
25125
+ this.camera.direction.x,
25126
+ this.camera.direction.y,
25127
+ this.camera.direction.z
25128
+ );
25129
+ if (basePosition.equals(new THREE$1.Vector3()) && baseTarget.equals(new THREE$1.Vector3())) {
25130
+ return;
25131
+ }
25113
25132
  const position = this.position;
25114
25133
  const direction = this.direction;
25115
25134
  let target = {
@@ -25131,10 +25150,6 @@ class Viewpoint {
25131
25150
  target = bb.getSphere().center;
25132
25151
  bb.reset();
25133
25152
  }
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
25153
  await camera.controls.setLookAt(
25139
25154
  position.x,
25140
25155
  position.y,
@@ -25195,6 +25210,12 @@ class Viewpoint {
25195
25210
  const manager = this._components.get(Viewpoints);
25196
25211
  manager.list.set(this.guid, this);
25197
25212
  }
25213
+ applyVisibility() {
25214
+ const hider = this._components.get(Hider);
25215
+ hider.set(this.defaultVisibility);
25216
+ hider.set(!this.defaultVisibility, this.exception);
25217
+ hider.set(true, this.selection);
25218
+ }
25198
25219
  /**
25199
25220
  * Applies color to the components in the viewpoint based on their GUIDs.
25200
25221
  *
@@ -25205,24 +25226,17 @@ class Viewpoint {
25205
25226
  * The color is applied using the `Classifier.setColor` method, which sets the color of the specified fragments.
25206
25227
  * The color is provided as a hexadecimal string, prefixed with a '#'.
25207
25228
  */
25208
- colorize() {
25229
+ applyColors() {
25209
25230
  const manager = this._components.get(Viewpoints);
25210
25231
  const fragments = this._components.get(FragmentsManager);
25211
25232
  const classifier = this._components.get(Classifier);
25212
25233
  for (const [color, guids] of this.componentColors) {
25213
25234
  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
- );
25235
+ classifier.setColor(fragmentIdMap, color, manager.config.overwriteColors);
25220
25236
  }
25221
25237
  }
25222
25238
  /**
25223
25239
  * 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
25240
  */
25227
25241
  resetColors() {
25228
25242
  const fragments = this._components.get(FragmentsManager);
@@ -25265,6 +25279,23 @@ class Viewpoint {
25265
25279
  }
25266
25280
  return tags;
25267
25281
  }
25282
+ createColorTags() {
25283
+ let colorTags = "";
25284
+ for (const [color, components] of this.componentColors.entries()) {
25285
+ const hex = `#${color.getHexString()}`;
25286
+ const tags = components.map((globalId) => `
25287
+ <Component IfcGuid="${globalId}" />`).join("\n");
25288
+ colorTags += `<Color Color="${hex}">
25289
+ ${tags}
25290
+ </Color>`;
25291
+ }
25292
+ if (colorTags.length !== 0) {
25293
+ return `<Coloring>
25294
+ ${colorTags}
25295
+ </Coloring>`;
25296
+ }
25297
+ return `<Coloring />`;
25298
+ }
25268
25299
  /**
25269
25300
  * Serializes the viewpoint into a buildingSMART compliant XML string for export.
25270
25301
  *
@@ -25323,6 +25354,7 @@ class Viewpoint {
25323
25354
  const viewSetupHints = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? false}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? false}" OpeningsVisible="${this.openingsVisible ?? false}" />`;
25324
25355
  const selectionTags = (await this.createComponentTags("selection")).trim();
25325
25356
  const exceptionTags = (await this.createComponentTags("exception")).trim();
25357
+ const colorTags = this.createColorTags();
25326
25358
  return `<?xml version="1.0" encoding="UTF-8"?>
25327
25359
  <VisualizationInfo Guid="${this.guid}">
25328
25360
  <Components>
@@ -25332,6 +25364,7 @@ class Viewpoint {
25332
25364
  ${version === "3" ? viewSetupHints : ""}
25333
25365
  ${exceptionTags.length !== 0 ? `<Exceptions>${exceptionTags}</Exceptions>` : ""}
25334
25366
  </Visibility>
25367
+ ${colorTags}
25335
25368
  </Components>
25336
25369
  ${cameraXML}
25337
25370
  </VisualizationInfo>`;
@@ -27284,6 +27317,7 @@ const createEntityFacets = (components, elements) => {
27284
27317
  if (element.cardinality)
27285
27318
  facet.cardinality = element.cardinality;
27286
27319
  facet.predefinedType = getParameterValue(element.predefinedType);
27320
+ facet.instructions = element.instructions;
27287
27321
  facets.push(facet);
27288
27322
  }
27289
27323
  return facets;
@@ -27299,6 +27333,7 @@ const createAttributeFacets = (components, elements) => {
27299
27333
  if (element.cardinality)
27300
27334
  facet.cardinality = element.cardinality;
27301
27335
  facet.value = getParameterValue(element.value);
27336
+ facet.instructions = element.instructions;
27302
27337
  facets.push(facet);
27303
27338
  }
27304
27339
  return facets;
@@ -27322,6 +27357,7 @@ const createClassificationFacets = (components, elements) => {
27322
27357
  }
27323
27358
  facet.value = value;
27324
27359
  facet.uri = element.uri;
27360
+ facet.instructions = element.instructions;
27325
27361
  facets.push(facet);
27326
27362
  }
27327
27363
  return facets;
@@ -27345,6 +27381,7 @@ const createPropertyFacets = (components, elements) => {
27345
27381
  facet.value = value;
27346
27382
  facet.dataType = element.dataType;
27347
27383
  facet.uri = element.uri;
27384
+ facet.instructions = element.instructions;
27348
27385
  facets.push(facet);
27349
27386
  }
27350
27387
  return facets;
@@ -27384,12 +27421,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27384
27421
  *
27385
27422
  * @returns The newly created IDSSpecification instance.
27386
27423
  */
27387
- create(name, ifcVersion) {
27424
+ create(name, ifcVersion, identifier) {
27388
27425
  const specification = new IDSSpecification(
27389
27426
  this.components,
27390
27427
  name,
27391
27428
  ifcVersion
27392
27429
  );
27430
+ if (identifier)
27431
+ specification.identifier = identifier;
27393
27432
  this.list.set(specification.identifier, specification);
27394
27433
  return specification;
27395
27434
  }
@@ -27409,7 +27448,7 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27409
27448
  if (specifications && specifications.specification) {
27410
27449
  const specs = Array.isArray(specifications.specification) ? specifications.specification : [specifications.specification];
27411
27450
  for (const spec of specs) {
27412
- const { name, ifcVersion } = spec;
27451
+ const { name, ifcVersion, description, instructions, identifier } = spec;
27413
27452
  if (!(name && ifcVersion))
27414
27453
  continue;
27415
27454
  const applicabilities = [];
@@ -27428,8 +27467,10 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27428
27467
  }
27429
27468
  }
27430
27469
  }
27470
+ let requirementsDescription;
27431
27471
  if (requirements) {
27432
27472
  const { maxOccurs, ...rest } = requirements;
27473
+ requirementsDescription = requirements.description;
27433
27474
  const facets = Array.isArray(rest) ? rest : [rest];
27434
27475
  for (const facet of facets) {
27435
27476
  for (const facetName in facet) {
@@ -27457,7 +27498,14 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
27457
27498
  }
27458
27499
  }
27459
27500
  if (applicabilities.length > 0 && reqs.length > 0) {
27460
- const specification = this.create(name, ifcVersion.split(/\s+/));
27501
+ const specification = this.create(
27502
+ name,
27503
+ ifcVersion.split(/\s+/),
27504
+ identifier
27505
+ );
27506
+ specification.description = description;
27507
+ specification.instructions = instructions;
27508
+ specification.requirementsDescription = requirementsDescription;
27461
27509
  specification.applicability.add(...applicabilities);
27462
27510
  specification.requirements.add(...reqs);
27463
27511
  result.push(specification);