@fc3/wireframe-renderer 0.0.0-stage → 0.1.0

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 (264) hide show
  1. package/LICENSE +673 -0
  2. package/README.md +123 -2
  3. package/bin/compile +55 -0
  4. package/bin/install +5 -0
  5. package/bin/lint +12 -0
  6. package/bin/postpublish +5 -0
  7. package/bin/precompile +71 -0
  8. package/bin/prepublish +7 -0
  9. package/bin/remap-paths +172 -0
  10. package/bin/test +9 -0
  11. package/bin/test-one +32 -0
  12. package/dist/.last-compile-time +1 -0
  13. package/dist/.last-publish-time +1 -0
  14. package/dist/src/camera.d.ts +26 -0
  15. package/dist/src/camera.js +90 -0
  16. package/dist/src/camera.js.map +1 -0
  17. package/dist/src/canvas-renderer.d.ts +22 -0
  18. package/dist/src/canvas-renderer.js +183 -0
  19. package/dist/src/canvas-renderer.js.map +1 -0
  20. package/dist/src/constant/axis-colors.d.ts +3 -0
  21. package/dist/src/constant/axis-colors.js +13 -0
  22. package/dist/src/constant/axis-colors.js.map +1 -0
  23. package/dist/src/constant/box-edge-index-pairs.d.ts +2 -0
  24. package/dist/src/constant/box-edge-index-pairs.js +18 -0
  25. package/dist/src/constant/box-edge-index-pairs.js.map +1 -0
  26. package/dist/src/constant/camera-limits.d.ts +7 -0
  27. package/dist/src/constant/camera-limits.js +10 -0
  28. package/dist/src/constant/camera-limits.js.map +1 -0
  29. package/dist/src/constant/default-camera-state.d.ts +3 -0
  30. package/dist/src/constant/default-camera-state.js +19 -0
  31. package/dist/src/constant/default-camera-state.js.map +1 -0
  32. package/dist/src/constant/default-palette.d.ts +2 -0
  33. package/dist/src/constant/default-palette.js +17 -0
  34. package/dist/src/constant/default-palette.js.map +1 -0
  35. package/dist/src/constant/interaction-rates.d.ts +5 -0
  36. package/dist/src/constant/interaction-rates.js +8 -0
  37. package/dist/src/constant/interaction-rates.js.map +1 -0
  38. package/dist/src/constant/rendering-defaults.d.ts +11 -0
  39. package/dist/src/constant/rendering-defaults.js +14 -0
  40. package/dist/src/constant/rendering-defaults.js.map +1 -0
  41. package/dist/src/constant/stylesheet.d.ts +2 -0
  42. package/dist/src/constant/stylesheet.js +140 -0
  43. package/dist/src/constant/stylesheet.js.map +1 -0
  44. package/dist/src/constant/theme.d.ts +9 -0
  45. package/dist/src/constant/theme.js +12 -0
  46. package/dist/src/constant/theme.js.map +1 -0
  47. package/dist/src/constant/view-orientations.d.ts +4 -0
  48. package/dist/src/constant/view-orientations.js +19 -0
  49. package/dist/src/constant/view-orientations.js.map +1 -0
  50. package/dist/src/enum/axis.d.ts +6 -0
  51. package/dist/src/enum/axis.js +10 -0
  52. package/dist/src/enum/axis.js.map +1 -0
  53. package/dist/src/enum/opening-shape.d.ts +5 -0
  54. package/dist/src/enum/opening-shape.js +9 -0
  55. package/dist/src/enum/opening-shape.js.map +1 -0
  56. package/dist/src/enum/plane.d.ts +6 -0
  57. package/dist/src/enum/plane.js +10 -0
  58. package/dist/src/enum/plane.js.map +1 -0
  59. package/dist/src/enum/primitive-type.d.ts +8 -0
  60. package/dist/src/enum/primitive-type.js +12 -0
  61. package/dist/src/enum/primitive-type.js.map +1 -0
  62. package/dist/src/enum/view-preset.d.ts +10 -0
  63. package/dist/src/enum/view-preset.js +14 -0
  64. package/dist/src/enum/view-preset.js.map +1 -0
  65. package/dist/src/enum/viewer-class-name.d.ts +15 -0
  66. package/dist/src/enum/viewer-class-name.js +19 -0
  67. package/dist/src/enum/viewer-class-name.js.map +1 -0
  68. package/dist/src/example/house-computer.d.ts +3 -0
  69. package/dist/src/example/house-computer.js +2081 -0
  70. package/dist/src/example/house-computer.js.map +1 -0
  71. package/dist/src/index.d.ts +20 -0
  72. package/dist/src/index.js +27 -0
  73. package/dist/src/index.js.map +1 -0
  74. package/dist/src/interaction-controller.d.ts +17 -0
  75. package/dist/src/interaction-controller.js +106 -0
  76. package/dist/src/interaction-controller.js.map +1 -0
  77. package/dist/src/sidebar.d.ts +24 -0
  78. package/dist/src/sidebar.js +121 -0
  79. package/dist/src/sidebar.js.map +1 -0
  80. package/dist/src/type/bounding-box.d.ts +6 -0
  81. package/dist/src/type/bounding-box.js +3 -0
  82. package/dist/src/type/bounding-box.js.map +1 -0
  83. package/dist/src/type/camera-state.d.ts +10 -0
  84. package/dist/src/type/camera-state.js +3 -0
  85. package/dist/src/type/camera-state.js.map +1 -0
  86. package/dist/src/type/display-component.d.ts +18 -0
  87. package/dist/src/type/display-component.js +3 -0
  88. package/dist/src/type/display-component.js.map +1 -0
  89. package/dist/src/type/drag-state.d.ts +6 -0
  90. package/dist/src/type/drag-state.js +3 -0
  91. package/dist/src/type/drag-state.js.map +1 -0
  92. package/dist/src/type/inherited-style.d.ts +8 -0
  93. package/dist/src/type/inherited-style.js +3 -0
  94. package/dist/src/type/inherited-style.js.map +1 -0
  95. package/dist/src/type/plane-axes.d.ts +7 -0
  96. package/dist/src/type/plane-axes.js +3 -0
  97. package/dist/src/type/plane-axes.js.map +1 -0
  98. package/dist/src/type/polyline.d.ts +3 -0
  99. package/dist/src/type/polyline.js +3 -0
  100. package/dist/src/type/polyline.js.map +1 -0
  101. package/dist/src/type/primitive/box.d.ts +8 -0
  102. package/dist/src/type/primitive/box.js +3 -0
  103. package/dist/src/type/primitive/box.js.map +1 -0
  104. package/dist/src/type/primitive/cylinder.d.ts +11 -0
  105. package/dist/src/type/primitive/cylinder.js +3 -0
  106. package/dist/src/type/primitive/cylinder.js.map +1 -0
  107. package/dist/src/type/primitive/opening.d.ts +24 -0
  108. package/dist/src/type/primitive/opening.js +3 -0
  109. package/dist/src/type/primitive/opening.js.map +1 -0
  110. package/dist/src/type/primitive/polyline.d.ts +8 -0
  111. package/dist/src/type/primitive/polyline.js +3 -0
  112. package/dist/src/type/primitive/polyline.js.map +1 -0
  113. package/dist/src/type/primitive/sphere.d.ts +8 -0
  114. package/dist/src/type/primitive/sphere.js +3 -0
  115. package/dist/src/type/primitive/sphere.js.map +1 -0
  116. package/dist/src/type/primitive-geometry.d.ts +9 -0
  117. package/dist/src/type/primitive-geometry.js +3 -0
  118. package/dist/src/type/primitive-geometry.js.map +1 -0
  119. package/dist/src/type/primitive.d.ts +7 -0
  120. package/dist/src/type/primitive.js +3 -0
  121. package/dist/src/type/primitive.js.map +1 -0
  122. package/dist/src/type/render-options.d.ts +5 -0
  123. package/dist/src/type/render-options.js +3 -0
  124. package/dist/src/type/render-options.js.map +1 -0
  125. package/dist/src/type/screen-point.d.ts +5 -0
  126. package/dist/src/type/screen-point.js +3 -0
  127. package/dist/src/type/screen-point.js.map +1 -0
  128. package/dist/src/type/sidebar-callbacks.d.ts +9 -0
  129. package/dist/src/type/sidebar-callbacks.js +3 -0
  130. package/dist/src/type/sidebar-callbacks.js.map +1 -0
  131. package/dist/src/type/stroke.d.ts +6 -0
  132. package/dist/src/type/stroke.js +3 -0
  133. package/dist/src/type/stroke.js.map +1 -0
  134. package/dist/src/type/vector3.d.ts +6 -0
  135. package/dist/src/type/vector3.js +3 -0
  136. package/dist/src/type/vector3.js.map +1 -0
  137. package/dist/src/type/view-orientation.d.ts +5 -0
  138. package/dist/src/type/view-orientation.js +3 -0
  139. package/dist/src/type/view-orientation.js.map +1 -0
  140. package/dist/src/type/viewport.d.ts +5 -0
  141. package/dist/src/type/viewport.js +3 -0
  142. package/dist/src/type/viewport.js.map +1 -0
  143. package/dist/src/type/visibility-map.d.ts +2 -0
  144. package/dist/src/type/visibility-map.js +3 -0
  145. package/dist/src/type/visibility-map.js.map +1 -0
  146. package/dist/src/type/wireframe-component.d.ts +13 -0
  147. package/dist/src/type/wireframe-component.js +3 -0
  148. package/dist/src/type/wireframe-component.js.map +1 -0
  149. package/dist/src/type/wireframe-scene.d.ts +10 -0
  150. package/dist/src/type/wireframe-scene.js +3 -0
  151. package/dist/src/type/wireframe-scene.js.map +1 -0
  152. package/dist/src/utility/add-vectors.d.ts +3 -0
  153. package/dist/src/utility/add-vectors.js +11 -0
  154. package/dist/src/utility/add-vectors.js.map +1 -0
  155. package/dist/src/utility/build-box-outlines.d.ts +4 -0
  156. package/dist/src/utility/build-box-outlines.js +32 -0
  157. package/dist/src/utility/build-box-outlines.js.map +1 -0
  158. package/dist/src/utility/build-circle-outline.d.ts +5 -0
  159. package/dist/src/utility/build-circle-outline.js +25 -0
  160. package/dist/src/utility/build-circle-outline.js.map +1 -0
  161. package/dist/src/utility/build-cylinder-outlines.d.ts +4 -0
  162. package/dist/src/utility/build-cylinder-outlines.js +34 -0
  163. package/dist/src/utility/build-cylinder-outlines.js.map +1 -0
  164. package/dist/src/utility/build-initial-visibility.d.ts +4 -0
  165. package/dist/src/utility/build-initial-visibility.js +11 -0
  166. package/dist/src/utility/build-initial-visibility.js.map +1 -0
  167. package/dist/src/utility/build-opening-outlines.d.ts +4 -0
  168. package/dist/src/utility/build-opening-outlines.js +31 -0
  169. package/dist/src/utility/build-opening-outlines.js.map +1 -0
  170. package/dist/src/utility/build-primitive-geometry.d.ts +4 -0
  171. package/dist/src/utility/build-primitive-geometry.js +40 -0
  172. package/dist/src/utility/build-primitive-geometry.js.map +1 -0
  173. package/dist/src/utility/build-rectangle-outline.d.ts +5 -0
  174. package/dist/src/utility/build-rectangle-outline.js +23 -0
  175. package/dist/src/utility/build-rectangle-outline.js.map +1 -0
  176. package/dist/src/utility/build-sphere-outlines.d.ts +4 -0
  177. package/dist/src/utility/build-sphere-outlines.js +16 -0
  178. package/dist/src/utility/build-sphere-outlines.js.map +1 -0
  179. package/dist/src/utility/clamp.d.ts +2 -0
  180. package/dist/src/utility/clamp.js +7 -0
  181. package/dist/src/utility/clamp.js.map +1 -0
  182. package/dist/src/utility/collect-display-points.d.ts +4 -0
  183. package/dist/src/utility/collect-display-points.js +13 -0
  184. package/dist/src/utility/collect-display-points.js.map +1 -0
  185. package/dist/src/utility/compute-bounding-box.d.ts +4 -0
  186. package/dist/src/utility/compute-bounding-box.js +29 -0
  187. package/dist/src/utility/compute-bounding-box.js.map +1 -0
  188. package/dist/src/utility/compute-centroid.d.ts +3 -0
  189. package/dist/src/utility/compute-centroid.js +17 -0
  190. package/dist/src/utility/compute-centroid.js.map +1 -0
  191. package/dist/src/utility/create-element.d.ts +2 -0
  192. package/dist/src/utility/create-element.js +11 -0
  193. package/dist/src/utility/create-element.js.map +1 -0
  194. package/dist/src/utility/fit-camera-to-bounding-box.d.ts +4 -0
  195. package/dist/src/utility/fit-camera-to-bounding-box.js +23 -0
  196. package/dist/src/utility/fit-camera-to-bounding-box.js.map +1 -0
  197. package/dist/src/utility/flatten-components.d.ts +4 -0
  198. package/dist/src/utility/flatten-components.js +70 -0
  199. package/dist/src/utility/flatten-components.js.map +1 -0
  200. package/dist/src/utility/get-bounding-box-center.d.ts +4 -0
  201. package/dist/src/utility/get-bounding-box-center.js +14 -0
  202. package/dist/src/utility/get-bounding-box-center.js.map +1 -0
  203. package/dist/src/utility/get-bounding-box-size.d.ts +4 -0
  204. package/dist/src/utility/get-bounding-box-size.js +12 -0
  205. package/dist/src/utility/get-bounding-box-size.js.map +1 -0
  206. package/dist/src/utility/get-focal-length.d.ts +2 -0
  207. package/dist/src/utility/get-focal-length.js +9 -0
  208. package/dist/src/utility/get-focal-length.js.map +1 -0
  209. package/dist/src/utility/get-perpendicular-axes.d.ts +3 -0
  210. package/dist/src/utility/get-perpendicular-axes.js +18 -0
  211. package/dist/src/utility/get-perpendicular-axes.js.map +1 -0
  212. package/dist/src/utility/get-plane-axes.d.ts +4 -0
  213. package/dist/src/utility/get-plane-axes.js +19 -0
  214. package/dist/src/utility/get-plane-axes.js.map +1 -0
  215. package/dist/src/utility/get-primitive-anchor.d.ts +4 -0
  216. package/dist/src/utility/get-primitive-anchor.js +20 -0
  217. package/dist/src/utility/get-primitive-anchor.js.map +1 -0
  218. package/dist/src/utility/get-vector-component.d.ts +4 -0
  219. package/dist/src/utility/get-vector-component.js +18 -0
  220. package/dist/src/utility/get-vector-component.js.map +1 -0
  221. package/dist/src/utility/get-vector-length.d.ts +3 -0
  222. package/dist/src/utility/get-vector-length.js +7 -0
  223. package/dist/src/utility/get-vector-length.js.map +1 -0
  224. package/dist/src/utility/has-hidden-ancestor.d.ts +4 -0
  225. package/dist/src/utility/has-hidden-ancestor.js +9 -0
  226. package/dist/src/utility/has-hidden-ancestor.js.map +1 -0
  227. package/dist/src/utility/inject-stylesheet.d.ts +2 -0
  228. package/dist/src/utility/inject-stylesheet.js +21 -0
  229. package/dist/src/utility/inject-stylesheet.js.map +1 -0
  230. package/dist/src/utility/is-component-shown.d.ts +4 -0
  231. package/dist/src/utility/is-component-shown.js +10 -0
  232. package/dist/src/utility/is-component-shown.js.map +1 -0
  233. package/dist/src/utility/offset-vector-along-axis.d.ts +4 -0
  234. package/dist/src/utility/offset-vector-along-axis.js +14 -0
  235. package/dist/src/utility/offset-vector-along-axis.js.map +1 -0
  236. package/dist/src/utility/pick-palette-color.d.ts +2 -0
  237. package/dist/src/utility/pick-palette-color.js +12 -0
  238. package/dist/src/utility/pick-palette-color.js.map +1 -0
  239. package/dist/src/utility/project-vector.d.ts +6 -0
  240. package/dist/src/utility/project-vector.js +30 -0
  241. package/dist/src/utility/project-vector.js.map +1 -0
  242. package/dist/src/utility/rotate-vector.d.ts +3 -0
  243. package/dist/src/utility/rotate-vector.js +17 -0
  244. package/dist/src/utility/rotate-vector.js.map +1 -0
  245. package/dist/src/utility/scale-vector.d.ts +3 -0
  246. package/dist/src/utility/scale-vector.js +11 -0
  247. package/dist/src/utility/scale-vector.js.map +1 -0
  248. package/dist/src/utility/subtract-vectors.d.ts +3 -0
  249. package/dist/src/utility/subtract-vectors.js +11 -0
  250. package/dist/src/utility/subtract-vectors.js.map +1 -0
  251. package/dist/src/utility/unrotate-vector.d.ts +3 -0
  252. package/dist/src/utility/unrotate-vector.js +17 -0
  253. package/dist/src/utility/unrotate-vector.js.map +1 -0
  254. package/dist/src/utility/validate-scene.d.ts +3 -0
  255. package/dist/src/utility/validate-scene.js +70 -0
  256. package/dist/src/utility/validate-scene.js.map +1 -0
  257. package/dist/src/utility/with-vector-component.d.ts +4 -0
  258. package/dist/src/utility/with-vector-component.js +18 -0
  259. package/dist/src/utility/with-vector-component.js.map +1 -0
  260. package/dist/src/wireframe-viewer.d.ts +27 -0
  261. package/dist/src/wireframe-viewer.js +144 -0
  262. package/dist/src/wireframe-viewer.js.map +1 -0
  263. package/dist/tsconfig.tsbuildinfo +1 -0
  264. package/package.json +44 -5
package/README.md CHANGED
@@ -1,3 +1,124 @@
1
- # Temporary Holding Version
1
+ # @fc3/wireframe-renderer
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A dependency-light 3D wireframe viewer for the browser. It takes a typed
4
+ scene object describing nested components built from a handful of
5
+ primitives, and renders them to a 2D canvas with an orbit camera and a
6
+ sidebar that lets the viewer toggle each component on and off.
7
+
8
+ The renderer knows nothing about what it is drawing. Grouping, colors,
9
+ labels, and default visibility all come from the scene you hand it.
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import {WireframeViewer, WireframeScene} from '@fc3/wireframe-renderer';
15
+
16
+ const scene: WireframeScene = {
17
+ title: 'Enclosure',
18
+ subtitle: 'Rev A',
19
+ units: 'mm',
20
+ components: [
21
+ /* see below */
22
+ ]
23
+ };
24
+
25
+ const container = document.getElementById('viewer');
26
+ const viewer = new WireframeViewer(container, scene);
27
+
28
+ viewer.mount();
29
+ ```
30
+
31
+ The viewer fills its container, so give the container a size. Call
32
+ `viewer.unmount()` to tear it down. `viewer.setComponentVisible(id, visible)`
33
+ toggles a component programmatically, and `viewer.getCamera()` exposes the
34
+ camera for scripted views.
35
+
36
+ This package ships CommonJS output under `dist/`. Bundling for the browser is
37
+ left to the consuming project.
38
+
39
+ ## Scene shape
40
+
41
+ ```ts
42
+ type WireframeScene = {
43
+ title: string;
44
+ subtitle?: string;
45
+ units?: string;
46
+ components: WireframeComponent[];
47
+ camera?: Partial<CameraState>;
48
+ };
49
+
50
+ interface WireframeComponent {
51
+ id: string;
52
+ label?: string;
53
+ note?: string;
54
+ color?: string;
55
+ alpha?: number;
56
+ line_width?: number;
57
+ visible?: boolean;
58
+ primitives?: Primitive[];
59
+ children?: WireframeComponent[];
60
+ }
61
+ ```
62
+
63
+ Components nest to any depth. The sidebar lists them depth first, indented by
64
+ level, each with a checkbox. Hiding a component hides its whole subtree and
65
+ disables the descendants' checkboxes until it is shown again.
66
+
67
+ Ids must be unique across the whole tree. `label` defaults to the id. `note`
68
+ appears as a tooltip on the sidebar row.
69
+
70
+ Top-level components without a `color` take successive colors from a built-in
71
+ palette. Children inherit `color`, `alpha`, and `line_width` from their parent
72
+ unless they set their own.
73
+
74
+ `visible` defaults to `true`. Set it to `false` for alternatives that should
75
+ start hidden; the viewer can switch them on.
76
+
77
+ The camera fits itself to the bounding box of every component on load.
78
+ Anything in `camera` overrides the fitted values.
79
+
80
+ ## Primitives
81
+
82
+ All coordinates are world units. Vectors are `{x, y, z}`.
83
+
84
+ | type | fields |
85
+ | ---------- | -------------------------------------------------------- |
86
+ | `box` | `center`, `size` |
87
+ | `cylinder` | `center`, `axis` (`Axis.X`, `Axis.Y`, `Axis.Z`), `radius`, `length` |
88
+ | `sphere` | `center`, `radius` |
89
+ | `polyline` | `points` (two or more), optional `width` |
90
+ | `opening` | `shape`, `plane`, `center`, `depth`, plus `width` and `height` for `OpeningShape.RECTANGLE` or `radius` for `OpeningShape.CIRCLE` |
91
+
92
+ An opening is a hole through a wall. `plane` names the wall's face
93
+ (`Plane.XY`, `Plane.XZ`, `Plane.YZ`), `center` sits in the middle of the
94
+ wall's thickness, and `depth` is that thickness. The outline is drawn on both
95
+ faces. Openings are ordinary primitives, so put them in their own child
96
+ component to make them toggleable on their own.
97
+
98
+ Polylines are drawn thicker than outlines, with a dot at each end.
99
+
100
+ ## Sidebar
101
+
102
+ - View buttons for front, back, left, right, top, under, and isometric.
103
+ - Perspective toggle.
104
+ - Labels toggle, drawing each shown component's label at its centroid.
105
+ - Ground reference toggle, drawing a faint rectangle under the scene.
106
+ - The component tree.
107
+
108
+ Drag to orbit, shift-drag or right-drag to pan, wheel or pinch to zoom.
109
+
110
+ ## Example
111
+
112
+ `HOUSE_COMPUTER_SCENE` is exported as a worked example: a small enclosure
113
+ with nine top-level groups and a few alternatives that start hidden.
114
+
115
+ ## Development
116
+
117
+ ```
118
+ npm install
119
+ ./bin/test
120
+ ./bin/lint
121
+ ```
122
+
123
+ Unit tests live under `test/unit/` mirroring `src/`. The canvas and DOM
124
+ classes are not unit tested; everything beneath them is.
package/bin/compile ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env bash
2
+
3
+ if [[ $1 == '--help' ]]; then
4
+ echo "Triggers recompilation of the source code for the current project."
5
+ echo "Supported flags:"
6
+ echo "--force : Bypasses any precompilation checks (cache, mutex, etc)"
7
+ echo " Use this if you want to recompile no matter what."
8
+ echo " "
9
+ exit 0
10
+ fi
11
+
12
+ if [[ $1 != '--force' ]]; then
13
+ ./bin/precompile
14
+
15
+ case $? in
16
+ 1)
17
+ exit 1
18
+ ;;
19
+ 3)
20
+ exit 0
21
+ ;;
22
+ esac
23
+ fi
24
+
25
+ echo "Recompiling..."
26
+ mkdir -p dist
27
+ echo $$ > dist/.compile-lock
28
+ rm -f dist/.last-compile-time
29
+
30
+ project_dir="$(dirname $(dirname "$0"))"
31
+
32
+ if [[ $1 == '--force' ]]; then
33
+ rm -rf dist/src
34
+ rm -rf dist/test
35
+ ./node_modules/.bin/tsc --declaration --project "$project_dir/config/tsconfig.json"
36
+ else
37
+ ./node_modules/.bin/tsc --declaration --incremental --project "$project_dir/config/tsconfig.json"
38
+ fi
39
+
40
+ exit_status=$?
41
+
42
+ if [[ $exit_status -eq 0 ]]; then
43
+ ./bin/remap-paths
44
+ echo $(date +%s) > dist/.last-compile-time
45
+ fi
46
+
47
+ pid=$(cat dist/.compile-lock)
48
+
49
+ if [[ $pid == $$ ]]; then
50
+ rm dist/.compile-lock
51
+ exit $exit_status
52
+ else
53
+ echo "Detected a conflicting compile lock..."
54
+ exit 1
55
+ fi
package/bin/install ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ ./bin/compile
package/bin/lint ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ if [[ "${1:-}" == "--fix" ]]; then
6
+ ./node_modules/.bin/eslint "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}" --fix
7
+ ./node_modules/.bin/prettier --write "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}"
8
+ else
9
+ ./node_modules/.bin/eslint "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}"
10
+ ./node_modules/.bin/prettier --check "src/**/*.{ts,tsx}" "test/unit/**/*.{ts,tsx}"
11
+ fi
12
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ rm ./dist/.last-publish-time
package/bin/precompile ADDED
@@ -0,0 +1,71 @@
1
+ #!/usr/bin/env bash
2
+
3
+ mkdir -p dist
4
+
5
+ if [ -f dist/.compile-lock ]; then
6
+ pid=$(cat dist/.compile-lock)
7
+ ticks=0
8
+ max_ticks=10
9
+
10
+ if ! ps -p $pid > /dev/null; then
11
+ echo "Detected a stale compile lock; deleting..."
12
+ rm -f dist/.compile-lock
13
+ else
14
+ echo "Compilation already in progress; waiting up to $max_ticks seconds..."
15
+ fi
16
+
17
+ while [ -f dist/.compile-lock ]; do
18
+ sleep 1
19
+ let ticks=ticks+1
20
+
21
+ if [ $ticks -ge $max_ticks ]; then
22
+ echo "Timed out waiting for compilation to clear"
23
+ exit 1
24
+ fi
25
+ done
26
+ fi
27
+
28
+ if [[ -f ./dist/.last-publish-time && ! -d src ]]; then
29
+ echo "Found publication compile artifact; skipping recompilation."
30
+ exit 3
31
+ fi
32
+
33
+ missing_output=false
34
+
35
+ if [ -d src ] && [ ! -d dist/src ]; then
36
+ missing_output=true
37
+ fi
38
+
39
+ if [ -d test ] && [ ! -d dist/test ]; then
40
+ missing_output=true
41
+ fi
42
+
43
+ if [[ $missing_output == true ]]; then
44
+ # The incremental build cache would otherwise skip re-emitting files.
45
+ rm -f dist/tsconfig.tsbuildinfo
46
+ exit 0
47
+ fi
48
+
49
+ if [ -f dist/.last-compile-time ]; then
50
+ if [ ! -d src ]; then
51
+ # TODO: Confirm we're within a deploy environment
52
+ echo "src folder does not exist; skipping recompilation."
53
+ exit 3
54
+ fi
55
+
56
+ typeset -i last_modification_time=$(find src test -type f -print0 |
57
+ xargs -0 stat -c "%Y %N" |
58
+ sort -rn |
59
+ head -1 |
60
+ awk '{ print $1 }')
61
+
62
+ typeset -i last_compile_time=$(cat dist/.last-compile-time)
63
+
64
+ if (( $last_compile_time > $last_modification_time )); then
65
+ echo "No changes since last compile; skipping recompilation."
66
+ exit 3
67
+ fi
68
+ fi
69
+
70
+ # Compilation should occur.
71
+ exit 0
package/bin/prepublish ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ ./bin/compile
6
+
7
+ date +%s > ./dist/.last-publish-time
@@ -0,0 +1,172 @@
1
+ #!/usr/bin/env node
2
+
3
+ const FS = require('fs');
4
+ const Path = require('path');
5
+
6
+ const JAVASCRIPT_EXTENSION = '.js';
7
+ const DECLARATION_EXTENSION = '.d.ts';
8
+ const UTF8_ENCODING = 'utf8';
9
+ const DIST_PATH = Path.resolve(__dirname, '../dist');
10
+
11
+ function processDirectory(directoryPath) {
12
+ const children = FS.readdirSync(directoryPath);
13
+
14
+ children.forEach(function each(child) {
15
+ // Ignore hidden files.
16
+ if (child[0] === '.') {
17
+ return;
18
+ }
19
+
20
+ const
21
+ childPath = Path.resolve(directoryPath, child),
22
+ parsedPath = Path.parse(childPath);
23
+
24
+ if (!parsedPath.ext) {
25
+ processDirectory(childPath);
26
+ } else if (parsedPath.ext === JAVASCRIPT_EXTENSION) {
27
+ processSourceFile(childPath);
28
+ } else if (childPath.slice(-5) === DECLARATION_EXTENSION) {
29
+ processDeclarationFile(childPath);
30
+ }
31
+ });
32
+ }
33
+
34
+ function processSourceFile(filePath) {
35
+ const contents = FS.readFileSync(filePath, UTF8_ENCODING);
36
+
37
+ const lines = contents.split('\n').map(function map(line) {
38
+ return line.replace(/require\((["'])([^"']+)/g, function replacer(match, quote, path) {
39
+ if (path[0] === '.') {
40
+ return match;
41
+ }
42
+
43
+ let dependencyPath = DIST_PATH + '/src/' + path + '.js';
44
+
45
+ if (!FS.existsSync(dependencyPath)) {
46
+ // Fall back to checking whether there's an index.js in a directory
47
+ // of this name, instead of a toplevel .js source file directly.
48
+ dependencyPath = DIST_PATH + '/src/' + path + '/index.js';
49
+
50
+ if (!FS.existsSync(dependencyPath)) {
51
+ // Well, we tried.
52
+ return match;
53
+ }
54
+ }
55
+
56
+ const parsedFile = Path.parse(filePath);
57
+ const parsedDependency = Path.parse(dependencyPath);
58
+
59
+ let relativeDirectory = Path.relative(parsedFile.dir, parsedDependency.dir);
60
+
61
+ if (relativeDirectory === '') {
62
+ relativeDirectory = '.';
63
+ } else {
64
+ relativeDirectory = './' + relativeDirectory;
65
+ }
66
+
67
+ const relativePath = relativeDirectory + '/' + parsedDependency.base;
68
+
69
+ return 'require(' + quote + relativePath;
70
+ });
71
+ });
72
+
73
+ FS.writeFileSync(filePath, lines.join('\n'), UTF8_ENCODING);
74
+ }
75
+
76
+ function processDeclarationFile(filePath) {
77
+ const contents = FS.readFileSync(filePath, UTF8_ENCODING);
78
+
79
+ const lines = contents.split('\n').map(function map(line) {
80
+ return line.replace(/from '([^']+)/g, function replacer(match, path) {
81
+ if (path[0] === '.') {
82
+ return match;
83
+ }
84
+
85
+ let dependencyPath = DIST_PATH + '/src/' + path + '.d.ts';
86
+
87
+ if (!FS.existsSync(dependencyPath)) {
88
+ // Fall back to checking whether there's an index.js in a directory
89
+ // of this name, instead of a toplevel .d.ts source file directly.
90
+ dependencyPath = DIST_PATH + '/src/' + path + '/index.d.ts';
91
+
92
+ if (!FS.existsSync(dependencyPath)) {
93
+ // Well, we tried.
94
+ return match;
95
+ }
96
+ }
97
+
98
+ const parsedFile = Path.parse(filePath);
99
+ const parsedDependency = Path.parse(dependencyPath);
100
+
101
+ let relativeDirectory = Path.relative(parsedFile.dir, parsedDependency.dir);
102
+
103
+ if (relativeDirectory === '') {
104
+ relativeDirectory = '.';
105
+ } else {
106
+ relativeDirectory = './' + relativeDirectory;
107
+ }
108
+
109
+ let relativePath = relativeDirectory + '/' + parsedDependency.base;
110
+
111
+ relativePath = relativePath.replace(DECLARATION_EXTENSION, '');
112
+
113
+ return "from '" + relativePath;
114
+ });
115
+ });
116
+
117
+ FS.writeFileSync(filePath, lines.join('\n'), UTF8_ENCODING);
118
+ }
119
+
120
+ const OUTPUT_SUFFIXES = ['.d.ts', '.js.map', '.js'];
121
+ const SOURCE_EXTENSIONS = ['.ts', '.tsx'];
122
+
123
+ function getSourceStem(output_path) {
124
+ const suffix = OUTPUT_SUFFIXES.find(function find(candidate) {
125
+ return output_path.endsWith(candidate);
126
+ });
127
+
128
+ if (suffix === undefined) {
129
+ return null;
130
+ }
131
+
132
+ return output_path.slice(0, -suffix.length);
133
+ }
134
+
135
+ function hasSource(source_stem) {
136
+ return SOURCE_EXTENSIONS.some(function some(extension) {
137
+ return FS.existsSync(source_stem + extension);
138
+ });
139
+ }
140
+
141
+ function pruneOrphanedOutputs(output_directory, source_directory) {
142
+ if (!FS.existsSync(output_directory)) {
143
+ return;
144
+ }
145
+
146
+ FS.readdirSync(output_directory).forEach(function each(child) {
147
+ const output_path = Path.resolve(output_directory, child);
148
+ const source_path = Path.resolve(source_directory, child);
149
+
150
+ if (FS.statSync(output_path).isDirectory()) {
151
+ pruneOrphanedOutputs(output_path, source_path);
152
+ return;
153
+ }
154
+
155
+ const output_stem = getSourceStem(child);
156
+
157
+ if (output_stem === null) {
158
+ return;
159
+ }
160
+
161
+ const source_stem = Path.resolve(source_directory, output_stem);
162
+
163
+ if (!hasSource(source_stem)) {
164
+ FS.unlinkSync(output_path);
165
+ }
166
+ });
167
+ }
168
+
169
+ pruneOrphanedOutputs('./dist/src', './src');
170
+ pruneOrphanedOutputs('./dist/test', './test');
171
+
172
+ processDirectory('./dist', 0);
package/bin/test ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ bin/compile
6
+
7
+ # It's important that the glob be quoted so that the Node engine
8
+ # can evaluate it rather than it being done by the shell.
9
+ NODE_ENV=test node --test "dist/test/**/*.js"
package/bin/test-one ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ RED='\033[0;31m'
6
+ YELLOW='\033[0;33m'
7
+ RESET='\033[0m'
8
+
9
+ bin/compile
10
+
11
+ FILE_TO_TEST=$1
12
+
13
+ if [ -f "dist/$1.js" ]; then
14
+ TEST_FILEPATH="$FILE_TO_TEST.js"
15
+ else
16
+ # If someone enters the path to the corresponding Typescript file for a test,
17
+ # we should map this to the associated JS file in the dist/test directory:
18
+ FILE_WITH_CORRECTED_EXTENSION=${FILE_TO_TEST/.ts/.js}
19
+
20
+ if [ -f "dist/$FILE_WITH_CORRECTED_EXTENSION" ]; then
21
+ TEST_FILEPATH=$FILE_WITH_CORRECTED_EXTENSION
22
+ fi
23
+ fi
24
+
25
+ if [ -f "dist/$TEST_FILEPATH" ]; then
26
+ NODE_ENV=test node --test dist/$TEST_FILEPATH
27
+ else
28
+ echo ""
29
+ echo -e "${RED}[ERROR]${RESET} No test file(s) found matching '$1'"
30
+ echo -e "${YELLOW}Example:${RESET} dev test test/unit/logger"
31
+ echo ""
32
+ fi
@@ -0,0 +1 @@
1
+ 1794918932
@@ -0,0 +1 @@
1
+ 1795098605
@@ -0,0 +1,26 @@
1
+ import Vector3 from './type/vector3';
2
+ import Viewport from './type/viewport';
3
+ import CameraState from './type/camera-state';
4
+ import ScreenPoint from './type/screen-point';
5
+ import ViewOrientation from './type/view-orientation';
6
+ declare class Camera {
7
+ private state;
8
+ private viewport;
9
+ constructor(state: CameraState);
10
+ getState(): CameraState;
11
+ setState(state: CameraState): void;
12
+ getViewport(): Viewport;
13
+ setViewport(viewport: Viewport): void;
14
+ applyOrientation(orientation: ViewOrientation): void;
15
+ setPerspective(perspective: boolean): void;
16
+ orbit(pixel_dx: number, pixel_dy: number): void;
17
+ pan(pixel_dx: number, pixel_dy: number): void;
18
+ zoomBy(factor: number): void;
19
+ rotateDirection(direction: Vector3): Vector3;
20
+ unrotateDirection(direction: Vector3): Vector3;
21
+ toCameraSpace(point: Vector3): Vector3;
22
+ project(point: Vector3): ScreenPoint | null;
23
+ getFocalLength(): number;
24
+ getWorldUnitsPerPixel(): number;
25
+ }
26
+ export default Camera;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const clamp_1 = __importDefault(require("./utility/clamp.js"));
7
+ const add_vectors_1 = __importDefault(require("./utility/add-vectors.js"));
8
+ const scale_vector_1 = __importDefault(require("./utility/scale-vector.js"));
9
+ const rotate_vector_1 = __importDefault(require("./utility/rotate-vector.js"));
10
+ const camera_limits_1 = __importDefault(require("./constant/camera-limits.js"));
11
+ const project_vector_1 = __importDefault(require("./utility/project-vector.js"));
12
+ const unrotate_vector_1 = __importDefault(require("./utility/unrotate-vector.js"));
13
+ const get_focal_length_1 = __importDefault(require("./utility/get-focal-length.js"));
14
+ const subtract_vectors_1 = __importDefault(require("./utility/subtract-vectors.js"));
15
+ const interaction_rates_1 = __importDefault(require("./constant/interaction-rates.js"));
16
+ const RIGHT_DIRECTION = { x: 1, y: 0, z: 0 };
17
+ const UP_DIRECTION = { x: 0, y: 1, z: 0 };
18
+ class Camera {
19
+ constructor(state) {
20
+ this.state = state;
21
+ this.viewport = { width: 1, height: 1 };
22
+ }
23
+ getState() {
24
+ return this.state;
25
+ }
26
+ setState(state) {
27
+ this.state = state;
28
+ }
29
+ getViewport() {
30
+ return this.viewport;
31
+ }
32
+ setViewport(viewport) {
33
+ this.viewport = viewport;
34
+ }
35
+ applyOrientation(orientation) {
36
+ const { yaw, elevation } = orientation;
37
+ this.state = { ...this.state, yaw, elevation };
38
+ }
39
+ setPerspective(perspective) {
40
+ this.state = { ...this.state, perspective };
41
+ }
42
+ orbit(pixel_dx, pixel_dy) {
43
+ const rate = interaction_rates_1.default.ORBIT_RADIANS_PER_PIXEL;
44
+ const yaw = this.state.yaw + pixel_dx * rate;
45
+ const raw_elevation = this.state.elevation + pixel_dy * rate;
46
+ const limit = camera_limits_1.default.MAXIMUM_ELEVATION;
47
+ const elevation = (0, clamp_1.default)(raw_elevation, limit * -1, limit);
48
+ this.state = { ...this.state, yaw, elevation };
49
+ }
50
+ pan(pixel_dx, pixel_dy) {
51
+ const units_per_pixel = this.getWorldUnitsPerPixel();
52
+ const right = this.unrotateDirection(RIGHT_DIRECTION);
53
+ const up = this.unrotateDirection(UP_DIRECTION);
54
+ const right_shift = (0, scale_vector_1.default)(right, pixel_dx * units_per_pixel * -1);
55
+ const up_shift = (0, scale_vector_1.default)(up, pixel_dy * units_per_pixel);
56
+ const shifted_target = (0, add_vectors_1.default)(this.state.target, right_shift);
57
+ const target = (0, add_vectors_1.default)(shifted_target, up_shift);
58
+ this.state = { ...this.state, target };
59
+ }
60
+ zoomBy(factor) {
61
+ const raw_distance = this.state.distance * factor;
62
+ const distance = (0, clamp_1.default)(raw_distance, camera_limits_1.default.MINIMUM_DISTANCE, camera_limits_1.default.MAXIMUM_DISTANCE);
63
+ this.state = { ...this.state, distance };
64
+ }
65
+ rotateDirection(direction) {
66
+ const { yaw, elevation } = this.state;
67
+ return (0, rotate_vector_1.default)(direction, yaw, elevation);
68
+ }
69
+ unrotateDirection(direction) {
70
+ const { yaw, elevation } = this.state;
71
+ return (0, unrotate_vector_1.default)(direction, yaw, elevation);
72
+ }
73
+ toCameraSpace(point) {
74
+ const relative_point = (0, subtract_vectors_1.default)(point, this.state.target);
75
+ return this.rotateDirection(relative_point);
76
+ }
77
+ project(point) {
78
+ const camera_vector = this.toCameraSpace(point);
79
+ return (0, project_vector_1.default)(camera_vector, this.state, this.viewport);
80
+ }
81
+ getFocalLength() {
82
+ return (0, get_focal_length_1.default)(this.state.field_of_view, this.viewport.height);
83
+ }
84
+ getWorldUnitsPerPixel() {
85
+ const focal_length = this.getFocalLength();
86
+ return this.state.distance / focal_length;
87
+ }
88
+ }
89
+ exports.default = Camera;
90
+ //# sourceMappingURL=camera.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/camera.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,22 @@
1
+ import Camera from './camera';
2
+ import BoundingBox from './type/bounding-box';
3
+ import RenderOptions from './type/render-options';
4
+ import VisibilityMap from './type/visibility-map';
5
+ import DisplayComponent from './type/display-component';
6
+ declare class CanvasRenderer {
7
+ private canvas;
8
+ private context;
9
+ private camera;
10
+ constructor(canvas: HTMLCanvasElement, camera: Camera);
11
+ render(components: DisplayComponent[], visibility: VisibilityMap, options: RenderOptions, bounding_box: BoundingBox): void;
12
+ private resizeToDisplaySize;
13
+ private clear;
14
+ private drawGround;
15
+ private drawComponent;
16
+ private drawLabel;
17
+ private drawDot;
18
+ private strokePolylines;
19
+ private tracePolyline;
20
+ private drawAxisTriad;
21
+ }
22
+ export default CanvasRenderer;