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

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