@itwin/imodel-components-react 4.0.0-dev.8 → 4.0.0

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