@itwin/imodel-components-react 3.6.0-dev.7 → 4.0.0-dev.2

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