mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
Merge the PR branch (c737a354): the model items' nodes pose the stations' joints
Itallo's merge of main carried his own port of the ISS model onto the draw port and gave the renderer contract a `nodes` member (the Cesium port writes each named glTF node's matrix once the model is ready, changed ones only). The satellites files keep this branch's versions, which cover both stations, the STATION and LIVE sections and telemetry; the joint drivers' poses are now the draw item's `nodes`, so the arrays, radiators, dishes and arms move again. His duplicate point-range setters go; the changelog fragment takes #1690.
This commit is contained in:
commit
501a34ecaf
9 files changed
+159
-26
No files matched your search
@@ -18,9 +18,9 @@ import { stationTrackedOn } from './policy.js';
|
||||
* a second, which at model range would show as a jump).
|
||||
*
|
||||
* The moving parts (the joint driver, `createArticulation`) write node
|
||||
* matrices into this part's node poses (`_nodePoses`), as they would into a
|
||||
* model's nodes; the draw contract has no per-node posing yet, so the model
|
||||
* draws rigid until it has, and the poses are kept for it.
|
||||
* matrices into this part's node poses, as they would into a model's nodes;
|
||||
* those poses are the draw item's `nodes`, which the renderer applies to the
|
||||
* model's named glTF nodes.
|
||||
*
|
||||
* @typedef {object} StationModelSpec
|
||||
* @property {string} key Short id ('iss', 'tiangong'): the STATION
|
||||
@@ -147,12 +147,14 @@ export function stationModelOrientation(position, axes, localAxes) {
|
||||
/**
|
||||
* Node poses as a joint driver writes them: `getNode(name)` hands a node
|
||||
* whose `matrix` it sets (a column-major 4×4, copied on write, as a model's
|
||||
* node copies), and `poses` keeps every matrix written, by node name.
|
||||
* node copies), and `poses` keeps every matrix written, by node name: the
|
||||
* draw item's `nodes` (`ModelItem.nodes`), one object for the item's life.
|
||||
* @returns {{ready: boolean, getNode: (name: string) => {matrix: Float64Array},
|
||||
* poses: Map<string, Float64Array>, clear: () => void}}
|
||||
* poses: Record<string, Float64Array>, clear: () => void}}
|
||||
*/
|
||||
export function createNodePoses() {
|
||||
const poses = new Map();
|
||||
/** @type {Record<string, Float64Array>} */
|
||||
const poses = {};
|
||||
const nodes = new Map();
|
||||
return {
|
||||
ready: true,
|
||||
@@ -162,14 +164,10 @@ export function createNodePoses() {
|
||||
if (!node) {
|
||||
node = {
|
||||
get matrix() {
|
||||
return poses.get(name);
|
||||
return poses[name];
|
||||
},
|
||||
set matrix(value) {
|
||||
let kept = poses.get(name);
|
||||
if (!kept) {
|
||||
kept = new Float64Array(16);
|
||||
poses.set(name, kept);
|
||||
}
|
||||
const kept = (poses[name] ??= new Float64Array(16));
|
||||
for (let i = 0; i < 16; i++) kept[i] = value[i];
|
||||
},
|
||||
};
|
||||
@@ -177,8 +175,9 @@ export function createNodePoses() {
|
||||
}
|
||||
return node;
|
||||
},
|
||||
/** Every node back to its authored pose (its name leaves the map). */
|
||||
clear() {
|
||||
poses.clear();
|
||||
for (const name of Object.keys(poses)) delete poses[name];
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -318,6 +317,8 @@ export function createStationModel(
|
||||
displayRange: nearRange,
|
||||
// So a click on the model tracks the station, as a click on its dot does.
|
||||
meta: { norad },
|
||||
// The joint driver's poses, applied to the model's named nodes.
|
||||
nodes: nodePoses.poses,
|
||||
show: false,
|
||||
};
|
||||
set.upsert([item]);
|
||||
@@ -763,7 +764,7 @@ export function createStationModel(
|
||||
_telemetryStatus: () => telemetry?.status() ?? null,
|
||||
/** The joint driver, for the STATION section. */
|
||||
_articulation: articulation,
|
||||
/** The node matrices the joint driver last wrote, by node name. */
|
||||
/** The node matrices the joint driver last wrote, by node name (the item's `nodes`). */
|
||||
_nodePoses: nodePoses.poses,
|
||||
};
|
||||
}
|
||||
@@ -248,7 +248,23 @@ test('posed, the model sits on the station with its flight axes as heading, pitc
|
||||
const track = column(ISS_MODEL_LOCAL_AXES.indexOf('x'));
|
||||
assert.ok(Math.abs(along(track)) < 1e-6, 'the along-track axis is level');
|
||||
assert.equal(f.updates.length, 1, 'the joints are driven');
|
||||
assert.equal(f.updates[0][0].ready, true, 'into node poses');
|
||||
const nodes = f.updates[0][0];
|
||||
assert.equal(nodes.ready, true, 'into node poses');
|
||||
// What the driver writes to a node is the item's `nodes`, by name, as a
|
||||
// column-major matrix the renderer applies to the model's glTF node.
|
||||
const turned = new Float64Array(16);
|
||||
turned[0] = turned[5] = turned[10] = turned[15] = 1;
|
||||
turned[14] = 2.5;
|
||||
nodes.getNode('SOLAR_JOINT').matrix = turned;
|
||||
f.tick();
|
||||
assert.equal(item.nodes, f.model._nodePoses, 'one object for the item');
|
||||
assert.deepEqual(Array.from(item.nodes.SOLAR_JOINT), Array.from(turned));
|
||||
f.model._destroyStationModel();
|
||||
assert.equal(
|
||||
Object.keys(f.model._nodePoses).length,
|
||||
0,
|
||||
'destroyed, every node goes back to its authored pose',
|
||||
);
|
||||
});
|
||||
|
||||
test('a station without views on its model hides it while the Cockpit rides the station, its own entry or a docked one', async (t) => {
|
||||
|
||||
Reference in new issue
Block a user