mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Icons turned about an axis stand along it on the Cesium port's billboards
rotationMode 'axis' was drawn upright: the item's alignedAxis now becomes the billboard's (normalised), and a changed axis restyles it in place.
This commit is contained in:
1 parent
b2ca9a7d3c
commit
0e8be0fb78
2 files changed
+46
No files matched your search
@@ -976,6 +976,15 @@ export function createCesiumDraw({
|
||||
),
|
||||
};
|
||||
if (item.rotationMode === 'screen') look.rotation = item.rotation ?? 0;
|
||||
// Its up turned along the axis on screen, as Cesium's own aligned
|
||||
// billboards stand; an axis of zero length stands upright.
|
||||
if (item.rotationMode === 'axis' && item.alignedAxis) {
|
||||
const { x = 0, y = 0, z = 0 } = item.alignedAxis;
|
||||
const axis = new Cesium.Cartesian3(x, y, z);
|
||||
const length = Cesium.Cartesian3.magnitude(axis);
|
||||
if (length > 0)
|
||||
look.alignedAxis = Cesium.Cartesian3.divideByScalar(axis, length, axis);
|
||||
}
|
||||
if (item.rotationMode === 'course') {
|
||||
const enu = Cesium.Transforms.eastNorthUpToFixedFrame(position);
|
||||
look.alignedAxis = Cesium.Matrix4.multiplyByPointAsVector(
|
||||
@@ -1015,6 +1024,9 @@ export function createCesiumDraw({
|
||||
fadeByDistance: curve(item.fadeByDistance),
|
||||
rotationMode: item.rotationMode,
|
||||
rotation: item.rotation,
|
||||
alignedAxis: item.alignedAxis
|
||||
? [item.alignedAxis.x, item.alignedAxis.y, item.alignedAxis.z]
|
||||
: undefined,
|
||||
course: item.course,
|
||||
pixelOffset: item.pixelOffset
|
||||
? [item.pixelOffset.x ?? 0, item.pixelOffset.y ?? 0]
|
||||
@@ -1065,6 +1077,11 @@ export function createCesiumDraw({
|
||||
sameCurve(style.fadeByDistance, item.fadeByDistance) &&
|
||||
style.rotationMode === item.rotationMode &&
|
||||
(item.rotationMode === 'screen' || style.rotation === item.rotation) &&
|
||||
(item.alignedAxis
|
||||
? style.alignedAxis?.[0] === item.alignedAxis.x &&
|
||||
style.alignedAxis[1] === item.alignedAxis.y &&
|
||||
style.alignedAxis[2] === item.alignedAxis.z
|
||||
: style.alignedAxis === undefined) &&
|
||||
style.course === item.course &&
|
||||
(item.pixelOffset
|
||||
? style.pixelOffset?.[0] === (item.pixelOffset.x ?? 0) &&
|
||||
|
||||
@@ -3352,6 +3352,35 @@ test('an icon stands off its position by its pixel offset, and back when it has
|
||||
set.dispose();
|
||||
});
|
||||
|
||||
test('an icon turned about an axis stands along it, restyled in place when the axis changes', () => {
|
||||
const { scene, draw } = drawOver();
|
||||
const set = draw.icons({ id: 'axis-pins' });
|
||||
const icon = (alignedAxis) => ({
|
||||
id: 'a',
|
||||
pos: { lon: 0, lat: 0 },
|
||||
image: 'pin.png',
|
||||
size: [8, 8],
|
||||
rotationMode: 'axis',
|
||||
alignedAxis,
|
||||
});
|
||||
set.set([icon({ x: 0, y: 0, z: 2 })]);
|
||||
const pin = () => scene.added[0].get(0);
|
||||
const axis = () => [
|
||||
pin().alignedAxis.x,
|
||||
pin().alignedAxis.y,
|
||||
pin().alignedAxis.z,
|
||||
];
|
||||
assert.deepEqual(axis(), [0, 0, 1], 'normalised');
|
||||
assert.equal(pin().rotation, 0);
|
||||
const drawn = pin();
|
||||
set.upsert([icon({ x: 0, y: 1, z: 0 })]);
|
||||
assert.equal(pin(), drawn, 'the same billboard');
|
||||
assert.deepEqual(axis(), [0, 1, 0]);
|
||||
set.upsert([{ ...icon(undefined), rotationMode: 'screen' }]);
|
||||
assert.deepEqual(axis(), [0, 0, 0], 'upright again');
|
||||
set.dispose();
|
||||
});
|
||||
|
||||
test('a wall stands up from the ellipsoid to its positions, with or without a fill', () => {
|
||||
const { scene, draw } = drawOver();
|
||||
const set = draw.shapes({ id: 'walls' });
|
||||
|
||||
Reference in new issue
Block a user