fl-web-component 2.1.16 → 2.1.18

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.
@@ -1468,68 +1468,68 @@ export class StreamLoader {
1468
1468
  }
1469
1469
  }
1470
1470
 
1471
- async getBox({ id, projectId = this.projectId || 0, isDebug }) {
1472
- // 1. 尝试从 IndexedDB 读取
1473
- const cached = await this._getFromDB(id, projectId);
1474
- if (cached && !isDebug) {
1475
- return cached;
1476
- }
1477
-
1478
- const getLegacyBox = async () => {
1479
- if (!this.modelApi || typeof this.modelApi.getBox !== 'function') {
1480
- throw new Error('modelApi.getBox is not available');
1481
- }
1482
- const res = await this.modelApi.getBox({ id, projectId });
1483
- if (!res) return null;
1484
- this._applyPrefixId(res, 'id', id);
1485
- this._saveToDB(id, res, projectId);
1486
- return res;
1487
- };
1488
-
1489
- // 2. 未配置批次数接口时,兼容旧版一次性请求。
1490
- if (!this.modelApi || typeof this.modelApi.getMeshBatchCount !== 'function') {
1491
- return getLegacyBox();
1492
- }
1493
-
1494
- // 3. 先获取批次数量,再顺序拉取每一批包围盒数据。
1495
- let batchResult;
1496
- try {
1497
- batchResult = await this.modelApi.getMeshBatchCount({ id, projectId });
1498
- } catch (error) {
1499
- const status = error && error.response ? error.response.status : error && error.status;
1500
- if (status === 404) {
1501
- return getLegacyBox();
1502
- }
1503
- throw error;
1504
- }
1505
- const batchCount = Number(
1506
- batchResult && typeof batchResult === 'object' ? batchResult.index : batchResult
1507
- );
1508
- if (!Number.isInteger(batchCount) || batchCount < 0) {
1509
- throw new Error('Invalid getBox batch count');
1510
- }
1511
- if (batchCount === 0) {
1512
- return [];
1513
- }
1514
-
1515
- const boxList = [];
1516
- for (let index = 0; index < batchCount; index++) {
1517
- const batch = await this.modelApi.getBox({ id, projectId, index });
1518
- if (!batch) {
1519
- throw new Error(`Failed to get box batch: ${index}`);
1520
- }
1521
- if (Array.isArray(batch)) {
1522
- boxList.push(...batch);
1523
- } else {
1524
- boxList.push(batch);
1525
- }
1526
- }
1527
-
1528
- // 4. 全部批次成功后统一处理并写入完整缓存。
1529
- this._applyPrefixId(boxList, 'id', id);
1530
- this._saveToDB(id, boxList, projectId);
1531
- return boxList;
1532
- }
1471
+ async getBox({ id, projectId = this.projectId || 0, isDebug }) {
1472
+ // 1. 尝试从 IndexedDB 读取
1473
+ const cached = await this._getFromDB(id, projectId);
1474
+ if (cached && !isDebug) {
1475
+ return cached;
1476
+ }
1477
+
1478
+ const getLegacyBox = async () => {
1479
+ if (!this.modelApi || typeof this.modelApi.getBox !== 'function') {
1480
+ throw new Error('modelApi.getBox is not available');
1481
+ }
1482
+ const res = await this.modelApi.getBox({ id, projectId });
1483
+ if (!res) return null;
1484
+ this._applyPrefixId(res, 'id', id);
1485
+ this._saveToDB(id, res, projectId);
1486
+ return res;
1487
+ };
1488
+
1489
+ // 2. 未配置批次数接口时,兼容旧版一次性请求。
1490
+ if (!this.modelApi || typeof this.modelApi.getMeshBatchCount !== 'function') {
1491
+ return getLegacyBox();
1492
+ }
1493
+
1494
+ // 3. 先获取批次数量,再顺序拉取每一批包围盒数据。
1495
+ let batchResult;
1496
+ try {
1497
+ batchResult = await this.modelApi.getMeshBatchCount({ id, projectId });
1498
+ } catch (error) {
1499
+ const status = error && error.response ? error.response.status : error && error.status;
1500
+ if (status === 404) {
1501
+ return getLegacyBox();
1502
+ }
1503
+ throw error;
1504
+ }
1505
+ const batchCount = Number(
1506
+ batchResult && typeof batchResult === 'object' ? batchResult.index : batchResult
1507
+ );
1508
+ if (!Number.isInteger(batchCount) || batchCount < 0) {
1509
+ throw new Error('Invalid getBox batch count');
1510
+ }
1511
+ if (batchCount === 0) {
1512
+ return [];
1513
+ }
1514
+
1515
+ const boxList = [];
1516
+ for (let index = 0; index < batchCount; index++) {
1517
+ const batch = await this.modelApi.getBox({ id, projectId, index });
1518
+ if (!batch) {
1519
+ throw new Error(`Failed to get box batch: ${index}`);
1520
+ }
1521
+ if (Array.isArray(batch)) {
1522
+ boxList.push(...batch);
1523
+ } else {
1524
+ boxList.push(batch);
1525
+ }
1526
+ }
1527
+
1528
+ // 4. 全部批次成功后统一处理并写入完整缓存。
1529
+ this._applyPrefixId(boxList, 'id', id);
1530
+ this._saveToDB(id, boxList, projectId);
1531
+ return boxList;
1532
+ }
1533
1533
 
1534
1534
  async handleCameraControlForStream(args) {
1535
1535
  // 性能优化注释:禁用 range 被注释字段的解构声明与初始化
@@ -27,6 +27,7 @@ var MeasureAngle = function (renderer, scene, camera, width, height, options = {
27
27
  // 创建一个辅助平面来捕获鼠标事件
28
28
  this.plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
29
29
  this.measureName = 'measureObj';
30
+ this.mousePoint = null
30
31
  // this.POINT_MATERIAL = new THREE.PointsMaterial({ color: 0xff5000, size: 1, opacity: 0.6, transparent: true, depthWrite: false, depthTest: false })
31
32
  // this.LINE_MATERIAL = new THREE.LineBasicMaterial({ color: 0xff0000, linewidth: 3, opacity: 0.8, transparent: true, side: THREE.DoubleSide, depthWrite: false, depthTest: false })
32
33
  };
@@ -235,6 +236,7 @@ MeasureAngle.prototype = {
235
236
  }
236
237
  if (_this.pointArray.length >= 3 && !_this.hasTempPoint) return;
237
238
  const positionResult = _this.getPosition(e);
239
+ _this.mousePoint = e;
238
240
  if (positionResult) {
239
241
  const point = positionResult.point;
240
242
  if (_this.hasTempPoint) {
@@ -364,9 +366,13 @@ MeasureAngle.prototype = {
364
366
  }
365
367
  },
366
368
  close(isClear) {
369
+ if (this.mousePoint) {
370
+ this.rightClick(this.mousePoint)
371
+ this.mousePoint = null
372
+ }
367
373
  this.renderer.domElement.removeEventListener('mouseup', this.click, false);
368
374
  this.renderer.domElement.removeEventListener('mousedown', this.mousedown, false);
369
- this.renderer.domElement.removeEventListener('mousemove', this.mousemove, false);
375
+ // this.renderer.domElement.removeEventListener('mousemove', this.mousemove, false);
370
376
  this.renderer.domElement.removeEventListener('contextmenu', this.rightClick, false);
371
377
  if (!isClear) {
372
378
  this.remove(this.points);
@@ -25,6 +25,7 @@ var MeasureArea = function (renderer, scene, camera, width, height, options = {}
25
25
  this.height = height;
26
26
  this.firstTime = 0;
27
27
  this.measureName = 'measureObj';
28
+ this.mousePoint = null;
28
29
  // 创建一个辅助平面来捕获鼠标事件
29
30
  this.plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
30
31
  };
@@ -209,6 +210,7 @@ MeasureArea.prototype = {
209
210
  mousemove(e) {
210
211
  if (_this.isCompleted || _this.pointArray.length === 0) return;
211
212
  const positionResult = _this.getPosition(e);
213
+ _this.mousePoint = e;
212
214
  if (positionResult) {
213
215
  const point = positionResult.point;
214
216
  if (_this.hasTempPoint) {
@@ -328,9 +330,13 @@ MeasureArea.prototype = {
328
330
  }
329
331
  },
330
332
  close(isClear) {
333
+ if (this.mousePoint) {
334
+ this.rightClick(this.mousePoint)
335
+ this.mousePoint = null
336
+ }
331
337
  this.renderer.domElement.removeEventListener('mouseup', this.click);
332
338
  this.renderer.domElement.removeEventListener('mousedown', this.mousedown);
333
- this.renderer.domElement.removeEventListener('mousemove', this.mousemove);
339
+ // this.renderer.domElement.removeEventListener('mousemove', this.mousemove);
334
340
  this.renderer.domElement.removeEventListener('contextmenu', this.rightClick);
335
341
  if (!isClear) {
336
342
  this.remove(this.points);
@@ -25,6 +25,7 @@ var MeasureDistance = function (renderer, scene, camera, width, height, options
25
25
  this.measureName = 'measureObj';
26
26
  // 创建一个辅助平面来捕获鼠标事件
27
27
  this.plane = new THREE.Plane(new THREE.Vector3(0, 0, 1), 0);
28
+ this.mousePoint = null
28
29
  };
29
30
 
30
31
  MeasureDistance.prototype = {
@@ -186,6 +187,7 @@ MeasureDistance.prototype = {
186
187
  },
187
188
  mousemove(e) {
188
189
  if (_this.isCompleted || _this.pointArray.length === 0) return;
190
+ _this.mousePoint = e;
189
191
  const positionResult = _this.getPosition(e);
190
192
  if (positionResult) {
191
193
  const point = positionResult.point;
@@ -328,9 +330,12 @@ MeasureDistance.prototype = {
328
330
  }
329
331
  },
330
332
  close(isClear) {
333
+ console.log(this.mousePoint)
334
+ if (this.mousePoint) {
335
+ this.rightClick(this.mousePoint)
336
+ }
331
337
  this.renderer.domElement.removeEventListener('mousedown', this.mousedown);
332
338
  this.renderer.domElement.removeEventListener('mouseup', this.click);
333
- this.renderer.domElement.removeEventListener('mousemove', this.mousemove);
334
339
  this.renderer.domElement.removeEventListener('contextmenu', this.rightClick);
335
340
  if (!isClear) {
336
341
  this.remove(this.points);