@thatopen/components 3.1.6 → 3.2.1

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
@@ -105,6 +105,10 @@ class Base {
105
105
  __publicField(this, "isConfigurable", () => {
106
106
  return "setup" in this && "config" in this && "onSetup" in this;
107
107
  });
108
+ /** Whether is component is {@link Serializable}. */
109
+ __publicField(this, "isSerializable", () => {
110
+ return "import" in this && "export" in this;
111
+ });
108
112
  this.components = components;
109
113
  }
110
114
  }
@@ -3157,6 +3161,7 @@ const _FragmentsManager = class _FragmentsManager extends Component {
3157
3161
  super(components);
3158
3162
  /** {@link Disposable.onDisposed} */
3159
3163
  __publicField(this, "onDisposed", new Event());
3164
+ __publicField(this, "onBeforeDispose", new Event());
3160
3165
  /**
3161
3166
  * Event triggered when fragments are loaded.
3162
3167
  */
@@ -3165,10 +3170,12 @@ const _FragmentsManager = class _FragmentsManager extends Component {
3165
3170
  __publicField(this, "baseCoordinationMatrix", new THREE$1.Matrix4());
3166
3171
  /** {@link Component.enabled} */
3167
3172
  __publicField(this, "enabled", true);
3168
- __publicField(this, "initialized", false);
3169
3173
  __publicField(this, "_core");
3170
3174
  this.components.add(_FragmentsManager.uuid, this);
3171
3175
  }
3176
+ get initialized() {
3177
+ return !!this._core;
3178
+ }
3172
3179
  /**
3173
3180
  * Map containing all loaded fragment models.
3174
3181
  * The key is the group's unique identifier, and the value is the model itself.
@@ -3182,8 +3189,12 @@ const _FragmentsManager = class _FragmentsManager extends Component {
3182
3189
  }
3183
3190
  return this._core;
3184
3191
  }
3192
+ get _hasCoordinationModel() {
3193
+ return this.baseCoordinationModel !== "";
3194
+ }
3185
3195
  /** {@link Disposable.dispose} */
3186
3196
  dispose() {
3197
+ this.onBeforeDispose.trigger();
3187
3198
  if (this._core) {
3188
3199
  this.core.dispose();
3189
3200
  this._core = void 0;
@@ -3195,12 +3206,14 @@ const _FragmentsManager = class _FragmentsManager extends Component {
3195
3206
  }
3196
3207
  init(workerURL) {
3197
3208
  this._core = new FragmentsModels(workerURL);
3198
- this.initialized = true;
3199
- this.core.onModelLoaded.add(async (model) => {
3200
- if (this.list.size !== 1)
3209
+ this.core.onModelLoaded.add(async () => {
3210
+ if (this._hasCoordinationModel)
3201
3211
  return;
3202
- this.baseCoordinationModel = model.modelId;
3203
- this.baseCoordinationMatrix = await model.getCoordinationMatrix();
3212
+ const firstModel = [...this.list.values()][0];
3213
+ if (!firstModel)
3214
+ return;
3215
+ this.baseCoordinationModel = firstModel.modelId;
3216
+ this.baseCoordinationMatrix = await firstModel.getCoordinationMatrix();
3204
3217
  });
3205
3218
  this.list.onItemDeleted.add(() => {
3206
3219
  if (this.list.size > 0)
@@ -3875,7 +3888,7 @@ __publicField(_BoundingBoxer, "uuid", "d1444724-dba6-4cdd-a0c7-68ee1450d166");
3875
3888
  let BoundingBoxer = _BoundingBoxer;
3876
3889
  class FinderQuery {
3877
3890
  constructor(components, queries) {
3878
- __publicField(this, "description");
3891
+ __publicField(this, "customData", {});
3879
3892
  __publicField(this, "_components");
3880
3893
  __publicField(this, "_queries", []);
3881
3894
  __publicField(this, "_aggregation", "exclusive");
@@ -3998,9 +4011,11 @@ class FinderQuery {
3998
4011
  * @returns A `SerializedFinderQuery` object representing the serialized query.
3999
4012
  */
4000
4013
  toJSON() {
4014
+ const manager = this._components.get(ItemsFinder);
4015
+ const name = manager.list.getKey(this) ?? "Finder Query";
4001
4016
  const result = {
4002
- name: "Finder Query",
4003
- description: this.description,
4017
+ name,
4018
+ customData: this.customData,
4004
4019
  queries: this.queries.map(this.serializeQueryParameters),
4005
4020
  aggregation: this.aggregation,
4006
4021
  cache: this.cache
@@ -4032,7 +4047,7 @@ class FinderQuery {
4032
4047
  * @returns A `FinderQuery` instance.
4033
4048
  */
4034
4049
  fromJSON(data) {
4035
- this.description = data.description;
4050
+ this.customData = data.customData;
4036
4051
  this.aggregation = data.aggregation;
4037
4052
  this.cache = data.cache;
4038
4053
  this.queries = data.queries.map(this.deserializeQueryParameters);
@@ -4132,9 +4147,9 @@ const _ItemsFinder = class _ItemsFinder extends Component {
4132
4147
  if (!data)
4133
4148
  return instances;
4134
4149
  for (const value of data) {
4135
- const { name, description, queries, aggregation, cache } = value;
4150
+ const { name, customData, queries, aggregation, cache } = value;
4136
4151
  const finderQuery = this.create(name, []);
4137
- finderQuery.fromJSON({ description, queries, aggregation, cache });
4152
+ finderQuery.fromJSON({ customData, queries, aggregation, cache });
4138
4153
  instances.push(finderQuery);
4139
4154
  }
4140
4155
  return instances;
@@ -15876,21 +15891,6 @@ ${users}
15876
15891
  const viewpoint = new Viewpoint(this.components, bcfViewpoint);
15877
15892
  createdViewpoints.push(viewpoint);
15878
15893
  }
15879
- const getNameWithoutExtension = (name) => {
15880
- const partsBySlash = name.split("/");
15881
- const partsByDot = partsBySlash[partsBySlash.length - 1].split(".");
15882
- partsByDot.pop();
15883
- return partsByDot.join(".");
15884
- };
15885
- const snapshotFiles = files.filter(
15886
- (file) => file.name.endsWith(".png") || file.name.endsWith(".jpeg")
15887
- );
15888
- for (const file of snapshotFiles) {
15889
- const name = getNameWithoutExtension(file.name);
15890
- const buffer = await file.async("arraybuffer");
15891
- const bytes = new Uint8Array(buffer);
15892
- viewpoints.snapshots.set(name, bytes);
15893
- }
15894
15894
  const topicRelations = {};
15895
15895
  const topics = [];
15896
15896
  const markupFiles = files.filter((file) => file.name.endsWith(".bcf"));
@@ -15939,12 +15939,16 @@ ${users}
15939
15939
  if (!(markupViewpoint && markupViewpoint.Guid))
15940
15940
  continue;
15941
15941
  const viewpoint = viewpoints.list.get(markupViewpoint.Guid);
15942
- if (viewpoint) {
15943
- topic.viewpoints.add(viewpoint.guid);
15944
- const snapshotName = getNameWithoutExtension(
15945
- markupViewpoint.Snapshot
15946
- );
15947
- viewpoint.snapshot = snapshotName ?? null;
15942
+ if (!viewpoint)
15943
+ continue;
15944
+ topic.viewpoints.add(viewpoint.guid);
15945
+ const snapshotName = `${topic.guid}/${markupViewpoint.Snapshot}`;
15946
+ const snapshotFile = files.find(({ name }) => name === snapshotName);
15947
+ if (snapshotFile) {
15948
+ const buffer = await snapshotFile.async("arraybuffer");
15949
+ const bytes = new Uint8Array(buffer);
15950
+ viewpoints.snapshots.set(viewpoint.guid, bytes);
15951
+ viewpoint.snapshot = viewpoint.guid ?? null;
15948
15952
  }
15949
15953
  }
15950
15954
  const markupDocReferences = this.getMarkupDocumentReferences(
@@ -18477,21 +18481,21 @@ ${colorTags}
18477
18481
  </CameraUpVector>`;
18478
18482
  const cameraRatioXML = `<AspectRatio>${this.camera.aspect_ratio}</AspectRatio>`;
18479
18483
  let cameraXML = "";
18480
- if ("viewToWorld" in this.camera) {
18484
+ if ("view_to_world_scale" in this.camera) {
18481
18485
  cameraXML = `<OrthogonalCamera>
18482
18486
  ${cameraViewpointXML}
18483
18487
  ${cameraDirectionXML}
18484
18488
  ${cameraUpVectorXML}
18485
18489
  ${cameraRatioXML}
18486
- <ViewToWorldScale>${this.camera.viewToWorld}</ViewToWorldScale>
18490
+ <ViewToWorldScale>${this.camera.view_to_world_scale}</ViewToWorldScale>
18487
18491
  </OrthogonalCamera>`;
18488
- } else if ("fov" in this.camera) {
18492
+ } else if ("field_of_view" in this.camera) {
18489
18493
  cameraXML = `<PerspectiveCamera>
18490
18494
  ${cameraViewpointXML}
18491
18495
  ${cameraDirectionXML}
18492
18496
  ${cameraUpVectorXML}
18493
18497
  ${cameraRatioXML}
18494
- <FieldOfView>${this.camera.fov}</FieldOfView>
18498
+ <FieldOfView>${this.camera.field_of_view}</FieldOfView>
18495
18499
  </PerspectiveCamera>`;
18496
18500
  }
18497
18501
  const viewSetupHints = `<ViewSetupHints SpacesVisible="${this.spacesVisible ?? false}" SpaceBoundariesVisible="${this.spaceBoundariesVisible ?? false}" OpeningsVisible="${this.openingsVisible ?? false}" />`;
@@ -20777,7 +20781,7 @@ class IDSSpecification {
20777
20781
  return xml;
20778
20782
  }
20779
20783
  }
20780
- const getParameterValue = (property) => {
20784
+ const getParameterValue = (property, parseNumericString = true) => {
20781
20785
  if (!property)
20782
20786
  return void 0;
20783
20787
  const result = {};
@@ -20795,7 +20799,7 @@ const getParameterValue = (property) => {
20795
20799
  if ("enumeration" in restriction) {
20796
20800
  result.type = "enumeration";
20797
20801
  const enumeration = restriction.enumeration.map(
20798
- ({ value }) => value
20802
+ ({ value }) => parseNumericString ? value : String(value)
20799
20803
  );
20800
20804
  result.parameter = enumeration;
20801
20805
  }
@@ -20889,19 +20893,19 @@ const createMaterialFacets = (components, elements) => {
20889
20893
  }
20890
20894
  return facets;
20891
20895
  };
20892
- const createPropertyFacets = (components, elements) => {
20896
+ const createPropertyFacets = (components, elements, parseNumericString) => {
20893
20897
  const facets = [];
20894
20898
  for (const element of elements) {
20895
20899
  const psetParameter = element.propertySet;
20896
20900
  const baseNameParameter = element.baseName;
20897
- const pset = getParameterValue(psetParameter);
20898
- const baseName = getParameterValue(baseNameParameter);
20901
+ const pset = getParameterValue(psetParameter, parseNumericString);
20902
+ const baseName = getParameterValue(baseNameParameter, parseNumericString);
20899
20903
  if (!(baseName && pset))
20900
20904
  continue;
20901
20905
  const facet = new IDSProperty(components, pset, baseName);
20902
20906
  if (element.cardinality)
20903
20907
  facet.cardinality = element.cardinality;
20904
- const value = getParameterValue(element.value);
20908
+ const value = getParameterValue(element.value, parseNumericString);
20905
20909
  facet.value = value;
20906
20910
  facet.dataType = element.dataType;
20907
20911
  facet.uri = element.uri;
@@ -21011,7 +21015,7 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
21011
21015
  *
21012
21016
  * @returns An array of IDSSpecification instances created from the parsed data.
21013
21017
  */
21014
- load(data) {
21018
+ load(data, config = { parseNumericString: true }) {
21015
21019
  const result = [];
21016
21020
  const ids = _IDSSpecifications.xmlParser.parse(data).ids;
21017
21021
  const { specifications } = ids;
@@ -21050,7 +21054,11 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
21050
21054
  applicabilities.push(...facets2);
21051
21055
  }
21052
21056
  if (facetName === "property") {
21053
- const facets2 = createPropertyFacets(this.components, elements);
21057
+ const facets2 = createPropertyFacets(
21058
+ this.components,
21059
+ elements,
21060
+ config.parseNumericString
21061
+ );
21054
21062
  applicabilities.push(...facets2);
21055
21063
  }
21056
21064
  if (facetName === "partOf") {
@@ -21088,7 +21096,11 @@ const _IDSSpecifications = class _IDSSpecifications extends Component {
21088
21096
  reqs.push(...facets2);
21089
21097
  }
21090
21098
  if (facetName === "property") {
21091
- const facets2 = createPropertyFacets(this.components, elements);
21099
+ const facets2 = createPropertyFacets(
21100
+ this.components,
21101
+ elements,
21102
+ config.parseNumericString
21103
+ );
21092
21104
  reqs.push(...facets2);
21093
21105
  }
21094
21106
  if (facetName === "partOf") {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@thatopen/components",
3
3
  "description": "Collection of core functionalities to author BIM apps.",
4
- "version": "3.1.6",
4
+ "version": "3.2.1",
5
5
  "author": "That Open Company",
6
6
  "contributors": [
7
7
  "Antonio Gonzalez Viegas (https://github.com/agviegas)",
@@ -37,13 +37,13 @@
37
37
  "access": "public"
38
38
  },
39
39
  "devDependencies": {
40
- "@thatopen/fragments": "~3.1.0",
41
- "@thatopen/ui": "~3.1.0",
40
+ "@thatopen/fragments": "~3.2.0",
41
+ "@thatopen/ui": "~3.2.0",
42
42
  "@types/convert-units": "2.3.11",
43
43
  "@types/three": "0.175.0",
44
44
  "stats.js": "^0.17.0",
45
45
  "three": "^0.175.0",
46
- "web-ifc": "0.0.71"
46
+ "web-ifc": "0.0.72"
47
47
  },
48
48
  "dependencies": {
49
49
  "camera-controls": "^2.9.0",
@@ -52,8 +52,8 @@
52
52
  "three-mesh-bvh": "0.7.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@thatopen/fragments": "~3.1.0",
55
+ "@thatopen/fragments": "~3.2.0",
56
56
  "three": ">=0.175.0",
57
- "web-ifc": ">=0.0.71"
57
+ "web-ifc": ">=0.0.72"
58
58
  }
59
59
  }