@johnmorrisdotca/chikyu-earth 0.46.4 → 0.46.6
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/CHANGELOG.md +8 -0
- package/README.md +3 -2
- package/dist/beam/geometry.d.ts +131 -0
- package/dist/beam/geometry.js +141 -0
- package/dist/beam/layer.d.ts +47 -0
- package/dist/beam/layer.js +308 -0
- package/dist/realistic/element-base.d.ts +1 -0
- package/dist/realistic/element-base.js +1 -1
- package/dist/space/element-base.d.ts +60 -1
- package/dist/space/element-base.js +132 -7
- package/dist/space/generic-satellite.d.ts +4 -4
- package/dist/space/generic-satellite.js +51 -11
- package/dist/space/index.d.ts +4 -2
- package/dist/space/index.js +2 -1
- package/dist/space/ride.d.ts +12 -0
- package/dist/space/satellite-layer.d.ts +3 -0
- package/dist/space/satellite-layer.js +5 -2
- package/dist/space/satellite-model.d.ts +72 -0
- package/dist/space/satellite-model.js +78 -0
- package/dist/space/scene.d.ts +6 -1
- package/dist/space/scene.js +36 -3
- package/package.json +1 -1
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { BEAM_COLOUR, beamCells, footprintAngle, footprintKm } from "./geometry.js";
|
|
2
|
+
/** Earth radii: the Earth's radius in kilometres, the unit the scene measures in. */
|
|
3
|
+
const EARTH_KM = 6371;
|
|
4
|
+
/** The footprint sits this far above the ground (in Earth radii): over the map tiles and the sphere's flat facets, as the grid does. */
|
|
5
|
+
const GROUND = 1.0015;
|
|
6
|
+
const CONE_SEGMENTS = 72;
|
|
7
|
+
const DISC_SEGMENTS = 64;
|
|
8
|
+
const DISC_RINGS = 6;
|
|
9
|
+
export const newBeamState = () => ({ on: false, elevation: 25, cells: 0, cellSize: 0, colour: BEAM_COLOUR, strength: 0.6, stats: { shown: false, heightKm: 0, radiusKm: 0, angleDegrees: 0, elevation: 25, cells: 0, cellRadiusKm: 0, builds: 0, failed: false } });
|
|
10
|
+
// The footprint's flat units (its radius is 1) mapped onto the sphere about the point below the satellite, the angle growing with the distance from the middle: the same map the rings use.
|
|
11
|
+
const MAP = /* glsl */ `
|
|
12
|
+
vec3 ground(vec2 p) {
|
|
13
|
+
float r = length(p);
|
|
14
|
+
vec2 d = r > 1e-6 ? p / r : vec2(1.0, 0.0);
|
|
15
|
+
float a = r * lambda;
|
|
16
|
+
return (nadir * cos(a) + (e1 * d.x + e2 * d.y) * sin(a)) * ${GROUND.toFixed(4)};
|
|
17
|
+
}`;
|
|
18
|
+
const CONE_VERT = /* glsl */ `
|
|
19
|
+
attribute vec4 cone;
|
|
20
|
+
attribute float shaft;
|
|
21
|
+
uniform vec3 sat;
|
|
22
|
+
uniform vec3 nadir;
|
|
23
|
+
uniform vec3 e1;
|
|
24
|
+
uniform vec3 e2;
|
|
25
|
+
uniform float lambda;
|
|
26
|
+
uniform float pitch;
|
|
27
|
+
uniform float circle;
|
|
28
|
+
uniform float weights;
|
|
29
|
+
uniform float cone0;
|
|
30
|
+
uniform float thin;
|
|
31
|
+
varying float vT;
|
|
32
|
+
varying float vFace;
|
|
33
|
+
varying float vRay;
|
|
34
|
+
varying float vDist;
|
|
35
|
+
varying float vWeight;
|
|
36
|
+
${MAP}
|
|
37
|
+
// the footprint's own cone (shaft 0) or the thin one to a cell (shaft 1)
|
|
38
|
+
vec3 rim(float phi) { return shaft > 0.5 ? ground(cone.zw * pitch + circle * thin * vec2(cos(phi), sin(phi))) : ground(vec2(cos(phi), sin(phi))); }
|
|
39
|
+
vec3 at(float t, float phi) { return mix(sat, rim(phi), t); }
|
|
40
|
+
void main() {
|
|
41
|
+
float t = cone.x;
|
|
42
|
+
float s = clamp(t, 0.05, 1.0);
|
|
43
|
+
vec3 p = at(t, cone.y);
|
|
44
|
+
vec3 dp = at(s, cone.y + 0.01) - at(s, cone.y - 0.01);
|
|
45
|
+
vec3 n = normalize(cross(dp, rim(cone.y) - sat));
|
|
46
|
+
vec3 v = cameraPosition - p;
|
|
47
|
+
vDist = length(v);
|
|
48
|
+
vFace = abs(dot(n, normalize(v)));
|
|
49
|
+
vT = t;
|
|
50
|
+
vRay = cone.y;
|
|
51
|
+
vWeight = shaft > 0.5 ? weights : cone0;
|
|
52
|
+
gl_Position = projectionMatrix * viewMatrix * vec4(p, 1.0);
|
|
53
|
+
}`;
|
|
54
|
+
const CONE_FRAG = /* glsl */ `
|
|
55
|
+
uniform vec3 colour;
|
|
56
|
+
uniform float strength;
|
|
57
|
+
varying float vT;
|
|
58
|
+
varying float vFace;
|
|
59
|
+
varying float vRay;
|
|
60
|
+
varying float vDist;
|
|
61
|
+
varying float vWeight;
|
|
62
|
+
void main() {
|
|
63
|
+
// brightest at the satellite, fading towards the ground; soft at the edges (a shaft is thickest through its middle), and a little streaked round
|
|
64
|
+
float along = 0.04 + 0.96 * pow(1.0 - vT, 1.7);
|
|
65
|
+
float body = 0.1 + 0.9 * pow(vFace, 1.4);
|
|
66
|
+
float streaks = 0.88 + 0.12 * sin(vRay * 36.0);
|
|
67
|
+
float near = smoothstep(0.004, 0.06, vDist);
|
|
68
|
+
float a = strength * vWeight * along * body * streaks * near;
|
|
69
|
+
gl_FragColor = vec4(colour, a);
|
|
70
|
+
}`;
|
|
71
|
+
// The footprint itself (kinds 2 and 3) and the cells (kinds 0 and 1), each a faint fill with a soft inner glow and a thin bright line, mapped from the footprint's flat units onto the sphere.
|
|
72
|
+
// The line is drawn in a band either side of the edge and shaped in pixels (from how fast the radius changes across the screen), so it is as thin on a small cell as on the whole footprint.
|
|
73
|
+
const DISC_VERT = /* glsl */ `
|
|
74
|
+
attribute vec4 disc;
|
|
75
|
+
attribute vec2 pol;
|
|
76
|
+
uniform vec3 nadir;
|
|
77
|
+
uniform vec3 e1;
|
|
78
|
+
uniform vec3 e2;
|
|
79
|
+
uniform float lambda;
|
|
80
|
+
uniform float pitch;
|
|
81
|
+
uniform float circle;
|
|
82
|
+
varying float vRho;
|
|
83
|
+
varying float vRing;
|
|
84
|
+
varying float vFill;
|
|
85
|
+
varying float vShare;
|
|
86
|
+
${MAP}
|
|
87
|
+
void main() {
|
|
88
|
+
bool foot = disc.w > 1.5;
|
|
89
|
+
vec2 q = vec2(cos(pol.y), sin(pol.y)) * pol.x;
|
|
90
|
+
vec2 p = foot ? q : disc.xy * pitch + circle * q;
|
|
91
|
+
vRho = pol.x;
|
|
92
|
+
vRing = mod(disc.w, 2.0);
|
|
93
|
+
vFill = foot ? 0.05 : 0.04;
|
|
94
|
+
vShare = foot ? 1.0 : 0.8;
|
|
95
|
+
gl_Position = projectionMatrix * viewMatrix * vec4(ground(p), 1.0);
|
|
96
|
+
}`;
|
|
97
|
+
const DISC_FRAG = /* glsl */ `
|
|
98
|
+
uniform vec3 colour;
|
|
99
|
+
uniform float strength;
|
|
100
|
+
varying float vRho;
|
|
101
|
+
varying float vRing;
|
|
102
|
+
varying float vFill;
|
|
103
|
+
varying float vShare;
|
|
104
|
+
void main() {
|
|
105
|
+
float a;
|
|
106
|
+
if (vRing > 0.5) {
|
|
107
|
+
float d = (vRho - 1.0) / max(fwidth(vRho), 1e-5);
|
|
108
|
+
float line = 1.0 - smoothstep(0.35, 1.1, abs(d));
|
|
109
|
+
float glow = d < 0.0 ? 0.34 * exp(d / 7.0) : 0.2 * exp(-d / 4.0);
|
|
110
|
+
a = vShare * min(1.0, line + glow);
|
|
111
|
+
} else {
|
|
112
|
+
a = vFill * (0.25 + 0.75 * pow(clamp(vRho, 0.0, 1.0), 5.0));
|
|
113
|
+
}
|
|
114
|
+
gl_FragColor = vec4(colour, strength * a);
|
|
115
|
+
}`;
|
|
116
|
+
/** The cones: the footprint's own, then one thin one for each lattice point. Each is a strip from the apex (t = 0) to the rim (t = 1), every phi round. */
|
|
117
|
+
function coneGeometry(three, lattice) {
|
|
118
|
+
const verts = [];
|
|
119
|
+
const shaft = [];
|
|
120
|
+
const index = [];
|
|
121
|
+
const add = (x, y, thin, rows, segments) => {
|
|
122
|
+
const base = verts.length / 4;
|
|
123
|
+
for (let r = 0; r <= rows; r += 1) {
|
|
124
|
+
for (let s = 0; s <= segments; s += 1) {
|
|
125
|
+
verts.push(r / rows, (s / segments) * Math.PI * 2, x, y);
|
|
126
|
+
shaft.push(thin);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
for (let r = 0; r < rows; r += 1) {
|
|
130
|
+
for (let s = 0; s < segments; s += 1) {
|
|
131
|
+
const a = base + r * (segments + 1) + s;
|
|
132
|
+
const b = a + segments + 1;
|
|
133
|
+
index.push(a, b, a + 1, a + 1, b, b + 1);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
add(0, 0, 0, 10, CONE_SEGMENTS);
|
|
138
|
+
for (const point of lattice)
|
|
139
|
+
add(point[0], point[1], 1, 6, 24);
|
|
140
|
+
const geometry = new three.BufferGeometry();
|
|
141
|
+
geometry.setAttribute("cone", new three.BufferAttribute(new Float32Array(verts), 4));
|
|
142
|
+
geometry.setAttribute("shaft", new three.BufferAttribute(new Float32Array(shaft), 1));
|
|
143
|
+
geometry.setAttribute("position", new three.BufferAttribute(new Float32Array((verts.length / 4) * 3), 3));
|
|
144
|
+
geometry.setIndex(index);
|
|
145
|
+
return geometry;
|
|
146
|
+
}
|
|
147
|
+
/** The ground: the footprint's disc and ring (kinds 2 and 3), then each cell's (kinds 0 and 1). */
|
|
148
|
+
function groundGeometry(three, lattice) {
|
|
149
|
+
const disc = [];
|
|
150
|
+
const pol = [];
|
|
151
|
+
const index = [];
|
|
152
|
+
const push = (x, y, kind, rho, phi, band = 0) => {
|
|
153
|
+
disc.push(x, y, band, kind);
|
|
154
|
+
pol.push(rho, phi);
|
|
155
|
+
return pol.length / 2 - 1;
|
|
156
|
+
};
|
|
157
|
+
const circleAt = (x, y, fillKind) => {
|
|
158
|
+
const fill = push(x, y, fillKind, 0, 0);
|
|
159
|
+
const first = pol.length / 2;
|
|
160
|
+
for (let r = 1; r <= DISC_RINGS; r += 1)
|
|
161
|
+
for (let s = 0; s < DISC_SEGMENTS; s += 1)
|
|
162
|
+
push(x, y, fillKind, (r / DISC_RINGS) * 0.985, (s / DISC_SEGMENTS) * Math.PI * 2);
|
|
163
|
+
for (let s = 0; s < DISC_SEGMENTS; s += 1)
|
|
164
|
+
index.push(fill, first + s, first + ((s + 1) % DISC_SEGMENTS));
|
|
165
|
+
for (let r = 1; r < DISC_RINGS; r += 1) {
|
|
166
|
+
for (let s = 0; s < DISC_SEGMENTS; s += 1) {
|
|
167
|
+
const a = first + (r - 1) * DISC_SEGMENTS + s;
|
|
168
|
+
const b = first + (r - 1) * DISC_SEGMENTS + ((s + 1) % DISC_SEGMENTS);
|
|
169
|
+
index.push(a, a + DISC_SEGMENTS, b, b, a + DISC_SEGMENTS, b + DISC_SEGMENTS);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// the ring: a band just inside the edge, brightest in the middle of it
|
|
173
|
+
const band = pol.length / 2;
|
|
174
|
+
for (const w of [0, 1])
|
|
175
|
+
for (let s = 0; s < DISC_SEGMENTS; s += 1)
|
|
176
|
+
push(x, y, fillKind + 1, 0.82 + 0.36 * w, (s / DISC_SEGMENTS) * Math.PI * 2, w);
|
|
177
|
+
for (let s = 0; s < DISC_SEGMENTS; s += 1) {
|
|
178
|
+
const a = band + s;
|
|
179
|
+
const b = band + ((s + 1) % DISC_SEGMENTS);
|
|
180
|
+
index.push(a, a + DISC_SEGMENTS, b, b, a + DISC_SEGMENTS, b + DISC_SEGMENTS);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
circleAt(0, 0, 2);
|
|
184
|
+
for (const point of lattice)
|
|
185
|
+
circleAt(point[0], point[1], 0);
|
|
186
|
+
const geometry = new three.BufferGeometry();
|
|
187
|
+
geometry.setAttribute("disc", new three.BufferAttribute(new Float32Array(disc), 4));
|
|
188
|
+
geometry.setAttribute("pol", new three.BufferAttribute(new Float32Array(pol), 2));
|
|
189
|
+
geometry.setAttribute("position", new three.BufferAttribute(new Float32Array((pol.length / 2) * 3), 3));
|
|
190
|
+
geometry.setIndex(index);
|
|
191
|
+
return geometry;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Makes the beam in `scene` (the world the satellites are in, not the Earth's turning group: the footprint is worked out for the satellite's place now).
|
|
195
|
+
*
|
|
196
|
+
* @param three - The page's three.js; it must have `AdditiveBlending`.
|
|
197
|
+
* @param scene - The scene the satellites are in.
|
|
198
|
+
* @param state - The model's beam.
|
|
199
|
+
* @param order - The render order: after the satellites' dots.
|
|
200
|
+
* @returns The layer.
|
|
201
|
+
*/
|
|
202
|
+
export function createBeamLayer(three, scene, state, order) {
|
|
203
|
+
if (three.AdditiveBlending === undefined)
|
|
204
|
+
throw new Error("the three.js handed over has no AdditiveBlending, which the beam needs");
|
|
205
|
+
const blending = three.AdditiveBlending;
|
|
206
|
+
const uniforms = {
|
|
207
|
+
sat: { value: new three.Vector3() },
|
|
208
|
+
nadir: { value: new three.Vector3(0, 1, 0) },
|
|
209
|
+
e1: { value: new three.Vector3(1, 0, 0) },
|
|
210
|
+
e2: { value: new three.Vector3(0, 0, 1) },
|
|
211
|
+
lambda: { value: 0 },
|
|
212
|
+
colour: { value: new three.Color(state.colour) },
|
|
213
|
+
strength: { value: state.strength },
|
|
214
|
+
pitch: { value: 0.2 },
|
|
215
|
+
circle: { value: 0.1 },
|
|
216
|
+
weights: { value: 0.3 },
|
|
217
|
+
cone0: { value: 0.42 },
|
|
218
|
+
thin: { value: 0.5 },
|
|
219
|
+
};
|
|
220
|
+
// forceSinglePass: a double-sided transparent material is drawn twice (back faces, then front); added light does not care about the order, so once is enough and the beam costs half the draw calls.
|
|
221
|
+
// Two draw calls in all: the cones (the footprint's own and the thin one to each cell), and the ground (the footprint's disc and ring and the cells').
|
|
222
|
+
const common = { transparent: true, depthWrite: false, blending, forceSinglePass: true, side: three.DoubleSide, uniforms };
|
|
223
|
+
const coneMaterial = new three.ShaderMaterial({ vertexShader: CONE_VERT, fragmentShader: CONE_FRAG, ...common });
|
|
224
|
+
const groundMaterial = new three.ShaderMaterial({ vertexShader: DISC_VERT, fragmentShader: DISC_FRAG, ...common });
|
|
225
|
+
let cones = null;
|
|
226
|
+
let ground = null;
|
|
227
|
+
let cellKey = "";
|
|
228
|
+
const make = (lattice) => {
|
|
229
|
+
for (const old of [cones, ground]) {
|
|
230
|
+
if (!old)
|
|
231
|
+
continue;
|
|
232
|
+
scene.remove(old);
|
|
233
|
+
old.geometry.dispose();
|
|
234
|
+
}
|
|
235
|
+
cones = new three.Mesh(coneGeometry(three, lattice), coneMaterial);
|
|
236
|
+
ground = new three.Mesh(groundGeometry(three, lattice), groundMaterial);
|
|
237
|
+
for (const part of [cones, ground]) {
|
|
238
|
+
part.frustumCulled = false;
|
|
239
|
+
part.renderOrder = order;
|
|
240
|
+
part.visible = false;
|
|
241
|
+
scene.add(part);
|
|
242
|
+
}
|
|
243
|
+
state.stats.builds += 1;
|
|
244
|
+
};
|
|
245
|
+
const stats = state.stats;
|
|
246
|
+
const up = new three.Vector3(0, 1, 0);
|
|
247
|
+
const side = new three.Vector3();
|
|
248
|
+
return {
|
|
249
|
+
sync(position) {
|
|
250
|
+
const height = position ? Math.hypot(position[0], position[1], position[2]) : 0;
|
|
251
|
+
const on = state.on && position !== null && height > 1;
|
|
252
|
+
stats.shown = on;
|
|
253
|
+
if (cones)
|
|
254
|
+
cones.visible = on;
|
|
255
|
+
if (ground)
|
|
256
|
+
ground.visible = on;
|
|
257
|
+
if (!on || !position) {
|
|
258
|
+
stats.heightKm = 0;
|
|
259
|
+
stats.radiusKm = 0;
|
|
260
|
+
stats.angleDegrees = 0;
|
|
261
|
+
stats.cells = 0;
|
|
262
|
+
stats.cellRadiusKm = 0;
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
const heightKm = (height - 1) * EARTH_KM;
|
|
266
|
+
const lambda = footprintAngle(heightKm, state.elevation);
|
|
267
|
+
stats.heightKm = heightKm;
|
|
268
|
+
stats.radiusKm = footprintKm(heightKm, state.elevation);
|
|
269
|
+
stats.angleDegrees = (lambda * 180) / Math.PI;
|
|
270
|
+
stats.elevation = state.elevation;
|
|
271
|
+
// the cells: the geometry is made again only when their number changes (and the first time); their size follows the footprint
|
|
272
|
+
const wanted = beamCells(state.cells, stats.radiusKm, state.cellSize);
|
|
273
|
+
const key = `${wanted.lattice.length}`;
|
|
274
|
+
if (!cones || key !== cellKey) {
|
|
275
|
+
cellKey = key;
|
|
276
|
+
make(wanted.lattice);
|
|
277
|
+
}
|
|
278
|
+
cones.visible = true;
|
|
279
|
+
ground.visible = true;
|
|
280
|
+
uniforms.sat.value.set(position[0], position[1], position[2]);
|
|
281
|
+
uniforms.nadir.value.set(position[0] / height, position[1] / height, position[2] / height);
|
|
282
|
+
side.copy(Math.abs(uniforms.nadir.value.y) > 0.99 ? side.set(1, 0, 0) : up).cross(uniforms.nadir.value).normalize();
|
|
283
|
+
uniforms.e1.value.copy(side);
|
|
284
|
+
uniforms.e2.value.copy(uniforms.nadir.value).cross(side);
|
|
285
|
+
uniforms.lambda.value = lambda;
|
|
286
|
+
uniforms.colour.value.set(state.colour);
|
|
287
|
+
uniforms.strength.value = state.strength;
|
|
288
|
+
uniforms.pitch.value = wanted.pitch;
|
|
289
|
+
uniforms.circle.value = wanted.radius;
|
|
290
|
+
// the shafts are the beam's body when there are cells (the footprint's own cone is then a faint haze); each is dimmer the more there are, since they add up at the satellite
|
|
291
|
+
uniforms.weights.value = 0.7 / Math.sqrt(Math.max(1, wanted.lattice.length / 7));
|
|
292
|
+
uniforms.cone0.value = wanted.lattice.length > 0 ? 0.12 : 0.42;
|
|
293
|
+
stats.cells = wanted.lattice.length;
|
|
294
|
+
stats.cellRadiusKm = wanted.lattice.length > 0 ? wanted.radius * stats.radiusKm : 0;
|
|
295
|
+
},
|
|
296
|
+
dispose() {
|
|
297
|
+
for (const part of [cones, ground]) {
|
|
298
|
+
if (!part)
|
|
299
|
+
continue;
|
|
300
|
+
scene.remove(part);
|
|
301
|
+
part.geometry.dispose();
|
|
302
|
+
}
|
|
303
|
+
coneMaterial.dispose();
|
|
304
|
+
groundMaterial.dispose();
|
|
305
|
+
stats.shown = false;
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
}
|
|
@@ -1399,7 +1399,7 @@ export class ChikyuEarthRealistic extends HTMLElement {
|
|
|
1399
1399
|
let epochMs = 0;
|
|
1400
1400
|
for (const group of this.#model.satellites.groups.values())
|
|
1401
1401
|
epochMs = Math.max(epochMs, group.satellites.newestEpochMs);
|
|
1402
|
-
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates };
|
|
1402
|
+
return { groups: this.#model.satellites.groups.size, placed: drawn.placed, segments: drawn.segments, tooFast: drawn.tooFast, dotScale: drawn.dotScale, longestStreakPx: drawn.longestStreakPx, streakCapPx: drawn.streakCapPx, weight: drawn.weight, fade: drawn.fade, earthPx: drawn.earthPx, epochMs, propagations, lastBatchMs, maxBatchMs, updateMs: drawn.updateMs, maxUpdateMs: drawn.maxUpdateMs, averageUpdateMs: drawn.updates ? drawn.totalMs / drawn.updates : 0, updates: drawn.updates, selectedRing: drawn.selectedRing };
|
|
1403
1403
|
}
|
|
1404
1404
|
// A press that does not turn the view (under 6 pixels) on a satellite tells the page, which chooses it with `selectSatellite` if it likes.
|
|
1405
1405
|
#downX = 0;
|
|
@@ -9,6 +9,7 @@ import { type BorderSets } from "../borders/lines.ts";
|
|
|
9
9
|
import type { BorderData, BorderStats } from "../borders/layer.ts";
|
|
10
10
|
import { type RouteLeg } from "../route.ts";
|
|
11
11
|
import type { GridStats } from "../grid/layer.ts";
|
|
12
|
+
import type { BeamStats } from "../beam/layer.ts";
|
|
12
13
|
import { type CountryNamesStats, type CountryNamesStyle } from "../country-names/host.ts";
|
|
13
14
|
import { type SeaNamesStats } from "../sea-names/host.ts";
|
|
14
15
|
import type { TileStats } from "../realistic/tile-set.ts";
|
|
@@ -18,7 +19,7 @@ import type { SatelliteInfo, SatelliteRef, Satellites } from "../satellites/type
|
|
|
18
19
|
import { type PlanetName } from "./ephemeris.ts";
|
|
19
20
|
import { type SatelliteScreen, type SatelliteStyle } from "./satellite-layer.ts";
|
|
20
21
|
import { type SatelliteOthers } from "./satellite-focus.ts";
|
|
21
|
-
import { type RideFace, type RideLook, type RideViewpoint } from "./ride.ts";
|
|
22
|
+
import { type RideFace, type RideLook, type RideModelSize, type RideViewpoint } from "./ride.ts";
|
|
22
23
|
import { type ScaleMode } from "./scale.ts";
|
|
23
24
|
import { BODY_NAMES, type CameraMode, type BodyName, type BodyPainter, type RideTarget, type SatellitePainter } from "./scene.ts";
|
|
24
25
|
import { type PaintSpec } from "../paint/buffer.ts";
|
|
@@ -116,6 +117,8 @@ export interface RideOptions {
|
|
|
116
117
|
face?: RideFace;
|
|
117
118
|
/** `outside` (the default, or the element's `ride-viewpoint`) shows the satellite: with `view: "from"` the camera is a little behind and above it (straight above it with `look: "down"`), and a satellite the page has no model for is drawn small from the package's own sketch of its kind. `inside` is the camera at the satellite, as before, and no sketch. A body is always ridden from inside. */
|
|
118
119
|
viewpoint?: RideViewpoint;
|
|
120
|
+
/** `distance` (the default, or the element's `ride-model-size`) lets the model of a satellite seen from above shrink as the camera rises and hand over to the ordinary mark, ring and name, between 1,000 and 2,000 km; `fixed` keeps one share of the picture at every height. */
|
|
121
|
+
modelSize?: RideModelSize;
|
|
119
122
|
distanceKm?: number;
|
|
120
123
|
smooth?: boolean;
|
|
121
124
|
}
|
|
@@ -138,6 +141,8 @@ export interface Riding {
|
|
|
138
141
|
distanceKm: number;
|
|
139
142
|
/** `outside` or `inside` (see `RideOptions`). */
|
|
140
143
|
viewpoint: RideViewpoint;
|
|
144
|
+
/** `distance` or `fixed` (see `RideOptions`). */
|
|
145
|
+
modelSize: RideModelSize;
|
|
141
146
|
}
|
|
142
147
|
type SatelliteStats = {
|
|
143
148
|
groups: number;
|
|
@@ -158,6 +163,7 @@ type SatelliteStats = {
|
|
|
158
163
|
maxUpdateMs: number;
|
|
159
164
|
averageUpdateMs: number;
|
|
160
165
|
updates: number;
|
|
166
|
+
selectedRing: boolean;
|
|
161
167
|
};
|
|
162
168
|
/**
|
|
163
169
|
* The `<chikyu-space>` custom element: the Earth, the Moon, the Sun and the planets where they are at a date and time, drawn with three.js through the shared renderer. It takes `center`, `time` (`now` or an ISO date), `speed` (1 is real time, 0 holds, 86400 is a day a second, negative runs backwards), `scale` (`compressed` or `true`), `labels` and `orbits` (`off` hides them); positions are computed in the browser by astronomy-engine, an optional peer dependency. It draws only when something changes, and nothing while it is out of sight.
|
|
@@ -174,6 +180,9 @@ type SatelliteStats = {
|
|
|
174
180
|
* `borders` draws the borders on the Earth's land as thin lines that turn with it, as on `<chikyu-earth-realistic>`: `countries`, `regions` (from the page's `borderData.regions`, once the Earth is
|
|
175
181
|
* large enough), or both with a bare attribute; `chikyu-borders-unavailable` is sent when the shapes cannot be loaded.
|
|
176
182
|
*
|
|
183
|
+
* `beam` draws a beam of light from the chosen satellite (the one marked, or the one ridden) down to the ground below it: a soft cone ending in a lit footprint, the circle from which the satellite is above
|
|
184
|
+
* `beam-elevation` degrees (25), with `beam-cells` spot cells inside it (an illustration, never an operator's plan), `beam-cell-size`, `beam-color` and `beam-strength` (the property `beam` and its siblings, and `stats.beam`).
|
|
185
|
+
*
|
|
177
186
|
* `grid` draws the meridians and parallels on the Earth, and `country-names` names its countries, as on `<chikyu-earth-realistic>`: the names keep clear of the bodies', the places' and the
|
|
178
187
|
* cities' names and stay on the Earth's disc; `chikyu-country-names-unavailable` is sent when the outlines cannot be loaded.
|
|
179
188
|
*
|
|
@@ -345,6 +354,39 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
345
354
|
*/
|
|
346
355
|
get cityNamesStyle(): CityNamesStyle;
|
|
347
356
|
set cityNamesStyle(value: CityNamesStyle);
|
|
357
|
+
/**
|
|
358
|
+
* Whether a beam of light is drawn from the chosen satellite down to the ground below it (the attribute `beam`, off unless set). The chosen satellite is the one marked with `selectSatellite` or a press,
|
|
359
|
+
* or the one ridden (Ride along and Ride above, where the camera looks down the beam). The beam is a soft cone, brighter at the satellite and fading towards the ground, ending in a lit ring on the
|
|
360
|
+
* surface: the footprint, the circle from which the satellite stands above `beamElevation` degrees (25), true to its height. Behind the Earth it is cut off by the limb. It is drawn with the draw that
|
|
361
|
+
* moves the satellite, and nothing is drawn at rest. Setting it writes the attribute, or takes it away; `stats.beam` says the footprint's radius in kilometres.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```ts no-run
|
|
365
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
366
|
+
*
|
|
367
|
+
* const space = document.querySelector<ChikyuSpace>("chikyu-space")!;
|
|
368
|
+
* space.beam = true;
|
|
369
|
+
* space.beamElevation = 30;
|
|
370
|
+
* console.log(space.stats.beam.radiusKm);
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
get beam(): boolean;
|
|
374
|
+
set beam(value: boolean);
|
|
375
|
+
/** The least elevation, in degrees, from which the footprint counts the satellite as seen (the attribute `beam-elevation`, 25). Setting it writes the attribute. */
|
|
376
|
+
get beamElevation(): number;
|
|
377
|
+
set beamElevation(value: number);
|
|
378
|
+
/** How many spot cells are drawn inside the footprint, 0 for none (the attribute `beam-cells`, up to 91). They are an illustration of a satellite that serves the ground in cells, not any operator's plan. */
|
|
379
|
+
get beamCells(): number;
|
|
380
|
+
set beamCells(value: number);
|
|
381
|
+
/** A spot cell's radius on the ground in kilometres, at most what fits (the attribute `beam-cell-size`, 0 for the fit). */
|
|
382
|
+
get beamCellSize(): number;
|
|
383
|
+
set beamCellSize(value: number);
|
|
384
|
+
/** The beam's colour, any CSS colour (the attribute `beam-color`, a pale blue). */
|
|
385
|
+
get beamColor(): string;
|
|
386
|
+
set beamColor(value: string);
|
|
387
|
+
/** How strong the beam is, from 0 to 1 (the attribute `beam-strength`, 0.6). */
|
|
388
|
+
get beamStrength(): number;
|
|
389
|
+
set beamStrength(value: number);
|
|
348
390
|
/** Whether the meridians and parallels are drawn on the Earth (the attribute `grid`). Setting it writes the attribute, or takes it away. */
|
|
349
391
|
get grid(): boolean;
|
|
350
392
|
set grid(value: boolean);
|
|
@@ -491,6 +533,21 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
491
533
|
*/
|
|
492
534
|
get rideViewpoint(): RideViewpoint;
|
|
493
535
|
set rideViewpoint(value: RideViewpoint);
|
|
536
|
+
/**
|
|
537
|
+
* How the model of a satellite seen from above is sized as the camera rises: `distance` (the default; the attribute `ride-model-size`) lets it shrink with the height and hand over to the ordinary mark (ring and name) between 1,000 and 2,000 km, `fixed` keeps the same share of the picture at every height, as 0.46.1 did.
|
|
538
|
+
* It is the default for the next `ride` and, set while riding, changes the one ridden at the next draw. See `RideOptions.modelSize`.
|
|
539
|
+
*
|
|
540
|
+
* @example
|
|
541
|
+
* ```ts
|
|
542
|
+
* import type { ChikyuSpace } from "@johnmorrisdotca/chikyu-earth/space/element";
|
|
543
|
+
*
|
|
544
|
+
* const space = document.createElement("chikyu-space") as ChikyuSpace;
|
|
545
|
+
* space.rideModelSize = "fixed";
|
|
546
|
+
* console.log(space.rideModelSize);
|
|
547
|
+
* ```
|
|
548
|
+
*/
|
|
549
|
+
get rideModelSize(): RideModelSize;
|
|
550
|
+
set rideModelSize(value: RideModelSize);
|
|
494
551
|
/** What the camera is riding along with now, or null. */
|
|
495
552
|
get riding(): Riding | null;
|
|
496
553
|
/**
|
|
@@ -742,6 +799,8 @@ export declare class ChikyuSpace extends HTMLElement {
|
|
|
742
799
|
borders: BorderStats;
|
|
743
800
|
/** The grid: whether it was drawn at the last draw, whether every 15 degrees (else 30), its segments then, how many times its lines were made, and whether it could not be made. */
|
|
744
801
|
grid: GridStats;
|
|
802
|
+
/** The beam: whether it was drawn at the last draw, the chosen satellite's height, the footprint's radius in kilometres and its angle at the Earth's centre, the elevation, the cells drawn and a cell's radius, and how many times its geometry was made. */
|
|
803
|
+
beam: BeamStats;
|
|
745
804
|
/** The route between two places: whether one is set, and its geodesic distance, great-circle distance and flight time at 900 km/h. */
|
|
746
805
|
route: {
|
|
747
806
|
on: boolean;
|