@itwin/imodel-components-react 4.0.0-dev.11 → 4.0.0-dev.13

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