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