@inweb/viewer-visualize 27.2.2 → 27.2.3

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.
@@ -1533,9 +1533,10 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1533
1533
  const ext = this.getViewer().getActiveExtents();
1534
1534
  const min = ext.min();
1535
1535
  const max = ext.max();
1536
- this.m_size_x = Math.abs(max[0] - min[0]) / 2;
1537
- this.m_size_y = Math.abs(max[1] - min[1]) / 2;
1538
- this.m_size_z = Math.abs(max[2] - min[2]) / 2;
1536
+ const sizeX = Math.abs(max[0] - min[0]);
1537
+ const sizeY = Math.abs(max[1] - min[1]);
1538
+ const sizeZ = Math.abs(max[2] - min[2]);
1539
+ this.m_size = Math.sqrt(sizeX * sizeX + sizeY * sizeY + sizeZ * sizeZ) || 1;
1539
1540
  this.m_center = this.toPoint(ext.center());
1540
1541
  this.m_normal = this.createNormal();
1541
1542
  const avp = this.getViewer().activeView;
@@ -1545,7 +1546,7 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1545
1546
  this.index = avp.numCuttingPlanes() - 1;
1546
1547
  const { red, green, blue } = this.subject.options.cuttingPlaneFillColor;
1547
1548
  avp.setEnableCuttingPlaneFill(true, red, green, blue);
1548
- avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kHorizontalBars, 0x0, 0x0, 0x0);
1549
+ avp.setCuttingPlaneFillPatternEnabled(true, this.m_module.CuttingPlaneFillStyle.kSlantRight, 0x0, 0x0, 0x0);
1549
1550
  this.m_model = this.getModel();
1550
1551
  this.createPreview();
1551
1552
  this.deleteAll([ext, avp, plane]);
@@ -1554,9 +1555,9 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1554
1555
  super.dispose();
1555
1556
  if (this.m_entity) {
1556
1557
  this.m_model.removeEntity(this.m_entity);
1557
- this.deleteAll([this.m_model, this.m_entity, this.planePreview, this.m_center]);
1558
+ this.deleteAll([this.m_model, this.m_entity, this.m_planePreview, this.m_center]);
1558
1559
  this.m_entity = null;
1559
- this.planePreview = null;
1560
+ this.m_planePreview = null;
1560
1561
  this.subject.update();
1561
1562
  }
1562
1563
  }
@@ -1572,7 +1573,6 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1572
1573
  start(x, y) {
1573
1574
  this.press = true;
1574
1575
  this.m_last = this.screenToWorld(x, y);
1575
- this.m_click = { x, y };
1576
1576
  }
1577
1577
  drag(x, y) {
1578
1578
  if (this.press) {
@@ -1584,52 +1584,47 @@ class OdBaseCuttingPlaneDragger extends OdBaseDragger {
1584
1584
  this.m_last = point;
1585
1585
  const avp = this.getViewer().activeView;
1586
1586
  const plane = this.createPlane();
1587
- const newPlane = plane.set(this.toGePoint(this.m_center), this.m_normal);
1588
- const newCutting = avp.updateCuttingPlane(this.index, plane);
1587
+ plane.set(this.toGePoint(this.m_center), this.m_normal);
1588
+ avp.updateCuttingPlane(this.index, plane);
1589
1589
  this.drawPreview();
1590
- this.deleteAll([avp, plane, oldCenter, delta, oldLast, newPlane, newCutting]);
1590
+ this.deleteAll([avp, plane, oldCenter, delta, oldLast]);
1591
1591
  const device = this.getViewer().getActiveDevice();
1592
1592
  device.invalidate(device.getSize());
1593
1593
  }
1594
1594
  }
1595
1595
  end(x, y) {
1596
1596
  this.press = false;
1597
- if (x === this.m_click.x && y === this.m_click.y) {
1598
- this.m_normal = [this.m_normal[0] * -1, this.m_normal[1] * -1, this.m_normal[2] * -1];
1599
- const avp = this.getViewer().activeView;
1600
- const plane = this.createPlane();
1601
- plane.set(this.toGePoint(this.m_center), this.m_normal);
1602
- avp.updateCuttingPlane(this.index, plane);
1603
- this.deleteAll([avp, plane, this.m_last]);
1604
- const device = this.getViewer().getActiveDevice();
1605
- device.invalidate(device.getSize());
1606
- }
1597
+ }
1598
+ dblclick(ev) {
1599
+ this.m_normal = [this.m_normal[0] * -1, this.m_normal[1] * -1, this.m_normal[2] * -1];
1600
+ const avp = this.getViewer().activeView;
1601
+ const plane = this.createPlane();
1602
+ plane.set(this.toGePoint(this.m_center), this.m_normal);
1603
+ avp.updateCuttingPlane(this.index, plane);
1604
+ this.deleteAll([avp, plane, this.m_last]);
1605
+ const device = this.getViewer().getActiveDevice();
1606
+ device.invalidate(device.getSize());
1607
1607
  }
1608
1608
  createPreview() {
1609
1609
  this.m_entity = this.m_model.appendEntity("&CuttingPlanePreview");
1610
1610
  const GeometryTypes = this.m_module.GeometryTypes;
1611
- const transparencyDef = new this.m_module.OdTvTransparencyDef();
1612
- const colorDef = new this.m_module.OdTvColorDef(112, 112, 112);
1613
- transparencyDef.setValue(0.9);
1611
+ const facesColorDef = new this.m_module.OdTvColorDef(0xf0, 0xf0, 0xf0);
1612
+ const facesTransparencyDef = new this.m_module.OdTvTransparencyDef(0.7);
1613
+ const edgesColorDef = new this.m_module.OdTvColorDef(0xd0, 0xd0, 0xd0);
1614
1614
  const entityPtr = this.m_entity.openObject();
1615
- entityPtr.setColor(colorDef, GeometryTypes.kFaces.value);
1616
- colorDef.setColor(112, 112, 112);
1617
- entityPtr.setColor(colorDef, GeometryTypes.kEdges.value);
1618
- entityPtr.setLineWeight(5);
1619
- entityPtr.setTransparency(transparencyDef, GeometryTypes.kFaces);
1620
- transparencyDef.setValue(1.0);
1621
- entityPtr.setTransparency(transparencyDef, GeometryTypes.kEdges);
1622
- this.planePreview = entityPtr.appendPolygon(this.getPlanePreviewCoordinate());
1623
- const polygonPtr = this.planePreview.openAsPolygon();
1615
+ entityPtr.setColor(facesColorDef, GeometryTypes.kFaces);
1616
+ entityPtr.setTransparency(facesTransparencyDef, GeometryTypes.kFaces);
1617
+ entityPtr.setColor(edgesColorDef, GeometryTypes.kEdges);
1618
+ entityPtr.setLineWeight(2);
1619
+ this.m_planePreview = entityPtr.appendPolygon(this.getPlanePreviewCoordinate());
1620
+ const polygonPtr = this.m_planePreview.openAsPolygon();
1624
1621
  polygonPtr.setFilled(true);
1625
- this.deleteAll([transparencyDef, colorDef, entityPtr, polygonPtr, GeometryTypes]);
1626
- this.subject.syncOverlay();
1622
+ this.deleteAll([facesColorDef, facesTransparencyDef, edgesColorDef, entityPtr, polygonPtr, GeometryTypes]);
1627
1623
  }
1628
1624
  drawPreview() {
1629
- const polygonPtr = this.planePreview.openAsPolygon();
1625
+ const polygonPtr = this.m_planePreview.openAsPolygon();
1630
1626
  polygonPtr.setPoints(this.getPlanePreviewCoordinate());
1631
1627
  this.deleteAll([polygonPtr]);
1632
- this.subject.syncOverlay();
1633
1628
  }
1634
1629
  }
1635
1630
 
@@ -1643,19 +1638,20 @@ class OdCuttingPlaneXAxisDragger extends OdBaseCuttingPlaneDragger {
1643
1638
  return delta;
1644
1639
  }
1645
1640
  getPlanePreviewCoordinate() {
1641
+ const halfSize = this.m_size / 2;
1646
1642
  return [
1647
1643
  this.m_center.x,
1648
- this.m_center.y - this.m_size_y,
1649
- this.m_center.z - this.m_size_z,
1644
+ this.m_center.y - halfSize,
1645
+ this.m_center.z - halfSize,
1650
1646
  this.m_center.x,
1651
- this.m_center.y + this.m_size_y,
1652
- this.m_center.z - this.m_size_z,
1647
+ this.m_center.y + halfSize,
1648
+ this.m_center.z - halfSize,
1653
1649
  this.m_center.x,
1654
- this.m_center.y + this.m_size_y,
1655
- this.m_center.z + this.m_size_z,
1650
+ this.m_center.y + halfSize,
1651
+ this.m_center.z + halfSize,
1656
1652
  this.m_center.x,
1657
- this.m_center.y - this.m_size_y,
1658
- this.m_center.z + this.m_size_z,
1653
+ this.m_center.y - halfSize,
1654
+ this.m_center.z + halfSize,
1659
1655
  ];
1660
1656
  }
1661
1657
  }
@@ -1670,19 +1666,20 @@ class OdCuttingPlaneYAxisDragger extends OdBaseCuttingPlaneDragger {
1670
1666
  return delta;
1671
1667
  }
1672
1668
  getPlanePreviewCoordinate() {
1669
+ const halfSize = this.m_size / 2;
1673
1670
  return [
1674
- this.m_center.x - this.m_size_x,
1671
+ this.m_center.x - halfSize,
1675
1672
  this.m_center.y,
1676
- this.m_center.z - this.m_size_z,
1677
- this.m_center.x + this.m_size_x,
1673
+ this.m_center.z - halfSize,
1674
+ this.m_center.x + halfSize,
1678
1675
  this.m_center.y,
1679
- this.m_center.z - this.m_size_z,
1680
- this.m_center.x + this.m_size_x,
1676
+ this.m_center.z - halfSize,
1677
+ this.m_center.x + halfSize,
1681
1678
  this.m_center.y,
1682
- this.m_center.z + this.m_size_z,
1683
- this.m_center.x - this.m_size_x,
1679
+ this.m_center.z + halfSize,
1680
+ this.m_center.x - halfSize,
1684
1681
  this.m_center.y,
1685
- this.m_center.z + this.m_size_z,
1682
+ this.m_center.z + halfSize,
1686
1683
  ];
1687
1684
  }
1688
1685
  }
@@ -1697,18 +1694,19 @@ class OdCuttingPlaneZAxisDragger extends OdBaseCuttingPlaneDragger {
1697
1694
  return delta;
1698
1695
  }
1699
1696
  getPlanePreviewCoordinate() {
1697
+ const halfSize = this.m_size / 2;
1700
1698
  return [
1701
- this.m_center.x - this.m_size_x,
1702
- this.m_center.y - this.m_size_y,
1699
+ this.m_center.x - halfSize,
1700
+ this.m_center.y - halfSize,
1703
1701
  this.m_center.z,
1704
- this.m_center.x + this.m_size_x,
1705
- this.m_center.y - this.m_size_y,
1702
+ this.m_center.x + halfSize,
1703
+ this.m_center.y - halfSize,
1706
1704
  this.m_center.z,
1707
- this.m_center.x + this.m_size_x,
1708
- this.m_center.y + this.m_size_y,
1705
+ this.m_center.x + halfSize,
1706
+ this.m_center.y + halfSize,
1709
1707
  this.m_center.z,
1710
- this.m_center.x - this.m_size_x,
1711
- this.m_center.y + this.m_size_y,
1708
+ this.m_center.x - halfSize,
1709
+ this.m_center.y + halfSize,
1712
1710
  this.m_center.z,
1713
1711
  ];
1714
1712
  }