Skip to content

Commit 77b445f

Browse files
committed
Tests TEMP
1 parent e111e3f commit 77b445f

File tree

4 files changed

+243
-28
lines changed

4 files changed

+243
-28
lines changed

Apps/Sandcastle/gallery/development/Pick From Ray.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@
4646
url: '../../SampleData/Cesium3DTiles/Tilesets/Tileset/tileset.json'
4747
}));
4848

49+
tileset.style = new Cesium.Cesium3DTileStyle({
50+
defines : {
51+
alpha : '${id} % 2 === 0 ? 0.5 : 1.0'
52+
},
53+
color : 'rgba(255, 255, 255, ${alpha})'
54+
});
55+
4956
viewer.zoomTo(tileset);
5057

5158
var blueCartographic = new Cesium.Cartographic(-1.3196863177294136, 0.6988508714746624, 30.0);
@@ -95,7 +102,7 @@
95102

96103
function hideAll() {
97104
for (i = 0; i < pickedFeatures.length; ++i) {
98-
pickedFeatures[i].color = Cesium.Color.WHITE;
105+
pickedFeatures[i].color = Cesium.Color.fromAlpha(Cesium.Color.WHITE, pickedFeatures[i].color.alpha);
99106
}
100107
for (i = 0; i < limit; ++i) {
101108
hitSpheres[i].show = false;
@@ -144,7 +151,7 @@
144151
for (i = 0; i < objects.length; ++i) {
145152
if (objects[i] instanceof Cesium.Cesium3DTileFeature) {
146153
pickedFeatures.push(objects[i]);
147-
objects[i].color = Cesium.Color.YELLOW;
154+
objects[i].color = Cesium.Color.fromAlpha(Cesium.Color.YELLOW, objects[i].color.alpha);
148155
}
149156
}
150157
for (i = 0; i < positions.length; ++i) {
@@ -179,7 +186,6 @@
179186
});
180187
});
181188
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
182-
183189
//Sandcastle_End
184190
Sandcastle.finishedLoading();
185191
}

Source/Scene/DerivedCommand.js

+1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ define([
289289
if (!defined(pickState)) {
290290
var rs = RenderState.getState(renderState);
291291
rs.blending.enabled = false;
292+
rs.depthMask = true;
292293

293294
pickState = RenderState.fromCache(rs);
294295
cache[renderState.id] = pickState;

Source/Scene/Scene.js

+18-25
Original file line numberDiff line numberDiff line change
@@ -3548,6 +3548,16 @@ define([
35483548
var scratchUp = new Cartesian3();
35493549

35503550
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+
35513561
var context = scene._context;
35523562
var uniformState = context.uniformState;
35533563
var frameState = scene._frameState;
@@ -3635,7 +3645,7 @@ define([
36353645
/**
36363646
* Returns an object with a `primitive` property that contains the first (top) primitive in the scene
36373647
* 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.
36393649
* <p>
36403650
* When a feature of a 3D Tiles tileset is picked, <code>pick</code> returns a {@link Cesium3DTileFeature} object.
36413651
* </p>
@@ -3648,17 +3658,15 @@ define([
36483658
* @see Scene#pick
36493659
*/
36503660
Scene.prototype.pickFromRay = function(ray) {
3651-
//>>includeStart('debug', pragmas.debug);
3652-
Check.defined('ray', ray);
3653-
//>>includeEnd('debug');
36543661
var pickResult = pickFromRay(this, ray, false, true);
36553662
if (defined(pickResult)) {
36563663
return pickResult.object;
36573664
}
36583665
};
36593666

36603667
/**
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.
36623670
*
36633671
* @private
36643672
*
@@ -3669,12 +3677,6 @@ define([
36693677
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
36703678
*/
36713679
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');
36783680
var pickResult = pickFromRay(this, ray, true, false);
36793681
if (defined(pickResult)) {
36803682
return Cartesian3.clone(pickResult.position, result);
@@ -3684,7 +3686,7 @@ define([
36843686
/**
36853687
* Returns a list of objects, each containing a `primitive` property, for all primitives hit
36863688
* 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.
36883690
* The primitives in the list are ordered by their visual order in the scene (front to back).
36893691
*
36903692
* @private
@@ -3696,9 +3698,6 @@ define([
36963698
* @see Scene#drillPick
36973699
*/
36983700
Scene.prototype.drillPickFromRay = function(ray, limit) {
3699-
//>>includeStart('debug', pragmas.debug);
3700-
Check.defined('ray', ray);
3701-
//>>includeEnd('debug');
37023701
var that = this;
37033702
var pickCallback = function() {
37043703
return pickFromRay(that, ray, false, true);
@@ -3710,7 +3709,7 @@ define([
37103709
};
37113710

37123711
/**
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.
37143713
*
37153714
* @private
37163715
*
@@ -3721,9 +3720,6 @@ define([
37213720
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
37223721
*/
37233722
Scene.prototype.drillPickPositionFromRay = function(ray, limit) {
3724-
//>>includeStart('debug', pragmas.debug);
3725-
Check.defined('ray', ray);
3726-
//>>includeEnd('debug');
37273723
if (!this.pickPositionSupported) {
37283724
throw new DeveloperError('Picking from the depth buffer is not supported. Check pickPositionSupported.');
37293725
}
@@ -3758,9 +3754,6 @@ define([
37583754
*
37593755
*/
37603756
Scene.prototype.drillPick = function(windowPosition, limit, width, height) {
3761-
//>>includeStart('debug', pragmas.debug);
3762-
Check.defined('windowPosition', windowPosition);
3763-
//>>includeEnd('debug');
37643757
var that = this;
37653758
var pickCallback = function() {
37663759
var object = that.pick(windowPosition, width, height);
@@ -3804,9 +3797,6 @@ define([
38043797
Scene.prototype.sampleHeight = function(position, objectsToExclude) {
38053798
//>>includeStart('debug', pragmas.debug);
38063799
Check.defined('position', position);
3807-
if (!this.pickPositionSupported) {
3808-
throw new DeveloperError('Picking from the depth buffer is not supported. Check pickPositionSupported.');
3809-
}
38103800
//>>includeEnd('debug');
38113801
var globe = this.globe;
38123802
var ellipsoid = defined(globe) ? globe.ellipsoid : this.mapProjection.ellipsoid;
@@ -3869,6 +3859,9 @@ define([
38693859
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
38703860
*/
38713861
Scene.prototype.clampToHeight = function(cartesian, objectsToExclude, result) {
3862+
//>>includeStart('debug', pragmas.debug);
3863+
Check.defined('cartesian', cartesian);
3864+
//>>includeEnd('debug');
38723865
var globe = this.globe;
38733866
var ellipsoid = defined(globe) ? globe.ellipsoid : this.mapProjection.ellipsoid;
38743867
var cartographic = Cartographic.fromCartesian(cartesian, ellipsoid, scratchPickCartographic);

0 commit comments

Comments
 (0)