mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
feat(render): an icon's offset may scale with it, and an axis-turned icon turns by its rotation too
The contract gains offsetScalesByDistance: the pixel offset grows and shrinks with scaleByDistance, as Cesium's pixelOffsetScaleByDistance does with the same curve. rotationMode 'axis' now also turns by rotation, as a Cesium billboard with an aligned axis and a rotation does. Cesium draws both on its billboards; its GPU icons take the rotation and refuse a scaled offset; the stub picks both. New conformance check draw.icons.offsetTurn.
This commit is contained in:
1 parent
c99c577b3e
commit
7ba15deb5e
6 files changed
+113
-12
No files matched your search
@@ -1356,6 +1356,10 @@ export function createCesiumDraw({
|
||||
// An empty range shows it nowhere.
|
||||
show: item.show !== false && displayable(item.displayRange),
|
||||
scaleByDistance: nearFarOf(item.scaleByDistance),
|
||||
// Its offset shrinks with it, as Cesium's KML icons' did.
|
||||
pixelOffsetScaleByDistance: item.offsetScalesByDistance
|
||||
? nearFarOf(item.scaleByDistance)
|
||||
: undefined,
|
||||
translucencyByDistance: nearFarOf(item.fadeByDistance),
|
||||
distanceDisplayCondition: displayConditionOf(item.displayRange),
|
||||
// The defaults, so a restyle in place puts back what an item dropped.
|
||||
@@ -1367,9 +1371,11 @@ export function createCesiumDraw({
|
||||
item.pixelOffset?.y ?? 0,
|
||||
),
|
||||
};
|
||||
if (item.rotationMode === 'screen') look.rotation = item.rotation ?? 0;
|
||||
if (item.rotationMode === 'screen' || item.rotationMode === 'axis')
|
||||
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.
|
||||
// billboards stand, then by its rotation; 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);
|
||||
@@ -1413,6 +1419,7 @@ export function createCesiumDraw({
|
||||
show: item.show,
|
||||
displayRange: item.displayRange ? [...item.displayRange] : undefined,
|
||||
scaleByDistance: curve(item.scaleByDistance),
|
||||
offsetScalesByDistance: item.offsetScalesByDistance,
|
||||
fadeByDistance: curve(item.fadeByDistance),
|
||||
rotationMode: item.rotationMode,
|
||||
rotation: item.rotation,
|
||||
@@ -1466,6 +1473,7 @@ export function createCesiumDraw({
|
||||
style.show === item.show &&
|
||||
sameList(style.displayRange, item.displayRange) &&
|
||||
sameCurve(style.scaleByDistance, item.scaleByDistance) &&
|
||||
style.offsetScalesByDistance === item.offsetScalesByDistance &&
|
||||
sameCurve(style.fadeByDistance, item.fadeByDistance) &&
|
||||
style.rotationMode === item.rotationMode &&
|
||||
(item.rotationMode === 'screen' || style.rotation === item.rotation) &&
|
||||
|
||||
@@ -240,6 +240,8 @@ export function createGpuIcons({
|
||||
const refuse = (what) => {
|
||||
throw new Error(`the Cesium renderer's GPU icons have no ${what}`);
|
||||
};
|
||||
if (item.offsetScalesByDistance && nonZero(item.pixelOffset))
|
||||
refuse('pixel offsets scaled by distance');
|
||||
// What a row reads from its extras texture, which WebGL 1 has not.
|
||||
if (scene.context?.webgl2 === false) {
|
||||
if (item.height !== undefined && item.height !== 'absolute')
|
||||
@@ -447,10 +449,12 @@ export function createGpuIcons({
|
||||
set.setAnchor(row, ANCHORS[item.anchor] ?? 0);
|
||||
set.setRotation(
|
||||
row,
|
||||
item.rotationMode === 'screen' ? (item.rotation ?? 0) : 0,
|
||||
item.rotationMode === 'screen' || item.rotationMode === 'axis'
|
||||
? (item.rotation ?? 0)
|
||||
: 0,
|
||||
);
|
||||
// Its up along the axis, as a billboard's; one of zero length
|
||||
// stands upright.
|
||||
// Its up along the axis, as a billboard's, then turned by its
|
||||
// rotation; one of zero length stands upright.
|
||||
const {
|
||||
x = 0,
|
||||
y = 0,
|
||||
|
||||
@@ -62,6 +62,7 @@ export const CESIUM_CHECKS = new Set([
|
||||
'draw.icons.cluster',
|
||||
'draw.icons.distance',
|
||||
'draw.icons.images',
|
||||
'draw.icons.offsetTurn',
|
||||
'draw.icons.update',
|
||||
'draw.lines.depthFail',
|
||||
'draw.lines.settled',
|
||||
|
||||
Reference in new issue
Block a user