@johnmorrisdotca/wakusei-planets 0.48.0 → 0.50.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/CHANGELOG.md +8 -0
- package/NOTICE.md +1 -1
- package/README.md +3 -3
- package/dist/scene/textures.d.ts +2 -2
- package/dist/surface/drive.d.ts +181 -0
- package/dist/surface/drive.js +247 -0
- package/dist/surface/dust.d.ts +46 -0
- package/dist/surface/dust.js +96 -0
- package/dist/surface/element.d.ts +46 -0
- package/dist/surface/element.js +426 -6
- package/dist/surface/glsl.d.ts +6 -0
- package/dist/surface/glsl.js +56 -1
- package/dist/surface/index.d.ts +4 -1
- package/dist/surface/index.js +4 -1
- package/dist/surface/land.d.ts +6 -0
- package/dist/surface/land.js +8 -0
- package/dist/surface/landing.d.ts +134 -0
- package/dist/surface/landing.js +237 -0
- package/dist/surface/scene.d.ts +16 -0
- package/dist/surface/scene.js +292 -3
- package/dist/surface/shapes.d.ts +16 -2
- package/dist/surface/shapes.js +42 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/surface/scene.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { rocksAround } from "./detail.js";
|
|
2
|
-
import { DISC_FRAGMENT, DISC_VERTEX, GROUND_FRAGMENT, GROUND_VERTEX, OBJECT_FRAGMENT, OBJECT_VERTEX, ROCK_FRAGMENT, ROCK_VERTEX, SHADOW_FRAGMENT, SHADOW_VERTEX, TRACK_FRAGMENT, TRACK_VERTEX } from "./glsl.js";
|
|
2
|
+
import { DISC_FRAGMENT, DISC_VERTEX, GROUND_FRAGMENT, GROUND_VERTEX, OBJECT_FRAGMENT, OBJECT_VERTEX, ROCK_FRAGMENT, ROCK_VERTEX, SHADOW_FRAGMENT, SHADOW_VERTEX, TRACK_FRAGMENT, TRACK_VERTEX, DUST_FRAGMENT, DUST_VERTEX, PLUME_FRAGMENT, PLUME_VERTEX } from "./glsl.js";
|
|
3
|
+
import { driveParts } from "./drive.js";
|
|
4
|
+
import { placePart, ascentParts, landerParts } from "./shapes.js";
|
|
3
5
|
import { KEEP_OUT, objectParts, partShadows } from "./objects.js";
|
|
4
6
|
import { rockMesh } from "./rocks.js";
|
|
5
7
|
import { cameraAxes, viewProjection } from "./view.js";
|
|
@@ -226,6 +228,7 @@ export function createSurfaceItem(options) {
|
|
|
226
228
|
const list = options.objects ?? [];
|
|
227
229
|
const ground = options.groundY;
|
|
228
230
|
const on = state.objects !== false && list.length > 0 && ground !== undefined;
|
|
231
|
+
const driving = state.vehicle !== undefined;
|
|
229
232
|
if (objectMesh !== undefined)
|
|
230
233
|
objectMesh.visible = on;
|
|
231
234
|
if (objectShadowMesh !== undefined)
|
|
@@ -234,7 +237,7 @@ export function createSurfaceItem(options) {
|
|
|
234
237
|
trackMesh.visible = on;
|
|
235
238
|
if (!on || ground === undefined)
|
|
236
239
|
return;
|
|
237
|
-
const key = `${state.sky.sun.azimuth.toFixed(1)}|${state.sky.sun.altitude.toFixed(1)}|${objectVersion}`;
|
|
240
|
+
const key = `${state.sky.sun.azimuth.toFixed(1)}|${state.sky.sun.altitude.toFixed(1)}|${objectVersion}|${driving}|${state.shadows !== false}|${state.lander !== undefined}`;
|
|
238
241
|
if (key === objectKey)
|
|
239
242
|
return;
|
|
240
243
|
objectKey = key;
|
|
@@ -244,6 +247,10 @@ export function createSurfaceItem(options) {
|
|
|
244
247
|
const tint = [];
|
|
245
248
|
const shadow = [];
|
|
246
249
|
for (const object of list) {
|
|
250
|
+
if (driving && object.kind === "rover")
|
|
251
|
+
continue;
|
|
252
|
+
if (state.lander !== undefined && object.kind === "lander")
|
|
253
|
+
continue;
|
|
247
254
|
const base = ground(object.east, object.north);
|
|
248
255
|
const parts = objectParts(object, base);
|
|
249
256
|
for (const part of parts) {
|
|
@@ -254,7 +261,8 @@ export function createSurfaceItem(options) {
|
|
|
254
261
|
tint.push(...(part.colour ?? [1, 1, 1]));
|
|
255
262
|
}
|
|
256
263
|
}
|
|
257
|
-
|
|
264
|
+
if (state.shadows !== false)
|
|
265
|
+
shadow.push(...partShadows(parts, base, state.sky.sun.azimuth, state.sky.sun.altitude));
|
|
258
266
|
}
|
|
259
267
|
const geometry = new T.BufferGeometry();
|
|
260
268
|
geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(position), 3));
|
|
@@ -333,6 +341,273 @@ export function createSurfaceItem(options) {
|
|
|
333
341
|
trackMesh.renderOrder = 0.5;
|
|
334
342
|
scene.add(trackMesh);
|
|
335
343
|
}
|
|
344
|
+
// the rover being driven: its parts as one mesh turned and placed at each draw (a few thousand corners: cheap), its shadow, the path it has left as tracks and the grains it throws as small squares
|
|
345
|
+
let vehicleMesh;
|
|
346
|
+
let vehicleShadow;
|
|
347
|
+
let vehicleCount = 0;
|
|
348
|
+
const makeVehicle = (state) => {
|
|
349
|
+
const v = state.vehicle;
|
|
350
|
+
if (v === undefined || state.objects === false) {
|
|
351
|
+
if (vehicleMesh !== undefined)
|
|
352
|
+
vehicleMesh.visible = false;
|
|
353
|
+
if (vehicleShadow !== undefined)
|
|
354
|
+
vehicleShadow.visible = false;
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const parts = driveParts(v);
|
|
358
|
+
const count = parts.reduce((n, part) => n + part.position.length / 3, 0);
|
|
359
|
+
if (vehicleMesh === undefined || count !== vehicleCount) {
|
|
360
|
+
vehicleMesh?.geometry.dispose();
|
|
361
|
+
const geometry = new T.BufferGeometry();
|
|
362
|
+
geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(count * 3), 3));
|
|
363
|
+
geometry.setAttribute("normal", new T.BufferAttribute(new Float32Array(count * 3), 3));
|
|
364
|
+
const tone = new Float32Array(count);
|
|
365
|
+
const tint = new Float32Array(count * 3);
|
|
366
|
+
let at = 0;
|
|
367
|
+
for (const part of parts) {
|
|
368
|
+
for (let i = 0; i < part.position.length / 3; i += 1) {
|
|
369
|
+
tone[at] = part.tone;
|
|
370
|
+
tint.set(part.colour ?? [1, 1, 1], at * 3);
|
|
371
|
+
at += 1;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
geometry.setAttribute("tone", new T.BufferAttribute(tone, 1));
|
|
375
|
+
geometry.setAttribute("tint", new T.BufferAttribute(tint, 3));
|
|
376
|
+
vehicleCount = count;
|
|
377
|
+
if (vehicleMesh === undefined) {
|
|
378
|
+
vehicleMesh = new T.Mesh(geometry, objectMaterial);
|
|
379
|
+
vehicleMesh.frustumCulled = false;
|
|
380
|
+
vehicleMesh.renderOrder = 1;
|
|
381
|
+
scene.add(vehicleMesh);
|
|
382
|
+
}
|
|
383
|
+
else
|
|
384
|
+
vehicleMesh.geometry = geometry;
|
|
385
|
+
}
|
|
386
|
+
const position = vehicleMesh.geometry.getAttribute("position");
|
|
387
|
+
const normal = vehicleMesh.geometry.getAttribute("normal");
|
|
388
|
+
let at = 0;
|
|
389
|
+
for (const part of parts) {
|
|
390
|
+
position.array.set(part.position, at * 3);
|
|
391
|
+
normal.array.set(part.normal, at * 3);
|
|
392
|
+
at += part.position.length / 3;
|
|
393
|
+
}
|
|
394
|
+
position.needsUpdate = true;
|
|
395
|
+
normal.needsUpdate = true;
|
|
396
|
+
vehicleMesh.visible = true;
|
|
397
|
+
const shadow = state.shadows === false ? [] : partShadows(parts, v.y, state.sky.sun.azimuth, state.sky.sun.altitude);
|
|
398
|
+
const geometry = new T.BufferGeometry();
|
|
399
|
+
geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(shadow), 3));
|
|
400
|
+
geometry.setAttribute("uv", new T.BufferAttribute(new Float32Array((shadow.length / 3) * 2).map((_, i) => (i % 2 === 1 ? 0 : 0.5)), 2));
|
|
401
|
+
if (vehicleShadow === undefined) {
|
|
402
|
+
vehicleShadow = new T.Mesh(geometry, shadowMaterial);
|
|
403
|
+
vehicleShadow.frustumCulled = false;
|
|
404
|
+
vehicleShadow.renderOrder = 2;
|
|
405
|
+
scene.add(vehicleShadow);
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
408
|
+
vehicleShadow.geometry.dispose();
|
|
409
|
+
vehicleShadow.geometry = geometry;
|
|
410
|
+
}
|
|
411
|
+
vehicleShadow.visible = true;
|
|
412
|
+
};
|
|
413
|
+
// the driven path: a strip like the published traverse's, grown as the rover goes (room for 6,000 points)
|
|
414
|
+
const TRAIL_MAX = 6000;
|
|
415
|
+
let trailMesh;
|
|
416
|
+
let trailMaterialDriven;
|
|
417
|
+
let trailBuilt = 0;
|
|
418
|
+
const makeTrail = (state) => {
|
|
419
|
+
const points = state.trail;
|
|
420
|
+
if (points === undefined || points.length < 4) {
|
|
421
|
+
if (trailMesh !== undefined)
|
|
422
|
+
trailMesh.visible = false;
|
|
423
|
+
trailBuilt = 0;
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (trailMesh === undefined) {
|
|
427
|
+
const geometry = new T.BufferGeometry();
|
|
428
|
+
geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(TRAIL_MAX * 2 * 3), 3));
|
|
429
|
+
geometry.setAttribute("uv", new T.BufferAttribute(new Float32Array(TRAIL_MAX * 2 * 2), 2));
|
|
430
|
+
const indices = new Uint32Array((TRAIL_MAX - 1) * 6);
|
|
431
|
+
for (let i = 1; i < TRAIL_MAX; i += 1)
|
|
432
|
+
indices.set([2 * i - 2, 2 * i - 1, 2 * i, 2 * i - 1, 2 * i + 1, 2 * i], (i - 1) * 6);
|
|
433
|
+
geometry.setIndex(new T.BufferAttribute(indices, 1));
|
|
434
|
+
const material = new T.ShaderMaterial({ vertexShader: TRACK_VERTEX, fragmentShader: TRACK_FRAGMENT, uniforms, transparent: true, depthWrite: false, side: 2 });
|
|
435
|
+
material.polygonOffset = true;
|
|
436
|
+
material.polygonOffsetFactor = -3;
|
|
437
|
+
material.polygonOffsetUnits = -3;
|
|
438
|
+
trailMaterialDriven = material;
|
|
439
|
+
trailMesh = new T.Mesh(geometry, material);
|
|
440
|
+
trailMesh.frustumCulled = false;
|
|
441
|
+
trailMesh.renderOrder = 0.6;
|
|
442
|
+
scene.add(trailMesh);
|
|
443
|
+
}
|
|
444
|
+
const count = Math.min(TRAIL_MAX, points.length / 2);
|
|
445
|
+
if (count < trailBuilt)
|
|
446
|
+
trailBuilt = 0;
|
|
447
|
+
const position = trailMesh.geometry.getAttribute("position").array;
|
|
448
|
+
const uv = trailMesh.geometry.getAttribute("uv").array;
|
|
449
|
+
let along = trailBuilt > 0 ? uv[(trailBuilt - 1) * 4] : 0;
|
|
450
|
+
for (let i = Math.max(0, trailBuilt - 1); i < count; i += 1) {
|
|
451
|
+
const a = Math.max(0, i - 1);
|
|
452
|
+
const b = Math.min(count - 1, i + 1);
|
|
453
|
+
const [dx, dy] = [points[2 * b] - points[2 * a], points[2 * b + 1] - points[2 * a + 1]];
|
|
454
|
+
const len = Math.hypot(dx, dy) || 1;
|
|
455
|
+
const [nx, ny] = [-dy / len, dx / len];
|
|
456
|
+
if (i > 0)
|
|
457
|
+
along += Math.hypot(points[2 * i] - points[2 * i - 2], points[2 * i + 1] - points[2 * i - 1]);
|
|
458
|
+
for (const side of [-1, 1]) {
|
|
459
|
+
const k = i * 2 + (side === 1 ? 1 : 0);
|
|
460
|
+
position[k * 3] = points[2 * i] + nx * 1.4 * side;
|
|
461
|
+
position[k * 3 + 1] = points[2 * i + 1] + ny * 1.4 * side;
|
|
462
|
+
position[k * 3 + 2] = 0;
|
|
463
|
+
uv[k * 2] = along;
|
|
464
|
+
uv[k * 2 + 1] = side;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
trailBuilt = count;
|
|
468
|
+
trailMesh.geometry.getAttribute("position").needsUpdate = true;
|
|
469
|
+
trailMesh.geometry.getAttribute("uv").needsUpdate = true;
|
|
470
|
+
trailMesh.geometry.setDrawRange(0, Math.max(0, (count - 1) * 6));
|
|
471
|
+
trailMesh.visible = true;
|
|
472
|
+
};
|
|
473
|
+
// the dust: one small square for each grain in the pool, in the corners of a fixed set of triangles
|
|
474
|
+
let dustMesh;
|
|
475
|
+
let dustMaterial;
|
|
476
|
+
const dustUniforms = { uVP: uniforms.uVP, uRight: { value: new T.Vector3(1, 0, 0) }, uUp: { value: new T.Vector3(0, 1, 0) }, uSize: { value: 0.022 }, uEyeWorld: { value: new T.Vector3() }, uMinAngle: { value: 0 } };
|
|
477
|
+
const makeDust = (state) => {
|
|
478
|
+
const grains = state.dust;
|
|
479
|
+
if (grains === undefined) {
|
|
480
|
+
if (dustMesh !== undefined)
|
|
481
|
+
dustMesh.visible = false;
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const n = grains.length / 3;
|
|
485
|
+
if (dustMesh === undefined) {
|
|
486
|
+
const geometry = new T.BufferGeometry();
|
|
487
|
+
geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(n * 4 * 3), 3));
|
|
488
|
+
const uv = new Float32Array(n * 4 * 2);
|
|
489
|
+
const index = new Uint32Array(n * 6);
|
|
490
|
+
for (let i = 0; i < n; i += 1) {
|
|
491
|
+
uv.set([0, 0, 1, 0, 1, 1, 0, 1], i * 8);
|
|
492
|
+
index.set([i * 4, i * 4 + 1, i * 4 + 2, i * 4, i * 4 + 2, i * 4 + 3], i * 6);
|
|
493
|
+
}
|
|
494
|
+
geometry.setAttribute("uv", new T.BufferAttribute(uv, 2));
|
|
495
|
+
geometry.setIndex(new T.BufferAttribute(index, 1));
|
|
496
|
+
const material = new T.ShaderMaterial({ vertexShader: DUST_VERTEX, fragmentShader: DUST_FRAGMENT, uniforms: dustUniforms, transparent: true, depthWrite: false });
|
|
497
|
+
dustMaterial = material;
|
|
498
|
+
dustMesh = new T.Mesh(geometry, material);
|
|
499
|
+
dustMesh.frustumCulled = false;
|
|
500
|
+
dustMesh.renderOrder = 3;
|
|
501
|
+
scene.add(dustMesh);
|
|
502
|
+
}
|
|
503
|
+
const position = dustMesh.geometry.getAttribute("position");
|
|
504
|
+
const array = position.array;
|
|
505
|
+
for (let i = 0; i < n; i += 1)
|
|
506
|
+
for (let c = 0; c < 4; c += 1)
|
|
507
|
+
array.set([grains[i * 3], grains[i * 3 + 1], grains[i * 3 + 2]], (i * 4 + c) * 3);
|
|
508
|
+
position.needsUpdate = true;
|
|
509
|
+
const axes = cameraAxes(state.look);
|
|
510
|
+
dustUniforms.uRight.value.set(axes.right[0], axes.right[1], axes.right[2]);
|
|
511
|
+
dustUniforms.uUp.value.set(axes.up[0], axes.up[1], axes.up[2]);
|
|
512
|
+
dustUniforms.uSize.value = state.lander === undefined ? 0.022 : 0.09;
|
|
513
|
+
dustUniforms.uEyeWorld.value.set(state.eye.east, state.eye.up, -state.eye.north);
|
|
514
|
+
dustUniforms.uMinAngle.value = state.lander === undefined ? 0 : 2.6 * fullPixel; // seen from far off a grain still shows as about two pixels // a blast's grains are thrown wider and bigger than a wheel's
|
|
515
|
+
dustMesh.visible = true;
|
|
516
|
+
};
|
|
517
|
+
// the lunar module coming down: its parts placed at each draw (a few thousand corners), its shadow on the ground far below it, and its plume
|
|
518
|
+
let landerMesh;
|
|
519
|
+
let landerShadow;
|
|
520
|
+
let plumeMesh;
|
|
521
|
+
let plumeMaterial;
|
|
522
|
+
const plumeUniforms = { uVP: uniforms.uVP, uBell: { value: new T.Vector3() }, uLength: { value: 5 }, uRadius: { value: 2 }, uPlume: { value: 1 } };
|
|
523
|
+
const landerLocal = [...landerParts(), ...ascentParts()];
|
|
524
|
+
const landerVertices = landerLocal.reduce((n, part) => n + part.position.length / 3, 0);
|
|
525
|
+
const makeLander = (state) => {
|
|
526
|
+
const l = state.lander;
|
|
527
|
+
const groundOf = options.groundY;
|
|
528
|
+
if (l === undefined || groundOf === undefined) {
|
|
529
|
+
if (landerMesh !== undefined)
|
|
530
|
+
landerMesh.visible = false;
|
|
531
|
+
if (landerShadow !== undefined)
|
|
532
|
+
landerShadow.visible = false;
|
|
533
|
+
if (plumeMesh !== undefined)
|
|
534
|
+
plumeMesh.visible = false;
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
const base = groundOf(l.east, l.north);
|
|
538
|
+
const turn = (l.heading * Math.PI) / 180;
|
|
539
|
+
const parts = landerLocal.map((part) => placePart(part, l.east, base + l.altitude, l.north, turn));
|
|
540
|
+
if (landerMesh === undefined) {
|
|
541
|
+
const geometry = new T.BufferGeometry();
|
|
542
|
+
geometry.setAttribute("position", new T.BufferAttribute(new Float32Array(landerVertices * 3), 3));
|
|
543
|
+
geometry.setAttribute("normal", new T.BufferAttribute(new Float32Array(landerVertices * 3), 3));
|
|
544
|
+
const tone = new Float32Array(landerVertices);
|
|
545
|
+
const tint = new Float32Array(landerVertices * 3);
|
|
546
|
+
let at = 0;
|
|
547
|
+
for (const part of parts) {
|
|
548
|
+
for (let i = 0; i < part.position.length / 3; i += 1) {
|
|
549
|
+
tone[at] = part.tone;
|
|
550
|
+
tint.set(part.colour ?? [1, 1, 1], at * 3);
|
|
551
|
+
at += 1;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
geometry.setAttribute("tone", new T.BufferAttribute(tone, 1));
|
|
555
|
+
geometry.setAttribute("tint", new T.BufferAttribute(tint, 3));
|
|
556
|
+
landerMesh = new T.Mesh(geometry, objectMaterial);
|
|
557
|
+
landerMesh.frustumCulled = false;
|
|
558
|
+
landerMesh.renderOrder = 1;
|
|
559
|
+
scene.add(landerMesh);
|
|
560
|
+
// the plume: a fixed cone of 24 by 12 corners, sized and placed by uniforms
|
|
561
|
+
const pos = [];
|
|
562
|
+
const index = [];
|
|
563
|
+
for (let j = 0; j <= 12; j += 1)
|
|
564
|
+
for (let i = 0; i <= 24; i += 1)
|
|
565
|
+
pos.push(i / 24, j / 12, 0);
|
|
566
|
+
for (let j = 0; j < 12; j += 1)
|
|
567
|
+
for (let i = 0; i < 24; i += 1)
|
|
568
|
+
index.push(j * 25 + i, j * 25 + i + 1, (j + 1) * 25 + i, j * 25 + i + 1, (j + 1) * 25 + i + 1, (j + 1) * 25 + i);
|
|
569
|
+
const cone = new T.BufferGeometry();
|
|
570
|
+
cone.setAttribute("position", new T.BufferAttribute(new Float32Array(pos), 3));
|
|
571
|
+
cone.setIndex(new T.BufferAttribute(new Uint16Array(index), 1));
|
|
572
|
+
plumeMaterial = new T.ShaderMaterial({ vertexShader: PLUME_VERTEX, fragmentShader: PLUME_FRAGMENT, uniforms: plumeUniforms, transparent: true, depthWrite: false, side: 2 });
|
|
573
|
+
plumeMesh = new T.Mesh(cone, plumeMaterial);
|
|
574
|
+
plumeMesh.frustumCulled = false;
|
|
575
|
+
plumeMesh.renderOrder = 4;
|
|
576
|
+
scene.add(plumeMesh);
|
|
577
|
+
}
|
|
578
|
+
const position = landerMesh.geometry.getAttribute("position");
|
|
579
|
+
const normal = landerMesh.geometry.getAttribute("normal");
|
|
580
|
+
let at = 0;
|
|
581
|
+
for (const part of parts) {
|
|
582
|
+
position.array.set(part.position, at * 3);
|
|
583
|
+
normal.array.set(part.normal, at * 3);
|
|
584
|
+
at += part.position.length / 3;
|
|
585
|
+
}
|
|
586
|
+
position.needsUpdate = true;
|
|
587
|
+
normal.needsUpdate = true;
|
|
588
|
+
landerMesh.visible = l.inside !== true;
|
|
589
|
+
const shadow = state.shadows === false ? [] : partShadows(parts, base, state.sky.sun.azimuth, state.sky.sun.altitude);
|
|
590
|
+
const shadowGeometry = new T.BufferGeometry();
|
|
591
|
+
shadowGeometry.setAttribute("position", new T.BufferAttribute(new Float32Array(shadow), 3));
|
|
592
|
+
shadowGeometry.setAttribute("uv", new T.BufferAttribute(new Float32Array((shadow.length / 3) * 2).map((_, i) => (i % 2 === 1 ? 0 : 0.5)), 2));
|
|
593
|
+
if (landerShadow === undefined) {
|
|
594
|
+
landerShadow = new T.Mesh(shadowGeometry, shadowMaterial);
|
|
595
|
+
landerShadow.frustumCulled = false;
|
|
596
|
+
landerShadow.renderOrder = 2;
|
|
597
|
+
scene.add(landerShadow);
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
landerShadow.geometry.dispose();
|
|
601
|
+
landerShadow.geometry = shadowGeometry;
|
|
602
|
+
}
|
|
603
|
+
landerShadow.visible = true;
|
|
604
|
+
// the bell's exit is 0.3 m up; the plume reaches farther and wider the harder the engine works
|
|
605
|
+
plumeUniforms.uBell.value.set(l.east, base + l.altitude + 0.3, l.north);
|
|
606
|
+
plumeUniforms.uLength.value = 3 + 9 * l.throttle;
|
|
607
|
+
plumeUniforms.uRadius.value = 1.3 + 2.6 * l.throttle;
|
|
608
|
+
plumeUniforms.uPlume.value = l.throttle;
|
|
609
|
+
plumeMesh.visible = l.throttle > 0.02 && l.inside !== true;
|
|
610
|
+
};
|
|
336
611
|
let measuring = false;
|
|
337
612
|
let drawMs;
|
|
338
613
|
let aspect = context.width / Math.max(1, context.height);
|
|
@@ -346,6 +621,10 @@ export function createSurfaceItem(options) {
|
|
|
346
621
|
fullPixel = (2 * Math.tan((look.fov * Math.PI) / 360)) / pixelHeight;
|
|
347
622
|
makeRocks(state);
|
|
348
623
|
makeObjects(state);
|
|
624
|
+
makeVehicle(state);
|
|
625
|
+
makeLander(state);
|
|
626
|
+
makeTrail(state);
|
|
627
|
+
makeDust(state);
|
|
349
628
|
measuring = state.measure === true;
|
|
350
629
|
const world = new T.Vector3(eye.east, eye.up, -eye.north);
|
|
351
630
|
const vp = viewProjection([world.x, world.y, world.z], look, aspect);
|
|
@@ -479,6 +758,16 @@ export function createSurfaceItem(options) {
|
|
|
479
758
|
objectShadowMesh?.geometry.dispose();
|
|
480
759
|
trackGeometry?.dispose();
|
|
481
760
|
trackMaterial?.dispose();
|
|
761
|
+
vehicleMesh?.geometry.dispose();
|
|
762
|
+
vehicleShadow?.geometry.dispose();
|
|
763
|
+
trailMesh?.geometry.dispose();
|
|
764
|
+
dustMesh?.geometry.dispose();
|
|
765
|
+
landerMesh?.geometry.dispose();
|
|
766
|
+
landerShadow?.geometry.dispose();
|
|
767
|
+
plumeMesh?.geometry.dispose();
|
|
768
|
+
plumeMaterial?.dispose();
|
|
769
|
+
trailMaterialDriven?.dispose();
|
|
770
|
+
dustMaterial?.dispose();
|
|
482
771
|
objectMaterial.dispose();
|
|
483
772
|
blitMaterial.dispose();
|
|
484
773
|
},
|
package/dist/surface/shapes.d.ts
CHANGED
|
@@ -47,8 +47,8 @@ export declare function placePart(part: Part, east: number, base: number, north:
|
|
|
47
47
|
export declare function landerParts(): Part[];
|
|
48
48
|
/**
|
|
49
49
|
* The lunar rover in its own frame (x right, z forward, the middle of its wheelbase on the ground at the origin): a frame and floor, four wheels (parts 0 to 3: front left, front right, rear left, rear right) with a
|
|
50
|
-
* fender over each, two seats, the console with its handle, the dish on its mast, the television camera on its own mast, a whip antenna and the boxes at both ends. Sizes from the published ones (3.
|
|
51
|
-
* wide, wheels 0.
|
|
50
|
+
* fender over each, two seats, the console with its handle, the dish on its mast, the television camera on its own mast, a whip antenna and the boxes at both ends. Sizes from the published ones (about 3.05 m long, 2.13 m
|
|
51
|
+
* wide, wheels 0.81 m across, the wheelbase 2.29 m).
|
|
52
52
|
*
|
|
53
53
|
* @returns The parts.
|
|
54
54
|
*
|
|
@@ -60,3 +60,17 @@ export declare function landerParts(): Part[];
|
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
62
|
export declare function roverParts(): Part[];
|
|
63
|
+
/**
|
|
64
|
+
* The lunar module's ascent stage in the same frame as `landerParts` (it sits on the descent stage's deck, 3.2 m up): the cabin, its two triangular windows, the hatch section on top with the docking tunnel, the four
|
|
65
|
+
* thruster quads at its corners, the rendezvous radar on its boom and the antenna. Plain shapes from the published sizes (the whole craft stands about 7 m on its legs); no mark or flag is drawn.
|
|
66
|
+
*
|
|
67
|
+
* @returns The parts.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* import { ascentParts } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
72
|
+
*
|
|
73
|
+
* console.log(ascentParts().length, "parts");
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export declare function ascentParts(): Part[];
|
package/dist/surface/shapes.js
CHANGED
|
@@ -171,8 +171,8 @@ export function landerParts() {
|
|
|
171
171
|
}
|
|
172
172
|
/**
|
|
173
173
|
* The lunar rover in its own frame (x right, z forward, the middle of its wheelbase on the ground at the origin): a frame and floor, four wheels (parts 0 to 3: front left, front right, rear left, rear right) with a
|
|
174
|
-
* fender over each, two seats, the console with its handle, the dish on its mast, the television camera on its own mast, a whip antenna and the boxes at both ends. Sizes from the published ones (3.
|
|
175
|
-
* wide, wheels 0.
|
|
174
|
+
* fender over each, two seats, the console with its handle, the dish on its mast, the television camera on its own mast, a whip antenna and the boxes at both ends. Sizes from the published ones (about 3.05 m long, 2.13 m
|
|
175
|
+
* wide, wheels 0.81 m across, the wheelbase 2.29 m).
|
|
176
176
|
*
|
|
177
177
|
* @returns The parts.
|
|
178
178
|
*
|
|
@@ -198,7 +198,7 @@ export function roverParts() {
|
|
|
198
198
|
parts.push(box([0, 0.57, -1.1], [1.15, 0.03, 0.6], 0, 1.0, 0, grey));
|
|
199
199
|
const wheels = [[-1, 1], [1, 1], [-1, -1], [1, -1]];
|
|
200
200
|
wheels.forEach(([sx, sz], index) => {
|
|
201
|
-
const centre = [sx *
|
|
201
|
+
const centre = [sx * 0.95, 0.41, sz * 1.15];
|
|
202
202
|
// a wheel of wire mesh (dark, with a lighter hub), its strut to the frame and its fender over the top
|
|
203
203
|
const wheel = cylinder([-0.115, 0, 0], 0.41, 0.23, 16, 0.55, true, DARK);
|
|
204
204
|
const hub = cylinder([-0.12, 0, 0], 0.16, 0.24, 10, 1.0, true, [0.7, 0.72, 0.76]);
|
|
@@ -211,7 +211,7 @@ export function roverParts() {
|
|
|
211
211
|
}
|
|
212
212
|
parts.push(part);
|
|
213
213
|
}
|
|
214
|
-
parts.push(strut([sx * 0.55, 0.55, sz * 1.15], [sx * 0.
|
|
214
|
+
parts.push(strut([sx * 0.55, 0.55, sz * 1.15], [sx * 0.85, 0.45, sz * 1.15], 0.07, 1.1, grey));
|
|
215
215
|
// the fender: five narrow boards along an arc a hand above the tyre
|
|
216
216
|
for (let s = 0; s < 5; s += 1) {
|
|
217
217
|
const a0 = ((-65 + s * 26) * Math.PI) / 180;
|
|
@@ -234,14 +234,47 @@ export function roverParts() {
|
|
|
234
234
|
parts.push(strut([0, 1.1, 0.35], [0, 1.4, 0.3], 0.03, 1.0, DARK));
|
|
235
235
|
parts.push(box([0, 1.42, 0.3], [0.2, 0.04, 0.05], 0, 1.0, 0, DARK));
|
|
236
236
|
// the dish on its mast at the front, turned up and back toward the Earth, and the camera's own mast beside it
|
|
237
|
-
parts.push(strut([0, 0.6, 1.2], [0, 1
|
|
238
|
-
parts.push(dish([0,
|
|
239
|
-
parts.push(strut([
|
|
240
|
-
parts.push(box([
|
|
241
|
-
parts.push(strut([0.
|
|
237
|
+
parts.push(strut([0, 0.6, 1.2], [0, 2.1, 1.2], 0.05, 1.2, grey));
|
|
238
|
+
parts.push(dish([0, 2.2, 1.2], [0, 0.55, -0.55], 0.46, 0.14, 14, 1.4, [0.95, 0.95, 0.97]));
|
|
239
|
+
parts.push(strut([0.5, 0.6, 1.3], [0.5, 1.3, 1.3], 0.04, 1.2, grey));
|
|
240
|
+
parts.push(box([0.5, 1.4, 1.3], [0.26, 0.16, 0.18], 0, 1.0, 0, [0.5, 0.52, 0.56]));
|
|
241
|
+
parts.push(strut([-0.8, 0.6, 1.3], [-0.8, 1.9, 1.3], 0.012, 1.0, DARK));
|
|
242
242
|
// the boxes: the batteries at the front, the tools at the back
|
|
243
243
|
for (const x of [-0.4, 0.4])
|
|
244
244
|
parts.push(box([x, 0.76, 0.85], [0.36, 0.26, 0.38], 0, 1.0, 0, SILVER));
|
|
245
245
|
parts.push(box([0, 0.78, -1.15], [0.9, 0.3, 0.5], 0, 1.05, 0, SILVER));
|
|
246
246
|
return parts;
|
|
247
247
|
}
|
|
248
|
+
/**
|
|
249
|
+
* The lunar module's ascent stage in the same frame as `landerParts` (it sits on the descent stage's deck, 3.2 m up): the cabin, its two triangular windows, the hatch section on top with the docking tunnel, the four
|
|
250
|
+
* thruster quads at its corners, the rendezvous radar on its boom and the antenna. Plain shapes from the published sizes (the whole craft stands about 7 m on its legs); no mark or flag is drawn.
|
|
251
|
+
*
|
|
252
|
+
* @returns The parts.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* ```ts
|
|
256
|
+
* import { ascentParts } from "@johnmorrisdotca/wakusei-planets/surface";
|
|
257
|
+
*
|
|
258
|
+
* console.log(ascentParts().length, "parts");
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
export function ascentParts() {
|
|
262
|
+
const parts = [];
|
|
263
|
+
const cabin = [0.86, 0.83, 0.76];
|
|
264
|
+
const dark = [0.2, 0.22, 0.26];
|
|
265
|
+
parts.push(box([0, 4.1, 0.1], [3.0, 1.8, 2.6], 0, 1.2, 0, cabin));
|
|
266
|
+
// the front face's two windows, and the hatch section with its tunnel on top
|
|
267
|
+
for (const x of [-0.8, 0.8])
|
|
268
|
+
parts.push(box([x, 4.3, 1.42], [0.5, 0.55, 0.05], 0, 0.6, 0, dark));
|
|
269
|
+
parts.push(box([0, 5.2, 0], [2.2, 0.7, 2.0], 0, 1.1, 0, cabin));
|
|
270
|
+
parts.push(cylinder([0, 5.55, 0], 0.5, 0.45, 12, 1.0, false, [0.7, 0.7, 0.72]));
|
|
271
|
+
// the four thruster quads at the corners of the cabin
|
|
272
|
+
for (const x of [-1, 1])
|
|
273
|
+
for (const z of [-1, 1])
|
|
274
|
+
parts.push(box([x * 1.65, 4.1, z * 1.2], [0.45, 0.45, 0.45], 0, 1.0, 0, [0.78, 0.78, 0.8]));
|
|
275
|
+
// the rendezvous radar on a boom and the antenna
|
|
276
|
+
parts.push(strut([0.6, 5.4, 0.2], [1.1, 6.1, 0.2], 0.06, 1.1, [0.8, 0.8, 0.82]));
|
|
277
|
+
parts.push(dish([1.1, 6.15, 0.2], [0.4, 0.8, 0.4], 0.35, 0.1, 10, 1.4, [0.95, 0.95, 0.97]));
|
|
278
|
+
parts.push(strut([-0.5, 5.4, -0.4], [-0.5, 6.4, -0.4], 0.02, 1.0, [0.5, 0.5, 0.52]));
|
|
279
|
+
return parts;
|
|
280
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.50.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.
|
|
1
|
+
export const VERSION = "0.50.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@johnmorrisdotca/wakusei-planets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.50.0",
|
|
4
4
|
"description": "Wakusei Planets 惑星 — The Sun, planets and moons for the web: each as a clean line drawing, a shaded realistic drawing or a painted surface map, with real sizes, axial tilt and rotation as data, and positions of the moons for any date and time. SVG for the lines, three.js (optional) for the rest.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"planets",
|