mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Delete the billboard and model mirrors; models become layer-held records
Aircraft draw from GPU icon sets, so the billboard mirror, the billboard treatment and the aircraft visual-state module had no callers left. 3D models are now records the layer holds under the contact's id (modelRecord.js): show and placement are written through showModel/placeModel and read back from the record; renderer-measured values stay on record.model. The tracked-model click check only matches when a tracked model exists, so an id-only pick is never mistaken for a click on the tracked plane.
This commit is contained in:
1 parent
c9f1fcd425
commit
83ec9473b6
35 files changed
+391
-788
No files matched your search
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @module modelRecord
|
||||
* @description A layer's own record of one 3D model it draws, held in the
|
||||
* layer's maps under the contact's id, so the layer reads what it pushed back
|
||||
* from itself instead of from the renderer's object.
|
||||
*
|
||||
* Write `show` and the placement with {@link showModel} and {@link placeModel};
|
||||
* read them from the record. What the renderer measures (`ready`,
|
||||
* `computedScale`) is still read from `record.model`. Colour stays out: the
|
||||
* cyber-sonar theme writes it too and reads the live value.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
|
||||
/**
|
||||
* @typedef {object} ModelRecord
|
||||
* @property {Cesium.Model} model
|
||||
* @property {boolean} show Whether the layer last showed the model.
|
||||
* @property {Cesium.Matrix4} matrix Where the layer last placed it.
|
||||
* @property {string|null} specKey The model spec it was loaded for; a class
|
||||
* change reloads.
|
||||
* @property {boolean|null} irBoost The IR boost it was loaded with; a flip
|
||||
* reloads.
|
||||
* @property {number} bellyM Metres from the model origin to its belly, to sit
|
||||
* it on the ground.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A record for a model the layer just made, from the options it made it with
|
||||
* (Cesium's defaults when none: shown, at the identity).
|
||||
* @param {Cesium.Model} model
|
||||
* @param {{specKey?: string, irBoost?: boolean, bellyM?: number}} [fields]
|
||||
* @returns {ModelRecord}
|
||||
*/
|
||||
export function createModelRecord(
|
||||
model,
|
||||
{ specKey = null, irBoost = null, bellyM = 0 } = {},
|
||||
) {
|
||||
return {
|
||||
model,
|
||||
show: model.show ?? true,
|
||||
matrix: Cesium.Matrix4.clone(model.modelMatrix ?? Cesium.Matrix4.IDENTITY),
|
||||
specKey,
|
||||
irBoost,
|
||||
bellyM,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Show or hide a model and record it.
|
||||
* @param {ModelRecord} record
|
||||
* @param {boolean} show
|
||||
*/
|
||||
export function showModel(record, show) {
|
||||
record.show = show;
|
||||
record.model.show = show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Place a model and record where. The matrix is copied into both, so a shared
|
||||
* scratch can be passed and reused straight after.
|
||||
* @param {ModelRecord} record
|
||||
* @param {Cesium.Matrix4} matrix
|
||||
*/
|
||||
export function placeModel(record, matrix) {
|
||||
Cesium.Matrix4.clone(matrix, record.matrix);
|
||||
const model = record.model;
|
||||
// Cesium clones the model's own matrix each frame, so write into it in place.
|
||||
if (model.modelMatrix) Cesium.Matrix4.clone(matrix, model.modelMatrix);
|
||||
else model.modelMatrix = Cesium.Matrix4.clone(matrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a record's model is what the user sees: loaded and shown.
|
||||
* @param {ModelRecord|null|undefined} record
|
||||
* @returns {boolean}
|
||||
*/
|
||||
export function modelIsRendering(record) {
|
||||
return !!record && record.model.ready === true && record.show === true;
|
||||
}
|
||||
Reference in new issue
Block a user