@itwin/imodel-components-react 3.7.12 → 3.7.13

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