You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This came up in #10092 using this Sandcastle. I intended to open a quick PR to fix this, but it exposed more issues that I'm not sure I understand.
Essentially, using camera.lookAt with an offset with range: 0 causes a crash. This is because the direction is calculated using the position derived from the offset parameters -- the position is zero, so the direction will be zero and unable to be normalized.
I was able to fix this by putting a check at around line 2420 of Camera.js:
if (!Cartesian3.equals(this.position, Cartesian3.ZERO)) {
Cartesian3.negate(this.position, this.direction);
}
and this prevents the Sandcastle from crashing. However, attempting to zoom in and out results in another crash:
The problem is that cartesianToCartographic(camera.position, zoom3DCartographic) returns undefined for the center of the ellipsoid, Cartesian.ZERO. I'm struggling to understand what's happening here, though, because the camera is not actually in the middle of the Earth in the Sandcastle. So why is camera.position zero, then? In any case, what should height default to in ScreenSpaceCameraController, line 2186, if the function returns undefined?
If those few questions get answered, I have no problem opening a PR with the changes, but I'm unfamiliar with the math here and don't want to make incorrect changes.
The text was updated successfully, but these errors were encountered:
position is not actually the global position in all cases. When camera.lookAt is called it puts the camera in a local coordinate system and position is relative to that. This is the main difference between position and positionWC, which is always a global position.
Looking at the ScreenSpaceCameraController I think there's a faulty assumption that the position is in global space. My guess is that that code gets run but is overridden later whenever it handles the local space math.
Unfortunately to fix this bug there might be a cascade of issues like that.
This came up in #10092 using this Sandcastle. I intended to open a quick PR to fix this, but it exposed more issues that I'm not sure I understand.
Essentially, using
camera.lookAt
with an offset withrange: 0
causes a crash. This is because thedirection
is calculated using theposition
derived from the offset parameters -- theposition
is zero, so thedirection
will be zero and unable to be normalized.I was able to fix this by putting a check at around line 2420 of
Camera.js
:and this prevents the Sandcastle from crashing. However, attempting to zoom in and out results in another crash:
The problem is that
cartesianToCartographic(camera.position, zoom3DCartographic)
returnsundefined
for the center of the ellipsoid,Cartesian.ZERO
. I'm struggling to understand what's happening here, though, because the camera is not actually in the middle of the Earth in the Sandcastle. So why iscamera.position
zero, then? In any case, what shouldheight
default to inScreenSpaceCameraController
, line 2186, if the function returnsundefined
?If those few questions get answered, I have no problem opening a PR with the changes, but I'm unfamiliar with the math here and don't want to make incorrect changes.
The text was updated successfully, but these errors were encountered: