@vitrosoftware/common-ui-ts 1.1.76 → 1.1.78

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.
Files changed (273) hide show
  1. package/css/common.css +2 -1
  2. package/css/std/controls/action-handler/action-handler.css +1 -1
  3. package/css/std/controls/bim-viewer/annotation.css +85 -0
  4. package/css/std/controls/bim-viewer/bim-viewer-index.css +1100 -0
  5. package/css/std/controls/bim-viewer/bim-viewer.css +53 -0
  6. package/css/std/controls/bim-viewer/comparison-popup.css +92 -0
  7. package/css/std/controls/bim-viewer/context-menu.css +54 -0
  8. package/css/std/controls/bim-viewer/dialog.css +50 -0
  9. package/css/std/controls/bim-viewer/nav-cube.css +18 -0
  10. package/css/std/controls/bim-viewer/prop-inspector.css +86 -0
  11. package/css/std/controls/bim-viewer/section-planes.css +8 -0
  12. package/css/std/controls/bim-viewer/sidebar.css +226 -0
  13. package/css/std/controls/bim-viewer/storey-views.css +57 -0
  14. package/css/std/controls/bim-viewer/style.css +56 -0
  15. package/css/std/controls/bim-viewer/toolbar.css +208 -0
  16. package/css/std/controls/bim-viewer/treeview.css +103 -0
  17. package/css/std/controls/file-version-select/file-version-select.css +160 -0
  18. package/css/std/controls/lookup-picker/lookup-picker-selected-item.css +0 -1
  19. package/css/std/controls/lookup-picker/lookup-picker.css +1 -1
  20. package/css/std/controls/pdf-viewer/custom.css +38 -19
  21. package/css/std/controls/pdf-viewer/pdf-viewer-index.css +5503 -0
  22. package/css/std/controls/pdf-viewer/pdf-viewer.css +12 -11
  23. package/css/std/controls/pdf-viewer/viewer.css +188 -158
  24. package/css/std/controls/tooltip/tooltip.css +2 -1
  25. package/css/third-party/jquery-growl/jquery.growl.css +96 -0
  26. package/css/third-party/uikit/uikit.css +12083 -0
  27. package/dist/index.css +218 -57
  28. package/dist/index.js +522 -279
  29. package/dist/index.js.map +1 -1
  30. package/dist/src/constants/Control.d.ts +11 -0
  31. package/dist/src/constants/Ctrl.d.ts +30 -0
  32. package/dist/src/constants/Event.d.ts +13 -0
  33. package/dist/src/constants/Factory.d.ts +3 -0
  34. package/dist/src/constants/KeyCode.d.ts +3 -0
  35. package/dist/src/constants/Placement.d.ts +7 -0
  36. package/dist/src/constants/Unit.d.ts +3 -0
  37. package/dist/src/controls/ActionHandler/ActionHandler.d.ts +31 -0
  38. package/dist/src/controls/ActionHandler/ActionHandlerConstants.d.ts +32 -0
  39. package/dist/src/controls/ActionHandler/ActionInfo.d.ts +12 -0
  40. package/dist/src/controls/ActionHandler/ActionInfoItem.d.ts +13 -0
  41. package/dist/src/controls/ActionHandler/UpdatingPopover.d.ts +2 -0
  42. package/dist/src/controls/Activity/Activity.d.ts +9 -0
  43. package/dist/src/controls/ActivityItem/ActivityItem.d.ts +16 -0
  44. package/dist/src/controls/ActivityItem/ActivityMessage.d.ts +6 -0
  45. package/dist/src/controls/Alert/Alert.d.ts +19 -0
  46. package/dist/src/controls/Alert/AlertConstants.d.ts +5 -0
  47. package/dist/src/controls/Avatar/Avatar.d.ts +8 -0
  48. package/dist/src/controls/BimViewer/BimViewer.d.ts +6 -0
  49. package/dist/src/controls/BimViewer/BimViewerContext.d.ts +20 -0
  50. package/dist/src/controls/BimViewer/Viewer.d.ts +6 -0
  51. package/dist/src/controls/Breadcrumbs/Breadcrumbs.d.ts +13 -0
  52. package/dist/src/controls/Breadcrumbs/Item.d.ts +10 -0
  53. package/dist/src/controls/Button/Button.d.ts +14 -0
  54. package/dist/src/controls/Checkbox/Checkbox.d.ts +11 -0
  55. package/dist/src/controls/CommandMenu/CommandMenu.d.ts +6 -0
  56. package/dist/src/controls/CommandMenu/CommandMenuButton.d.ts +13 -0
  57. package/dist/src/controls/CommandMenu/CommandMenuDropdownButton.d.ts +18 -0
  58. package/dist/src/controls/CommandMenu/CommandMenuItemHeader.d.ts +11 -0
  59. package/dist/src/controls/CommandMenu/CommandMenuLookupPicker.d.ts +32 -0
  60. package/dist/src/controls/CommandMenu/CommandMenuSubItem.d.ts +13 -0
  61. package/dist/src/controls/ComponentLoader/ComponentLoader.d.ts +8 -0
  62. package/dist/src/controls/ComponentLoader/ComponentLoaderContextImpl.d.ts +11 -0
  63. package/dist/src/controls/ControlGroup/ControlGroup.d.ts +7 -0
  64. package/dist/src/controls/Criterion/ConditionSelect.d.ts +9 -0
  65. package/dist/src/controls/Criterion/Criterion.d.ts +23 -0
  66. package/dist/src/controls/DatePicker/DatePicker.d.ts +29 -0
  67. package/dist/src/controls/DatePicker/DatePickerConstants.d.ts +12 -0
  68. package/dist/src/controls/Dialog/Dialog.d.ts +23 -0
  69. package/dist/src/controls/Dialog/DialogButton.d.ts +8 -0
  70. package/dist/src/controls/Dialog/DialogCloseButton.d.ts +8 -0
  71. package/dist/src/controls/Dialog/DialogComponent.d.ts +8 -0
  72. package/dist/src/controls/Dialog/DialogConstants.d.ts +5 -0
  73. package/dist/src/controls/Dialog/DialogContent.d.ts +7 -0
  74. package/dist/src/controls/Dialog/DialogFooter.d.ts +11 -0
  75. package/dist/src/controls/Dialog/DialogHeader.d.ts +8 -0
  76. package/dist/src/controls/DropdownButton/DropdownButton.d.ts +13 -0
  77. package/dist/src/controls/FieldIterator/FieldIterator.d.ts +24 -0
  78. package/dist/src/controls/FileVersionSelect/FileVersionItem.d.ts +6 -0
  79. package/dist/src/controls/FileVersionSelect/FileVersionSelect.d.ts +12 -0
  80. package/dist/src/controls/FileVersionSelect/Item.d.ts +10 -0
  81. package/dist/src/controls/Icon/Icon.d.ts +11 -0
  82. package/dist/src/controls/ImagePicker/ImagePicker.d.ts +16 -0
  83. package/dist/src/controls/ImagePicker/ImagePickerConstants.d.ts +8 -0
  84. package/dist/src/controls/Input/Input.d.ts +32 -0
  85. package/dist/src/controls/Input/InputConstants.d.ts +4 -0
  86. package/dist/src/controls/IssueTile/IssueTile.d.ts +26 -0
  87. package/dist/src/controls/IssueTile/IssueTileConstants.d.ts +3 -0
  88. package/dist/src/controls/IssueTile/IssueTileFooter.d.ts +8 -0
  89. package/dist/src/controls/IssueTile/IssueTileHeader.d.ts +18 -0
  90. package/dist/src/controls/Label/Label.d.ts +9 -0
  91. package/dist/src/controls/Label/LabelConstants.d.ts +3 -0
  92. package/dist/src/controls/Login/Login.d.ts +16 -0
  93. package/dist/src/controls/Login/LoginConstants.d.ts +17 -0
  94. package/dist/src/controls/Login/LoginFooter.d.ts +10 -0
  95. package/dist/src/controls/LookupPicker/LookupPickerConstants.d.ts +3 -0
  96. package/dist/src/controls/LookupPicker/SelectedValueList.d.ts +14 -0
  97. package/dist/src/controls/LookupPicker/ValueList.d.ts +22 -0
  98. package/dist/src/controls/LookupPicker/ValueListItem.d.ts +11 -0
  99. package/dist/src/controls/MessageInput/MessageInput.d.ts +12 -0
  100. package/dist/src/controls/MessageInput/MessageInputConstants.d.ts +3 -0
  101. package/dist/src/controls/MicroFrontend/MicroFrontend.d.ts +8 -0
  102. package/dist/src/controls/MicroFrontend/MicroFrontendState.d.ts +8 -0
  103. package/dist/src/controls/MicroFrontend/renderMicrofrontend.d.ts +2 -0
  104. package/dist/src/controls/NumberInput/NumberInput.d.ts +30 -0
  105. package/dist/src/controls/NumberInput/NumberInputConstants.d.ts +12 -0
  106. package/dist/src/controls/PasswordInput/PasswordInput.d.ts +31 -0
  107. package/dist/src/controls/PasswordInput/PasswordInputConstants.d.ts +4 -0
  108. package/dist/src/controls/PdfViewer/PdfViewerContext.d.ts +7 -2
  109. package/dist/src/controls/RouteItem/RouteItem.d.ts +17 -0
  110. package/dist/src/controls/ScrollBar/ScrollBar.d.ts +9 -0
  111. package/dist/src/controls/Search/CheckboxList.d.ts +12 -0
  112. package/dist/src/controls/Search/Filter.d.ts +21 -0
  113. package/dist/src/controls/Search/Input.d.ts +21 -0
  114. package/dist/src/controls/Search/Search.d.ts +29 -0
  115. package/dist/src/controls/Search/SearchConstants.d.ts +4 -0
  116. package/dist/src/controls/Sidebar/Item.d.ts +9 -0
  117. package/dist/src/controls/Sidebar/LinkItem.d.ts +17 -0
  118. package/dist/src/controls/Sidebar/Section.d.ts +11 -0
  119. package/dist/src/controls/Sidebar/SectionList.d.ts +10 -0
  120. package/dist/src/controls/Sidebar/Sidebar.d.ts +14 -0
  121. package/dist/src/controls/Sidebar/SidebarConstants.d.ts +4 -0
  122. package/dist/src/controls/Splitter/Splitter.d.ts +18 -0
  123. package/dist/src/controls/Splitter/SplitterConstants.d.ts +9 -0
  124. package/dist/src/controls/TabGroup/OverflowButton.d.ts +7 -0
  125. package/dist/src/controls/TabGroup/Tab.d.ts +10 -0
  126. package/dist/src/controls/TabGroup/TabGroup.d.ts +10 -0
  127. package/dist/src/controls/TabGroup/TabGroupComponent.d.ts +9 -0
  128. package/dist/src/controls/TabGroup/TabGroupConstants.d.ts +4 -0
  129. package/dist/src/controls/TabGroup/TabGroupHeader.d.ts +9 -0
  130. package/dist/src/controls/TableView/TableView.d.ts +26 -0
  131. package/dist/src/controls/TableView/TableViewContext.d.ts +1 -0
  132. package/dist/src/controls/TableView/TreeGrid.d.ts +17 -0
  133. package/dist/src/controls/TableView/TreeGridTableViewContextImpl.d.ts +92 -0
  134. package/dist/src/controls/TaskTile/TaskTile.d.ts +18 -0
  135. package/dist/src/controls/TelerikUploader/TelerikUploader.d.ts +11 -0
  136. package/dist/src/controls/TelerikUploader/TelerikUploaderConstants.d.ts +16 -0
  137. package/dist/src/controls/TelerikUploader/TelerikUploaderContextImpl.d.ts +39 -0
  138. package/dist/src/controls/TimePicker/TimePicker.d.ts +23 -0
  139. package/dist/src/controls/TimePicker/TimePickerConstants.d.ts +12 -0
  140. package/dist/src/controls/Tooltip/Tooltip.d.ts +10 -0
  141. package/dist/src/controls/Tooltip/TooltipConstants.d.ts +6 -0
  142. package/dist/src/controls/TopLevelMenu/LinkItem.d.ts +9 -0
  143. package/dist/src/controls/TopLevelMenu/TopLevelMenu.d.ts +9 -0
  144. package/dist/src/controls/TreeView/JsTreeViewContextImpl.d.ts +35 -0
  145. package/dist/src/controls/TreeView/TreeView.d.ts +13 -0
  146. package/dist/src/controls/TreeView/TreeViewConfig.d.ts +34 -0
  147. package/dist/src/controls/TreeView/TreeViewConstants.d.ts +52 -0
  148. package/dist/src/controls/UserLookupPicker/UserLookupPicker.d.ts +40 -0
  149. package/dist/src/controls/UserProfile/UserProfile.d.ts +12 -0
  150. package/dist/src/controls/UserProfile/UserProfileMenuItem.d.ts +11 -0
  151. package/dist/src/controls/View/View.d.ts +7 -0
  152. package/dist/src/controls/ViewPart/ViewPart.d.ts +10 -0
  153. package/dist/src/exceptions/impl/AbortExceptionImpl.d.ts +3 -0
  154. package/dist/{index.d.ts → src/index.d.ts} +8 -0
  155. package/lib/jquery-dialogextend/jquery.dialogextend.min.js +2 -0
  156. package/lib/jquery-growl/jquery.growl.js +315 -0
  157. package/lib/jszip/jszip-utils.min.js +1 -0
  158. package/lib/jszip/jszip.min.js +13 -0
  159. package/lib/third-party.js +1379 -15
  160. package/lib/uikit/uikit-icons.min.js +1 -0
  161. package/lib/uikit/uikit.min.js +1 -0
  162. package/lib/webL10n/l10n.js +1028 -0
  163. package/lib/xeokit/VitroFastNavPlugin.js +920 -0
  164. package/lib/xeokit/VitroTreeViewPlugin.js +650 -0
  165. package/lib/xeokit/xeokit-sdk.es.js +188506 -0
  166. package/package.json +5 -3
  167. package/src/controls/BimViewer/js/bim-viewer.js +2697 -0
  168. package/src/controls/BimViewer/js/init-viewer-page.js +24 -0
  169. package/src/controls/PdfViewer/js/init-viewer-page.js +1 -2
  170. package/src/controls/PdfViewer/js/pdf-viewer.js +60 -56
  171. package/css/std/controls/pdf-viewer/img/annotation-check.svg +0 -11
  172. package/css/std/controls/pdf-viewer/img/annotation-comment.svg +0 -16
  173. package/css/std/controls/pdf-viewer/img/annotation-help.svg +0 -26
  174. package/css/std/controls/pdf-viewer/img/annotation-insert.svg +0 -10
  175. package/css/std/controls/pdf-viewer/img/annotation-key.svg +0 -11
  176. package/css/std/controls/pdf-viewer/img/annotation-newparagraph.svg +0 -11
  177. package/css/std/controls/pdf-viewer/img/annotation-noicon.svg +0 -7
  178. package/css/std/controls/pdf-viewer/img/annotation-note.svg +0 -42
  179. package/css/std/controls/pdf-viewer/img/annotation-paperclip.svg +0 -6
  180. package/css/std/controls/pdf-viewer/img/annotation-paragraph.svg +0 -16
  181. package/css/std/controls/pdf-viewer/img/annotation-pushpin.svg +0 -7
  182. package/css/std/controls/pdf-viewer/img/close-compare-viewer.png +0 -0
  183. package/css/std/controls/pdf-viewer/img/close-compare-viewer_active.png +0 -0
  184. package/css/std/controls/pdf-viewer/img/compare-overlay.png +0 -0
  185. package/css/std/controls/pdf-viewer/img/compare-side-by-side.png +0 -0
  186. package/css/std/controls/pdf-viewer/img/cursor-editorFreeText.svg +0 -3
  187. package/css/std/controls/pdf-viewer/img/cursor-editorInk.svg +0 -4
  188. package/css/std/controls/pdf-viewer/img/delete-active.png +0 -0
  189. package/css/std/controls/pdf-viewer/img/delete.png +0 -0
  190. package/css/std/controls/pdf-viewer/img/dlg-compare-ico.png +0 -0
  191. package/css/std/controls/pdf-viewer/img/do-compare.png +0 -0
  192. package/css/std/controls/pdf-viewer/img/draw-annotation-arrow.png +0 -0
  193. package/css/std/controls/pdf-viewer/img/draw-annotation-cloud.png +0 -0
  194. package/css/std/controls/pdf-viewer/img/draw-annotation-ellipse.png +0 -0
  195. package/css/std/controls/pdf-viewer/img/draw-annotation-line.png +0 -0
  196. package/css/std/controls/pdf-viewer/img/draw-annotation-polygon.png +0 -0
  197. package/css/std/controls/pdf-viewer/img/draw-annotation-rect.png +0 -0
  198. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar-arrow.png +0 -0
  199. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar-cloud.png +0 -0
  200. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar-ellipse.png +0 -0
  201. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar-line.png +0 -0
  202. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar-polygon.png +0 -0
  203. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar-rect.png +0 -0
  204. package/css/std/controls/pdf-viewer/img/draw-annotation-toolbar.png +0 -0
  205. package/css/std/controls/pdf-viewer/img/draw-annotation.png +0 -0
  206. package/css/std/controls/pdf-viewer/img/dropdown-arrow.png +0 -0
  207. package/css/std/controls/pdf-viewer/img/findbarButton-next.svg +0 -3
  208. package/css/std/controls/pdf-viewer/img/findbarButton-previous.svg +0 -3
  209. package/css/std/controls/pdf-viewer/img/finish-align.png +0 -0
  210. package/css/std/controls/pdf-viewer/img/finish-align_active.png +0 -0
  211. package/css/std/controls/pdf-viewer/img/fit-to-view.png +0 -0
  212. package/css/std/controls/pdf-viewer/img/fit-to-view_active.png +0 -0
  213. package/css/std/controls/pdf-viewer/img/gv-toolbarButton-download.svg +0 -3
  214. package/css/std/controls/pdf-viewer/img/gv-toolbarButton-openinapp.svg +0 -11
  215. package/css/std/controls/pdf-viewer/img/hide-annotation.png +0 -0
  216. package/css/std/controls/pdf-viewer/img/hide-colors.png +0 -0
  217. package/css/std/controls/pdf-viewer/img/hide-colors_active.png +0 -0
  218. package/css/std/controls/pdf-viewer/img/layer-unvisible.png +0 -0
  219. package/css/std/controls/pdf-viewer/img/layer-visible.png +0 -0
  220. package/css/std/controls/pdf-viewer/img/loading-dark.svg +0 -24
  221. package/css/std/controls/pdf-viewer/img/loading-icon.gif +0 -0
  222. package/css/std/controls/pdf-viewer/img/loading.svg +0 -1
  223. package/css/std/controls/pdf-viewer/img/overlay.png +0 -0
  224. package/css/std/controls/pdf-viewer/img/overlay_active.png +0 -0
  225. package/css/std/controls/pdf-viewer/img/pan.png +0 -0
  226. package/css/std/controls/pdf-viewer/img/pan_active.png +0 -0
  227. package/css/std/controls/pdf-viewer/img/panel-visibility.png +0 -0
  228. package/css/std/controls/pdf-viewer/img/panel-visibility_active.png +0 -0
  229. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-documentProperties.svg +0 -3
  230. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-firstPage.svg +0 -3
  231. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-handTool.svg +0 -3
  232. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-lastPage.svg +0 -3
  233. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-rotateCcw.svg +0 -3
  234. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-rotateCw.svg +0 -3
  235. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-scrollHorizontal.svg +0 -3
  236. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-scrollPage.svg +0 -3
  237. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-scrollVertical.svg +0 -3
  238. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-scrollWrapped.svg +0 -3
  239. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-selectTool.svg +0 -3
  240. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-spreadEven.svg +0 -3
  241. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-spreadNone.svg +0 -3
  242. package/css/std/controls/pdf-viewer/img/secondaryToolbarButton-spreadOdd.svg +0 -3
  243. package/css/std/controls/pdf-viewer/img/shadow.png +0 -0
  244. package/css/std/controls/pdf-viewer/img/show-annotation.png +0 -0
  245. package/css/std/controls/pdf-viewer/img/side-by-side.png +0 -0
  246. package/css/std/controls/pdf-viewer/img/side-by-side_active.png +0 -0
  247. package/css/std/controls/pdf-viewer/img/sidebar-notes-toggle.png +0 -0
  248. package/css/std/controls/pdf-viewer/img/spinner.gif +0 -0
  249. package/css/std/controls/pdf-viewer/img/toolbarButton-bookmark.svg +0 -3
  250. package/css/std/controls/pdf-viewer/img/toolbarButton-currentOutlineItem.svg +0 -3
  251. package/css/std/controls/pdf-viewer/img/toolbarButton-download.svg +0 -4
  252. package/css/std/controls/pdf-viewer/img/toolbarButton-editorFreeText.svg +0 -3
  253. package/css/std/controls/pdf-viewer/img/toolbarButton-editorInk.svg +0 -4
  254. package/css/std/controls/pdf-viewer/img/toolbarButton-editorStamp.svg +0 -8
  255. package/css/std/controls/pdf-viewer/img/toolbarButton-menuArrow.svg +0 -3
  256. package/css/std/controls/pdf-viewer/img/toolbarButton-openFile.svg +0 -3
  257. package/css/std/controls/pdf-viewer/img/toolbarButton-pageDown.svg +0 -3
  258. package/css/std/controls/pdf-viewer/img/toolbarButton-pageUp.svg +0 -3
  259. package/css/std/controls/pdf-viewer/img/toolbarButton-presentationMode.svg +0 -3
  260. package/css/std/controls/pdf-viewer/img/toolbarButton-print.svg +0 -3
  261. package/css/std/controls/pdf-viewer/img/toolbarButton-search.svg +0 -3
  262. package/css/std/controls/pdf-viewer/img/toolbarButton-secondaryToolbarToggle.svg +0 -3
  263. package/css/std/controls/pdf-viewer/img/toolbarButton-sidebarToggle.svg +0 -3
  264. package/css/std/controls/pdf-viewer/img/toolbarButton-viewAttachments.svg +0 -3
  265. package/css/std/controls/pdf-viewer/img/toolbarButton-viewLayers.svg +0 -3
  266. package/css/std/controls/pdf-viewer/img/toolbarButton-viewOutline.svg +0 -3
  267. package/css/std/controls/pdf-viewer/img/toolbarButton-viewThumbnail.svg +0 -3
  268. package/css/std/controls/pdf-viewer/img/toolbarButton-zoomIn.svg +0 -3
  269. package/css/std/controls/pdf-viewer/img/toolbarButton-zoomOut.svg +0 -3
  270. package/css/std/controls/pdf-viewer/img/treeitem-collapsed.svg +0 -1
  271. package/css/std/controls/pdf-viewer/img/treeitem-expanded.svg +0 -1
  272. package/css/std/controls/pdf-viewer/img/zoom.png +0 -0
  273. package/css/std/controls/pdf-viewer/img/zoom_active.png +0 -0
@@ -0,0 +1,920 @@
1
+ import { Viewer, Plugin, math } from "/resource/bimViewer/js/xeokit/xeokit-sdk.es.js";
2
+
3
+ // JavaScript source code
4
+ class VitroFastNavPlugin extends Plugin {
5
+
6
+ /**
7
+ * @constructor
8
+ * @param {Viewer} viewer The Viewer.
9
+ * @param {Object} cfg FastNavPlugin configuration.
10
+ * @param {String} [cfg.id="FastNav"] Optional ID for this plugin, so that we can find it within {@link Viewer#plugins}.
11
+ * @param {Boolean} [cfg.hideColorTexture=true] Whether to temporarily hide color textures whenever we interact with the Viewer.
12
+ * @param {Boolean} [cfg.hidePBR=true] Whether to temporarily hide physically-based rendering (PBR) whenever we interact with the Viewer.
13
+ * @param {Boolean} [cfg.hideSAO=true] Whether to temporarily hide scalable ambient occlusion (SAO) whenever we interact with the Viewer.
14
+ * @param {Boolean} [cfg.hideEdges=true] Whether to temporarily hide edges whenever we interact with the Viewer.
15
+ * @param {Boolean} [cfg.hideTransparentObjects=false] Whether to temporarily hide transparent objects whenever we interact with the Viewer.
16
+ * @param {Number} [cfg.scaleCanvasResolution=false] Whether to temporarily down-scale the canvas resolution whenever we interact with the Viewer.
17
+ * @param {Number} [cfg.scaleCanvasResolutionFactor=0.6] The factor by which we downscale the canvas resolution whenever we interact with the Viewer.
18
+ * @param {Boolean} [cfg.delayBeforeRestore=true] Whether to temporarily have a delay before restoring normal rendering after we stop interacting with the Viewer.
19
+ * @param {Number} [cfg.delayBeforeRestoreSeconds=0.5] Delay in seconds before restoring normal rendering after we stop interacting with the Viewer.
20
+ */
21
+ constructor(viewer, cfg = {}) {
22
+
23
+ super("FastNav", viewer);
24
+
25
+ this._hideColorTexture = cfg.hideColorTexture !== false;
26
+ this._hidePBR = cfg.hidePBR !== false;
27
+ this._hideSAO = cfg.hideSAO !== false;
28
+ this._hideEdges = cfg.hideEdges !== false;
29
+ this._hideTransparentObjects = !!cfg.hideTransparentObjects;
30
+ this._scaleCanvasResolution = !!cfg.scaleCanvasResolution;
31
+ this._scaleCanvasResolutionFactor = cfg.scaleCanvasResolutionFactor || 0.6;
32
+ this._delayBeforeRestore = (cfg.delayBeforeRestore !== false);
33
+ this._delayBeforeRestoreSeconds = cfg.delayBeforeRestoreSeconds || 0.5;
34
+ this._hideTempObj = cfg.hideTempObj !== false;
35
+ this._hiddenEntityList = [];
36
+
37
+ this._objectCullStates = getObjectCullStates(viewer.scene); // Combines updates from multiple culling systems for its Scene's Entities
38
+ this._modelInfos = {};
39
+
40
+ this._maxTreeDepth = cfg.maxTreeDepth || MAX_KD_TREE_DEPTH;
41
+
42
+ this._frustum = new Frustum();
43
+ this._kdRoot = null;
44
+
45
+ this._frustumDirty = false;
46
+ this._kdTreeDirty = false;
47
+
48
+ this._onViewMatrix = viewer.scene.camera.on("viewMatrix", () => {
49
+ this._frustumDirty = true;
50
+ });
51
+
52
+ this._onProjMatrix = viewer.scene.camera.on("projMatMatrix", () => {
53
+ this._frustumDirty = true;
54
+ });
55
+
56
+ this._onModelLoaded = viewer.scene.on("modelLoaded", (modelId) => {
57
+ const model = this.viewer.scene.models[modelId];
58
+ if (model) {
59
+ this._addModel(model);
60
+ }
61
+ });
62
+
63
+
64
+ let timer = this._delayBeforeRestoreSeconds * 1000;
65
+ let fastMode = false;
66
+
67
+ const switchToLowQuality = () => {
68
+ timer = (this._delayBeforeRestoreSeconds * 1000);
69
+ if (!fastMode) {
70
+ if(window.model){
71
+ for (let i = 0; i < window.model._entityList.length; i++) {
72
+ let aabb = window.model._entityList[i]._aabb;
73
+ let a = aabb[0] - aabb[3];
74
+ let b = aabb[1] - aabb[4];
75
+ let c = aabb[2] - aabb[5];
76
+
77
+ let size = Math.sqrt((a * a) + (b * b) + (c * c));
78
+
79
+ if (size < 250) {
80
+ window.model._entityList[i].culled = true;
81
+ }
82
+ }
83
+ }
84
+
85
+
86
+
87
+ viewer.scene._renderer.setColorTextureEnabled(!this._hideColorTexture);
88
+ viewer.scene._renderer.setPBREnabled(!this._hidePBR);
89
+ viewer.scene._renderer.setSAOEnabled(!this._hideSAO);
90
+ viewer.scene._renderer.setTransparentEnabled(!this._hideTransparentObjects);
91
+ viewer.scene._renderer.setEdgesEnabled(!this._hideEdges);
92
+ if (this._scaleCanvasResolution) {
93
+ viewer.scene.canvas.resolutionScale = this._scaleCanvasResolutionFactor;
94
+ } else {
95
+ viewer.scene.canvas.resolutionScale = 1;
96
+ }
97
+
98
+ if (this._hideTempObj) {
99
+ const objects = viewer.scene.objects;
100
+ for (let objectId in objects) {
101
+ const entity = objects[objectId];
102
+ entity.culled = objectId.includes("~");
103
+ }
104
+ }
105
+ fastMode = true;
106
+ }
107
+ };
108
+
109
+ const switchToHighQuality = () => {
110
+
111
+
112
+ viewer.scene.canvas.resolutionScale = 1;
113
+ viewer.scene._renderer.setEdgesEnabled(true);
114
+ viewer.scene._renderer.setColorTextureEnabled(true);
115
+ viewer.scene._renderer.setPBREnabled(true);
116
+ viewer.scene._renderer.setSAOEnabled(true);
117
+ viewer.scene._renderer.setTransparentEnabled(true);
118
+
119
+ this._frustumDirty = true;
120
+ this._doCull();
121
+ /*
122
+ const objects = viewer.scene.objects;
123
+ let allObjects = 0;
124
+ let culledObjects = 0;
125
+ let visibleObjects = 0;
126
+ for (let objectId in objects) {
127
+ allObjects++;
128
+ const entity = objects[objectId];
129
+ if (entity.visible)
130
+ visibleObjects++
131
+ if (entity.culled)
132
+ culledObjects++
133
+ }
134
+ console.log('allObjects', allObjects);
135
+ console.log('visibleObjects', visibleObjects);
136
+ console.log('culledObjects', culledObjects);
137
+ */
138
+ fastMode = false;
139
+ };
140
+
141
+ this._onCanvasBoundary = viewer.scene.canvas.on("boundary", switchToLowQuality);
142
+ this._onCameraMatrix = viewer.scene.camera.on("matrix", switchToLowQuality);
143
+
144
+ this._onSceneTick = viewer.scene.on("tick", (tickEvent) => {
145
+ if (!fastMode) {
146
+ //smallSceneModel.IsStoppedLoad = true;
147
+
148
+ return;
149
+ }
150
+
151
+ if (this._delayBeforeRestoreSeconds * 1000 > tickEvent.deltaTime) {
152
+ timer -= tickEvent.deltaTime;
153
+
154
+ if ((!this._delayBeforeRestore) || timer <= 0) {
155
+ switchToHighQuality();
156
+ }
157
+ }
158
+ });
159
+
160
+ let down = false;
161
+
162
+ this._onSceneMouseDown = viewer.scene.input.on("mousedown", () => {
163
+ down = true;
164
+ });
165
+
166
+ this._onSceneMouseUp = viewer.scene.input.on("mouseup", () => {
167
+ down = false;
168
+ });
169
+
170
+ this._onSceneMouseMove = viewer.scene.input.on("mousemove", () => {
171
+ if (!down) {
172
+ return;
173
+ }
174
+ switchToLowQuality();
175
+ });
176
+ }
177
+
178
+ _addModel(model) {
179
+ const modelInfo = {
180
+ model: model,
181
+ onDestroyed: model.on("destroyed", () => {
182
+ this._removeModel(model);
183
+ })
184
+ };
185
+ this._modelInfos[model.id] = modelInfo;
186
+ this._kdTreeDirty = true;
187
+ }
188
+
189
+ _removeModel(model) {
190
+ const modelInfo = this._modelInfos[model.id];
191
+ if (modelInfo) {
192
+ modelInfo.model.off(modelInfo.onDestroyed);
193
+ delete this._modelInfos[model.id];
194
+ this._kdTreeDirty = true;
195
+ }
196
+ }
197
+
198
+ _doCull() {
199
+ const cullDirty = (this._frustumDirty || this._kdTreeDirty);
200
+ if (this._frustumDirty) {
201
+ this._buildFrustum();
202
+ }
203
+ if (this._kdTreeDirty) {
204
+ this._buildKDTree();
205
+ }
206
+ if (cullDirty) {
207
+ const kdNode = this._kdRoot;
208
+ if (kdNode) {
209
+ this._visitKDNode(kdNode);
210
+ }
211
+ }
212
+ }
213
+
214
+ _buildFrustum() {
215
+ const camera = this.viewer.scene.camera;
216
+ setFrustum(this._frustum, camera.viewMatrix, camera.projMatrix);
217
+ this._frustumDirty = false;
218
+ }
219
+
220
+ _buildKDTree() {
221
+ const viewer = this.viewer;
222
+ const scene = viewer.scene;
223
+ const depth = 0;
224
+ if (this._kdRoot);
225
+ this._kdRoot = {
226
+ aabb: scene.getAABB(),
227
+ intersection: Frustum.INTERSECT
228
+ };
229
+ for (let objectIdx = 0, len = this._objectCullStates.numObjects; objectIdx < len; objectIdx++) {
230
+ const entity = this._objectCullStates.objects[objectIdx];
231
+ this._insertEntityIntoKDTree(this._kdRoot, entity, objectIdx, depth + 1);
232
+ }
233
+ this._kdTreeDirty = false;
234
+ }
235
+
236
+ _insertEntityIntoKDTree(kdNode, entity, objectIdx, depth) {
237
+
238
+ const entityAABB = entity.aabb;
239
+
240
+ if (depth >= this._maxTreeDepth) {
241
+ kdNode.objects = kdNode.objects || [];
242
+ kdNode.objects.push(entity/*objectIdx*/);//vitro
243
+ math.expandAABB3(kdNode.aabb, entityAABB);
244
+ return;
245
+ }
246
+
247
+ if (kdNode.left) {
248
+ if (math.containsAABB3(kdNode.left.aabb, entityAABB)) {
249
+ this._insertEntityIntoKDTree(kdNode.left, entity, objectIdx, depth + 1);
250
+ return;
251
+ }
252
+ }
253
+
254
+ if (kdNode.right) {
255
+ if (math.containsAABB3(kdNode.right.aabb, entityAABB)) {
256
+ this._insertEntityIntoKDTree(kdNode.right, entity, objectIdx, depth + 1);
257
+ return;
258
+ }
259
+ }
260
+
261
+ const nodeAABB = kdNode.aabb;
262
+
263
+ kdTreeDimLength[0] = nodeAABB[3] - nodeAABB[0];
264
+ kdTreeDimLength[1] = nodeAABB[4] - nodeAABB[1];
265
+ kdTreeDimLength[2] = nodeAABB[5] - nodeAABB[2];
266
+
267
+ let dim = 0;
268
+
269
+ if (kdTreeDimLength[1] > kdTreeDimLength[dim]) {
270
+ dim = 1;
271
+ }
272
+
273
+ if (kdTreeDimLength[2] > kdTreeDimLength[dim]) {
274
+ dim = 2;
275
+ }
276
+
277
+ if (!kdNode.left) {
278
+ const aabbLeft = nodeAABB.slice();
279
+ aabbLeft[dim + 3] = ((nodeAABB[dim] + nodeAABB[dim + 3]) / 2.0);
280
+ kdNode.left = {
281
+ aabb: aabbLeft,
282
+ intersection: Frustum.INTERSECT
283
+ };
284
+ if (math.containsAABB3(aabbLeft, entityAABB)) {
285
+ this._insertEntityIntoKDTree(kdNode.left, entity, objectIdx, depth + 1);
286
+ return;
287
+ }
288
+ }
289
+
290
+ if (!kdNode.right) {
291
+ const aabbRight = nodeAABB.slice();
292
+ aabbRight[dim] = ((nodeAABB[dim] + nodeAABB[dim + 3]) / 2.0);
293
+ kdNode.right = {
294
+ aabb: aabbRight,
295
+ intersection: Frustum.INTERSECT
296
+ };
297
+ if (math.containsAABB3(aabbRight, entityAABB)) {
298
+ this._insertEntityIntoKDTree(kdNode.right, entity, objectIdx, depth + 1);
299
+ return;
300
+ }
301
+ }
302
+
303
+ kdNode.objects = kdNode.objects || [];
304
+ kdNode.objects.push(entity/*objectIdx*/);//vitro
305
+
306
+ math.expandAABB3(kdNode.aabb, entityAABB);
307
+ }
308
+
309
+ _visitKDNode(kdNode, intersects = Frustum.INTERSECT) {
310
+ //if (intersects !== Frustum.INTERSECT && kdNode.intersects === intersects) {//vitro
311
+ // return;
312
+ //}
313
+ if (intersects === Frustum.INTERSECT) {
314
+ intersects = frustumIntersectsAABB3(this._frustum, kdNode.aabb);
315
+ kdNode.intersects = intersects;
316
+ }
317
+ const culled = (intersects === Frustum.OUTSIDE);
318
+ const objects = kdNode.objects;
319
+ if (objects && objects.length > 0) {
320
+ for (let i = 0, len = objects.length; i < len; i++) {
321
+ objects[i].culled = culled;//vitro
322
+ //const objectIdx = objects[i];
323
+ //this._objectCullStates.setObjectViewCulled(objectIdx, culled);
324
+ }
325
+ }
326
+ if (kdNode.left) {
327
+ this._visitKDNode(kdNode.left, intersects);
328
+ }
329
+ if (kdNode.right) {
330
+ this._visitKDNode(kdNode.right, intersects);
331
+ }
332
+ }
333
+
334
+
335
+ /**
336
+ * Gets whether to temporarily hide color textures whenever we interact with the Viewer.
337
+ *
338
+ * Default is ````true````.
339
+ *
340
+ * @return {Boolean} ````true```` if hiding color textures.
341
+ */
342
+ get hideColorTexture() {
343
+ return this._hideColorTexture;
344
+ }
345
+
346
+ /**
347
+ * Sets whether to temporarily hide color textures whenever we interact with the Viewer.
348
+ *
349
+ * Default is ````true````.
350
+ *
351
+ * @param {Boolean} hideColorTexture ````true```` to hide color textures.
352
+ */
353
+ set hideColorTexture(hideColorTexture) {
354
+ this._hideColorTexture = hideColorTexture;
355
+ }
356
+
357
+ /**
358
+ * Gets whether to temporarily hide physically-based rendering (PBR) whenever we interact with the Viewer.
359
+ *
360
+ * Default is ````true````.
361
+ *
362
+ * @return {Boolean} ````true```` if hiding PBR.
363
+ */
364
+ get hidePBR() {
365
+ return this._hidePBR;
366
+ }
367
+
368
+ /**
369
+ * Sets whether to temporarily hide physically-based rendering (PBR) whenever we interact with the Viewer.
370
+ *
371
+ * Default is ````true````.
372
+ *
373
+ * @param {Boolean} hidePBR ````true```` to hide PBR.
374
+ */
375
+ set hidePBR(hidePBR) {
376
+ this._hidePBR = hidePBR;
377
+ }
378
+
379
+ /**
380
+ * Gets whether to temporarily hide scalable ambient shadows (SAO) whenever we interact with the Viewer.
381
+ *
382
+ * Default is ````true````.
383
+ *
384
+ * @return {Boolean} ````true```` if hiding SAO.
385
+ */
386
+ get hideSAO() {
387
+ return this._hideSAO;
388
+ }
389
+
390
+ /**
391
+ * Sets whether to temporarily hide scalable ambient shadows (SAO) whenever we interact with the Viewer.
392
+ *
393
+ * Default is ````true````.
394
+ *
395
+ * @param {Boolean} hideSAO ````true```` to hide SAO.
396
+ */
397
+ set hideSAO(hideSAO) {
398
+ this._hideSAO = hideSAO;
399
+ }
400
+
401
+ /**
402
+ * Gets whether to temporarily hide edges whenever we interact with the Viewer.
403
+ *
404
+ * Default is ````true````.
405
+ *
406
+ * @return {Boolean} ````true```` if hiding edges.
407
+ */
408
+ get hideEdges() {
409
+ return this._hideEdges;
410
+ }
411
+
412
+ /**
413
+ * Sets whether to temporarily hide edges whenever we interact with the Viewer.
414
+ *
415
+ * Default is ````true````.
416
+ *
417
+ * @param {Boolean} hideEdges ````true```` to hide edges.
418
+ */
419
+ set hideEdges(hideEdges) {
420
+ this._hideEdges = hideEdges;
421
+ }
422
+
423
+ /**
424
+ * Gets whether to temporarily hide transparent objects whenever we interact with the Viewer.
425
+ *
426
+ * Does not hide X-rayed, selected, highlighted objects.
427
+ *
428
+ * Default is ````false````.
429
+ *
430
+ * @return {Boolean} ````true```` if hiding transparent objects.
431
+ */
432
+ get hideTransparentObjects() {
433
+ return this._hideTransparentObjects
434
+ }
435
+
436
+ /**
437
+ * Sets whether to temporarily hide transparent objects whenever we interact with the Viewer.
438
+ *
439
+ * Does not hide X-rayed, selected, highlighted objects.
440
+ *
441
+ * Default is ````false````.
442
+ *
443
+ * @param {Boolean} hideTransparentObjects ````true```` to hide transparent objects.
444
+ */
445
+ set hideTransparentObjects(hideTransparentObjects) {
446
+ this._hideTransparentObjects = (hideTransparentObjects !== false);
447
+ }
448
+
449
+ /**
450
+ * Gets whether to temporarily scale the canvas resolution whenever we interact with the Viewer.
451
+ *
452
+ * Default is ````false````.
453
+ *
454
+ * The scaling factor is configured via {@link FastNavPlugin#scaleCanvasResolutionFactor}.
455
+ *
456
+ * @return {Boolean} ````true```` if scaling the canvas resolution.
457
+ */
458
+ get scaleCanvasResolution() {
459
+ return this._scaleCanvasResolution;
460
+ }
461
+
462
+ /**
463
+ * Sets whether to temporarily scale the canvas resolution whenever we interact with the Viewer.
464
+ *
465
+ * Default is ````false````.
466
+ *
467
+ * The scaling factor is configured via {@link FastNavPlugin#scaleCanvasResolutionFactor}.
468
+ *
469
+ * @param {Boolean} scaleCanvasResolution ````true```` to scale the canvas resolution.
470
+ */
471
+ set scaleCanvasResolution(scaleCanvasResolution) {
472
+ this._scaleCanvasResolution = scaleCanvasResolution;
473
+ }
474
+
475
+ /**
476
+ * Gets the factor by which we temporarily scale the canvas resolution when we interact with the viewer.
477
+ *
478
+ * Default is ````0.6````.
479
+ *
480
+ * Enable canvas resolution scaling by setting {@link FastNavPlugin#scaleCanvasResolution} ````true````.
481
+ *
482
+ * @return {Number} Factor by which we scale the canvas resolution.
483
+ */
484
+ get scaleCanvasResolutionFactor() {
485
+ return this._scaleCanvasResolutionFactor;
486
+ }
487
+
488
+ /**
489
+ * Sets the factor by which we temporarily scale the canvas resolution when we interact with the viewer.
490
+ *
491
+ * Accepted range is ````[0.0 .. 1.0]````.
492
+ *
493
+ * Default is ````0.6````.
494
+ *
495
+ * Enable canvas resolution scaling by setting {@link FastNavPlugin#scaleCanvasResolution} ````true````.
496
+ *
497
+ * @param {Number} scaleCanvasResolutionFactor Factor by which we scale the canvas resolution.
498
+ */
499
+ set scaleCanvasResolutionFactor(scaleCanvasResolutionFactor) {
500
+ this._scaleCanvasResolutionFactor = scaleCanvasResolutionFactor || 0.6;
501
+ }
502
+
503
+ /**
504
+ * Gets whether to have a delay before restoring normal rendering after we stop interacting with the Viewer.
505
+ *
506
+ * The delay duration is configured via {@link FastNavPlugin#delayBeforeRestoreSeconds}.
507
+ *
508
+ * Default is ````true````.
509
+ *
510
+ * @return {Boolean} Whether to have a delay.
511
+ */
512
+ get delayBeforeRestore() {
513
+ return this._delayBeforeRestore;
514
+ }
515
+
516
+ /**
517
+ * Sets whether to have a delay before restoring normal rendering after we stop interacting with the Viewer.
518
+ *
519
+ * The delay duration is configured via {@link FastNavPlugin#delayBeforeRestoreSeconds}.
520
+ *
521
+ * Default is ````true````.
522
+ *
523
+ * @param {Boolean} delayBeforeRestore Whether to have a delay.
524
+ */
525
+ set delayBeforeRestore(delayBeforeRestore) {
526
+ this._delayBeforeRestore = delayBeforeRestore;
527
+ }
528
+
529
+ /**
530
+ * Gets the delay before restoring normal rendering after we stop interacting with the Viewer.
531
+ *
532
+ * The delay is enabled when {@link FastNavPlugin#delayBeforeRestore} is ````true````.
533
+ *
534
+ * Default is ````0.5```` seconds.
535
+ *
536
+ * @return {Number} Delay in seconds.
537
+ */
538
+ get delayBeforeRestoreSeconds() {
539
+ return this._delayBeforeRestoreSeconds;
540
+ }
541
+
542
+ /**
543
+ * Sets the delay before restoring normal rendering after we stop interacting with the Viewer.
544
+ *
545
+ * The delay is enabled when {@link FastNavPlugin#delayBeforeRestore} is ````true````.
546
+ *
547
+ * Default is ````0.5```` seconds.
548
+ *
549
+ * @param {Number} delayBeforeRestoreSeconds Delay in seconds.
550
+ */
551
+ set delayBeforeRestoreSeconds(delayBeforeRestoreSeconds) {
552
+ this._delayBeforeRestoreSeconds = delayBeforeRestoreSeconds !== null && delayBeforeRestoreSeconds !== undefined ? delayBeforeRestoreSeconds : 0.5;
553
+ }
554
+
555
+ /**
556
+ * @private
557
+ */
558
+ send(name, value) {
559
+ }
560
+
561
+ /**
562
+ * Destroys this plugin.
563
+ */
564
+ destroy() {
565
+ this._clear();
566
+ const scene = this.viewer.scene;
567
+ const camera = scene.camera;
568
+ scene.off(this._onModelLoaded);
569
+ camera.off(this._onViewMatrix);
570
+ camera.off(this._onProjMatrix);
571
+
572
+
573
+ this.viewer.scene.camera.off(this._onCameraMatrix);
574
+ this.viewer.scene.canvas.off(this._onCanvasBoundary);
575
+ this.viewer.scene.input.off(this._onSceneMouseDown);
576
+ this.viewer.scene.input.off(this._onSceneMouseUp);
577
+ this.viewer.scene.input.off(this._onSceneMouseMove);
578
+ this.viewer.scene.off(this._onSceneTick);
579
+ super.destroy();
580
+ }
581
+
582
+ _clear() {
583
+ for (let modelId in this._modelInfos) {
584
+ const modelInfo = this._modelInfos[modelId];
585
+ modelInfo.model.off(modelInfo.onDestroyed);
586
+ }
587
+ this._modelInfos = {};
588
+ this._kdRoot = null;
589
+ this._kdTreeDirty = true;
590
+ }
591
+ }
592
+
593
+
594
+ //from sdk
595
+
596
+ const tempVec3a$1 = math.vec3();
597
+ const tempVec3b$1 = math.vec3();
598
+ const tempMat4a = math.mat4();
599
+
600
+ /**
601
+ * @private
602
+ */
603
+ class FrustumPlane {
604
+
605
+ constructor() {
606
+ this.normal = math.vec3();
607
+ this.offset = 0;
608
+ this.testVertex = math.vec3();
609
+ }
610
+
611
+ set(nx, ny, nz, offset) {
612
+ const s = 1.0 / Math.sqrt(nx * nx + ny * ny + nz * nz);
613
+ this.normal[0] = nx * s;
614
+ this.normal[1] = ny * s;
615
+ this.normal[2] = nz * s;
616
+ this.offset = offset * s;
617
+ this.testVertex[0] = (this.normal[0] >= 0.0) ? 1 : 0;
618
+ this.testVertex[1] = (this.normal[1] >= 0.0) ? 1 : 0;
619
+ this.testVertex[2] = (this.normal[2] >= 0.0) ? 1 : 0;
620
+ }
621
+ }
622
+
623
+
624
+ /**
625
+ * @private
626
+ */
627
+ class Frustum {
628
+ constructor() {
629
+ this.planes = [
630
+ new FrustumPlane(), new FrustumPlane(), new FrustumPlane(),
631
+ new FrustumPlane(), new FrustumPlane(), new FrustumPlane()
632
+ ];
633
+ }
634
+ }
635
+
636
+ Frustum.INSIDE = 0;
637
+ Frustum.INTERSECT = 1;
638
+ Frustum.OUTSIDE = 2;
639
+
640
+ /** @private */
641
+ function setFrustum(frustum, viewMat, projMat) {
642
+
643
+ const m = math.mulMat4(projMat, viewMat, tempMat4a);
644
+
645
+ const m0 = m[0];
646
+ const m1 = m[1];
647
+ const m2 = m[2];
648
+ const m3 = m[3];
649
+ const m4 = m[4];
650
+ const m5 = m[5];
651
+ const m6 = m[6];
652
+ const m7 = m[7];
653
+ const m8 = m[8];
654
+ const m9 = m[9];
655
+ const m10 = m[10];
656
+ const m11 = m[11];
657
+ const m12 = m[12];
658
+ const m13 = m[13];
659
+ const m14 = m[14];
660
+ const m15 = m[15];
661
+
662
+ frustum.planes[0].set(m3 - m0, m7 - m4, m11 - m8, m15 - m12);
663
+ frustum.planes[1].set(m3 + m0, m7 + m4, m11 + m8, m15 + m12);
664
+ frustum.planes[2].set(m3 - m1, m7 - m5, m11 - m9, m15 - m13);
665
+ frustum.planes[3].set(m3 + m1, m7 + m5, m11 + m9, m15 + m13);
666
+ frustum.planes[4].set(m3 - m2, m7 - m6, m11 - m10, m15 - m14);
667
+ frustum.planes[5].set(m3 + m2, m7 + m6, m11 + m10, m15 + m14);
668
+ }
669
+
670
+ /** @private */
671
+ function frustumIntersectsAABB3(frustum, aabb) {
672
+
673
+ let ret = Frustum.INSIDE;
674
+
675
+ const min = tempVec3a$1;
676
+ const max = tempVec3b$1;
677
+
678
+ min[0] = aabb[0];
679
+ min[1] = aabb[1];
680
+ min[2] = aabb[2];
681
+ max[0] = aabb[3];
682
+ max[1] = aabb[4];
683
+ max[2] = aabb[5];
684
+
685
+ const bminmax = [min, max];
686
+
687
+ for (let i = 0; i < 6; ++i) {
688
+ const plane = frustum.planes[i];
689
+ if (((plane.normal[0] * bminmax[plane.testVertex[0]][0]) +
690
+ (plane.normal[1] * bminmax[plane.testVertex[1]][1]) +
691
+ (plane.normal[2] * bminmax[plane.testVertex[2]][2]) +
692
+ (plane.offset)) < 0.0) {
693
+ return Frustum.OUTSIDE;
694
+ }
695
+
696
+ if (((plane.normal[0] * bminmax[1 - plane.testVertex[0]][0]) +
697
+ (plane.normal[1] * bminmax[1 - plane.testVertex[1]][1]) +
698
+ (plane.normal[2] * bminmax[1 - plane.testVertex[2]][2]) +
699
+ (plane.offset)) < 0.0) {
700
+ ret = Frustum.INTERSECT;
701
+ }
702
+ }
703
+
704
+ return ret;
705
+ }
706
+
707
+ /**
708
+ * For each Entity in its Scene, efficiently combines updates from multiple culling systems into a single "culled" state.
709
+ *
710
+ * Two culling systems are supported:
711
+ *
712
+ * * View culling - culls Entities when they fall outside the current view frustum, and
713
+ * * Detail culling - momentarily culls less visually-significant Entities while we are moving the camera.
714
+ *
715
+ * @private
716
+ */
717
+ class ObjectCullStates {
718
+
719
+ /**
720
+ * @private
721
+ * @param scene
722
+ */
723
+ constructor(scene) {
724
+
725
+ this._scene = scene;
726
+
727
+ this._objects = []; // Array of all Entity instances that represent objects
728
+ this._objectsViewCulled = []; // A flag for each object to indicate its view-cull status
729
+ this._objectsDetailCulled = []; // A flag for each object to indicate its detail-cull status
730
+ this._objectsChanged = []; // A flag for each object, set whenever its cull status has changed since last _applyChanges()
731
+ this._objectsChangedList = []; // A list of objects whose cull status has changed, applied and cleared by _applyChanges()
732
+
733
+ this._modelInfos = {};
734
+
735
+ this._numObjects = 0;
736
+ this._lenObjectsChangedList = 0;
737
+
738
+ this._dirty = true;
739
+
740
+ this._onModelLoaded = scene.on("modelLoaded", (modelId) => {
741
+ const model = scene.models[modelId];
742
+ if (model) {
743
+ this._addModel(model);
744
+ }
745
+ });
746
+
747
+ // this._onTick = scene.on("tick", () => {
748
+ // if (this._dirty) {
749
+ // this._build();
750
+ // }
751
+ // this._applyChanges();
752
+ // });
753
+ }
754
+
755
+ _addModel(model) {
756
+ const modelInfo = {
757
+ model: model,
758
+ onDestroyed: model.on("destroyed", () => {
759
+ this._removeModel(model);
760
+ })
761
+ };
762
+ this._modelInfos[model.id] = modelInfo;
763
+ this._dirty = true;
764
+ }
765
+
766
+ _removeModel(model) {
767
+ const modelInfo = this._modelInfos[model.id];
768
+ if (modelInfo) {
769
+ modelInfo.model.off(modelInfo.onDestroyed);
770
+ delete this._modelInfos[model.id];
771
+ this._dirty = true;
772
+ }
773
+ }
774
+
775
+ _build() {
776
+ if (!this._dirty) {
777
+ return;
778
+ }
779
+ this._applyChanges();
780
+ const objects = this._scene.objects;
781
+ for (let i = 0; i < this._numObjects; i++) {
782
+ this._objects[i] = null;
783
+ }
784
+ this._numObjects = 0;
785
+ for (let objectId in objects) {
786
+ const entity = objects[objectId];
787
+ this._objects[this._numObjects++] = entity;
788
+ }
789
+ this._lenObjectsChangedList = 0;
790
+ this._dirty = false;
791
+ }
792
+
793
+ _applyChanges() {
794
+ if (this._lenObjectsChangedList > 0) {
795
+ for (let i = 0; i < this._lenObjectsChangedList; i++) {
796
+ const objectIdx = this._objectsChangedList[i];
797
+ const object = this._objects[objectIdx];
798
+ const viewCulled = this._objectsViewCulled[objectIdx];
799
+ const detailCulled = this._objectsDetailCulled[objectIdx];
800
+ const culled = (viewCulled || detailCulled);
801
+ object.culled = culled;
802
+ this._objectsChanged[objectIdx] = false;
803
+ }
804
+ this._lenObjectsChangedList = 0;
805
+ }
806
+ }
807
+
808
+ /**
809
+ * Array of {@link Entity} instances that represent objects in the {@link Scene}.
810
+ *
811
+ * ObjectCullStates rebuilds this from {@link Scene#objects} whenever ````Scene```` fires a ````modelLoaded```` event.
812
+ *
813
+ * @returns {Entity[]}
814
+ */
815
+ get objects() {
816
+ if (this._dirty) {
817
+ this._build();
818
+ }
819
+ return this._objects;
820
+ }
821
+
822
+ /**
823
+ * Number of objects in {@link ObjectCullStates#objects},
824
+ *
825
+ * Updated whenever ````Scene```` fires a ````modelLoaded```` event.
826
+ *
827
+ * @returns {Number}
828
+ */
829
+ get numObjects() {
830
+ if (this._dirty) {
831
+ this._build();
832
+ }
833
+ return this._numObjects;
834
+ }
835
+
836
+ /**
837
+ * Updates an object's view-cull status.
838
+ *
839
+ * @param {Number} objectIdx Index of the object in {@link ObjectCullStates#objects}
840
+ * @param {boolean} culled Whether to view-cull or not.
841
+ */
842
+ setObjectViewCulled(objectIdx, culled) {
843
+ if (this._dirty) {
844
+ this._build();
845
+ }
846
+ if (this._objectsViewCulled[objectIdx] === culled) {
847
+ return;
848
+ }
849
+ this._objectsViewCulled[objectIdx] = culled;
850
+ if (!this._objectsChanged[objectIdx]) {
851
+ this._objectsChanged[objectIdx] = true;
852
+ this._objectsChangedList[this._lenObjectsChangedList++] = objectIdx;
853
+ }
854
+ }
855
+
856
+ /**
857
+ * Updates an object's detail-cull status.
858
+ *
859
+ * @param {Number} objectIdx Index of the object in {@link ObjectCullStates#objects}
860
+ * @param {boolean} culled Whether to detail-cull or not.
861
+ */
862
+ setObjectDetailCulled(objectIdx, culled) {
863
+ if (this._dirty) {
864
+ this._build();
865
+ }
866
+ if (this._objectsDetailCulled[objectIdx] === culled) {
867
+ return;
868
+ }
869
+ this._objectsDetailCulled[objectIdx] = culled;
870
+ if (!this._objectsChanged[objectIdx]) {
871
+ this._objectsChanged[objectIdx] = true;
872
+ this._objectsChangedList[this._lenObjectsChangedList++] = objectIdx;
873
+ }
874
+ }
875
+
876
+ /**
877
+ * Destroys this ObjectCullStAtes.
878
+ */
879
+ _destroy() {
880
+ this._clear();
881
+ this._scene.off(this._onModelLoaded);
882
+ this._scene.off(this._onTick);
883
+ }
884
+
885
+ _clear() {
886
+ for (let modelId in this._modelInfos) {
887
+ const modelInfo = this._modelInfos[modelId];
888
+ modelInfo.model.off(modelInfo.onDestroyed);
889
+ }
890
+ this._modelInfos = {};
891
+ this._dirty = true;
892
+ }
893
+ }
894
+
895
+ const sceneObjectCullStates = {};
896
+
897
+ /**
898
+ * @private
899
+ */
900
+ function getObjectCullStates(scene) {
901
+ const sceneId = scene.id;
902
+ let objectCullStates = sceneObjectCullStates[sceneId];
903
+ if (!objectCullStates) {
904
+ objectCullStates = new ObjectCullStates(scene);
905
+ sceneObjectCullStates[sceneId] = objectCullStates;
906
+ scene.on("destroyed", () => {
907
+ delete sceneObjectCullStates[sceneId];
908
+ objectCullStates._destroy();
909
+ });
910
+ }
911
+ return objectCullStates;
912
+ }
913
+
914
+ const MAX_KD_TREE_DEPTH = 8; // Increase if greater precision needed
915
+
916
+ const kdTreeDimLength = new Float32Array(3);
917
+
918
+
919
+ export { VitroFastNavPlugin };
920
+