Skip to content

Commit

Permalink
Tests TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Sep 13, 2018
1 parent e111e3f commit 77b445f
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 28 deletions.
12 changes: 9 additions & 3 deletions Apps/Sandcastle/gallery/development/Pick From Ray.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
url: '../../SampleData/Cesium3DTiles/Tilesets/Tileset/tileset.json'
}));

tileset.style = new Cesium.Cesium3DTileStyle({
defines : {
alpha : '${id} % 2 === 0 ? 0.5 : 1.0'
},
color : 'rgba(255, 255, 255, ${alpha})'
});

viewer.zoomTo(tileset);

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

function hideAll() {
for (i = 0; i < pickedFeatures.length; ++i) {
pickedFeatures[i].color = Cesium.Color.WHITE;
pickedFeatures[i].color = Cesium.Color.fromAlpha(Cesium.Color.WHITE, pickedFeatures[i].color.alpha);
}
for (i = 0; i < limit; ++i) {
hitSpheres[i].show = false;
Expand Down Expand Up @@ -144,7 +151,7 @@
for (i = 0; i < objects.length; ++i) {
if (objects[i] instanceof Cesium.Cesium3DTileFeature) {
pickedFeatures.push(objects[i]);
objects[i].color = Cesium.Color.YELLOW;
objects[i].color = Cesium.Color.fromAlpha(Cesium.Color.YELLOW, objects[i].color.alpha);
}
}
for (i = 0; i < positions.length; ++i) {
Expand Down Expand Up @@ -179,7 +186,6 @@
});
});
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

//Sandcastle_End
Sandcastle.finishedLoading();
}
Expand Down
1 change: 1 addition & 0 deletions Source/Scene/DerivedCommand.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ define([
if (!defined(pickState)) {
var rs = RenderState.getState(renderState);
rs.blending.enabled = false;
rs.depthMask = true;

pickState = RenderState.fromCache(rs);
cache[renderState.id] = pickState;
Expand Down
43 changes: 18 additions & 25 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,16 @@ define([
var scratchUp = new Cartesian3();

function pickFromRay(scene, ray, pickPosition, pickObject) {
//>>includeStart('debug', pragmas.debug);
Check.defined('ray', ray);
if (pickPosition && !scene.pickPositionSupported) {
throw new DeveloperError('Picking from the depth buffer is not supported. Check pickPositionSupported.');
}
if (scene._mode === SceneMode.SCENE2D) {
throw new DeveloperError('Pick from ray is not supported in 2D.');
}
//>>includeEnd('debug');

var context = scene._context;
var uniformState = context.uniformState;
var frameState = scene._frameState;
Expand Down Expand Up @@ -3635,7 +3645,7 @@ define([
/**
* Returns an object with a `primitive` property that contains the first (top) primitive in the scene
* hit by the ray or undefined if nothing is hit. Other properties may potentially be set depending on the type
* of primitive and may be used to further identify the picked object.
* of primitive and may be used to further identify the picked object. The ray must be given in world coordinates.
* <p>
* When a feature of a 3D Tiles tileset is picked, <code>pick</code> returns a {@link Cesium3DTileFeature} object.
* </p>
Expand All @@ -3648,17 +3658,15 @@ define([
* @see Scene#pick
*/
Scene.prototype.pickFromRay = function(ray) {
//>>includeStart('debug', pragmas.debug);
Check.defined('ray', ray);
//>>includeEnd('debug');
var pickResult = pickFromRay(this, ray, false, true);
if (defined(pickResult)) {
return pickResult.object;
}
};

/**
* Returns the cartesian position of the first intersection of the ray or undefined if nothing is hit.
* Returns the position, in world coordinates, of the first intersection of the ray or undefined if nothing is hit.
* The ray must be given in world coordinates.
*
* @private
*
Expand All @@ -3669,12 +3677,6 @@ define([
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
*/
Scene.prototype.pickPositionFromRay = function(ray, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined('ray', ray);
if (!this.pickPositionSupported) {
throw new DeveloperError('Picking from the depth buffer is not supported. Check pickPositionSupported.');
}
//>>includeEnd('debug');
var pickResult = pickFromRay(this, ray, true, false);
if (defined(pickResult)) {
return Cartesian3.clone(pickResult.position, result);
Expand All @@ -3684,7 +3686,7 @@ define([
/**
* Returns a list of objects, each containing a `primitive` property, for all primitives hit
* by the ray. Other properties may also be set depending on the type of primitive and may be
* used to further identify the picked object.
* used to further identify the picked object. The ray must be given in world coordinates.
* The primitives in the list are ordered by their visual order in the scene (front to back).
*
* @private
Expand All @@ -3696,9 +3698,6 @@ define([
* @see Scene#drillPick
*/
Scene.prototype.drillPickFromRay = function(ray, limit) {
//>>includeStart('debug', pragmas.debug);
Check.defined('ray', ray);
//>>includeEnd('debug');
var that = this;
var pickCallback = function() {
return pickFromRay(that, ray, false, true);
Expand All @@ -3710,7 +3709,7 @@ define([
};

/**
* Returns a list of cartesian positions containing intersections of the ray in the scene.
* Returns a list of cartesian positions, in world coordinates, containing intersections of the ray in the scene.
*
* @private
*
Expand All @@ -3721,9 +3720,6 @@ define([
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
*/
Scene.prototype.drillPickPositionFromRay = function(ray, limit) {
//>>includeStart('debug', pragmas.debug);
Check.defined('ray', ray);
//>>includeEnd('debug');
if (!this.pickPositionSupported) {
throw new DeveloperError('Picking from the depth buffer is not supported. Check pickPositionSupported.');
}
Expand Down Expand Up @@ -3758,9 +3754,6 @@ define([
*
*/
Scene.prototype.drillPick = function(windowPosition, limit, width, height) {
//>>includeStart('debug', pragmas.debug);
Check.defined('windowPosition', windowPosition);
//>>includeEnd('debug');
var that = this;
var pickCallback = function() {
var object = that.pick(windowPosition, width, height);
Expand Down Expand Up @@ -3804,9 +3797,6 @@ define([
Scene.prototype.sampleHeight = function(position, objectsToExclude) {
//>>includeStart('debug', pragmas.debug);
Check.defined('position', position);
if (!this.pickPositionSupported) {
throw new DeveloperError('Picking from the depth buffer is not supported. Check pickPositionSupported.');
}
//>>includeEnd('debug');
var globe = this.globe;
var ellipsoid = defined(globe) ? globe.ellipsoid : this.mapProjection.ellipsoid;
Expand Down Expand Up @@ -3869,6 +3859,9 @@ define([
* @exception {DeveloperError} Picking from the depth buffer is not supported. Check pickPositionSupported.
*/
Scene.prototype.clampToHeight = function(cartesian, objectsToExclude, result) {
//>>includeStart('debug', pragmas.debug);
Check.defined('cartesian', cartesian);
//>>includeEnd('debug');
var globe = this.globe;
var ellipsoid = defined(globe) ? globe.ellipsoid : this.mapProjection.ellipsoid;
var cartographic = Cartographic.fromCartesian(cartesian, ellipsoid, scratchPickCartographic);
Expand Down
Loading

0 comments on commit 77b445f

Please sign in to comment.