mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-14 23:32:20 +00:00
Stretch a vessel to its beam only beside a reported length
A vessel drawn at its type's typical length keeps the model's proportions: a reported beam alone would squeeze a 300 m container ship to that width.
This commit is contained in:
1 parent
432a29ba59
commit
92d34bc4cc
2 files changed
+13
-3
No files matched your search
@@ -343,18 +343,22 @@ export function aircraftModelSpec(set, { typeCode, type, category } = {}) {
|
|||||||
* @returns {object} {@link fleetModelSpec}
|
* @returns {object} {@link fleetModelSpec}
|
||||||
*/
|
*/
|
||||||
export function vesselModelSpec(set, { type, length, beam, name } = {}) {
|
export function vesselModelSpec(set, { type, length, beam, name } = {}) {
|
||||||
|
// A beam counts only beside a reported length: a vessel drawn at its type's
|
||||||
|
// typical length keeps the model's proportions.
|
||||||
|
const reported = hullLength(length ?? undefined);
|
||||||
|
const hullWidth = reported === undefined ? undefined : (beam ?? undefined);
|
||||||
const resolved = resolveVessel(
|
const resolved = resolveVessel(
|
||||||
set.types,
|
set.types,
|
||||||
aisShipTypeCode(type),
|
aisShipTypeCode(type),
|
||||||
length ?? undefined,
|
reported,
|
||||||
beam ?? undefined,
|
hullWidth,
|
||||||
name ?? undefined,
|
name ?? undefined,
|
||||||
);
|
);
|
||||||
return specOf(
|
return specOf(
|
||||||
set,
|
set,
|
||||||
resolved,
|
resolved,
|
||||||
(r) => ({ model: set.types.default_vessel, length: r.length }),
|
(r) => ({ model: set.types.default_vessel, length: r.length }),
|
||||||
{ beam: beam ?? undefined },
|
{ beam: hullWidth },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -291,6 +291,12 @@ test('vessel specs read AIS codes and text families, stretched to the reported b
|
|||||||
const [sx, sy, sz] = box.scaleXYZ;
|
const [sx, sy, sz] = box.scaleXYZ;
|
||||||
assert.ok(Math.abs(sy - 51 / catalog.container_ship.beam) < 1e-12);
|
assert.ok(Math.abs(sy - 51 / catalog.container_ship.beam) < 1e-12);
|
||||||
assert.ok(Math.abs(sz - (sx + sy) / 2) < 1e-12);
|
assert.ok(Math.abs(sz - (sx + sy) / 2) < 1e-12);
|
||||||
|
// A beam with no reported length: the type's typical length, in the model's
|
||||||
|
// own proportions, not a typical-length hull squeezed to that beam.
|
||||||
|
const unsized = vesselModelSpec(set, { type: '70', length: 0, beam: 14 });
|
||||||
|
assert.equal(unsized.model, 'container_ship');
|
||||||
|
const [ux, uy, uz] = unsized.scaleXYZ;
|
||||||
|
assert.ok(Math.abs(uy - ux) < 1e-12 && Math.abs(uz - ux) < 1e-12);
|
||||||
assert.equal(vesselModelSpec(set, { type: 'Tug', length: 30 }).model, 'tug');
|
assert.equal(vesselModelSpec(set, { type: 'Tug', length: 30 }).model, 'tug');
|
||||||
assert.equal(vesselModelSpec(set, { type: '36' }).model, 'sailboat');
|
assert.equal(vesselModelSpec(set, { type: '36' }).model, 'sailboat');
|
||||||
// No type, no size: the generic vessel as built.
|
// No type, no size: the generic vessel as built.
|
||||||
|
|||||||
Reference in new issue
Block a user