@vitrosoftware/common-ui-ts 1.1.257 → 1.1.258

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.js CHANGED
@@ -67699,7 +67699,7 @@ var Viewer = function Viewer(props) {
67699
67699
  };
67700
67700
 
67701
67701
  var name = "@vitrosoftware/common-ui-ts";
67702
- var version$1 = "1.1.257";
67702
+ var version$1 = "1.1.258";
67703
67703
  var description = "vitro software common ui ts";
67704
67704
  var author = "";
67705
67705
  var license = "MIT";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitrosoftware/common-ui-ts",
3
- "version": "1.1.257",
3
+ "version": "1.1.258",
4
4
  "description": "vitro software common ui ts",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -1,11 +1,11 @@
1
- import { BIMModel, BIMCommon, BIMAnnotation } from '/resource/bimViewer/js/bim-viewer-models.js?version=1.1.257';
1
+ import { BIMModel, BIMCommon, BIMAnnotation } from '/resource/bimViewer/js/bim-viewer-models.js?version=1.1.258';
2
2
 
3
3
  import {
4
4
  Viewer, XKTLoaderPlugin, NavCubePlugin, SectionPlanesPlugin, math, BCFViewpointsPlugin, AnnotationsPlugin,
5
5
  ContextMenu, TreeViewPlugin, StoreyViewsPlugin, AngleMeasurementsPlugin, CameraMemento, DistanceMeasurementsPlugin,
6
6
  GLTFLoaderPlugin, utils, FastNavPlugin, MetaObject, parsers, buildVectorTextGeometry
7
7
  }
8
- from '/resource/bimViewer/js/xeokit/xeokit-sdk.es.js?version=1.1.257';
8
+ from '/resource/bimViewer/js/xeokit/xeokit-sdk.es.js?version=1.1.258';
9
9
 
10
10
 
11
11
  //----------------------------------------------------------------------------------------------------------------------
@@ -1,18 +1,18 @@
1
- import * as three from '/resource/dxfViewer/js/three/three.module.js?version=1.1.257';
2
- import { Matrix3, Vector2 } from '/resource/dxfViewer/js/three/three.module.js?version=1.1.257';
3
- import { Batch, DxfViewer, Layer } from '/resource/dxfViewer/js/viewer/DxfViewer.js?version=1.1.257';
4
- import { Block as SceneBlock } from '/resource/dxfViewer/js/viewer/DxfScene.js?version=1.1.257';
5
- import { Block } from '/resource/dxfViewer/js/viewer/DxfViewer.js?version=1.1.257';
6
- import { DxfScene, Entity, ColorCode } from '/resource/dxfViewer/js/viewer/DxfScene.js?version=1.1.257';
7
- import { TextRenderer, ParseSpecialChars, HAlign, VAlign } from '/resource/dxfViewer/js/viewer/TextRenderer.js?version=1.1.257';
8
- import { DxfWorker } from '/resource/dxfViewer/js/viewer/DxfWorker.js?version=1.1.257';
9
- import { DxfFetcher } from '/resource/dxfViewer/js/viewer/DxfFetcher.js?version=1.1.257';
10
- import DxfParser from '/resource/dxfViewer/js/viewer/parser/DxfParser.js?version=1.1.257';
11
- import { RenderBatch } from '/resource/dxfViewer/js/viewer/DxfScene.js?version=1.1.257';
12
- import { DynamicBuffer, NativeType } from '/resource/dxfViewer/js/viewer/DynamicBuffer.js?version=1.1.257';
13
- import { OrbitControls } from '/resource/dxfViewer/js/viewer/OrbitControls.js?version=1.1.257';
14
- import { CSS2DRenderer, CSS2DObject } from '/resource/dxfViewer/js/three/three.module.js?version=1.1.257';
15
- import * as fflate from '/resource/dxfViewer/js/fflate/fflate.module.js?version=1.1.257'
1
+ import * as three from '/resource/dxfViewer/js/three/three.module.js?version=1.1.258';
2
+ import { Matrix3, Vector2 } from '/resource/dxfViewer/js/three/three.module.js?version=1.1.258';
3
+ import { Batch, DxfViewer, Layer } from '/resource/dxfViewer/js/viewer/DxfViewer.js?version=1.1.258';
4
+ import { Block as SceneBlock } from '/resource/dxfViewer/js/viewer/DxfScene.js?version=1.1.258';
5
+ import { Block } from '/resource/dxfViewer/js/viewer/DxfViewer.js?version=1.1.258';
6
+ import { DxfScene, Entity, ColorCode, PdMode } from '/resource/dxfViewer/js/viewer/DxfScene.js?version=1.1.258';
7
+ import { TextRenderer, ParseSpecialChars, HAlign, VAlign } from '/resource/dxfViewer/js/viewer/TextRenderer.js?version=1.1.258';
8
+ import { DxfWorker } from '/resource/dxfViewer/js/viewer/DxfWorker.js?version=1.1.258';
9
+ import { DxfFetcher } from '/resource/dxfViewer/js/viewer/DxfFetcher.js?version=1.1.258';
10
+ import DxfParser from '/resource/dxfViewer/js/viewer/parser/DxfParser.js?version=1.1.258';
11
+ import { RenderBatch } from '/resource/dxfViewer/js/viewer/DxfScene.js?version=1.1.258';
12
+ import { DynamicBuffer, NativeType } from '/resource/dxfViewer/js/viewer/DynamicBuffer.js?version=1.1.258';
13
+ import { OrbitControls } from '/resource/dxfViewer/js/viewer/OrbitControls.js?version=1.1.258';
14
+ import { CSS2DRenderer, CSS2DObject } from '/resource/dxfViewer/js/three/three.module.js?version=1.1.258';
15
+ import * as fflate from '/resource/dxfViewer/js/fflate/fflate.module.js?version=1.1.258'
16
16
 
17
17
  let treeViewData = [];
18
18
  let notes = [];
@@ -387,6 +387,9 @@ export class VitroBlock extends SceneBlock {
387
387
  }
388
388
  }
389
389
  }
390
+ const POINT_SHAPE_BLOCK_NAME = "__point_shape"
391
+ const POINT_CIRCLE_TESSELLATION_ANGLE = 15 * Math.PI / 180
392
+
390
393
  export class VitroDxfScene extends DxfScene {
391
394
 
392
395
  constructor(options) {
@@ -755,63 +758,6 @@ export class VitroDxfScene extends DxfScene {
755
758
  return !blockCtx || blockCtx.block.IsSpace()
756
759
  }
757
760
 
758
-
759
- _CreatePointShapeBlock() {//to override to new VitroBlock
760
- if (this.pointShapeBlock) {
761
- return
762
- }
763
- /* This mimics DXF block entity. */
764
- this.pointShapeBlock = new VitroBlock({
765
- name: POINT_SHAPE_BLOCK_NAME,
766
- position: { x: 0, y: 0 }
767
- })
768
- /* Fix block origin at zero. */
769
- this.pointShapeBlock.offset = new Vector2(0, 0)
770
- const blockCtx = this.pointShapeBlock.DefinitionContext()
771
-
772
- const markType = this.pdMode & PdMode.MARK_MASK
773
- if (markType !== PdMode.DOT && markType !== PdMode.NONE) {
774
- const vertices = []
775
- this._CreatePointMarker(vertices, markType)
776
- const entity = new Entity({
777
- type: Entity.Type.LINE_SEGMENTS,
778
- vertices,
779
- color: ColorCode.BY_BLOCK
780
- })
781
- this._ProcessEntity(entity, blockCtx)
782
- }
783
-
784
- if (this.pdMode & PdMode.SQUARE) {
785
- const r = this.pdSize * 0.5
786
- const vertices = [
787
- { x: -r, y: r },
788
- { x: r, y: r },
789
- { x: r, y: -r },
790
- { x: -r, y: -r }
791
- ]
792
- const entity = new Entity({
793
- type: Entity.Type.POLYLINE, vertices,
794
- color: ColorCode.BY_BLOCK,
795
- shape: true
796
- })
797
- this._ProcessEntity(entity, blockCtx)
798
- }
799
- if (this.pdMode & PdMode.CIRCLE) {
800
- const vertices = []
801
- this._GenerateArcVertices({
802
- vertices, center: { x: 0, y: 0 },
803
- radius: this.pdSize * 0.5,
804
- tessellationAngle: POINT_CIRCLE_TESSELLATION_ANGLE
805
- })
806
- const entity = new Entity({
807
- type: Entity.Type.POLYLINE, vertices,
808
- color: ColorCode.BY_BLOCK,
809
- shape: true
810
- })
811
- this._ProcessEntity(entity, blockCtx)
812
- }
813
- }
814
-
815
761
  _ProcessDxfEntity(entity, blockCtx = null) {
816
762
  let renderEntities
817
763
  switch (entity.type) {
@@ -1041,7 +987,7 @@ export class VitroDxfScene extends DxfScene {
1041
987
  const name = entity.name
1042
988
  entity.name = entity.block
1043
989
  entity.position = { x: 0, y:0, z: 0 }
1044
- this._ProcessInsert(entity, blockCtx)
990
+ this._ProcessInsert(entity, blockCtx)//block insertion simulation
1045
991
  entity.name = name
1046
992
  return
1047
993
  }
@@ -1074,6 +1020,110 @@ export class VitroDxfScene extends DxfScene {
1074
1020
  yield* super._DecomposeLine(entity, blockCtx)
1075
1021
  }
1076
1022
 
1023
+ *_DecomposePoint(entity, blockCtx) {
1024
+ if (this.pdMode === PdMode.NONE) {
1025
+ /* Points not displayed. */
1026
+ return
1027
+ }
1028
+ if (this.pdMode !== PdMode.DOT && this.pdSize <= 0) {
1029
+ /* Currently not supported. */
1030
+ return
1031
+ }
1032
+ const color = this._GetEntityColor(entity, blockCtx)
1033
+ const layer = this._GetEntityLayer(entity, blockCtx)
1034
+ const markType = this.pdMode & PdMode.MARK_MASK
1035
+ const isShaped = (this.pdMode & PdMode.SHAPE_MASK) !== 0
1036
+
1037
+ if (isShaped) {
1038
+ /* Shaped mark should be instanced. */
1039
+ const key = new BatchingKey(layer, POINT_SHAPE_BLOCK_NAME,
1040
+ BatchingKey.GeometryType.POINT_INSTANCE, color, 0)
1041
+ const batch = this._GetBatch(key)
1042
+ batch.PushVertex(this._TransformVertex(entity.position, blockCtx))
1043
+ this._CreatePointShapeBlock(entity)
1044
+
1045
+ const name = entity.name
1046
+ entity.name = POINT_SHAPE_BLOCK_NAME
1047
+ this._ProcessInsert(entity, blockCtx)//block insertion simulation
1048
+ entity.name = name
1049
+ return
1050
+ }
1051
+
1052
+ if (markType === PdMode.DOT) {
1053
+ yield new Entity({
1054
+ type: Entity.Type.POINTS,
1055
+ vertices: [entity.position],
1056
+ layer, color,
1057
+ lineType: null
1058
+ })
1059
+ return
1060
+ }
1061
+
1062
+ const vertices = []
1063
+ this._CreatePointMarker(vertices, markType, entity.position)
1064
+ yield new Entity({
1065
+ type: Entity.Type.LINE_SEGMENTS,
1066
+ vertices, layer, color,
1067
+ lineType: null
1068
+ })
1069
+ }
1070
+
1071
+ _CreatePointShapeBlock() {//to override to new VitroBlock
1072
+ if (this.pointShapeBlock) {
1073
+ return
1074
+ }
1075
+ /* This mimics DXF block entity. */
1076
+ this.pointShapeBlock = new VitroBlock({
1077
+ name: POINT_SHAPE_BLOCK_NAME,
1078
+ position: { x: 0, y: 0 }
1079
+ })
1080
+ /* Fix block origin at zero. */
1081
+ this.pointShapeBlock.offset = new Vector2(0, 0)
1082
+ const blockCtx = this.pointShapeBlock.DefinitionContext()
1083
+
1084
+ const markType = this.pdMode & PdMode.MARK_MASK
1085
+ if (markType !== PdMode.DOT && markType !== PdMode.NONE) {
1086
+ const vertices = []
1087
+ this._CreatePointMarker(vertices, markType)
1088
+ const entity = new Entity({
1089
+ type: Entity.Type.LINE_SEGMENTS,
1090
+ vertices,
1091
+ color: ColorCode.BY_BLOCK
1092
+ })
1093
+ this._ProcessEntity(entity, blockCtx)
1094
+ }
1095
+
1096
+ if (this.pdMode & PdMode.SQUARE) {
1097
+ const r = this.pdSize * 0.5
1098
+ const vertices = [
1099
+ { x: -r, y: r },
1100
+ { x: r, y: r },
1101
+ { x: r, y: -r },
1102
+ { x: -r, y: -r }
1103
+ ]
1104
+ const entity = new Entity({
1105
+ type: Entity.Type.POLYLINE, vertices,
1106
+ color: ColorCode.BY_BLOCK,
1107
+ shape: true
1108
+ })
1109
+ this._ProcessEntity(entity, blockCtx)
1110
+ }
1111
+ if (this.pdMode & PdMode.CIRCLE) {
1112
+ const vertices = []
1113
+ this._GenerateArcVertices({
1114
+ vertices, center: { x: 0, y: 0 },
1115
+ radius: this.pdSize * 0.5,
1116
+ tessellationAngle: POINT_CIRCLE_TESSELLATION_ANGLE
1117
+ })
1118
+ const entity = new Entity({
1119
+ type: Entity.Type.POLYLINE, vertices,
1120
+ color: ColorCode.BY_BLOCK,
1121
+ shape: true
1122
+ })
1123
+ this._ProcessEntity(entity, blockCtx)
1124
+ }
1125
+ }
1126
+
1077
1127
 
1078
1128
  /**
1079
1129
  * Updates batches directly.
@@ -1588,7 +1638,9 @@ export class Viewer extends DxfViewer {
1588
1638
  //render current space entities (viewport borders (for layouts) and etc.)
1589
1639
  this.renderer.setViewport(0, 0, this.canvasWidth, this.canvasHeight);
1590
1640
  this.renderer.setScissor(0, 0, this.canvasWidth, this.canvasHeight);
1641
+
1591
1642
  console.log("Start render")
1643
+ this.CheckCullingObj(space.scene)
1592
1644
  this.renderer.render(space.scene, this.camera)
1593
1645
  console.log("Finish render")
1594
1646
 
@@ -1597,6 +1649,94 @@ export class Viewer extends DxfViewer {
1597
1649
  }
1598
1650
  }
1599
1651
 
1652
+ CheckCullingObj(scene) {
1653
+ let culed = 0;
1654
+ let maxVisibleObj;
1655
+ let maxVisibleLen = 0;
1656
+ for (const obj of scene.children) {
1657
+ if (obj.visible) {
1658
+ const isFrustumCulled = !this.IsObjectInFrustum(obj, this.camera)
1659
+ if (!isFrustumCulled) {
1660
+ const state = this.GetObjectVisibleState(obj, this.camera, this.renderer)
1661
+ obj.layers.set(!state.visible ? 1 : 0)
1662
+ if (!state.visible) {
1663
+ culed++
1664
+ if (state.length > maxVisibleLen && obj.type !== 'Mesh') {
1665
+ maxVisibleLen = state.length
1666
+ maxVisibleObj = obj;
1667
+ }
1668
+ }
1669
+ }
1670
+ }
1671
+ }
1672
+ if (maxVisibleObj) {
1673
+ maxVisibleObj.layers.set(0)//retain maxlen object
1674
+ culed--
1675
+ }
1676
+ console.info(`Objects culed ${culed}`)
1677
+ }
1678
+
1679
+
1680
+ IsObjectInFrustum(object, camera) {
1681
+ // 1. Update the camera's matrices
1682
+ camera.updateMatrix();
1683
+ camera.updateMatrixWorld();
1684
+
1685
+ // 2. Create a Frustum object
1686
+ const frustum = new three.Frustum();
1687
+ // 3. Set the frustum from the camera's projection matrix
1688
+ frustum.setFromProjectionMatrix(
1689
+ new three.Matrix4().multiplyMatrices(
1690
+ camera.projectionMatrix,
1691
+ camera.matrixWorldInverse
1692
+ )
1693
+ );
1694
+
1695
+ // 4. Check if the object intersects the frustum
1696
+ // This uses the object's bounding sphere/box for the test
1697
+ return frustum.intersectsObject(object);
1698
+ }
1699
+
1700
+ GetObjectVisibleState(object, camera, renderer) {
1701
+ // 1. Get the bounding box in world coordinates
1702
+ const bbox = new three.Box3().setFromObject(object);
1703
+ const distance = bbox.min.distanceTo(bbox.max);
1704
+ if (distance <= 1) {
1705
+ return {
1706
+ visible: true,
1707
+ length: distance
1708
+ }
1709
+ }
1710
+
1711
+ // 2. Get the canvas dimensions
1712
+ const canvas = renderer.domElement;
1713
+ const width = canvas.clientWidth;
1714
+ const height = canvas.clientHeight;
1715
+
1716
+ // 3. Project the min and max corners of the bounding box to screen space
1717
+ const min = bbox.min.clone();
1718
+ const max = bbox.max.clone();
1719
+
1720
+ // Project method mutates the vector in place to Normalized Device Coordinates (NDC)
1721
+ min.project(camera);
1722
+ max.project(camera);
1723
+
1724
+ // 4. Convert NDC values to canvas pixel coordinates
1725
+ const minX = (min.x + 1) * width / 2;
1726
+ const minY = -(min.y - 1) * height / 2; // Y is inverted in screen space (top is 0)
1727
+ const maxX = (max.x + 1) * width / 2;
1728
+ const maxY = -(max.y - 1) * height / 2;
1729
+
1730
+ // 5. Calculate pixel width and height
1731
+ const pixelWidth = Math.abs(maxX - minX);
1732
+ const pixelHeight = Math.abs(maxY - minY);
1733
+
1734
+ return {
1735
+ visible: pixelWidth > 5 || pixelHeight > 5,
1736
+ length: distance
1737
+ }
1738
+ }
1739
+
1600
1740
  CreateDxfWorker(workerFactory) {
1601
1741
  return new VitroDxfWorker(workerFactory ? workerFactory() : null)
1602
1742
  }
@@ -21208,7 +21208,7 @@ const defaultOptions = {
21208
21208
  kind: OptionKind.WORKER
21209
21209
  },
21210
21210
  workerSrc: {
21211
- value: "resource/pdfViewer/js/pdf.worker.js?version=1.1.257",
21211
+ value: "resource/pdfViewer/js/pdf.worker.js?version=1.1.258",
21212
21212
  kind: OptionKind.WORKER
21213
21213
  }
21214
21214
  };