@@ -3548,6 +3548,17 @@ define([
3548
3548
var scratchUp = new Cartesian3 ( ) ;
3549
3549
3550
3550
function pickFromRay ( scene , ray , pickPosition , pickObject ) {
3551
+ //>>includeStart('debug', pragmas.debug);
3552
+ Check . defined ( 'ray' , ray ) ;
3553
+ if ( pickPosition && ! this . pickPositionSupported ) {
3554
+ throw new DeveloperError ( 'Picking from the depth buffer is not supported. Check pickPositionSupported.' ) ;
3555
+ }
3556
+ if ( scene . _mode === SceneMode . SCENE2D ) {
3557
+ throw new DeveloperError ( 'Pick from ray is not supported in 2D.' ) ;
3558
+ }
3559
+ //>>includeEnd('debug');
3560
+
3561
+
3551
3562
var context = scene . _context ;
3552
3563
var uniformState = context . uniformState ;
3553
3564
var frameState = scene . _frameState ;
@@ -3635,7 +3646,7 @@ define([
3635
3646
/**
3636
3647
* Returns an object with a `primitive` property that contains the first (top) primitive in the scene
3637
3648
* hit by the ray or undefined if nothing is hit. Other properties may potentially be set depending on the type
3638
- * of primitive and may be used to further identify the picked object.
3649
+ * of primitive and may be used to further identify the picked object. The ray must be given in world coordinates.
3639
3650
* <p>
3640
3651
* When a feature of a 3D Tiles tileset is picked, <code>pick</code> returns a {@link Cesium3DTileFeature} object.
3641
3652
* </p>
@@ -3648,17 +3659,15 @@ define([
3648
3659
* @see Scene#pick
3649
3660
*/
3650
3661
Scene . prototype . pickFromRay = function ( ray ) {
3651
- //>>includeStart('debug', pragmas.debug);
3652
- Check . defined ( 'ray' , ray ) ;
3653
- //>>includeEnd('debug');
3654
3662
var pickResult = pickFromRay ( this , ray , false , true ) ;
3655
3663
if ( defined ( pickResult ) ) {
3656
3664
return pickResult . object ;
3657
3665
}
3658
3666
} ;
3659
3667
3660
3668
/**
3661
- * Returns the cartesian position of the first intersection of the ray or undefined if nothing is hit.
3669
+ * Returns the position, in world coordinates, of the first intersection of the ray or undefined if nothing is hit.
3670
+ * The ray must be given in world coordinates.
3662
3671
*
3663
3672
* @private
3664
3673
*
@@ -3669,12 +3678,6 @@ define([
3669
3678
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
3670
3679
*/
3671
3680
Scene . prototype . pickPositionFromRay = function ( ray , result ) {
3672
- //>>includeStart('debug', pragmas.debug);
3673
- Check . defined ( 'ray' , ray ) ;
3674
- if ( ! this . pickPositionSupported ) {
3675
- throw new DeveloperError ( 'Picking from the depth buffer is not supported. Check pickPositionSupported.' ) ;
3676
- }
3677
- //>>includeEnd('debug');
3678
3681
var pickResult = pickFromRay ( this , ray , true , false ) ;
3679
3682
if ( defined ( pickResult ) ) {
3680
3683
return Cartesian3 . clone ( pickResult . position , result ) ;
@@ -3684,7 +3687,7 @@ define([
3684
3687
/**
3685
3688
* Returns a list of objects, each containing a `primitive` property, for all primitives hit
3686
3689
* by the ray. Other properties may also be set depending on the type of primitive and may be
3687
- * used to further identify the picked object.
3690
+ * used to further identify the picked object. The ray must be given in world coordinates.
3688
3691
* The primitives in the list are ordered by their visual order in the scene (front to back).
3689
3692
*
3690
3693
* @private
@@ -3696,9 +3699,6 @@ define([
3696
3699
* @see Scene#drillPick
3697
3700
*/
3698
3701
Scene . prototype . drillPickFromRay = function ( ray , limit ) {
3699
- //>>includeStart('debug', pragmas.debug);
3700
- Check . defined ( 'ray' , ray ) ;
3701
- //>>includeEnd('debug');
3702
3702
var that = this ;
3703
3703
var pickCallback = function ( ) {
3704
3704
return pickFromRay ( that , ray , false , true ) ;
@@ -3710,7 +3710,7 @@ define([
3710
3710
} ;
3711
3711
3712
3712
/**
3713
- * Returns a list of cartesian positions containing intersections of the ray in the scene.
3713
+ * Returns a list of cartesian positions, in world coordinates, containing intersections of the ray in the scene.
3714
3714
*
3715
3715
* @private
3716
3716
*
@@ -3721,9 +3721,6 @@ define([
3721
3721
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
3722
3722
*/
3723
3723
Scene . prototype . drillPickPositionFromRay = function ( ray , limit ) {
3724
- //>>includeStart('debug', pragmas.debug);
3725
- Check . defined ( 'ray' , ray ) ;
3726
- //>>includeEnd('debug');
3727
3724
if ( ! this . pickPositionSupported ) {
3728
3725
throw new DeveloperError ( 'Picking from the depth buffer is not supported. Check pickPositionSupported.' ) ;
3729
3726
}
@@ -3758,9 +3755,6 @@ define([
3758
3755
*
3759
3756
*/
3760
3757
Scene . prototype . drillPick = function ( windowPosition , limit , width , height ) {
3761
- //>>includeStart('debug', pragmas.debug);
3762
- Check . defined ( 'windowPosition' , windowPosition ) ;
3763
- //>>includeEnd('debug');
3764
3758
var that = this ;
3765
3759
var pickCallback = function ( ) {
3766
3760
var object = that . pick ( windowPosition , width , height ) ;
@@ -3804,9 +3798,6 @@ define([
3804
3798
Scene . prototype . sampleHeight = function ( position , objectsToExclude ) {
3805
3799
//>>includeStart('debug', pragmas.debug);
3806
3800
Check . defined ( 'position' , position ) ;
3807
- if ( ! this . pickPositionSupported ) {
3808
- throw new DeveloperError ( 'Picking from the depth buffer is not supported. Check pickPositionSupported.' ) ;
3809
- }
3810
3801
//>>includeEnd('debug');
3811
3802
var globe = this . globe ;
3812
3803
var ellipsoid = defined ( globe ) ? globe . ellipsoid : this . mapProjection . ellipsoid ;
@@ -3869,6 +3860,9 @@ define([
3869
3860
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
3870
3861
*/
3871
3862
Scene . prototype . clampToHeight = function ( cartesian , objectsToExclude , result ) {
3863
+ //>>includeStart('debug', pragmas.debug);
3864
+ Check . defined ( 'cartesian' , cartesian ) ;
3865
+ //>>includeEnd('debug');
3872
3866
var globe = this . globe ;
3873
3867
var ellipsoid = defined ( globe ) ? globe . ellipsoid : this . mapProjection . ellipsoid ;
3874
3868
var cartographic = Cartographic . fromCartesian ( cartesian , ellipsoid , scratchPickCartographic ) ;
0 commit comments