@xtctwins/tctwins-bimx-viewer 0.1.12 → 0.1.13

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.
@@ -69856,9 +69856,10 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
69856
69856
  this._eventTrigger = new _EventTrigger__WEBPACK_IMPORTED_MODULE_2__["default"]();
69857
69857
  this.navCubeCanvasElement = cfg.navCubeCanvasElement;
69858
69858
  this.viewerElement = cfg.viewerElement;
69859
- this._modelId = cfg.modelId;
69859
+ this._multiModel = cfg.multiModel ? cfg.multiModel : false;
69860
69860
  this._hasOutlier = false;
69861
69861
  this._outlierObjectIds = [];
69862
+ this._projectId = cfg.projectId ? cfg.projectId : "";
69862
69863
  this.viewer = viewer;
69863
69864
  // this._objectsKdTree3 = new ObjectsKdTree3({
69864
69865
  // viewer
@@ -69868,12 +69869,11 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
69868
69869
  enableEditModels: false,
69869
69870
  modelFromOutSide: true,
69870
69871
  modelType: cfg.modelType,
69871
- modelContent: cfg.modelContent,
69872
69872
  modelSrc: cfg.modelSrc ? cfg.modelSrc : "/",
69873
- modelMetaData: cfg.modelMetaData,
69874
69873
  modelConfig: cfg.modelConfig,
69875
69874
  IfcAPI: cfg.IfcAPI,
69876
- WebIFC: cfg.WebIFC
69875
+ WebIFC: cfg.WebIFC,
69876
+ multiModel: this._multiModel
69877
69877
  });
69878
69878
  this._objectsExplorer = new _explorer_ObjectsExplorer__WEBPACK_IMPORTED_MODULE_12__["default"](this, {
69879
69879
  modelType: cfg.modelType
@@ -69921,7 +69921,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
69921
69921
  });
69922
69922
  this._hideTool = new _toolbar_HideTool__WEBPACK_IMPORTED_MODULE_7__["default"](this, {});
69923
69923
  this._annotationTool = new _toolbar_AnnotationTool__WEBPACK_IMPORTED_MODULE_17__["default"](this, {
69924
- modelId: this._modelId
69924
+ modelId: this._projectId
69925
69925
  });
69926
69926
  this._measureTool = new _toolbar_MeasureTool__WEBPACK_IMPORTED_MODULE_18__["default"](this, {});
69927
69927
  this._sectionTool = new _toolbar_SectionTool__WEBPACK_IMPORTED_MODULE_9__["default"](this, {});
@@ -69965,6 +69965,9 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
69965
69965
  get eventTrigger() {
69966
69966
  return this._eventTrigger;
69967
69967
  }
69968
+ get multiModel() {
69969
+ return this._multiModel;
69970
+ }
69968
69971
  /**
69969
69972
  * Returns the LocaleService that was configured on this Viewer.
69970
69973
  *
@@ -70319,8 +70322,8 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
70319
70322
  *
70320
70323
  * @returns {String[]} The IDs of the models in the currently loaded project.
70321
70324
  */
70322
- modelId() {
70323
- return this._modelId;
70325
+ projectId() {
70326
+ return this._projectId;
70324
70327
  }
70325
70328
  /**
70326
70329
  * Loads a model into the viewer.
@@ -70331,15 +70334,15 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
70331
70334
  * @param {Function} done Callback invoked on success.
70332
70335
  * @param {Function} error Callback invoked on failure, into which the error message string is passed.
70333
70336
  */
70334
- loadModel(done = () => { }, error = () => { }) {
70335
- this._modelsExplorer.loadModel(this._modelId, done, error);
70337
+ loadModel(modelId, modelBuffer, done = () => { }, error = () => { }) {
70338
+ this._modelsExplorer.loadModel(modelId, modelBuffer, done, error);
70336
70339
  }
70337
70340
  /**
70338
70341
  * 单独加载元数据
70339
70342
  * @param deflatedMetadata
70340
70343
  */
70341
- loadMetadata(deflatedMetadata, force = true, done = () => { }) {
70342
- this._modelsExplorer.loadMetadata(this.viewer.metaScene.metaModels[this._modelId], deflatedMetadata, force, () => {
70344
+ loadMetadata(modelId, deflatedMetadata, force = true, done = () => { }) {
70345
+ this._modelsExplorer.loadMetadata(modelId, deflatedMetadata, force, () => {
70343
70346
  this._metaLoaded = true;
70344
70347
  if (this._focusPartial) {
70345
70348
  this.viewFitPartial(0, done);
@@ -70415,8 +70418,8 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
70415
70418
  * 获取模型信息
70416
70419
  * @returns
70417
70420
  */
70418
- getModelInfo() {
70419
- const metaModel = this.viewer.metaScene.metaModels[this._modelId];
70421
+ getModelInfo(modelId) {
70422
+ const metaModel = this.viewer.metaScene.metaModels[modelId];
70420
70423
  const modelInfo = {
70421
70424
  id: metaModel.id,
70422
70425
  createDate: metaModel.createdAt ? metaModel.createdAt : "",
@@ -70426,6 +70429,9 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
70426
70429
  };
70427
70430
  return modelInfo;
70428
70431
  }
70432
+ getMetaModel(modelId) {
70433
+ return this.viewer.metaScene.metaModels[modelId];
70434
+ }
70429
70435
  //------------------------------------------------------------------------------------------------------------------
70430
70436
  // 视图设置
70431
70437
  //------------------------------------------------------------------------------------------------------------------
@@ -70768,7 +70774,7 @@ class BIMXViewer extends _Controller__WEBPACK_IMPORTED_MODULE_3__["default"] {
70768
70774
  this._hasOutlier = true;
70769
70775
  this._outlierObjectIds = exceptionIDs;
70770
70776
  }
70771
- const model = this.viewer.scene.models[this._modelId];
70777
+ const model = this.viewer.scene.models[this._projectId];
70772
70778
  const newExceptionsIds = exceptionIDs.concat(model.exceptionIds);
70773
70779
  model.exceptionIds = newExceptionsIds;
70774
70780
  this.viewer.scene.setObjectsVisible(newExceptionsIds, false);
@@ -72280,9 +72286,8 @@ class ModelsExplorer extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"]
72280
72286
  constructor(parent, cfg) {
72281
72287
  super(parent, cfg);
72282
72288
  this._modelFromOutSide = cfg.modelFromOutSide;
72289
+ this._projectId = cfg.projectId;
72283
72290
  this._modelType = cfg.modelType;
72284
- this._modelArrayBuffer = cfg.modelContent;
72285
- this._modelMetaData = cfg.modelMetaData;
72286
72291
  this._modelSrc = cfg.modelSrc;
72287
72292
  this._eventTrigger = parent.eventTrigger;
72288
72293
  this._dataSource = new BIMViewerDataSource(this.server, {
@@ -72317,7 +72322,6 @@ class ModelsExplorer extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"]
72317
72322
  this._modelsInfo = {};
72318
72323
  this._numModels = 0;
72319
72324
  this._numModelsLoaded = 0;
72320
- this._projectId = null;
72321
72325
  }
72322
72326
  /**
72323
72327
  *
@@ -72325,57 +72329,81 @@ class ModelsExplorer extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"]
72325
72329
  getModelIds() {
72326
72330
  return Object.keys(this._modelsInfo);
72327
72331
  }
72332
+ getModelInfo(modelId) {
72333
+ return this._modelsInfo[modelId];
72334
+ }
72328
72335
  /**
72329
72336
  * @param {string} modelId
72330
72337
  * @param {Function} done
72331
72338
  * @param {Function} error
72332
72339
  */
72333
- loadModel(modelId, done = () => { }, error = () => { }) {
72334
- let modelInfo = this._modelsInfo[modelId];
72335
- if (!modelInfo) {
72336
- modelInfo = {
72337
- id: "testModel",
72338
- name: "testModel",
72339
- objectColorSource: "model",
72340
+ loadModel(modelId, modelBuffer, done = () => { }, error = () => { }) {
72341
+ if (this._modelType == "ifc") {
72342
+ this._modelsInfo[modelId] = {
72343
+ id: modelId,
72344
+ ifc: modelBuffer,
72345
+ metaBuffer: null,
72346
+ edges: true,
72347
+ loadMetadata: false,
72348
+ saoEnabled: true,
72349
+ pbrEnabled: true,
72350
+ dtxEnabled: true
72351
+ };
72352
+ }
72353
+ else {
72354
+ this._modelsInfo[modelId] = {
72355
+ id: modelId,
72356
+ xtc: modelBuffer,
72357
+ metaBuffer: null,
72340
72358
  edges: true,
72359
+ loadMetadata: false,
72341
72360
  saoEnabled: true,
72342
- pbrEnabled: true
72361
+ pbrEnabled: true,
72362
+ dtxEnabled: true
72343
72363
  };
72344
72364
  }
72345
- this._loadGeometry(modelId, modelInfo, this._modelMetaData, done, error);
72365
+ this._loadGeometry(modelId, done, error);
72366
+ }
72367
+ /**
72368
+ * 销毁已载入模型
72369
+ * @param {string} modelId
72370
+ * @returns
72371
+ */
72372
+ unloadModel(modelId) {
72373
+ const model = this.viewer.scene.models[modelId];
72374
+ if (!model) {
72375
+ this.error("Model not loaded: " + modelId);
72376
+ return;
72377
+ }
72378
+ model.destroy();
72379
+ this.fire("modelUnloaded", modelId);
72346
72380
  }
72347
72381
  /**
72348
72382
  * 单独加载元数据
72349
72383
  * @param metaModel
72350
72384
  * @param deflatedMetadata
72351
72385
  */
72352
- loadMetadata(metaModel, deflatedMetadata, force, done) {
72353
- if (this._xtcLoader)
72354
- this._xtcLoader.loadMetadata(metaModel, deflatedMetadata, force, done);
72386
+ loadMetadata(modelId, deflatedMetadata, force, done) {
72387
+ if (this._xtcLoader) {
72388
+ if (this._modelsInfo[modelId]) {
72389
+ this._modelsInfo[modelId].metaBuffer = deflatedMetadata;
72390
+ }
72391
+ this._xtcLoader.loadMetadata(this.viewer.metaScene.metaModels[modelId], deflatedMetadata, force, done);
72392
+ }
72355
72393
  }
72356
72394
  /**
72357
72395
  * @param {string} modelId
72358
- * @param {*} modelInfo
72359
72396
  * @param {*} json
72360
72397
  * @param {Function} done
72361
72398
  * @param {Function} error
72362
72399
  */
72363
- _loadGeometry(modelId, modelInfo, json, done, error) {
72400
+ _loadGeometry(modelId, done, error) {
72401
+ const modelInfo = this._modelsInfo[modelId];
72364
72402
  const modelLoaded = () => {
72365
- this._numModelsLoaded += 1;
72366
- if (this._numModelsLoaded === 1) {
72367
- // Jump camera to view-fit first model loaded
72368
- this._jumpToInitialCamera();
72369
- this.fire("modelLoaded", modelId);
72370
- if (done) {
72371
- done();
72372
- }
72373
- }
72374
- else {
72375
- this.fire("modelLoaded", modelId);
72376
- if (done) {
72377
- done();
72378
- }
72403
+ this._jumpToInitialCamera();
72404
+ this.fire("modelLoaded", modelId);
72405
+ if (done) {
72406
+ done();
72379
72407
  }
72380
72408
  };
72381
72409
  const loadError = (errMsg) => {
@@ -72384,44 +72412,11 @@ class ModelsExplorer extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"]
72384
72412
  error(errMsg);
72385
72413
  }
72386
72414
  };
72387
- if (modelInfo.manifest) {
72388
- // Load multi-part split model;
72389
- // Uses the BIMViewerDataSource, which then uses the BIMViewer's Server strategy
72390
- this._dataSource.setProjectId(this._projectId);
72391
- this._dataSource.setModelId(modelId);
72392
- if (this._xtcLoader) {
72393
- const model = this._xtcLoader.load({
72394
- id: modelId,
72395
- manifestSrc: modelInfo.manifest,
72396
- // objectDefaults,
72397
- excludeUnclassifiedObjects: true,
72398
- origin: modelInfo.origin || modelInfo.position,
72399
- scale: modelInfo.scale,
72400
- rotation: modelInfo.rotation,
72401
- matrix: modelInfo.matrix,
72402
- edges: modelInfo.edges !== false,
72403
- saoEnabled: modelInfo.saoEnabled,
72404
- pbrEnabled: modelInfo.pbrEnabled,
72405
- backfaces: modelInfo.backfaces,
72406
- globalizeObjectIds: modelInfo.globalizeObjectIds,
72407
- reuseGeometries: modelInfo.reuseGeometries !== false
72408
- });
72409
- model.on("loaded", modelLoaded);
72410
- model.on("error", loadError);
72411
- }
72412
- }
72413
- else if (this._modelType == "ifc") {
72415
+ if (this._modelType == "ifc") {
72414
72416
  if (this._ifcLoader) {
72415
72417
  if (this._modelFromOutSide) {
72416
72418
  this.log("加载从外部传入的ifc模型...");
72417
- const model = this._ifcLoader.load({
72418
- id: modelId,
72419
- ifc: this._modelArrayBuffer,
72420
- edges: this._modelConfig.edges ? this._modelConfig.edges : false,
72421
- loadMetadata: false,
72422
- dtxEnabled: true,
72423
- metadata: json
72424
- });
72419
+ const model = this._ifcLoader.load(modelInfo);
72425
72420
  model.on("loaded", modelLoaded);
72426
72421
  model.on("error", loadError);
72427
72422
  }
@@ -72430,12 +72425,10 @@ class ModelsExplorer extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"]
72430
72425
  const model = this._ifcLoader.load({
72431
72426
  id: modelId,
72432
72427
  src: this._modelSrc,
72433
- edges: this._modelConfig.edges !== undefined ? this._modelConfig.edges : false,
72428
+ edges: modelInfo.edges,
72434
72429
  loadMetadata: false,
72435
- metadata: json,
72436
- // pbrEnabled: true,
72437
- dtxEnabled: true
72438
- // excludeUnclassifiedObjects: true
72430
+ pbrEnabled: modelInfo.pbrEnabled,
72431
+ dtxEnabled: modelInfo.dtxEnabled
72439
72432
  });
72440
72433
  model.on("loaded", modelLoaded);
72441
72434
  model.on("error", loadError);
@@ -72445,22 +72438,7 @@ class ModelsExplorer extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"]
72445
72438
  else if (this._xtcLoader) {
72446
72439
  if (this._modelFromOutSide) {
72447
72440
  this.log("加载从外部传入的xtc模型...");
72448
- const model = this._xtcLoader.load({
72449
- id: modelId,
72450
- metaModelData: json,
72451
- xtc: this._modelArrayBuffer,
72452
- // objectDefaults,
72453
- origin: modelInfo.origin || modelInfo.position,
72454
- scale: modelInfo.scale,
72455
- rotation: modelInfo.rotation,
72456
- matrix: modelInfo.matrix,
72457
- edges: this._modelConfig.edges ? this._modelConfig.edges : false,
72458
- saoEnabled: modelInfo.saoEnabled,
72459
- pbrEnabled: modelInfo.pbrEnabled,
72460
- backfaces: modelInfo.backfaces,
72461
- globalizeObjectIds: modelInfo.globalizeObjectIds,
72462
- reuseGeometries: modelInfo.reuseGeometries !== false
72463
- });
72441
+ const model = this._xtcLoader.load(modelInfo);
72464
72442
  model.on("loaded", modelLoaded);
72465
72443
  model.on("error", loadError);
72466
72444
  }
@@ -73973,11 +73951,9 @@ class CommentsTool extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"] {
73973
73951
  this._revocationMechanism = null;
73974
73952
  this.on("active", (active) => {
73975
73953
  if (active) {
73976
- // this.saveSVG();
73977
- // this.endCommentsTool();
73954
+ this.saveSVG();
73978
73955
  }
73979
73956
  else {
73980
- // this.endCommentsTool();
73981
73957
  this.endCommentsTool();
73982
73958
  }
73983
73959
  });
@@ -76077,8 +76053,14 @@ class FitAction extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"] {
76077
76053
  fit(callback) {
76078
76054
  const { viewer } = this;
76079
76055
  const { scene } = viewer;
76080
- const { aabb } = scene;
76081
76056
  const { center } = scene;
76057
+ let aabb;
76058
+ if (this.bimViewer.multiModel) {
76059
+ aabb = scene.getAABB(scene.visibleObjectIds);
76060
+ }
76061
+ else {
76062
+ aabb = scene.aabb;
76063
+ }
76082
76064
  const diag = _xtctwins_tctwins_core__WEBPACK_IMPORTED_MODULE_0__.math.getAABB3Diag(aabb);
76083
76065
  viewer.cameraControl.pivotPos = center;
76084
76066
  if (viewer.cameraControl.planView)
@@ -77225,8 +77207,13 @@ class ResetAction extends _Controller__WEBPACK_IMPORTED_MODULE_1__["default"] {
77225
77207
  _resetCamera(callback) {
77226
77208
  const { viewer } = this;
77227
77209
  const { scene } = viewer;
77228
- const { aabb } = scene;
77229
- // const aabb = scene.getAABB(scene.visibleObjectIds);
77210
+ let aabb;
77211
+ if (this.bimViewer.multiModel) {
77212
+ aabb = scene.getAABB(scene.visibleObjectIds);
77213
+ }
77214
+ else {
77215
+ aabb = scene.aabb;
77216
+ }
77230
77217
  const diag = _xtctwins_tctwins_core__WEBPACK_IMPORTED_MODULE_0__.math.getAABB3Diag(aabb);
77231
77218
  const center = _xtctwins_tctwins_core__WEBPACK_IMPORTED_MODULE_0__.math.getAABB3Center(aabb, tempVec3a);
77232
77219
  const { camera } = scene;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtctwins/tctwins-bimx-viewer",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "description": "BIM viewer built on xtctwins",
6
6
  "main": "./dist/tctwins-bimx-viewer.min.es.js",
@@ -44,7 +44,8 @@ export default class BIMXViewer extends Controller {
44
44
  protected _eventTrigger: EventTrigger;
45
45
  private navCubeCanvasElement;
46
46
  private viewerElement;
47
- private _modelId;
47
+ private _projectId;
48
+ private _multiModel;
48
49
  protected _configs: any;
49
50
  protected _disableClickEvent: boolean;
50
51
  /** 是否有异常构建 */
@@ -68,6 +69,7 @@ export default class BIMXViewer extends Controller {
68
69
  */
69
70
  constructor(cfg?: any);
70
71
  get eventTrigger(): EventTrigger;
72
+ get multiModel(): boolean;
71
73
  /**
72
74
  * Returns the LocaleService that was configured on this Viewer.
73
75
  *
@@ -124,7 +126,7 @@ export default class BIMXViewer extends Controller {
124
126
  *
125
127
  * @returns {String[]} The IDs of the models in the currently loaded project.
126
128
  */
127
- modelId(): string;
129
+ projectId(): string;
128
130
  /**
129
131
  * Loads a model into the viewer.
130
132
  *
@@ -134,12 +136,12 @@ export default class BIMXViewer extends Controller {
134
136
  * @param {Function} done Callback invoked on success.
135
137
  * @param {Function} error Callback invoked on failure, into which the error message string is passed.
136
138
  */
137
- loadModel(done?: (result?: any) => void, error?: (errorMsg: string) => void): void;
139
+ loadModel(modelId: string, modelBuffer: ArrayBuffer, done?: (result?: any) => void, error?: (errorMsg: string) => void): void;
138
140
  /**
139
141
  * 单独加载元数据
140
142
  * @param deflatedMetadata
141
143
  */
142
- loadMetadata(deflatedMetadata: Buffer, force?: boolean, done?: (content?: any) => void): void;
144
+ loadMetadata(modelId: string, deflatedMetadata: Buffer, force?: boolean, done?: (content?: any) => void): void;
143
145
  /**
144
146
  * Sets where the colors for model objects will be loaded from.
145
147
  *
@@ -168,13 +170,14 @@ export default class BIMXViewer extends Controller {
168
170
  * 获取模型信息
169
171
  * @returns
170
172
  */
171
- getModelInfo(): {
173
+ getModelInfo(modelId: string): {
172
174
  id: string | number;
173
175
  createDate: string;
174
176
  author: string;
175
177
  objectCount: string | number;
176
178
  propertySetCount: string | number;
177
179
  };
180
+ getMetaModel(modelId: string): import("@xtctwins/tctwins-core").MetaModel;
178
181
  protected _withObjectsInSubtree(objectIds: string[], callback?: (content?: any) => void): void;
179
182
  /**
180
183
  * Flies the camera to fit the given object in view.
@@ -59,8 +59,6 @@ export default class ModelsExplorer extends Controller {
59
59
  protected _projectId: string | null;
60
60
  protected _modelFromOutSide: boolean;
61
61
  protected _modelType: string;
62
- protected _modelArrayBuffer: ArrayBuffer;
63
- protected _modelMetaData: any;
64
62
  protected _modelSrc: string;
65
63
  protected _modelConfig: any;
66
64
  protected _eventTrigger: EventTrigger;
@@ -74,26 +72,32 @@ export default class ModelsExplorer extends Controller {
74
72
  *
75
73
  */
76
74
  getModelIds(): string[];
75
+ getModelInfo(modelId: string): any;
77
76
  /**
78
77
  * @param {string} modelId
79
78
  * @param {Function} done
80
79
  * @param {Function} error
81
80
  */
82
- loadModel(modelId: string, done?: Function, error?: Function): void;
81
+ loadModel(modelId: string, modelBuffer: ArrayBuffer, done?: Function, error?: Function): void;
82
+ /**
83
+ * 销毁已载入模型
84
+ * @param {string} modelId
85
+ * @returns
86
+ */
87
+ unloadModel(modelId: string): void;
83
88
  /**
84
89
  * 单独加载元数据
85
90
  * @param metaModel
86
91
  * @param deflatedMetadata
87
92
  */
88
- loadMetadata(metaModel: any, deflatedMetadata: any, force: boolean, done?: Function): void;
93
+ loadMetadata(modelId: string, deflatedMetadata: any, force: boolean, done?: Function): void;
89
94
  /**
90
95
  * @param {string} modelId
91
- * @param {*} modelInfo
92
96
  * @param {*} json
93
97
  * @param {Function} done
94
98
  * @param {Function} error
95
99
  */
96
- protected _loadGeometry(modelId: string, modelInfo: any, json: any, done: Function, error: Function): void;
100
+ protected _loadGeometry(modelId: string, done: Function, error: Function): void;
97
101
  /**
98
102
  *
99
103
  */