@itwin/imodel-components-react 4.0.0-dev.10 → 4.0.0-dev.12

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 (362) hide show
  1. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js +77 -79
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +186 -186
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  8. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  11. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +108 -107
  12. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  13. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +90 -90
  14. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  15. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +74 -74
  16. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  17. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  18. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +145 -145
  19. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  20. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  21. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  22. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  23. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +139 -137
  24. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  25. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +62 -63
  26. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +22 -22
  27. package/lib/cjs/imodel-components-react/color/HueSlider.js +199 -199
  28. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/color/HueSlider.scss +61 -61
  30. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  31. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +213 -213
  32. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  33. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
  34. package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
  35. package/lib/cjs/imodel-components-react/color/Swatch.js +60 -60
  36. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  37. package/lib/cjs/imodel-components-react/color/Swatch.scss +22 -23
  38. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  39. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
  40. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  42. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +151 -151
  43. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  44. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  45. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  46. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +160 -160
  47. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  48. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  49. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  50. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +96 -96
  51. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  52. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  53. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  54. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +268 -265
  55. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +106 -107
  57. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  58. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +85 -85
  59. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  60. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  61. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  62. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +159 -159
  63. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  64. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +52 -52
  65. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  66. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +127 -127
  67. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  68. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  69. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +174 -174
  70. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  71. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +638 -634
  72. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  73. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -182
  74. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  75. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  76. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +653 -647
  77. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  78. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -134
  79. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  80. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +99 -99
  81. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  82. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +63 -63
  83. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  84. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +53 -53
  85. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  87. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  88. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +84 -83
  89. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  90. package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  91. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +86 -86
  92. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  93. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  94. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +109 -109
  95. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  96. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  97. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +133 -133
  98. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  99. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  100. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +184 -184
  101. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  102. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  103. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +145 -145
  104. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  105. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  106. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +59 -59
  107. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  108. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  109. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +47 -47
  110. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  111. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  112. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +54 -54
  113. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  114. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  115. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +48 -48
  116. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  117. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  118. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +50 -50
  119. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  120. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  121. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +58 -58
  122. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  123. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  124. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +47 -47
  125. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  126. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  127. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +56 -56
  128. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  129. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  130. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +95 -95
  131. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  132. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  133. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +119 -119
  134. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  135. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  136. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +143 -143
  137. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  138. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  139. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
  140. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  141. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  142. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +81 -81
  143. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  144. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
  145. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  146. package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  147. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +95 -91
  148. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  149. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +28 -31
  150. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  151. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +191 -191
  152. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  153. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +105 -112
  154. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  155. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  156. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +428 -424
  157. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  158. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +359 -356
  159. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  160. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +54 -54
  161. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  162. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  163. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
  164. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +133 -133
  165. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  166. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +365 -358
  167. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  168. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +161 -164
  169. package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +174 -174
  170. package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
  171. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  172. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  173. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +274 -274
  174. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  175. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  176. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
  177. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  178. package/lib/cjs/imodel-components-react.d.ts +82 -82
  179. package/lib/cjs/imodel-components-react.js +101 -101
  180. package/lib/cjs/imodel-components-react.js.map +1 -1
  181. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
  182. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  183. package/lib/esm/imodel-components-react/UiIModelComponents.js +73 -75
  184. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  185. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +36 -36
  186. package/lib/esm/imodel-components-react/color/AlphaSlider.js +160 -160
  187. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  188. package/lib/esm/imodel-components-react/color/AlphaSlider.scss +63 -63
  189. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
  190. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  191. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +83 -82
  192. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  193. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +90 -90
  194. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
  195. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +51 -51
  196. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  197. package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
  198. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +122 -122
  199. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  200. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  201. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
  202. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  203. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +114 -112
  204. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  205. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +62 -63
  206. package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
  207. package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
  208. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  209. package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
  210. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
  211. package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
  212. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  213. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
  214. package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
  215. package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
  216. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  217. package/lib/esm/imodel-components-react/color/Swatch.scss +22 -23
  218. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
  219. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
  220. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  221. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
  222. package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
  223. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  224. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  225. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
  226. package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
  227. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  228. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  229. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
  230. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
  231. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  232. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
  233. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  234. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +243 -240
  235. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  236. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +106 -107
  237. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
  238. package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
  239. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  240. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  241. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
  242. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +133 -133
  243. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  244. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +52 -52
  245. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
  246. package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
  247. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  248. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  249. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +174 -174
  250. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  251. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +610 -606
  252. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  253. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -182
  254. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
  255. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  256. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +626 -620
  257. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  258. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -134
  259. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
  260. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
  261. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  262. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +63 -63
  263. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
  264. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +30 -30
  265. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  266. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
  267. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  268. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +61 -60
  269. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  270. package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
  271. package/lib/esm/imodel-components-react/quantityformat/FormatType.js +63 -63
  272. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  273. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
  274. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +83 -83
  275. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  276. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
  277. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +110 -110
  278. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  279. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
  280. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +158 -158
  281. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  282. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
  283. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +122 -122
  284. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  285. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
  286. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
  287. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  288. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
  289. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
  290. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  291. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
  292. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
  293. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  294. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
  295. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
  296. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  297. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
  298. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
  299. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  300. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
  301. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
  302. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  303. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
  304. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
  305. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  306. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
  307. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
  308. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  309. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
  310. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +69 -69
  311. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  312. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
  313. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
  314. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  315. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
  316. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +139 -139
  317. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  318. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
  319. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
  320. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  321. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
  322. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
  323. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  324. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
  325. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
  326. package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts.map +1 -1
  327. package/lib/esm/imodel-components-react/timeline/PlayerButton.js +68 -64
  328. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  329. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +28 -31
  330. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
  331. package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
  332. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  333. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +105 -112
  334. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
  335. package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
  336. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +402 -398
  337. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  338. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +359 -356
  339. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
  340. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
  341. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  342. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  343. package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
  344. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +133 -133
  345. package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts.map +1 -1
  346. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +339 -332
  347. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  348. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +161 -164
  349. package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +174 -174
  350. package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
  351. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  352. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
  353. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +251 -251
  354. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  355. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
  356. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +95 -95
  357. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  358. package/lib/esm/imodel-components-react.d.ts +82 -82
  359. package/lib/esm/imodel-components-react.js +87 -87
  360. package/lib/esm/imodel-components-react.js.map +1 -1
  361. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  362. package/package.json +22 -26
@@ -1,635 +1,639 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
- * See LICENSE.md in the project root for license terms and full copyright notice.
5
- *--------------------------------------------------------------------------------------------*/
6
- /** @packageDocumentation
7
- * @module NavigationAids
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
28
- var __importDefault = (this && this.__importDefault) || function (mod) {
29
- return (mod && mod.__esModule) ? mod : { "default": mod };
30
- };
31
- Object.defineProperty(exports, "__esModule", { value: true });
32
- exports.FaceCell = exports.NavCubeFace = exports.CubeNavigationAid = exports.CubeHover = exports.HitBoxZ = exports.CubeNavigationHitBoxZ = exports.HitBoxY = exports.CubeNavigationHitBoxY = exports.HitBoxX = exports.CubeNavigationHitBoxX = void 0;
33
- require("./CubeNavigationAid.scss");
34
- const classnames_1 = __importDefault(require("classnames"));
35
- const React = __importStar(require("react"));
36
- const core_geometry_1 = require("@itwin/core-geometry");
37
- const core_frontend_1 = require("@itwin/core-frontend");
38
- const UiIModelComponents_1 = require("../UiIModelComponents");
39
- const ViewportComponentEvents_1 = require("../viewport/ViewportComponentEvents");
40
- const Cube_1 = require("./Cube");
41
- /** @public */
42
- var CubeNavigationHitBoxX;
43
- (function (CubeNavigationHitBoxX) {
44
- CubeNavigationHitBoxX[CubeNavigationHitBoxX["None"] = 0] = "None";
45
- CubeNavigationHitBoxX[CubeNavigationHitBoxX["Right"] = 1] = "Right";
46
- CubeNavigationHitBoxX[CubeNavigationHitBoxX["Left"] = -1] = "Left";
47
- })(CubeNavigationHitBoxX = exports.CubeNavigationHitBoxX || (exports.CubeNavigationHitBoxX = {}));
48
- /** @internal
49
- * @deprecated Use [[CubeNavigationHitBoxX]] */
50
- var HitBoxX;
51
- (function (HitBoxX) {
52
- HitBoxX[HitBoxX["None"] = 0] = "None";
53
- HitBoxX[HitBoxX["Right"] = 1] = "Right";
54
- HitBoxX[HitBoxX["Left"] = -1] = "Left";
55
- })(HitBoxX = exports.HitBoxX || (exports.HitBoxX = {}));
56
- /** @public */
57
- var CubeNavigationHitBoxY;
58
- (function (CubeNavigationHitBoxY) {
59
- CubeNavigationHitBoxY[CubeNavigationHitBoxY["None"] = 0] = "None";
60
- CubeNavigationHitBoxY[CubeNavigationHitBoxY["Back"] = 1] = "Back";
61
- CubeNavigationHitBoxY[CubeNavigationHitBoxY["Front"] = -1] = "Front";
62
- })(CubeNavigationHitBoxY = exports.CubeNavigationHitBoxY || (exports.CubeNavigationHitBoxY = {}));
63
- /** @internal
64
- * @deprecated Use [[CubeNavigationHitBoxY]] */
65
- var HitBoxY;
66
- (function (HitBoxY) {
67
- HitBoxY[HitBoxY["None"] = 0] = "None";
68
- HitBoxY[HitBoxY["Back"] = 1] = "Back";
69
- HitBoxY[HitBoxY["Front"] = -1] = "Front";
70
- })(HitBoxY = exports.HitBoxY || (exports.HitBoxY = {}));
71
- /** @public */
72
- var CubeNavigationHitBoxZ;
73
- (function (CubeNavigationHitBoxZ) {
74
- CubeNavigationHitBoxZ[CubeNavigationHitBoxZ["None"] = 0] = "None";
75
- CubeNavigationHitBoxZ[CubeNavigationHitBoxZ["Top"] = 1] = "Top";
76
- CubeNavigationHitBoxZ[CubeNavigationHitBoxZ["Bottom"] = -1] = "Bottom";
77
- })(CubeNavigationHitBoxZ = exports.CubeNavigationHitBoxZ || (exports.CubeNavigationHitBoxZ = {}));
78
- /** @internal
79
- * @deprecated [[CubeNavigationHitBoxZ]] */
80
- var HitBoxZ;
81
- (function (HitBoxZ) {
82
- HitBoxZ[HitBoxZ["None"] = 0] = "None";
83
- HitBoxZ[HitBoxZ["Top"] = 1] = "Top";
84
- HitBoxZ[HitBoxZ["Bottom"] = -1] = "Bottom";
85
- })(HitBoxZ = exports.HitBoxZ || (exports.HitBoxZ = {}));
86
- const cubeNavigationFaceLocs = {
87
- [Cube_1.Face.Left]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.Left, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.None),
88
- [Cube_1.Face.Right]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.Right, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.None),
89
- [Cube_1.Face.Back]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.Back, CubeNavigationHitBoxZ.None),
90
- [Cube_1.Face.Front]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.Front, CubeNavigationHitBoxZ.None),
91
- [Cube_1.Face.Bottom]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.Bottom),
92
- [Cube_1.Face.Top]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.Top),
93
- };
94
- const cubeNavigationFaceRotations = {
95
- [Cube_1.Face.Left]: core_geometry_1.Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0),
96
- [Cube_1.Face.Right]: core_geometry_1.Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0),
97
- [Cube_1.Face.Back]: core_geometry_1.Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0),
98
- [Cube_1.Face.Front]: core_geometry_1.Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0),
99
- [Cube_1.Face.Bottom]: core_geometry_1.Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1),
100
- [Cube_1.Face.Top]: core_geometry_1.Matrix3d.createRowValues(1, 0, 0, 0, 1, 0, 0, 0, 1),
101
- };
102
- // data relating Up/Down/Left/Right directions relative to every surface
103
- const cubeNavigationRoutes = {
104
- [Cube_1.Face.Front]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Left, right: Cube_1.Face.Right },
105
- [Cube_1.Face.Back]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Right, right: Cube_1.Face.Left },
106
- [Cube_1.Face.Top]: { up: Cube_1.Face.Back, down: Cube_1.Face.Front, left: Cube_1.Face.Left, right: Cube_1.Face.Right },
107
- [Cube_1.Face.Bottom]: { up: Cube_1.Face.Front, down: Cube_1.Face.Back, left: Cube_1.Face.Left, right: Cube_1.Face.Right },
108
- [Cube_1.Face.Right]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Front, right: Cube_1.Face.Back },
109
- [Cube_1.Face.Left]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Back, right: Cube_1.Face.Front },
110
- };
111
- /** The default tolerance (1.0e-6) is appropriate if very dirty viewing operations are expected. */
112
- const DEFAULT_TOLERANCE = 1.0e-6;
113
- /** @internal */
114
- var CubeHover;
115
- (function (CubeHover) {
116
- CubeHover[CubeHover["None"] = 0] = "None";
117
- CubeHover[CubeHover["Hover"] = 1] = "Hover";
118
- CubeHover[CubeHover["Active"] = 2] = "Active";
119
- })(CubeHover = exports.CubeHover || (exports.CubeHover = {}));
120
- /** Cube Navigation Aid Component
121
- * @public
122
- */
123
- class CubeNavigationAid extends React.Component {
124
- constructor() {
125
- super(...arguments);
126
- this._start = core_geometry_1.Vector2d.createZero();
127
- /** @internal */
128
- this.state = {
129
- dragging: false,
130
- startRotMatrix: core_geometry_1.Matrix3d.createIdentity(),
131
- endRotMatrix: core_geometry_1.Matrix3d.createIdentity(),
132
- animation: 1,
133
- hoverMap: {},
134
- face: Cube_1.Face.Top,
135
- };
136
- this._mounted = false;
137
- this._labels = {
138
- [Cube_1.Face.Right]: UiIModelComponents_1.UiIModelComponents.translate("cube.right"),
139
- [Cube_1.Face.Left]: UiIModelComponents_1.UiIModelComponents.translate("cube.left"),
140
- [Cube_1.Face.Back]: UiIModelComponents_1.UiIModelComponents.translate("cube.back"),
141
- [Cube_1.Face.Front]: UiIModelComponents_1.UiIModelComponents.translate("cube.front"),
142
- [Cube_1.Face.Top]: UiIModelComponents_1.UiIModelComponents.translate("cube.top"),
143
- [Cube_1.Face.Bottom]: UiIModelComponents_1.UiIModelComponents.translate("cube.bottom"),
144
- };
145
- // Synchronize with rotation coming from the Viewport
146
- this._handleViewRotationChangeEvent = (args) => {
147
- const { animation, dragging, endRotMatrix } = this.state;
148
- // istanbul ignore else
149
- if (this.props.viewport === args.viewport && animation >= 1 && !dragging) {
150
- const newMatrix = this.props.viewport.view.getRotation().clone();
151
- if (!endRotMatrix.isAlmostEqual(newMatrix)) {
152
- this.setState({ startRotMatrix: newMatrix, endRotMatrix: newMatrix, animation: 1, face: Cube_1.Face.None });
153
- }
154
- }
155
- };
156
- this._animation = () => {
157
- const t = Date.now();
158
- const delta = this._lastTime ? t - this._lastTime : 16;
159
- this._lastTime = t;
160
- if (this.state.animation !== 1) {
161
- const animation = Math.min(1, this.state.animation + delta / (1000 * (this.props.animationTime || /* istanbul ignore next */ 0.4)));
162
- // istanbul ignore next
163
- if (this._mounted) {
164
- this.setState({ animation }, () => {
165
- this._animationFrame = setTimeout(this._animation, 16.667);
166
- });
167
- }
168
- }
169
- else {
170
- this._lastTime = undefined;
171
- this._animationEnd();
172
- }
173
- };
174
- this._animationEnd = () => {
175
- ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(this.state.endRotMatrix, this.state.face, true);
176
- const startRotMatrix = this.state.endRotMatrix.clone();
177
- // istanbul ignore next
178
- if (this._mounted) {
179
- this.setState({ startRotMatrix }, () => {
180
- // istanbul ignore else
181
- if (this.props.onAnimationEnd)
182
- this.props.onAnimationEnd();
183
- });
184
- }
185
- };
186
- this._handleCellHoverChange = (vect, state) => {
187
- var _a, _b;
188
- if (this._isInteractionLocked()) {
189
- (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
190
- return;
191
- }
192
- const hoverMap = this.state.hoverMap;
193
- hoverMap[`${vect.x}-${vect.y}-${vect.z}`] = state;
194
- this.setState({ hoverMap });
195
- };
196
- this._isInteractionLocked = () => {
197
- // Locked by markup
198
- if (undefined !== this.props.viewport && this.props.viewport === core_frontend_1.IModelApp.toolAdmin.markupView) {
199
- return true;
200
- }
201
- return false;
202
- };
203
- this._onArrowClick = (arrow) => {
204
- var _a, _b;
205
- if (this._isInteractionLocked()) {
206
- // istanbul ignore next
207
- (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
208
- return;
209
- }
210
- const { newRotation, face } = this.getArrowRotationAndFace(arrow);
211
- this._animateRotation(newRotation, face);
212
- };
213
- this._lastClientXY = core_geometry_1.Vector2d.createZero();
214
- this._handleBoxMouseDown = (event) => {
215
- var _a, _b;
216
- if (this._isInteractionLocked()) {
217
- (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
218
- return;
219
- }
220
- event.preventDefault();
221
- // only start listening after drag is confirmed. Ie. the 3D box is clicked.
222
- window.addEventListener("mousemove", this._onMouseMove, false);
223
- window.addEventListener("mouseup", this._onMouseUp, false);
224
- this._lastClientXY = core_geometry_1.Vector2d.create(event.clientX, event.clientY);
225
- this._start = this._lastClientXY;
226
- };
227
- this._onMouseMove = (event) => {
228
- const mousePos = core_geometry_1.Vector2d.create(event.clientX, event.clientY);
229
- this._processDrag(mousePos);
230
- };
231
- this._onMouseUp = () => {
232
- if (this.state.dragging) {
233
- this.setState({ dragging: false });
234
- ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(this.state.endRotMatrix, CubeNavigationAid._getMatrixFace(this.state.endRotMatrix), true);
235
- }
236
- // remove so event only triggers after this.onMouseStartDrag
237
- window.removeEventListener("mousemove", this._onMouseMove);
238
- window.removeEventListener("mouseup", this._onMouseUp);
239
- };
240
- // istanbul ignore next - unable to test touch
241
- this._handleBoxTouchStart = (event) => {
242
- var _a, _b;
243
- if (this._isInteractionLocked()) {
244
- (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
245
- return;
246
- }
247
- if (1 !== event.targetTouches.length)
248
- return;
249
- window.addEventListener("touchmove", this._onTouchMove, false);
250
- window.addEventListener("touchend", this._onTouchEnd, false);
251
- this._lastClientXY = core_geometry_1.Vector2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
252
- this._start = this._lastClientXY;
253
- };
254
- // istanbul ignore next - unable to test touch
255
- this._onTouchMove = (event) => {
256
- if (1 !== event.targetTouches.length)
257
- return;
258
- const mousePos = core_geometry_1.Vector2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
259
- this._processDrag(mousePos);
260
- };
261
- // istanbul ignore next - unable to test touch
262
- this._onTouchEnd = (event) => {
263
- if (0 !== event.targetTouches.length)
264
- return;
265
- if (this.state.dragging) {
266
- this.setState({ dragging: false });
267
- ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(this.state.endRotMatrix, CubeNavigationAid._getMatrixFace(this.state.endRotMatrix), true);
268
- }
269
- window.removeEventListener("touchmove", this._onTouchMove);
270
- window.removeEventListener("touchend", this._onTouchEnd);
271
- };
272
- this._handleFaceCellClick = (pos, face) => {
273
- var _a, _b;
274
- if (this._isInteractionLocked()) {
275
- (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
276
- return;
277
- }
278
- const { endRotMatrix } = this.state;
279
- let rotMatrix = core_geometry_1.Matrix3d.createRigidViewAxesZTowardsEye(pos.x, pos.y, pos.z).inverse();
280
- // istanbul ignore else
281
- if (rotMatrix) {
282
- // if isMatrixFace and user is clicking on top/bottom, the current matrix face must be top or bottom
283
- if (!CubeNavigationAid._isMatrixFace(endRotMatrix) && (face === Cube_1.Face.Top || face === Cube_1.Face.Bottom)) {
284
- const angleAxis = endRotMatrix.getAxisAndAngleOfRotation();
285
- // istanbul ignore else
286
- if (angleAxis.ok) {
287
- const xAx = endRotMatrix.columnX();
288
- const a = Math.atan2(xAx.y, xAx.x);
289
- const r = Math.round(a * 2 / Math.PI) * Math.PI / 2; // round to quarter turn intervals
290
- const rot = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.Z, core_geometry_1.Angle.createRadians(r));
291
- rotMatrix = rot.multiplyMatrixMatrix(rotMatrix);
292
- }
293
- }
294
- this._animateRotation(rotMatrix, face);
295
- }
296
- window.removeEventListener("mousemove", this._onMouseMove);
297
- };
298
- this._animateRotation = (endRotMatrix, face) => {
299
- if (this.state.endRotMatrix.isAlmostEqual(endRotMatrix))
300
- return;
301
- // set animation variables, let css transitions animate it.
302
- this._animationFrame = setTimeout(this._animation, 16.667);
303
- this.setState((prevState) => ({
304
- startRotMatrix: prevState.endRotMatrix, endRotMatrix,
305
- animation: 0,
306
- face,
307
- }));
308
- };
309
- this._setRotation = (endRotMatrix, face) => {
310
- ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(endRotMatrix, face);
311
- // set variables, with animTime at 0 to prevent animation.
312
- this.setState({
313
- startRotMatrix: endRotMatrix,
314
- endRotMatrix,
315
- animation: 1,
316
- face,
317
- });
318
- };
319
- }
320
- /** @internal */
321
- componentDidMount() {
322
- this._mounted = true;
323
- ViewportComponentEvents_1.ViewportComponentEvents.onViewRotationChangeEvent.addListener(this._handleViewRotationChangeEvent);
324
- // set initial rotation
325
- if (this.props.viewport) {
326
- const newMatrix = this.props.viewport.view.getRotation().clone();
327
- this.setState({ startRotMatrix: newMatrix, endRotMatrix: newMatrix, animation: 1 });
328
- }
329
- }
330
- /** @internal */
331
- componentWillUnmount() {
332
- ViewportComponentEvents_1.ViewportComponentEvents.onViewRotationChangeEvent.removeListener(this._handleViewRotationChangeEvent);
333
- clearTimeout(this._animationFrame);
334
- this._mounted = false;
335
- }
336
- render() {
337
- const { animation, startRotMatrix, endRotMatrix } = this.state;
338
- const visible = CubeNavigationAid._isMatrixFace(endRotMatrix) && animation === 1.0;
339
- const rotMatrix = CubeNavigationAid._interpolateRotMatrix(startRotMatrix, animation, endRotMatrix);
340
- if (rotMatrix !== startRotMatrix && rotMatrix !== endRotMatrix)
341
- ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(rotMatrix, Cube_1.Face.None);
342
- const faces = {};
343
- for (const key in this._labels) {
344
- // istanbul ignore else
345
- if (this._labels.hasOwnProperty(key)) {
346
- const f = key;
347
- const label = this._labels[f];
348
- faces[f] =
349
- React.createElement(NavCubeFace, { face: f, label: label, hoverMap: this.state.hoverMap, onFaceCellClick: this._handleFaceCellClick, onFaceCellHoverChange: this._handleCellHoverChange });
350
- }
351
- }
352
- const cubeClassNames = (0, classnames_1.default)("nav-cube", this.state.dragging && "cube-dragging");
353
- const upTitle = this.getArrowTitle(Pointer.Up);
354
- const downTitle = this.getArrowTitle(Pointer.Down);
355
- const leftTitle = this.getArrowTitle(Pointer.Left);
356
- const rightTitle = this.getArrowTitle(Pointer.Right);
357
- return (React.createElement("div", { className: (0, classnames_1.default)("components-cube-container", this.props.className), style: this.props.style, "data-testid": "components-cube-navigation-aid", onMouseDown: this._handleBoxMouseDown, onTouchStart: this._handleBoxTouchStart, role: "presentation" },
358
- React.createElement("div", { className: "cube-element-container" },
359
- React.createElement(Cube_1.Cube, { className: cubeClassNames, rotMatrix: rotMatrix, faces: faces })),
360
- React.createElement(PointerButton, { "data-testid": "cube-pointer-button-up", visible: visible, pointerType: Pointer.Up, onArrowClick: this._onArrowClick, title: upTitle }),
361
- React.createElement(PointerButton, { "data-testid": "cube-pointer-button-down", visible: visible, pointerType: Pointer.Down, onArrowClick: this._onArrowClick, title: downTitle }),
362
- React.createElement(PointerButton, { "data-testid": "cube-pointer-button-left", visible: visible, pointerType: Pointer.Left, onArrowClick: this._onArrowClick, title: leftTitle }),
363
- React.createElement(PointerButton, { "data-testid": "cube-pointer-button-right", visible: visible, pointerType: Pointer.Right, onArrowClick: this._onArrowClick, title: rightTitle })));
364
- }
365
- static correctSmallNumber(value, tolerance) {
366
- return Math.abs(value) < tolerance ? 0 : value;
367
- }
368
- /**
369
- * Snap coordinates of a vector to zero and to each other so that the vector prefers to be
370
- * * perpendicular to a face of the unit cube.
371
- * * or pass through a nearby vertex or edge of the unit cube.
372
- * @param zVector existing z vector.
373
- * @param tolerance tolerance to determine if a z vector component is close to zero or 1.
374
- */
375
- static snapVectorToCubeFeatures(zVector, tolerance) {
376
- const x = CubeNavigationAid.correctSmallNumber(zVector.x, tolerance);
377
- let y = CubeNavigationAid.correctSmallNumber(zVector.y, tolerance);
378
- let z = CubeNavigationAid.correctSmallNumber(zVector.z, tolerance);
379
- const xx = Math.abs(x);
380
- const yy = Math.abs(y);
381
- const zz = Math.abs(z);
382
- // adjust any adjacent pair of near equal values to the first.
383
- // istanbul ignore next
384
- if (core_geometry_1.Geometry.isSameCoordinate(xx, yy, tolerance)) {
385
- y = core_geometry_1.Geometry.split3WaySign(y, -xx, xx, xx);
386
- }
387
- if (core_geometry_1.Geometry.isSameCoordinate(yy, zz, tolerance)) {
388
- z = core_geometry_1.Geometry.split3WaySign(z, -yy, yy, yy);
389
- }
390
- if (core_geometry_1.Geometry.isSameCoordinate(xx, zz, tolerance)) {
391
- z = core_geometry_1.Geometry.split3WaySign(z, -xx, xx, xx);
392
- }
393
- return core_geometry_1.Vector3d.create(x, y, z);
394
- }
395
- /**
396
- * Adjust a worldToView matrix to favor both
397
- * * direct view at faces, edges, and corners of a view cube.
398
- * * heads up
399
- * @param worldToView candidate matrix
400
- * @param tolerance tolerance for cleaning up fuzz. The default (1.0e-6) is appropriate if very dirty viewing operations are expected.
401
- * @param result optional result.
402
- */
403
- static snapWorldToViewMatrixToCubeFeatures(worldToView, tolerance, result) {
404
- const oldZ = worldToView.rowZ();
405
- const newZ = CubeNavigationAid.snapVectorToCubeFeatures(oldZ, tolerance);
406
- // If newZ is true up or down, it will have true 0 for x and y.
407
- // special case this to take x direction from the input.
408
- // istanbul ignore next
409
- if (newZ.x === 0.0 && newZ.y === 0) {
410
- const perpVector = worldToView.rowX();
411
- result = core_geometry_1.Matrix3d.createRigidFromColumns(newZ, perpVector, core_geometry_1.AxisOrder.ZXY, result);
412
- }
413
- else {
414
- result = core_geometry_1.Matrix3d.createRigidViewAxesZTowardsEye(newZ.x, newZ.y, newZ.z, result);
415
- }
416
- // istanbul ignore else
417
- if (result)
418
- result.transposeInPlace();
419
- return result;
420
- }
421
- getArrowRotationAndFace(arrow) {
422
- const localRotationAxis = core_geometry_1.Vector3d.create(0, 0, 0);
423
- switch (arrow) {
424
- case Pointer.Up:
425
- localRotationAxis.x = -1.0;
426
- break;
427
- case Pointer.Down:
428
- localRotationAxis.x = 1.0;
429
- break;
430
- case Pointer.Left:
431
- localRotationAxis.y = -1.0;
432
- break;
433
- default:
434
- localRotationAxis.y = 1.0;
435
- break;
436
- }
437
- const localRotation = core_geometry_1.Matrix3d.createRotationAroundVector(localRotationAxis, core_geometry_1.Angle.createDegrees(-90));
438
- const newRotation = localRotation.multiplyMatrixMatrix(this.state.endRotMatrix);
439
- CubeNavigationAid.snapWorldToViewMatrixToCubeFeatures(newRotation, DEFAULT_TOLERANCE, newRotation);
440
- const face = CubeNavigationAid._getMatrixFace(newRotation);
441
- return { newRotation, face };
442
- }
443
- getArrowTitle(arrow) {
444
- const { face } = this.getArrowRotationAndFace(arrow);
445
- return this._labels[face];
446
- }
447
- _processDrag(mousePos) {
448
- // istanbul ignore else
449
- if (!this._start.isAlmostEqual(mousePos)) {
450
- const movement = mousePos.minus(this._lastClientXY);
451
- const diff = movement.scale(0.05);
452
- const yaw = core_geometry_1.Angle.createRadians(diff.x);
453
- const pitch = core_geometry_1.Angle.createRadians(diff.y);
454
- const matX = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.X, pitch);
455
- const matZ = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.Z, yaw);
456
- const mat = matX.multiplyMatrixMatrix(this.state.startRotMatrix).multiplyMatrixMatrix(matZ);
457
- this._setRotation(mat, CubeNavigationAid._getMatrixFace(mat));
458
- if (!this.state.dragging)
459
- this.setState({ dragging: true });
460
- }
461
- this._lastClientXY = mousePos;
462
- }
463
- }
464
- exports.CubeNavigationAid = CubeNavigationAid;
465
- CubeNavigationAid._animationFn = (t) => t < .5 ? 2 * t ** 2 : -1 + (4 - 2 * t) * t;
466
- CubeNavigationAid._isMatrixFace = (matrix) => {
467
- let sum = 0;
468
- for (const coff of matrix.coffs) {
469
- if (core_geometry_1.Geometry.isAlmostEqualNumber(Math.abs(coff), 1))
470
- sum++;
471
- }
472
- // Assuming matrix is a proper rotation matrix:
473
- // if matrix viewing a face, there will be a total of 3 values either almost -1, or almost 1.
474
- return sum === 3;
475
- };
476
- CubeNavigationAid._getMatrixFace = (rotMatrix) => {
477
- if (!CubeNavigationAid._isMatrixFace(rotMatrix)) {
478
- return Cube_1.Face.None;
479
- }
480
- let matrixFace = Cube_1.Face.None;
481
- for (const face in cubeNavigationFaceRotations) {
482
- // istanbul ignore else
483
- if (face in cubeNavigationFaceRotations) {
484
- const loc = cubeNavigationFaceRotations[face];
485
- if (rotMatrix.isAlmostEqual(loc)) {
486
- matrixFace = face;
487
- break;
488
- }
489
- }
490
- }
491
- return matrixFace;
492
- };
493
- CubeNavigationAid._interpolateRotMatrix = (start, anim, end) => {
494
- if (anim === 0)
495
- return start;
496
- if (anim === 1 || start.isAlmostEqual(end))
497
- return end;
498
- const startInverse = start.transpose();
499
- const diff = end.multiplyMatrixMatrix(startInverse);
500
- const angleAxis = diff.getAxisAndAngleOfRotation();
501
- // istanbul ignore else
502
- if (angleAxis.ok) {
503
- const angle = core_geometry_1.Angle.createRadians(angleAxis.angle.radians * CubeNavigationAid._animationFn(anim));
504
- const newDiff = core_geometry_1.Matrix3d.createRotationAroundVector(angleAxis.axis, angle);
505
- // istanbul ignore else
506
- if (newDiff) {
507
- const newMatrix = newDiff.multiplyMatrixMatrix(start);
508
- return newMatrix;
509
- }
510
- }
511
- // istanbul ignore next
512
- return end;
513
- };
514
- /** @internal */
515
- class NavCubeFace extends React.Component {
516
- render() {
517
- const { face, hoverMap, onFaceCellClick, onFaceCellHoverChange, label } = this.props;
518
- return (React.createElement("div", { className: "nav-cube-face", "data-testid": "nav-cube-face" }, [-1, 0, 1].map((y) => {
519
- return (React.createElement(FaceRow, { key: y, center: y === 0 }, [-1, 0, 1].map((x) => {
520
- return (React.createElement(FaceCell, { key: x, onFaceCellHoverChange: onFaceCellHoverChange, onFaceCellClick: onFaceCellClick, hoverMap: hoverMap, vector: NavCubeFace.faceCellToPos(face, x, y), face: face, center: x === 0 }, x === 0 && y === 0 &&
521
- label));
522
- })));
523
- })));
524
- }
525
- }
526
- exports.NavCubeFace = NavCubeFace;
527
- NavCubeFace.faceCellToPos = (face, x, y) => {
528
- const faceVect = cubeNavigationFaceLocs[face];
529
- const route = cubeNavigationRoutes[face];
530
- const faceX = x < 0 ? route.left : x > 0 ? route.right : Cube_1.Face.None;
531
- const xVect = faceX !== Cube_1.Face.None ? cubeNavigationFaceLocs[faceX] : core_geometry_1.Vector3d.createZero();
532
- const faceY = y < 0 ? route.up : y > 0 ? route.down : Cube_1.Face.None;
533
- const yVect = faceY !== Cube_1.Face.None ? cubeNavigationFaceLocs[faceY] : core_geometry_1.Vector3d.createZero();
534
- return faceVect.plus(xVect).plus(yVect);
535
- };
536
- class FaceRow extends React.Component {
537
- render() {
538
- const { center, children, ...props } = this.props;
539
- const classNames = (0, classnames_1.default)("face-row", center && "cube-center");
540
- return React.createElement("div", { className: classNames, ...props }, children);
541
- }
542
- }
543
- /** @internal */
544
- class FaceCell extends React.Component {
545
- constructor() {
546
- super(...arguments);
547
- this._handleMouseOver = () => {
548
- const { vector } = this.props;
549
- this.props.onFaceCellHoverChange(vector, CubeHover.Hover);
550
- };
551
- this._handleMouseOut = () => {
552
- const { vector } = this.props;
553
- this.props.onFaceCellHoverChange(vector, CubeHover.None);
554
- };
555
- this._handleMouseDown = (event) => {
556
- const { clientX, clientY } = event;
557
- this.handlePointerDown(clientX, clientY);
558
- };
559
- this._handleMouseUp = (event) => {
560
- const { clientX, clientY } = event;
561
- this.handlePointerUp(clientX, clientY);
562
- };
563
- this._handleTouchStart = (event) => {
564
- event.preventDefault();
565
- event.targetTouches.length === 1 && this.handlePointerDown(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
566
- };
567
- this._handleTouchEnd = (event) => {
568
- event.preventDefault();
569
- event.changedTouches.length === 1 && this.handlePointerUp(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
570
- };
571
- }
572
- render() {
573
- const { center, children, onFaceCellClick, onFaceCellHoverChange, hoverMap, face, vector, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars
574
- const { x, y, z } = vector;
575
- const n = `${x}-${y}-${z}`;
576
- const hover = hoverMap[n] === CubeHover.Hover;
577
- const active = hoverMap[n] === CubeHover.Active;
578
- const classNames = (0, classnames_1.default)("face-cell", center && "cube-center", hover && "cube-hover", active && "cube-active");
579
- // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
580
- return React.createElement("div", { onMouseDown: this._handleMouseDown, onMouseUp: this._handleMouseUp, onMouseOver: this._handleMouseOver, onMouseOut: this._handleMouseOut, onTouchStart: this._handleTouchStart, onTouchEnd: this._handleTouchEnd, "data-testid": `nav-cube-face-cell-${face}-${n}`, className: classNames, role: "presentation", ...props }, children);
581
- }
582
- handlePointerDown(x, y) {
583
- const { vector } = this.props;
584
- this._startMouse = core_geometry_1.Point2d.create(x, y);
585
- this.props.onFaceCellHoverChange(vector, CubeHover.Active);
586
- }
587
- handlePointerUp(x, y) {
588
- const { vector, face } = this.props;
589
- this.props.onFaceCellHoverChange(vector, CubeHover.None);
590
- const mouse = core_geometry_1.Point2d.create(x, y);
591
- if (this._startMouse && this._startMouse.isAlmostEqual(mouse)) {
592
- const isFace = Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z) === 1;
593
- this.props.onFaceCellClick(vector, isFace ? face : Cube_1.Face.None);
594
- }
595
- }
596
- }
597
- exports.FaceCell = FaceCell;
598
- var Pointer;
599
- (function (Pointer) {
600
- Pointer[Pointer["None"] = 0] = "None";
601
- Pointer[Pointer["Up"] = 1] = "Up";
602
- Pointer[Pointer["Down"] = 2] = "Down";
603
- Pointer[Pointer["Left"] = 3] = "Left";
604
- Pointer[Pointer["Right"] = 4] = "Right";
605
- })(Pointer || (Pointer = {}));
606
- const pointerIconClass = {
607
- [Pointer.Up]: "icon-caret-down",
608
- [Pointer.Down]: "icon-caret-up",
609
- [Pointer.Left]: "icon-caret-right",
610
- [Pointer.Right]: "icon-caret-left",
611
- };
612
- const pointerClass = {
613
- [Pointer.Up]: "cube-up",
614
- [Pointer.Down]: "cube-down",
615
- [Pointer.Left]: "cube-left",
616
- [Pointer.Right]: "cube-right",
617
- };
618
- class PointerButton extends React.Component {
619
- constructor() {
620
- super(...arguments);
621
- this._handleClick = (event) => {
622
- const { pointerType } = this.props;
623
- event.preventDefault();
624
- this.props.onArrowClick(pointerType);
625
- };
626
- }
627
- render() {
628
- const { visible, pointerType, onArrowClick, title, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars
629
- const classes = (0, classnames_1.default)("cube-pointer", "icon", pointerClass[pointerType], pointerIconClass[pointerType], visible && "cube-visible");
630
- return (
631
- // eslint-disable-next-line jsx-a11y/click-events-have-key-events
632
- React.createElement("div", { className: classes, role: "button", tabIndex: -1, title: title, ...props, onClick: this._handleClick }));
633
- }
634
- }
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module NavigationAids
8
+ */
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
18
+ }) : function(o, v) {
19
+ o["default"] = v;
20
+ });
21
+ var __importStar = (this && this.__importStar) || function (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __importDefault = (this && this.__importDefault) || function (mod) {
29
+ return (mod && mod.__esModule) ? mod : { "default": mod };
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.FaceCell = exports.NavCubeFace = exports.CubeNavigationAid = exports.CubeHover = exports.HitBoxZ = exports.CubeNavigationHitBoxZ = exports.HitBoxY = exports.CubeNavigationHitBoxY = exports.HitBoxX = exports.CubeNavigationHitBoxX = void 0;
33
+ require("./CubeNavigationAid.scss");
34
+ const classnames_1 = __importDefault(require("classnames"));
35
+ const React = __importStar(require("react"));
36
+ const core_geometry_1 = require("@itwin/core-geometry");
37
+ const core_frontend_1 = require("@itwin/core-frontend");
38
+ const core_react_1 = require("@itwin/core-react");
39
+ const UiIModelComponents_1 = require("../UiIModelComponents");
40
+ const ViewportComponentEvents_1 = require("../viewport/ViewportComponentEvents");
41
+ const Cube_1 = require("./Cube");
42
+ const itwinui_icons_react_1 = require("@itwin/itwinui-icons-react");
43
+ /** @public */
44
+ var CubeNavigationHitBoxX;
45
+ (function (CubeNavigationHitBoxX) {
46
+ CubeNavigationHitBoxX[CubeNavigationHitBoxX["None"] = 0] = "None";
47
+ CubeNavigationHitBoxX[CubeNavigationHitBoxX["Right"] = 1] = "Right";
48
+ CubeNavigationHitBoxX[CubeNavigationHitBoxX["Left"] = -1] = "Left";
49
+ })(CubeNavigationHitBoxX = exports.CubeNavigationHitBoxX || (exports.CubeNavigationHitBoxX = {}));
50
+ /** @internal
51
+ * @deprecated in 2.x. Use [[CubeNavigationHitBoxX]] */
52
+ var HitBoxX;
53
+ (function (HitBoxX) {
54
+ HitBoxX[HitBoxX["None"] = 0] = "None";
55
+ HitBoxX[HitBoxX["Right"] = 1] = "Right";
56
+ HitBoxX[HitBoxX["Left"] = -1] = "Left";
57
+ })(HitBoxX = exports.HitBoxX || (exports.HitBoxX = {}));
58
+ /** @public */
59
+ var CubeNavigationHitBoxY;
60
+ (function (CubeNavigationHitBoxY) {
61
+ CubeNavigationHitBoxY[CubeNavigationHitBoxY["None"] = 0] = "None";
62
+ CubeNavigationHitBoxY[CubeNavigationHitBoxY["Back"] = 1] = "Back";
63
+ CubeNavigationHitBoxY[CubeNavigationHitBoxY["Front"] = -1] = "Front";
64
+ })(CubeNavigationHitBoxY = exports.CubeNavigationHitBoxY || (exports.CubeNavigationHitBoxY = {}));
65
+ /** @internal
66
+ * @deprecated in 2.x. Use [[CubeNavigationHitBoxY]] */
67
+ var HitBoxY;
68
+ (function (HitBoxY) {
69
+ HitBoxY[HitBoxY["None"] = 0] = "None";
70
+ HitBoxY[HitBoxY["Back"] = 1] = "Back";
71
+ HitBoxY[HitBoxY["Front"] = -1] = "Front";
72
+ })(HitBoxY = exports.HitBoxY || (exports.HitBoxY = {}));
73
+ /** @public */
74
+ var CubeNavigationHitBoxZ;
75
+ (function (CubeNavigationHitBoxZ) {
76
+ CubeNavigationHitBoxZ[CubeNavigationHitBoxZ["None"] = 0] = "None";
77
+ CubeNavigationHitBoxZ[CubeNavigationHitBoxZ["Top"] = 1] = "Top";
78
+ CubeNavigationHitBoxZ[CubeNavigationHitBoxZ["Bottom"] = -1] = "Bottom";
79
+ })(CubeNavigationHitBoxZ = exports.CubeNavigationHitBoxZ || (exports.CubeNavigationHitBoxZ = {}));
80
+ /** @internal
81
+ * @deprecated in 2.x. [[CubeNavigationHitBoxZ]] */
82
+ var HitBoxZ;
83
+ (function (HitBoxZ) {
84
+ HitBoxZ[HitBoxZ["None"] = 0] = "None";
85
+ HitBoxZ[HitBoxZ["Top"] = 1] = "Top";
86
+ HitBoxZ[HitBoxZ["Bottom"] = -1] = "Bottom";
87
+ })(HitBoxZ = exports.HitBoxZ || (exports.HitBoxZ = {}));
88
+ const cubeNavigationFaceLocs = {
89
+ [Cube_1.Face.Left]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.Left, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.None),
90
+ [Cube_1.Face.Right]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.Right, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.None),
91
+ [Cube_1.Face.Back]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.Back, CubeNavigationHitBoxZ.None),
92
+ [Cube_1.Face.Front]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.Front, CubeNavigationHitBoxZ.None),
93
+ [Cube_1.Face.Bottom]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.Bottom),
94
+ [Cube_1.Face.Top]: core_geometry_1.Vector3d.create(CubeNavigationHitBoxX.None, CubeNavigationHitBoxY.None, CubeNavigationHitBoxZ.Top),
95
+ };
96
+ const cubeNavigationFaceRotations = {
97
+ [Cube_1.Face.Left]: core_geometry_1.Matrix3d.createRowValues(0, -1, 0, 0, 0, 1, -1, 0, 0),
98
+ [Cube_1.Face.Right]: core_geometry_1.Matrix3d.createRowValues(0, 1, 0, 0, 0, 1, 1, 0, 0),
99
+ [Cube_1.Face.Back]: core_geometry_1.Matrix3d.createRowValues(-1, 0, 0, 0, 0, 1, 0, 1, 0),
100
+ [Cube_1.Face.Front]: core_geometry_1.Matrix3d.createRowValues(1, 0, 0, 0, 0, 1, 0, -1, 0),
101
+ [Cube_1.Face.Bottom]: core_geometry_1.Matrix3d.createRowValues(1, 0, 0, 0, -1, 0, 0, 0, -1),
102
+ [Cube_1.Face.Top]: core_geometry_1.Matrix3d.createRowValues(1, 0, 0, 0, 1, 0, 0, 0, 1),
103
+ };
104
+ // data relating Up/Down/Left/Right directions relative to every surface
105
+ const cubeNavigationRoutes = {
106
+ [Cube_1.Face.Front]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Left, right: Cube_1.Face.Right },
107
+ [Cube_1.Face.Back]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Right, right: Cube_1.Face.Left },
108
+ [Cube_1.Face.Top]: { up: Cube_1.Face.Back, down: Cube_1.Face.Front, left: Cube_1.Face.Left, right: Cube_1.Face.Right },
109
+ [Cube_1.Face.Bottom]: { up: Cube_1.Face.Front, down: Cube_1.Face.Back, left: Cube_1.Face.Left, right: Cube_1.Face.Right },
110
+ [Cube_1.Face.Right]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Front, right: Cube_1.Face.Back },
111
+ [Cube_1.Face.Left]: { up: Cube_1.Face.Top, down: Cube_1.Face.Bottom, left: Cube_1.Face.Back, right: Cube_1.Face.Front },
112
+ };
113
+ /** The default tolerance (1.0e-6) is appropriate if very dirty viewing operations are expected. */
114
+ const DEFAULT_TOLERANCE = 1.0e-6;
115
+ /** @internal */
116
+ var CubeHover;
117
+ (function (CubeHover) {
118
+ CubeHover[CubeHover["None"] = 0] = "None";
119
+ CubeHover[CubeHover["Hover"] = 1] = "Hover";
120
+ CubeHover[CubeHover["Active"] = 2] = "Active";
121
+ })(CubeHover = exports.CubeHover || (exports.CubeHover = {}));
122
+ /** Cube Navigation Aid Component
123
+ * @public
124
+ */
125
+ class CubeNavigationAid extends React.Component {
126
+ constructor() {
127
+ super(...arguments);
128
+ this._start = core_geometry_1.Vector2d.createZero();
129
+ /** @internal */
130
+ this.state = {
131
+ dragging: false,
132
+ startRotMatrix: core_geometry_1.Matrix3d.createIdentity(),
133
+ endRotMatrix: core_geometry_1.Matrix3d.createIdentity(),
134
+ animation: 1,
135
+ hoverMap: {},
136
+ face: Cube_1.Face.Top,
137
+ };
138
+ this._mounted = false;
139
+ this._labels = {
140
+ [Cube_1.Face.Right]: UiIModelComponents_1.UiIModelComponents.translate("cube.right"),
141
+ [Cube_1.Face.Left]: UiIModelComponents_1.UiIModelComponents.translate("cube.left"),
142
+ [Cube_1.Face.Back]: UiIModelComponents_1.UiIModelComponents.translate("cube.back"),
143
+ [Cube_1.Face.Front]: UiIModelComponents_1.UiIModelComponents.translate("cube.front"),
144
+ [Cube_1.Face.Top]: UiIModelComponents_1.UiIModelComponents.translate("cube.top"),
145
+ [Cube_1.Face.Bottom]: UiIModelComponents_1.UiIModelComponents.translate("cube.bottom"),
146
+ };
147
+ // Synchronize with rotation coming from the Viewport
148
+ this._handleViewRotationChangeEvent = (args) => {
149
+ const { animation, dragging, endRotMatrix } = this.state;
150
+ // istanbul ignore else
151
+ if (this.props.viewport === args.viewport && animation >= 1 && !dragging) {
152
+ const newMatrix = this.props.viewport.view.getRotation().clone();
153
+ if (!endRotMatrix.isAlmostEqual(newMatrix)) {
154
+ this.setState({ startRotMatrix: newMatrix, endRotMatrix: newMatrix, animation: 1, face: Cube_1.Face.None });
155
+ }
156
+ }
157
+ };
158
+ this._animation = () => {
159
+ const t = Date.now();
160
+ const delta = this._lastTime ? t - this._lastTime : 16;
161
+ this._lastTime = t;
162
+ if (this.state.animation !== 1) {
163
+ const animation = Math.min(1, this.state.animation + delta / (1000 * (this.props.animationTime || /* istanbul ignore next */ 0.4)));
164
+ // istanbul ignore next
165
+ if (this._mounted) {
166
+ this.setState({ animation }, () => {
167
+ this._animationFrame = setTimeout(this._animation, 16.667);
168
+ });
169
+ }
170
+ }
171
+ else {
172
+ this._lastTime = undefined;
173
+ this._animationEnd();
174
+ }
175
+ };
176
+ this._animationEnd = () => {
177
+ ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(this.state.endRotMatrix, this.state.face, true);
178
+ const startRotMatrix = this.state.endRotMatrix.clone();
179
+ // istanbul ignore next
180
+ if (this._mounted) {
181
+ this.setState({ startRotMatrix }, () => {
182
+ // istanbul ignore else
183
+ if (this.props.onAnimationEnd)
184
+ this.props.onAnimationEnd();
185
+ });
186
+ }
187
+ };
188
+ this._handleCellHoverChange = (vect, state) => {
189
+ var _a, _b;
190
+ if (this._isInteractionLocked()) {
191
+ (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
192
+ return;
193
+ }
194
+ const hoverMap = this.state.hoverMap;
195
+ hoverMap[`${vect.x}-${vect.y}-${vect.z}`] = state;
196
+ this.setState({ hoverMap });
197
+ };
198
+ this._isInteractionLocked = () => {
199
+ // Locked by markup
200
+ if (undefined !== this.props.viewport && this.props.viewport === core_frontend_1.IModelApp.toolAdmin.markupView) {
201
+ return true;
202
+ }
203
+ return false;
204
+ };
205
+ this._onArrowClick = (arrow) => {
206
+ var _a, _b;
207
+ if (this._isInteractionLocked()) {
208
+ // istanbul ignore next
209
+ (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
210
+ return;
211
+ }
212
+ const { newRotation, face } = this.getArrowRotationAndFace(arrow);
213
+ this._animateRotation(newRotation, face);
214
+ };
215
+ this._lastClientXY = core_geometry_1.Vector2d.createZero();
216
+ this._handleBoxMouseDown = (event) => {
217
+ var _a, _b;
218
+ if (this._isInteractionLocked()) {
219
+ (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
220
+ return;
221
+ }
222
+ event.preventDefault();
223
+ // only start listening after drag is confirmed. Ie. the 3D box is clicked.
224
+ window.addEventListener("mousemove", this._onMouseMove, false);
225
+ window.addEventListener("mouseup", this._onMouseUp, false);
226
+ this._lastClientXY = core_geometry_1.Vector2d.create(event.clientX, event.clientY);
227
+ this._start = this._lastClientXY;
228
+ };
229
+ this._onMouseMove = (event) => {
230
+ const mousePos = core_geometry_1.Vector2d.create(event.clientX, event.clientY);
231
+ this._processDrag(mousePos);
232
+ };
233
+ this._onMouseUp = () => {
234
+ if (this.state.dragging) {
235
+ this.setState({ dragging: false });
236
+ ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(this.state.endRotMatrix, CubeNavigationAid._getMatrixFace(this.state.endRotMatrix), true);
237
+ }
238
+ // remove so event only triggers after this.onMouseStartDrag
239
+ window.removeEventListener("mousemove", this._onMouseMove);
240
+ window.removeEventListener("mouseup", this._onMouseUp);
241
+ };
242
+ // istanbul ignore next - unable to test touch
243
+ this._handleBoxTouchStart = (event) => {
244
+ var _a, _b;
245
+ if (this._isInteractionLocked()) {
246
+ (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
247
+ return;
248
+ }
249
+ if (1 !== event.targetTouches.length)
250
+ return;
251
+ window.addEventListener("touchmove", this._onTouchMove, false);
252
+ window.addEventListener("touchend", this._onTouchEnd, false);
253
+ this._lastClientXY = core_geometry_1.Vector2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
254
+ this._start = this._lastClientXY;
255
+ };
256
+ // istanbul ignore next - unable to test touch
257
+ this._onTouchMove = (event) => {
258
+ if (1 !== event.targetTouches.length)
259
+ return;
260
+ const mousePos = core_geometry_1.Vector2d.create(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
261
+ this._processDrag(mousePos);
262
+ };
263
+ // istanbul ignore next - unable to test touch
264
+ this._onTouchEnd = (event) => {
265
+ if (0 !== event.targetTouches.length)
266
+ return;
267
+ if (this.state.dragging) {
268
+ this.setState({ dragging: false });
269
+ ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(this.state.endRotMatrix, CubeNavigationAid._getMatrixFace(this.state.endRotMatrix), true);
270
+ }
271
+ window.removeEventListener("touchmove", this._onTouchMove);
272
+ window.removeEventListener("touchend", this._onTouchEnd);
273
+ };
274
+ this._handleFaceCellClick = (pos, face) => {
275
+ var _a, _b;
276
+ if (this._isInteractionLocked()) {
277
+ (_b = (_a = this.props).onAnimationEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
278
+ return;
279
+ }
280
+ const { endRotMatrix } = this.state;
281
+ let rotMatrix = core_geometry_1.Matrix3d.createRigidViewAxesZTowardsEye(pos.x, pos.y, pos.z).inverse();
282
+ // istanbul ignore else
283
+ if (rotMatrix) {
284
+ // if isMatrixFace and user is clicking on top/bottom, the current matrix face must be top or bottom
285
+ if (!CubeNavigationAid._isMatrixFace(endRotMatrix) && (face === Cube_1.Face.Top || face === Cube_1.Face.Bottom)) {
286
+ const angleAxis = endRotMatrix.getAxisAndAngleOfRotation();
287
+ // istanbul ignore else
288
+ if (angleAxis.ok) {
289
+ const xAx = endRotMatrix.columnX();
290
+ const a = Math.atan2(xAx.y, xAx.x);
291
+ const r = Math.round(a * 2 / Math.PI) * Math.PI / 2; // round to quarter turn intervals
292
+ const rot = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.Z, core_geometry_1.Angle.createRadians(r));
293
+ rotMatrix = rot.multiplyMatrixMatrix(rotMatrix);
294
+ }
295
+ }
296
+ this._animateRotation(rotMatrix, face);
297
+ }
298
+ window.removeEventListener("mousemove", this._onMouseMove);
299
+ };
300
+ this._animateRotation = (endRotMatrix, face) => {
301
+ if (this.state.endRotMatrix.isAlmostEqual(endRotMatrix))
302
+ return;
303
+ // set animation variables, let css transitions animate it.
304
+ this._animationFrame = setTimeout(this._animation, 16.667);
305
+ this.setState((prevState) => ({
306
+ startRotMatrix: prevState.endRotMatrix, endRotMatrix,
307
+ animation: 0,
308
+ face,
309
+ }));
310
+ };
311
+ this._setRotation = (endRotMatrix, face) => {
312
+ ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(endRotMatrix, face);
313
+ // set variables, with animTime at 0 to prevent animation.
314
+ this.setState({
315
+ startRotMatrix: endRotMatrix,
316
+ endRotMatrix,
317
+ animation: 1,
318
+ face,
319
+ });
320
+ };
321
+ }
322
+ /** @internal */
323
+ componentDidMount() {
324
+ this._mounted = true;
325
+ ViewportComponentEvents_1.ViewportComponentEvents.onViewRotationChangeEvent.addListener(this._handleViewRotationChangeEvent);
326
+ // set initial rotation
327
+ if (this.props.viewport) {
328
+ const newMatrix = this.props.viewport.view.getRotation().clone();
329
+ this.setState({ startRotMatrix: newMatrix, endRotMatrix: newMatrix, animation: 1 });
330
+ }
331
+ }
332
+ /** @internal */
333
+ componentWillUnmount() {
334
+ ViewportComponentEvents_1.ViewportComponentEvents.onViewRotationChangeEvent.removeListener(this._handleViewRotationChangeEvent);
335
+ clearTimeout(this._animationFrame);
336
+ this._mounted = false;
337
+ }
338
+ render() {
339
+ const { animation, startRotMatrix, endRotMatrix } = this.state;
340
+ const visible = CubeNavigationAid._isMatrixFace(endRotMatrix) && animation === 1.0;
341
+ const rotMatrix = CubeNavigationAid._interpolateRotMatrix(startRotMatrix, animation, endRotMatrix);
342
+ if (rotMatrix !== startRotMatrix && rotMatrix !== endRotMatrix)
343
+ ViewportComponentEvents_1.ViewportComponentEvents.setCubeMatrix(rotMatrix, Cube_1.Face.None);
344
+ const faces = {};
345
+ for (const key in this._labels) {
346
+ // istanbul ignore else
347
+ if (this._labels.hasOwnProperty(key)) {
348
+ const f = key;
349
+ const label = this._labels[f];
350
+ faces[f] =
351
+ React.createElement(NavCubeFace, { face: f, label: label, hoverMap: this.state.hoverMap, onFaceCellClick: this._handleFaceCellClick, onFaceCellHoverChange: this._handleCellHoverChange });
352
+ }
353
+ }
354
+ const cubeClassNames = (0, classnames_1.default)("nav-cube", this.state.dragging && "cube-dragging");
355
+ const upTitle = this.getArrowTitle(Pointer.Up);
356
+ const downTitle = this.getArrowTitle(Pointer.Down);
357
+ const leftTitle = this.getArrowTitle(Pointer.Left);
358
+ const rightTitle = this.getArrowTitle(Pointer.Right);
359
+ return (React.createElement("div", { className: (0, classnames_1.default)("components-cube-container", this.props.className), style: this.props.style, "data-testid": "components-cube-navigation-aid", onMouseDown: this._handleBoxMouseDown, onTouchStart: this._handleBoxTouchStart, role: "presentation" },
360
+ React.createElement("div", { className: "cube-element-container" },
361
+ React.createElement(Cube_1.Cube, { className: cubeClassNames, rotMatrix: rotMatrix, faces: faces })),
362
+ React.createElement(PointerButton, { "data-testid": "cube-pointer-button-up", visible: visible, pointerType: Pointer.Up, onArrowClick: this._onArrowClick, title: upTitle }),
363
+ React.createElement(PointerButton, { "data-testid": "cube-pointer-button-down", visible: visible, pointerType: Pointer.Down, onArrowClick: this._onArrowClick, title: downTitle }),
364
+ React.createElement(PointerButton, { "data-testid": "cube-pointer-button-left", visible: visible, pointerType: Pointer.Left, onArrowClick: this._onArrowClick, title: leftTitle }),
365
+ React.createElement(PointerButton, { "data-testid": "cube-pointer-button-right", visible: visible, pointerType: Pointer.Right, onArrowClick: this._onArrowClick, title: rightTitle })));
366
+ }
367
+ static correctSmallNumber(value, tolerance) {
368
+ return Math.abs(value) < tolerance ? 0 : value;
369
+ }
370
+ /**
371
+ * Snap coordinates of a vector to zero and to each other so that the vector prefers to be
372
+ * * perpendicular to a face of the unit cube.
373
+ * * or pass through a nearby vertex or edge of the unit cube.
374
+ * @param zVector existing z vector.
375
+ * @param tolerance tolerance to determine if a z vector component is close to zero or 1.
376
+ */
377
+ static snapVectorToCubeFeatures(zVector, tolerance) {
378
+ const x = CubeNavigationAid.correctSmallNumber(zVector.x, tolerance);
379
+ let y = CubeNavigationAid.correctSmallNumber(zVector.y, tolerance);
380
+ let z = CubeNavigationAid.correctSmallNumber(zVector.z, tolerance);
381
+ const xx = Math.abs(x);
382
+ const yy = Math.abs(y);
383
+ const zz = Math.abs(z);
384
+ // adjust any adjacent pair of near equal values to the first.
385
+ // istanbul ignore next
386
+ if (core_geometry_1.Geometry.isSameCoordinate(xx, yy, tolerance)) {
387
+ y = core_geometry_1.Geometry.split3WaySign(y, -xx, xx, xx);
388
+ }
389
+ if (core_geometry_1.Geometry.isSameCoordinate(yy, zz, tolerance)) {
390
+ z = core_geometry_1.Geometry.split3WaySign(z, -yy, yy, yy);
391
+ }
392
+ if (core_geometry_1.Geometry.isSameCoordinate(xx, zz, tolerance)) {
393
+ z = core_geometry_1.Geometry.split3WaySign(z, -xx, xx, xx);
394
+ }
395
+ return core_geometry_1.Vector3d.create(x, y, z);
396
+ }
397
+ /**
398
+ * Adjust a worldToView matrix to favor both
399
+ * * direct view at faces, edges, and corners of a view cube.
400
+ * * heads up
401
+ * @param worldToView candidate matrix
402
+ * @param tolerance tolerance for cleaning up fuzz. The default (1.0e-6) is appropriate if very dirty viewing operations are expected.
403
+ * @param result optional result.
404
+ */
405
+ static snapWorldToViewMatrixToCubeFeatures(worldToView, tolerance, result) {
406
+ const oldZ = worldToView.rowZ();
407
+ const newZ = CubeNavigationAid.snapVectorToCubeFeatures(oldZ, tolerance);
408
+ // If newZ is true up or down, it will have true 0 for x and y.
409
+ // special case this to take x direction from the input.
410
+ // istanbul ignore next
411
+ if (newZ.x === 0.0 && newZ.y === 0) {
412
+ const perpVector = worldToView.rowX();
413
+ result = core_geometry_1.Matrix3d.createRigidFromColumns(newZ, perpVector, core_geometry_1.AxisOrder.ZXY, result);
414
+ }
415
+ else {
416
+ result = core_geometry_1.Matrix3d.createRigidViewAxesZTowardsEye(newZ.x, newZ.y, newZ.z, result);
417
+ }
418
+ // istanbul ignore else
419
+ if (result)
420
+ result.transposeInPlace();
421
+ return result;
422
+ }
423
+ getArrowRotationAndFace(arrow) {
424
+ const localRotationAxis = core_geometry_1.Vector3d.create(0, 0, 0);
425
+ switch (arrow) {
426
+ case Pointer.Up:
427
+ localRotationAxis.x = -1.0;
428
+ break;
429
+ case Pointer.Down:
430
+ localRotationAxis.x = 1.0;
431
+ break;
432
+ case Pointer.Left:
433
+ localRotationAxis.y = -1.0;
434
+ break;
435
+ default:
436
+ localRotationAxis.y = 1.0;
437
+ break;
438
+ }
439
+ const localRotation = core_geometry_1.Matrix3d.createRotationAroundVector(localRotationAxis, core_geometry_1.Angle.createDegrees(-90));
440
+ const newRotation = localRotation.multiplyMatrixMatrix(this.state.endRotMatrix);
441
+ CubeNavigationAid.snapWorldToViewMatrixToCubeFeatures(newRotation, DEFAULT_TOLERANCE, newRotation);
442
+ const face = CubeNavigationAid._getMatrixFace(newRotation);
443
+ return { newRotation, face };
444
+ }
445
+ getArrowTitle(arrow) {
446
+ const { face } = this.getArrowRotationAndFace(arrow);
447
+ return this._labels[face];
448
+ }
449
+ _processDrag(mousePos) {
450
+ // istanbul ignore else
451
+ if (!this._start.isAlmostEqual(mousePos)) {
452
+ const movement = mousePos.minus(this._lastClientXY);
453
+ const diff = movement.scale(0.05);
454
+ const yaw = core_geometry_1.Angle.createRadians(diff.x);
455
+ const pitch = core_geometry_1.Angle.createRadians(diff.y);
456
+ const matX = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.X, pitch);
457
+ const matZ = core_geometry_1.Matrix3d.createRotationAroundAxisIndex(core_geometry_1.AxisIndex.Z, yaw);
458
+ const mat = matX.multiplyMatrixMatrix(this.state.startRotMatrix).multiplyMatrixMatrix(matZ);
459
+ this._setRotation(mat, CubeNavigationAid._getMatrixFace(mat));
460
+ if (!this.state.dragging)
461
+ this.setState({ dragging: true });
462
+ }
463
+ this._lastClientXY = mousePos;
464
+ }
465
+ }
466
+ exports.CubeNavigationAid = CubeNavigationAid;
467
+ CubeNavigationAid._animationFn = (t) => t < .5 ? 2 * t ** 2 : -1 + (4 - 2 * t) * t;
468
+ CubeNavigationAid._isMatrixFace = (matrix) => {
469
+ let sum = 0;
470
+ for (const coff of matrix.coffs) {
471
+ if (core_geometry_1.Geometry.isAlmostEqualNumber(Math.abs(coff), 1))
472
+ sum++;
473
+ }
474
+ // Assuming matrix is a proper rotation matrix:
475
+ // if matrix viewing a face, there will be a total of 3 values either almost -1, or almost 1.
476
+ return sum === 3;
477
+ };
478
+ CubeNavigationAid._getMatrixFace = (rotMatrix) => {
479
+ if (!CubeNavigationAid._isMatrixFace(rotMatrix)) {
480
+ return Cube_1.Face.None;
481
+ }
482
+ let matrixFace = Cube_1.Face.None;
483
+ for (const face in cubeNavigationFaceRotations) {
484
+ // istanbul ignore else
485
+ if (face in cubeNavigationFaceRotations) {
486
+ const loc = cubeNavigationFaceRotations[face];
487
+ if (rotMatrix.isAlmostEqual(loc)) {
488
+ matrixFace = face;
489
+ break;
490
+ }
491
+ }
492
+ }
493
+ return matrixFace;
494
+ };
495
+ CubeNavigationAid._interpolateRotMatrix = (start, anim, end) => {
496
+ if (anim === 0)
497
+ return start;
498
+ if (anim === 1 || start.isAlmostEqual(end))
499
+ return end;
500
+ const startInverse = start.transpose();
501
+ const diff = end.multiplyMatrixMatrix(startInverse);
502
+ const angleAxis = diff.getAxisAndAngleOfRotation();
503
+ // istanbul ignore else
504
+ if (angleAxis.ok) {
505
+ const angle = core_geometry_1.Angle.createRadians(angleAxis.angle.radians * CubeNavigationAid._animationFn(anim));
506
+ const newDiff = core_geometry_1.Matrix3d.createRotationAroundVector(angleAxis.axis, angle);
507
+ // istanbul ignore else
508
+ if (newDiff) {
509
+ const newMatrix = newDiff.multiplyMatrixMatrix(start);
510
+ return newMatrix;
511
+ }
512
+ }
513
+ // istanbul ignore next
514
+ return end;
515
+ };
516
+ /** @internal */
517
+ class NavCubeFace extends React.Component {
518
+ render() {
519
+ const { face, hoverMap, onFaceCellClick, onFaceCellHoverChange, label } = this.props;
520
+ return (React.createElement("div", { className: "nav-cube-face", "data-testid": "nav-cube-face" }, [-1, 0, 1].map((y) => {
521
+ return (React.createElement(FaceRow, { key: y, center: y === 0 }, [-1, 0, 1].map((x) => {
522
+ return (React.createElement(FaceCell, { key: x, onFaceCellHoverChange: onFaceCellHoverChange, onFaceCellClick: onFaceCellClick, hoverMap: hoverMap, vector: NavCubeFace.faceCellToPos(face, x, y), face: face, center: x === 0 }, x === 0 && y === 0 &&
523
+ label));
524
+ })));
525
+ })));
526
+ }
527
+ }
528
+ exports.NavCubeFace = NavCubeFace;
529
+ NavCubeFace.faceCellToPos = (face, x, y) => {
530
+ const faceVect = cubeNavigationFaceLocs[face];
531
+ const route = cubeNavigationRoutes[face];
532
+ const faceX = x < 0 ? route.left : x > 0 ? route.right : Cube_1.Face.None;
533
+ const xVect = faceX !== Cube_1.Face.None ? cubeNavigationFaceLocs[faceX] : core_geometry_1.Vector3d.createZero();
534
+ const faceY = y < 0 ? route.up : y > 0 ? route.down : Cube_1.Face.None;
535
+ const yVect = faceY !== Cube_1.Face.None ? cubeNavigationFaceLocs[faceY] : core_geometry_1.Vector3d.createZero();
536
+ return faceVect.plus(xVect).plus(yVect);
537
+ };
538
+ class FaceRow extends React.Component {
539
+ render() {
540
+ const { center, children, ...props } = this.props;
541
+ const classNames = (0, classnames_1.default)("face-row", center && "cube-center");
542
+ return React.createElement("div", { className: classNames, ...props }, children);
543
+ }
544
+ }
545
+ /** @internal */
546
+ class FaceCell extends React.Component {
547
+ constructor() {
548
+ super(...arguments);
549
+ this._handleMouseOver = () => {
550
+ const { vector } = this.props;
551
+ this.props.onFaceCellHoverChange(vector, CubeHover.Hover);
552
+ };
553
+ this._handleMouseOut = () => {
554
+ const { vector } = this.props;
555
+ this.props.onFaceCellHoverChange(vector, CubeHover.None);
556
+ };
557
+ this._handleMouseDown = (event) => {
558
+ const { clientX, clientY } = event;
559
+ this.handlePointerDown(clientX, clientY);
560
+ };
561
+ this._handleMouseUp = (event) => {
562
+ const { clientX, clientY } = event;
563
+ this.handlePointerUp(clientX, clientY);
564
+ };
565
+ this._handleTouchStart = (event) => {
566
+ event.preventDefault();
567
+ event.targetTouches.length === 1 && this.handlePointerDown(event.targetTouches[0].clientX, event.targetTouches[0].clientY);
568
+ };
569
+ this._handleTouchEnd = (event) => {
570
+ event.preventDefault();
571
+ event.changedTouches.length === 1 && this.handlePointerUp(event.changedTouches[0].clientX, event.changedTouches[0].clientY);
572
+ };
573
+ }
574
+ render() {
575
+ const { center, children, onFaceCellClick, onFaceCellHoverChange, hoverMap, face, vector, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars
576
+ const { x, y, z } = vector;
577
+ const n = `${x}-${y}-${z}`;
578
+ const hover = hoverMap[n] === CubeHover.Hover;
579
+ const active = hoverMap[n] === CubeHover.Active;
580
+ const classNames = (0, classnames_1.default)("face-cell", center && "cube-center", hover && "cube-hover", active && "cube-active");
581
+ // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
582
+ return React.createElement("div", { onMouseDown: this._handleMouseDown, onMouseUp: this._handleMouseUp, onMouseOver: this._handleMouseOver, onMouseOut: this._handleMouseOut, onTouchStart: this._handleTouchStart, onTouchEnd: this._handleTouchEnd, "data-testid": `nav-cube-face-cell-${face}-${n}`, className: classNames, role: "presentation", ...props }, children);
583
+ }
584
+ handlePointerDown(x, y) {
585
+ const { vector } = this.props;
586
+ this._startMouse = core_geometry_1.Point2d.create(x, y);
587
+ this.props.onFaceCellHoverChange(vector, CubeHover.Active);
588
+ }
589
+ handlePointerUp(x, y) {
590
+ const { vector, face } = this.props;
591
+ this.props.onFaceCellHoverChange(vector, CubeHover.None);
592
+ const mouse = core_geometry_1.Point2d.create(x, y);
593
+ if (this._startMouse && this._startMouse.isAlmostEqual(mouse)) {
594
+ const isFace = Math.abs(vector.x) + Math.abs(vector.y) + Math.abs(vector.z) === 1;
595
+ this.props.onFaceCellClick(vector, isFace ? face : Cube_1.Face.None);
596
+ }
597
+ }
598
+ }
599
+ exports.FaceCell = FaceCell;
600
+ var Pointer;
601
+ (function (Pointer) {
602
+ Pointer[Pointer["None"] = 0] = "None";
603
+ Pointer[Pointer["Up"] = 1] = "Up";
604
+ Pointer[Pointer["Down"] = 2] = "Down";
605
+ Pointer[Pointer["Left"] = 3] = "Left";
606
+ Pointer[Pointer["Right"] = 4] = "Right";
607
+ })(Pointer || (Pointer = {}));
608
+ const pointerIconSpec = {
609
+ [Pointer.Up]: React.createElement(itwinui_icons_react_1.SvgCaretDownSmall, null),
610
+ [Pointer.Down]: React.createElement(itwinui_icons_react_1.SvgCaretUpSmall, null),
611
+ [Pointer.Left]: React.createElement(itwinui_icons_react_1.SvgCaretRightSmall, null),
612
+ [Pointer.Right]: React.createElement(itwinui_icons_react_1.SvgCaretLeftSmall, null),
613
+ };
614
+ const pointerClass = {
615
+ [Pointer.Up]: "cube-up",
616
+ [Pointer.Down]: "cube-down",
617
+ [Pointer.Left]: "cube-left",
618
+ [Pointer.Right]: "cube-right",
619
+ };
620
+ class PointerButton extends React.Component {
621
+ constructor() {
622
+ super(...arguments);
623
+ this._handleClick = (event) => {
624
+ const { pointerType } = this.props;
625
+ event.preventDefault();
626
+ this.props.onArrowClick(pointerType);
627
+ };
628
+ }
629
+ render() {
630
+ const { visible, pointerType, onArrowClick, title, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars
631
+ const classes = (0, classnames_1.default)("cube-pointer", "icon", pointerClass[pointerType], visible && "cube-visible");
632
+ return (
633
+ // eslint-disable-next-line jsx-a11y/click-events-have-key-events
634
+ React.createElement("div", { className: classes, role: "button", tabIndex: -1, title: title, ...props, onClick: this._handleClick },
635
+ React.createElement(core_react_1.Icon, { iconSpec: pointerIconSpec[pointerType] }),
636
+ " "));
637
+ }
638
+ }
635
639
  //# sourceMappingURL=CubeNavigationAid.js.map