@mark1russell7/visuals 0.1.0 → 0.2.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.
@@ -0,0 +1,192 @@
1
+ import { i as StageContent } from "./stage-CtWLSoV-.js";
2
+ import { S as ViewAngles, d as StageView, t as StageTheme } from "./theme-CKXd_emk.js";
3
+ import { Raycaster } from "three";
4
+ import { LatLon, Region } from "@mark1russell7/geo";
5
+ import { Point3 } from "@mark1russell7/layout-contract";
6
+ /** The look of the areas and the points of one kind. Each color is a CSS hex color. */
7
+ interface GlobeStyle {
8
+ /** The color of the surface of an area, or of a point. An area with no color has no surface, and a point with no color is not in the picture. */
9
+ readonly fill?: string | undefined;
10
+ /** The part of the light that the surface of an area stops, from 0 to 1. The default is 1. */
11
+ readonly opacity?: number | undefined;
12
+ /** The color of the edge of an area, or of the ring around a point. An area with no color has no edge. */
13
+ readonly line?: string | undefined;
14
+ }
15
+ /** The colors of a globe. Each color is a CSS hex color. */
16
+ interface GlobeTheme extends StageTheme {
17
+ /** The color of the Earth where it has no area, for example the sea. */
18
+ readonly ball: string;
19
+ /** The color of the meridians and the parallels. */
20
+ readonly grid: string;
21
+ /** The color of the shade at the rim of the Earth. */
22
+ readonly shade: string;
23
+ /** The style of each kind of area or point, by the name of the kind. */
24
+ readonly styles: Readonly<Record<string, GlobeStyle>>;
25
+ /** The style of a kind that `styles` does not have. */
26
+ readonly other: GlobeStyle;
27
+ /** The color of the edge of a record under the pointer, or in the highlighted list. */
28
+ readonly hovered: string;
29
+ /** The color of the edge of the selected record. */
30
+ readonly selected: string;
31
+ }
32
+ /** An area of a globe: a region of the Earth that belongs to a record. */
33
+ interface GlobeArea<P> {
34
+ /** The name of the record. Two parts with one name are one record: the stage highlights them together. */
35
+ readonly record: string;
36
+ /** The region, with edges that are straight lines in longitude and latitude, as in `@mark1russell7/geo`. */
37
+ readonly region: Region;
38
+ /** The name of the style of the area in the theme. */
39
+ readonly kind: string;
40
+ /** The value that a pick of the area gives to the page. */
41
+ readonly value: P;
42
+ /** This value is false for an area that the pointer does not find. The default is true. */
43
+ readonly pick?: boolean | undefined;
44
+ }
45
+ /** A point of a globe: a place on the Earth that belongs to a record. The picture shows it as a dot of a constant size. */
46
+ interface GlobePoint<P> {
47
+ /** The name of the record. Two parts with one name are one record: the stage highlights them together. */
48
+ readonly record: string;
49
+ readonly place: LatLon;
50
+ /** The name of the style of the point in the theme. */
51
+ readonly kind: string;
52
+ /** The value that a pick of the point gives to the page. */
53
+ readonly value: P;
54
+ /** The width of the dot, in CSS pixels. The default is the option `pointSize` of the globe. */
55
+ readonly size?: number | undefined;
56
+ /** This value is false for a point that the pointer does not find. The default is true. */
57
+ readonly pick?: boolean | undefined;
58
+ }
59
+ /** The options of a globe. Each width is in CSS pixels. */
60
+ interface GlobeOptions<P> {
61
+ /** The areas, in the sequence of the picture: a later area is above an earlier area, and the pointer finds it first. */
62
+ readonly areas?: readonly GlobeArea<P>[] | undefined;
63
+ /** The points. Each point is above each area. */
64
+ readonly points?: readonly GlobePoint<P>[] | undefined;
65
+ /** The radius of the globe, in the units of the stage. The default is 1. */
66
+ readonly radius?: number | undefined;
67
+ /** The largest step of an edge in longitude or latitude, in degrees. A smaller step follows the curve of the Earth better. The default is 1. */
68
+ readonly step?: number | undefined;
69
+ /** The angle between two lines of the grid, in degrees. The value 0 gives no grid. The default is 15. */
70
+ readonly grid?: number | undefined;
71
+ /** The smallest height of the camera above the surface, as a part of the radius. The default is 0.005. */
72
+ readonly nearest?: number | undefined;
73
+ /** The width of the edge of an area. The default is 1.25. */
74
+ readonly lineWidth?: number | undefined;
75
+ /** The width of the edge of a record with a highlight. The default is 2.5. */
76
+ readonly highlightWidth?: number | undefined;
77
+ /** The width of a line of the grid. The default is 1. */
78
+ readonly gridWidth?: number | undefined;
79
+ /** The width of the dot of a point. The default is 9. */
80
+ readonly pointSize?: number | undefined;
81
+ /** The strength of the shade at the rim of the Earth, from 0 to 1. The default is 0.4. */
82
+ readonly shade?: number | undefined;
83
+ }
84
+ /** The content of a stage that shows the Earth as a globe, with areas and points on it. */
85
+ interface GlobeContent<P> extends StageContent<P, GlobeTheme> {
86
+ /**
87
+ * This function shows only the areas and the points that a test accepts. A part that the picture does not show gets no pick.
88
+ * Start `refresh` of the stage after it. A test that accepts each part shows all of them again.
89
+ */
90
+ show(test: (part: GlobeArea<P> | GlobePoint<P>) => boolean): void;
91
+ /** This function gives the place on the Earth that a ray from the camera finds. A ray that does not find the Earth gives `undefined`. */
92
+ placeAt(ray: Raycaster): LatLon | undefined;
93
+ }
94
+ /**
95
+ * This function makes the content of a stage that shows the Earth as a globe. The center of the globe is the origin of the stage.
96
+ *
97
+ * The materials use no light, so each color in the picture is the color of the theme. Use `GLOBE_POLAR` and no pan in the options of the stage.
98
+ * The function throws an `Error` with the name of the record for an area that is not correct. Its cause is the error of `@mark1russell7/geo`.
99
+ */
100
+ export declare function createGlobe<P>(options?: GlobeOptions<P>): GlobeContent<P>;
101
+ /**
102
+ * The surface of a region as triangles. The region and the triangles are in the plane of longitude and latitude,
103
+ * as the polygon tests of `@mark1russell7/geo` are. So a triangle does not go across the antimeridian.
104
+ */
105
+ interface RegionSurface {
106
+ /** The longitude and the latitude of each corner, in degrees: two numbers for each corner. */
107
+ readonly corners: Float64Array;
108
+ /** The three corners of each triangle, as indices of corners. Each triangle is counterclockwise in the plane, with east on the right and north up. */
109
+ readonly triangles: Uint32Array;
110
+ }
111
+ /** The largest count of corners of the surface of one region. A smaller step gives more corners. */
112
+ export declare const MAX_SURFACE_CORNERS = 2e6;
113
+ /**
114
+ * This function gives the height of the flat triangles of a surface below a ball of radius 1, at most.
115
+ * A layer at this height above a ball does not go into the ball. `step` is the step of the surface, in degrees.
116
+ */
117
+ export declare function surfaceSag(step: number): number;
118
+ /**
119
+ * This function divides the surface of a region into triangles that follow the curve of the Earth.
120
+ *
121
+ * `step` is the largest step of an edge of the outline in longitude or latitude, in degrees. The outline is the outline of `densify` with this step:
122
+ * each edge of the outline of the surface is an edge of that outline. So a line through the points of `densify` is exactly on the outline of the surface.
123
+ * An edge in the surface is not longer than 1.25 steps. A step of longitude is as long as it is on the Earth at that latitude, and a quarter of a step at least.
124
+ *
125
+ * A straight edge in the plane is a curve on the Earth. So a flat triangle on a globe is not exactly the triangle in the plane.
126
+ * The difference is small for a small step. It is largest near a pole.
127
+ *
128
+ * The function throws a `GeoError` for a region or a step that is not correct, and a `RangeError` for a surface with too many corners.
129
+ */
130
+ export declare function regionSurface(region: Region, step: number, maxCorners?: number): RegionSurface;
131
+ /**
132
+ * This function gives the edges of a region as lines, for the outline that a person sees. Each line is a list of longitudes and latitudes, in degrees:
133
+ * two numbers for each point.
134
+ *
135
+ * `step` is the largest step of a line in longitude or latitude, in degrees. The points are the points of `densify`, so they are corners of `regionSurface`.
136
+ * An edge that is only a cut gets no line. A cut is an edge along a pole, or an edge on the antimeridian with an edge of the region on its other side.
137
+ */
138
+ export declare function regionEdges(region: Region, step: number): Float64Array[];
139
+ /**
140
+ * This function gives the lines of a grid of meridians and parallels. Each line is a list of longitudes and latitudes, in degrees: two numbers for each point.
141
+ *
142
+ * `spacing` is the angle between two lines, in degrees, and `step` is the largest step of a line. A spacing of 0 or less gives no lines.
143
+ * The meridians at each 90 degrees go to the poles. The other meridians stop one spacing before each pole, so the poles stay clear.
144
+ */
145
+ export declare function gridLines(spacing: number, step: number): Float64Array[];
146
+ /**
147
+ * The polar limits of the camera of a globe: the camera goes above each pole.
148
+ * Give this value to the option `polar` of a stage. Set the option `pan` to false, so the camera turns around the center of the Earth.
149
+ */
150
+ export declare const GLOBE_POLAR: {
151
+ readonly min: number;
152
+ readonly max: number;
153
+ };
154
+ /**
155
+ * This function gives the point of a globe for a place on the Earth. The center of the globe is the origin of the stage.
156
+ *
157
+ * The axis `y` of the stage goes to the north pole. The axis `z` goes to latitude 0 and longitude 0, and the axis `x` goes to latitude 0 and longitude 90 east.
158
+ * `radius` is the distance of the point from the center. The default is 1.
159
+ */
160
+ export declare function globePoint(place: LatLon, radius?: number): Point3;
161
+ /**
162
+ * This function gives the place on the Earth in the direction of a point of the stage, as seen from the center of the globe.
163
+ * The center of the globe has no direction, so it gives `undefined`.
164
+ */
165
+ export declare function globePlace(point: Point3): LatLon | undefined;
166
+ /** This function gives the direction of a camera that is above a place on the Earth. */
167
+ export declare function globeAngles(place: LatLon): ViewAngles;
168
+ /**
169
+ * This function makes a view from above a place on the Earth. The picture shows the cap of the Earth around the place.
170
+ *
171
+ * `degrees` is the angle of the cap at the center of the Earth. It is the distance from the place to the edge of the cap, in degrees of a great circle.
172
+ * The default is 90: the picture shows a half of the Earth. `margin` is the space around the cap, as a factor of the height above the surface.
173
+ */
174
+ export declare function globeView(place: LatLon, degrees?: number, margin?: number): StageView;
175
+ /**
176
+ * This function makes a view that shows each region of a list. The camera is above the middle of the regions.
177
+ * A list with no regions gives a view of a half of the Earth. `margin` is the space around the regions, as a factor of the height above the surface.
178
+ */
179
+ export declare function regionView(regions: readonly Region[], margin?: number): StageView;
180
+ /**
181
+ * This function gives the first point of a ball that a ray finds. The center of the ball is the origin of the stage.
182
+ *
183
+ * `direction` has the length 1. A ray that does not find the ball gives `undefined`, and a ray that starts in the ball also gives `undefined`.
184
+ */
185
+ export declare function rayBall(origin: Point3, direction: Point3, radius: number): Point3 | undefined;
186
+ /**
187
+ * This function tells if a camera at `eye` sees a point of the surface of a ball. The center of the ball is the origin of the stage.
188
+ * A point on the far side of the ball gives false.
189
+ */
190
+ export declare function inSight(point: Point3, eye: Point3, radius: number): boolean;
191
+ export type { GlobeArea, GlobeContent, GlobeOptions, GlobePoint, GlobeStyle, GlobeTheme, RegionSurface };
192
+ //# sourceMappingURL=globe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globe.d.ts","names":[],"sources":["../src/globe/content.ts","../src/globe/mesh.ts","../src/globe/space.ts"],"mappings":";;;;;;UA6BiB;;WAEN;;WAEA;;WAEA;;;UAIM,mBAAmB;;WAEzB;;WAEA;;WAE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