@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.
- package/LICENSE +673 -0
- package/README.md +123 -2
- package/bin/compile +55 -0
- package/bin/install +5 -0
- package/bin/lint +12 -0
- package/bin/postpublish +5 -0
- package/bin/precompile +71 -0
- package/bin/prepublish +7 -0
- package/bin/remap-paths +172 -0
- package/bin/test +9 -0
- package/bin/test-one +32 -0
- package/dist/.last-compile-time +1 -0
- package/dist/.last-publish-time +1 -0
- package/dist/src/camera.d.ts +26 -0
- package/dist/src/camera.js +90 -0
- package/dist/src/camera.js.map +1 -0
- package/dist/src/canvas-renderer.d.ts +22 -0
- package/dist/src/canvas-renderer.js +183 -0
- package/dist/src/canvas-renderer.js.map +1 -0
- package/dist/src/constant/axis-colors.d.ts +3 -0
- package/dist/src/constant/axis-colors.js +13 -0
- package/dist/src/constant/axis-colors.js.map +1 -0
- package/dist/src/constant/box-edge-index-pairs.d.ts +2 -0
- package/dist/src/constant/box-edge-index-pairs.js +18 -0
- package/dist/src/constant/box-edge-index-pairs.js.map +1 -0
- package/dist/src/constant/camera-limits.d.ts +7 -0
- package/dist/src/constant/camera-limits.js +10 -0
- package/dist/src/constant/camera-limits.js.map +1 -0
- package/dist/src/constant/default-camera-state.d.ts +3 -0
- package/dist/src/constant/default-camera-state.js +19 -0
- package/dist/src/constant/default-camera-state.js.map +1 -0
- package/dist/src/constant/default-palette.d.ts +2 -0
- package/dist/src/constant/default-palette.js +17 -0
- package/dist/src/constant/default-palette.js.map +1 -0
- package/dist/src/constant/interaction-rates.d.ts +5 -0
- package/dist/src/constant/interaction-rates.js +8 -0
- package/dist/src/constant/interaction-rates.js.map +1 -0
- package/dist/src/constant/rendering-defaults.d.ts +11 -0
- package/dist/src/constant/rendering-defaults.js +14 -0
- package/dist/src/constant/rendering-defaults.js.map +1 -0
- package/dist/src/constant/stylesheet.d.ts +2 -0
- package/dist/src/constant/stylesheet.js +140 -0
- package/dist/src/constant/stylesheet.js.map +1 -0
- package/dist/src/constant/theme.d.ts +9 -0
- package/dist/src/constant/theme.js +12 -0
- package/dist/src/constant/theme.js.map +1 -0
- package/dist/src/constant/view-orientations.d.ts +4 -0
- package/dist/src/constant/view-orientations.js +19 -0
- package/dist/src/constant/view-orientations.js.map +1 -0
- package/dist/src/enum/axis.d.ts +6 -0
- package/dist/src/enum/axis.js +10 -0
- package/dist/src/enum/axis.js.map +1 -0
- package/dist/src/enum/opening-shape.d.ts +5 -0
- package/dist/src/enum/opening-shape.js +9 -0
- package/dist/src/enum/opening-shape.js.map +1 -0
- package/dist/src/enum/plane.d.ts +6 -0
- package/dist/src/enum/plane.js +10 -0
- package/dist/src/enum/plane.js.map +1 -0
- package/dist/src/enum/primitive-type.d.ts +8 -0
- package/dist/src/enum/primitive-type.js +12 -0
- package/dist/src/enum/primitive-type.js.map +1 -0
- package/dist/src/enum/view-preset.d.ts +10 -0
- package/dist/src/enum/view-preset.js +14 -0
- package/dist/src/enum/view-preset.js.map +1 -0
- package/dist/src/enum/viewer-class-name.d.ts +15 -0
- package/dist/src/enum/viewer-class-name.js +19 -0
- package/dist/src/enum/viewer-class-name.js.map +1 -0
- package/dist/src/example/house-computer.d.ts +3 -0
- package/dist/src/example/house-computer.js +2081 -0
- package/dist/src/example/house-computer.js.map +1 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/index.js +27 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interaction-controller.d.ts +17 -0
- package/dist/src/interaction-controller.js +106 -0
- package/dist/src/interaction-controller.js.map +1 -0
- package/dist/src/sidebar.d.ts +24 -0
- package/dist/src/sidebar.js +121 -0
- package/dist/src/sidebar.js.map +1 -0
- package/dist/src/type/bounding-box.d.ts +6 -0
- package/dist/src/type/bounding-box.js +3 -0
- package/dist/src/type/bounding-box.js.map +1 -0
- package/dist/src/type/camera-state.d.ts +10 -0
- package/dist/src/type/camera-state.js +3 -0
- package/dist/src/type/camera-state.js.map +1 -0
- package/dist/src/type/display-component.d.ts +18 -0
- package/dist/src/type/display-component.js +3 -0
- package/dist/src/type/display-component.js.map +1 -0
- package/dist/src/type/drag-state.d.ts +6 -0
- package/dist/src/type/drag-state.js +3 -0
- package/dist/src/type/drag-state.js.map +1 -0
- package/dist/src/type/inherited-style.d.ts +8 -0
- package/dist/src/type/inherited-style.js +3 -0
- package/dist/src/type/inherited-style.js.map +1 -0
- package/dist/src/type/plane-axes.d.ts +7 -0
- package/dist/src/type/plane-axes.js +3 -0
- package/dist/src/type/plane-axes.js.map +1 -0
- package/dist/src/type/polyline.d.ts +3 -0
- package/dist/src/type/polyline.js +3 -0
- package/dist/src/type/polyline.js.map +1 -0
- package/dist/src/type/primitive/box.d.ts +8 -0
- package/dist/src/type/primitive/box.js +3 -0
- package/dist/src/type/primitive/box.js.map +1 -0
- package/dist/src/type/primitive/cylinder.d.ts +11 -0
- package/dist/src/type/primitive/cylinder.js +3 -0
- package/dist/src/type/primitive/cylinder.js.map +1 -0
- package/dist/src/type/primitive/opening.d.ts +24 -0
- package/dist/src/type/primitive/opening.js +3 -0
- package/dist/src/type/primitive/opening.js.map +1 -0
- package/dist/src/type/primitive/polyline.d.ts +8 -0
- package/dist/src/type/primitive/polyline.js +3 -0
- package/dist/src/type/primitive/polyline.js.map +1 -0
- package/dist/src/type/primitive/sphere.d.ts +8 -0
- package/dist/src/type/primitive/sphere.js +3 -0
- package/dist/src/type/primitive/sphere.js.map +1 -0
- package/dist/src/type/primitive-geometry.d.ts +9 -0
- package/dist/src/type/primitive-geometry.js +3 -0
- package/dist/src/type/primitive-geometry.js.map +1 -0
- package/dist/src/type/primitive.d.ts +7 -0
- package/dist/src/type/primitive.js +3 -0
- package/dist/src/type/primitive.js.map +1 -0
- package/dist/src/type/render-options.d.ts +5 -0
- package/dist/src/type/render-options.js +3 -0
- package/dist/src/type/render-options.js.map +1 -0
- package/dist/src/type/screen-point.d.ts +5 -0
- package/dist/src/type/screen-point.js +3 -0
- package/dist/src/type/screen-point.js.map +1 -0
- package/dist/src/type/sidebar-callbacks.d.ts +9 -0
- package/dist/src/type/sidebar-callbacks.js +3 -0
- package/dist/src/type/sidebar-callbacks.js.map +1 -0
- package/dist/src/type/stroke.d.ts +6 -0
- package/dist/src/type/stroke.js +3 -0
- package/dist/src/type/stroke.js.map +1 -0
- package/dist/src/type/vector3.d.ts +6 -0
- package/dist/src/type/vector3.js +3 -0
- package/dist/src/type/vector3.js.map +1 -0
- package/dist/src/type/view-orientation.d.ts +5 -0
- package/dist/src/type/view-orientation.js +3 -0
- package/dist/src/type/view-orientation.js.map +1 -0
- package/dist/src/type/viewport.d.ts +5 -0
- package/dist/src/type/viewport.js +3 -0
- package/dist/src/type/viewport.js.map +1 -0
- package/dist/src/type/visibility-map.d.ts +2 -0
- package/dist/src/type/visibility-map.js +3 -0
- package/dist/src/type/visibility-map.js.map +1 -0
- package/dist/src/type/wireframe-component.d.ts +13 -0
- package/dist/src/type/wireframe-component.js +3 -0
- package/dist/src/type/wireframe-component.js.map +1 -0
- package/dist/src/type/wireframe-scene.d.ts +10 -0
- package/dist/src/type/wireframe-scene.js +3 -0
- package/dist/src/type/wireframe-scene.js.map +1 -0
- package/dist/src/utility/add-vectors.d.ts +3 -0
- package/dist/src/utility/add-vectors.js +11 -0
- package/dist/src/utility/add-vectors.js.map +1 -0
- package/dist/src/utility/build-box-outlines.d.ts +4 -0
- package/dist/src/utility/build-box-outlines.js +32 -0
- package/dist/src/utility/build-box-outlines.js.map +1 -0
- package/dist/src/utility/build-circle-outline.d.ts +5 -0
- package/dist/src/utility/build-circle-outline.js +25 -0
- package/dist/src/utility/build-circle-outline.js.map +1 -0
- package/dist/src/utility/build-cylinder-outlines.d.ts +4 -0
- package/dist/src/utility/build-cylinder-outlines.js +34 -0
- package/dist/src/utility/build-cylinder-outlines.js.map +1 -0
- package/dist/src/utility/build-initial-visibility.d.ts +4 -0
- package/dist/src/utility/build-initial-visibility.js +11 -0
- package/dist/src/utility/build-initial-visibility.js.map +1 -0
- package/dist/src/utility/build-opening-outlines.d.ts +4 -0
- package/dist/src/utility/build-opening-outlines.js +31 -0
- package/dist/src/utility/build-opening-outlines.js.map +1 -0
- package/dist/src/utility/build-primitive-geometry.d.ts +4 -0
- package/dist/src/utility/build-primitive-geometry.js +40 -0
- package/dist/src/utility/build-primitive-geometry.js.map +1 -0
- package/dist/src/utility/build-rectangle-outline.d.ts +5 -0
- package/dist/src/utility/build-rectangle-outline.js +23 -0
- package/dist/src/utility/build-rectangle-outline.js.map +1 -0
- package/dist/src/utility/build-sphere-outlines.d.ts +4 -0
- package/dist/src/utility/build-sphere-outlines.js +16 -0
- package/dist/src/utility/build-sphere-outlines.js.map +1 -0
- package/dist/src/utility/clamp.d.ts +2 -0
- package/dist/src/utility/clamp.js +7 -0
- package/dist/src/utility/clamp.js.map +1 -0
- package/dist/src/utility/collect-display-points.d.ts +4 -0
- package/dist/src/utility/collect-display-points.js +13 -0
- package/dist/src/utility/collect-display-points.js.map +1 -0
- package/dist/src/utility/compute-bounding-box.d.ts +4 -0
- package/dist/src/utility/compute-bounding-box.js +29 -0
- package/dist/src/utility/compute-bounding-box.js.map +1 -0
- package/dist/src/utility/compute-centroid.d.ts +3 -0
- package/dist/src/utility/compute-centroid.js +17 -0
- package/dist/src/utility/compute-centroid.js.map +1 -0
- package/dist/src/utility/create-element.d.ts +2 -0
- package/dist/src/utility/create-element.js +11 -0
- package/dist/src/utility/create-element.js.map +1 -0
- package/dist/src/utility/fit-camera-to-bounding-box.d.ts +4 -0
- package/dist/src/utility/fit-camera-to-bounding-box.js +23 -0
- package/dist/src/utility/fit-camera-to-bounding-box.js.map +1 -0
- package/dist/src/utility/flatten-components.d.ts +4 -0
- package/dist/src/utility/flatten-components.js +70 -0
- package/dist/src/utility/flatten-components.js.map +1 -0
- package/dist/src/utility/get-bounding-box-center.d.ts +4 -0
- package/dist/src/utility/get-bounding-box-center.js +14 -0
- package/dist/src/utility/get-bounding-box-center.js.map +1 -0
- package/dist/src/utility/get-bounding-box-size.d.ts +4 -0
- package/dist/src/utility/get-bounding-box-size.js +12 -0
- package/dist/src/utility/get-bounding-box-size.js.map +1 -0
- package/dist/src/utility/get-focal-length.d.ts +2 -0
- package/dist/src/utility/get-focal-length.js +9 -0
- package/dist/src/utility/get-focal-length.js.map +1 -0
- package/dist/src/utility/get-perpendicular-axes.d.ts +3 -0
- package/dist/src/utility/get-perpendicular-axes.js +18 -0
- package/dist/src/utility/get-perpendicular-axes.js.map +1 -0
- package/dist/src/utility/get-plane-axes.d.ts +4 -0
- package/dist/src/utility/get-plane-axes.js +19 -0
- package/dist/src/utility/get-plane-axes.js.map +1 -0
- package/dist/src/utility/get-primitive-anchor.d.ts +4 -0
- package/dist/src/utility/get-primitive-anchor.js +20 -0
- package/dist/src/utility/get-primitive-anchor.js.map +1 -0
- package/dist/src/utility/get-vector-component.d.ts +4 -0
- package/dist/src/utility/get-vector-component.js +18 -0
- package/dist/src/utility/get-vector-component.js.map +1 -0
- package/dist/src/utility/get-vector-length.d.ts +3 -0
- package/dist/src/utility/get-vector-length.js +7 -0
- package/dist/src/utility/get-vector-length.js.map +1 -0
- package/dist/src/utility/has-hidden-ancestor.d.ts +4 -0
- package/dist/src/utility/has-hidden-ancestor.js +9 -0
- package/dist/src/utility/has-hidden-ancestor.js.map +1 -0
- package/dist/src/utility/inject-stylesheet.d.ts +2 -0
- package/dist/src/utility/inject-stylesheet.js +21 -0
- package/dist/src/utility/inject-stylesheet.js.map +1 -0
- package/dist/src/utility/is-component-shown.d.ts +4 -0
- package/dist/src/utility/is-component-shown.js +10 -0
- package/dist/src/utility/is-component-shown.js.map +1 -0
- package/dist/src/utility/offset-vector-along-axis.d.ts +4 -0
- package/dist/src/utility/offset-vector-along-axis.js +14 -0
- package/dist/src/utility/offset-vector-along-axis.js.map +1 -0
- package/dist/src/utility/pick-palette-color.d.ts +2 -0
- package/dist/src/utility/pick-palette-color.js +12 -0
- package/dist/src/utility/pick-palette-color.js.map +1 -0
- package/dist/src/utility/project-vector.d.ts +6 -0
- package/dist/src/utility/project-vector.js +30 -0
- package/dist/src/utility/project-vector.js.map +1 -0
- package/dist/src/utility/rotate-vector.d.ts +3 -0
- package/dist/src/utility/rotate-vector.js +17 -0
- package/dist/src/utility/rotate-vector.js.map +1 -0
- package/dist/src/utility/scale-vector.d.ts +3 -0
- package/dist/src/utility/scale-vector.js +11 -0
- package/dist/src/utility/scale-vector.js.map +1 -0
- package/dist/src/utility/subtract-vectors.d.ts +3 -0
- package/dist/src/utility/subtract-vectors.js +11 -0
- package/dist/src/utility/subtract-vectors.js.map +1 -0
- package/dist/src/utility/unrotate-vector.d.ts +3 -0
- package/dist/src/utility/unrotate-vector.js +17 -0
- package/dist/src/utility/unrotate-vector.js.map +1 -0
- package/dist/src/utility/validate-scene.d.ts +3 -0
- package/dist/src/utility/validate-scene.js +70 -0
- package/dist/src/utility/validate-scene.js.map +1 -0
- package/dist/src/utility/with-vector-component.d.ts +4 -0
- package/dist/src/utility/with-vector-component.js +18 -0
- package/dist/src/utility/with-vector-component.js.map +1 -0
- package/dist/src/wireframe-viewer.d.ts +27 -0
- package/dist/src/wireframe-viewer.js +144 -0
- package/dist/src/wireframe-viewer.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +44 -5
package/README.md
CHANGED
|
@@ -1,3 +1,124 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @fc3/wireframe-renderer
|
|
2
2
|
|
|
3
|
-
|
|
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
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
|
+
|
package/bin/postpublish
ADDED
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
package/bin/remap-paths
ADDED
|
@@ -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
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":";;;;;AAAA,0DAAkC;AAGlC,sEAA6C;AAG7C,wEAA+C;AAC/C,0EAAiD;AACjD,2EAAmD;AACn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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;
|