@@ -240,7 +240,7 @@ define([
240
240
QuadtreePrimitive . prototype . updateHeight = function ( cartographic , callback ) {
241
241
var primitive = this ;
242
242
var object = {
243
- position : undefined ,
243
+ positionOnEllipsoidSurface : undefined ,
244
244
positionCartographic : cartographic ,
245
245
level : - 1 ,
246
246
callback : callback
@@ -455,7 +455,7 @@ define([
455
455
customDataRemoved . length = 0 ;
456
456
}
457
457
458
- // Our goal with load ordering is to first load all of the tiles we need to
458
+ // Our goal with load ordering is to first load all of the tiles we need to
459
459
// render the current scene at full detail. Loading any other tiles is just
460
460
// a form of prefetching, and we need not do it at all (other concerns aside). This
461
461
// simple and obvious statement gets more complicated when we realize that, because
@@ -761,12 +761,13 @@ define([
761
761
var data = customData [ i ] ;
762
762
763
763
if ( tile . level > data . level ) {
764
- if ( ! defined ( data . position ) ) {
765
- data . position = ellipsoid . cartographicToCartesian ( data . positionCartographic ) ;
764
+ if ( ! defined ( data . positionOnEllipsoidSurface ) ) {
765
+ // cartesian has to be on the ellipsoid surface for `ellipsoid.geodeticSurfaceNormal`
766
+ data . positionOnEllipsoidSurface = Cartesian3 . fromRadians ( data . positionCartographic . longitude , data . positionCartographic . latitude , 0.0 , ellipsoid ) ;
766
767
}
767
768
768
769
if ( mode === SceneMode . SCENE3D ) {
769
- var surfaceNormal = ellipsoid . geodeticSurfaceNormal ( data . position , scratchRay . direction ) ;
770
+ var surfaceNormal = ellipsoid . geodeticSurfaceNormal ( data . positionOnEllipsoidSurface , scratchRay . direction ) ;
770
771
771
772
// compute origin point
772
773
@@ -778,29 +779,26 @@ define([
778
779
779
780
// avoid dividing by zero
780
781
if ( Math . abs ( surfaceNormal . x ) > CesiumMath . EPSILON16 ) {
781
- magnitude = data . position . x / surfaceNormal . x ;
782
+ magnitude = data . positionOnEllipsoidSurface . x / surfaceNormal . x ;
782
783
} else if ( Math . abs ( surfaceNormal . y ) > CesiumMath . EPSILON16 ) {
783
- magnitude = data . position . y / surfaceNormal . y ;
784
+ magnitude = data . positionOnEllipsoidSurface . y / surfaceNormal . y ;
784
785
} else if ( Math . abs ( surfaceNormal . z ) > CesiumMath . EPSILON16 ) { //surface normal is (0,0,1) | (0,0,-1) | (0,0,0)
785
- magnitude = data . position . z / surfaceNormal . z ;
786
+ magnitude = data . positionOnEllipsoidSurface . z / surfaceNormal . z ;
786
787
} else { //(0,0,0), just for case
787
788
magnitude = 0 ;
788
789
}
789
790
790
791
var vectorToMinimumPoint = Cartesian3 . multiplyByScalar ( surfaceNormal , magnitude , scratchPosition ) ;
791
- Cartesian3 . subtract ( data . position , vectorToMinimumPoint , scratchRay . origin ) ;
792
+ Cartesian3 . subtract ( data . positionOnEllipsoidSurface , vectorToMinimumPoint , scratchRay . origin ) ;
792
793
793
794
// Theoretically, the intersection point can be outside the ellipsoid, so we have to check if the result's 'z' is inside the ellipsoid (with some buffer)
794
795
if ( Math . abs ( scratchRay . origin . z ) >= ellipsoid . radii . z - 11500.0 ) {
795
796
// intersection point is outside the ellipsoid, try other value
796
797
magnitude = Math . min ( defaultValue ( tile . data . minimumHeight , 0.0 ) , - 11500.0 ) ;
797
798
798
- // take into account the position height
799
- magnitude -= data . positionCartographic . height ;
800
-
801
799
// multiply by the *positive* value of the magnitude
802
800
vectorToMinimumPoint = Cartesian3 . multiplyByScalar ( surfaceNormal , Math . abs ( magnitude ) + 1 , scratchPosition ) ;
803
- Cartesian3 . subtract ( data . position , vectorToMinimumPoint , scratchRay . origin ) ;
801
+ Cartesian3 . subtract ( data . positionOnEllipsoidSurface , vectorToMinimumPoint , scratchRay . origin ) ;
804
802
}
805
803
806
804
} else {
0 commit comments