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

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