@itwin/imodel-components-react 4.0.0-dev.9 → 4.0.1

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