diff --git a/CHANGES.md b/CHANGES.md index 8676fa10f7ed..4b0d5d7cd63f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,14 @@ Change Log ========== +### 1.54 - 2019-02-01 + +##### Deprecated :hourglass_flowing_sand: +* `Scene.clampToHeight` now takes an optional `width` argument before the `result` argument. The previous function definition will no longer work in 1.56. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) + +##### Additions :tada: +* Added the ability to specify the width of the intersection volume for `Scene.sampleHeight`, `Scene.clampToHeight`, `Scene.sampleHeightMostDetailed`, and `Scene.clampToHeightMostDetailed`. [#7287](https://github.com/AnalyticalGraphicsInc/cesium/pull/7287) + ### 1.53 - 2019-01-02 ##### Additions :tada: diff --git a/Source/Scene/Cesium3DTileset.js b/Source/Scene/Cesium3DTileset.js index 0ad7115a8ab6..ba3ec49fc12e 100644 --- a/Source/Scene/Cesium3DTileset.js +++ b/Source/Scene/Cesium3DTileset.js @@ -1973,7 +1973,7 @@ define([ var passes = frameState.passes; var isRender = passes.render; var isPick = passes.pick; - var isAsync = passes.async; + var isAsync = passes.asynchronous; var statistics = tileset._statistics; statistics.clear(); diff --git a/Source/Scene/FrameState.js b/Source/Scene/FrameState.js index b2297b39d959..ddb9518c662a 100644 --- a/Source/Scene/FrameState.js +++ b/Source/Scene/FrameState.js @@ -187,11 +187,11 @@ define([ offscreen : false, /** - * true if the primitive should update for an async pass, false otherwise. + * true if the primitive should update for an asynchronous pass, false otherwise. * @type {Boolean} * @default false */ - async : false + asynchronous : false }; /** diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 31da36b54cfa..2e8e2c058281 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -172,8 +172,9 @@ define([ }; }; - function AsyncRayPick(ray, primitives) { + function AsyncRayPick(ray, width, primitives) { this.ray = ray; + this.width = width; this.primitives = primitives; this.ready = false; this.deferred = when.defer(); @@ -777,10 +778,11 @@ define([ camera.frustum.far = 10000000000.0; } + var pickOffscreenDefaultWidth = 0.1; var pickOffscreenViewport = new BoundingRectangle(0, 0, 1, 1); var pickOffscreenCamera = new Camera(this); pickOffscreenCamera.frustum = new OrthographicFrustum({ - width: 0.01, + width: pickOffscreenDefaultWidth, aspectRatio: 1.0, near: 0.1 }); @@ -788,6 +790,11 @@ define([ this._view = new View(this, camera, viewport); this._pickOffscreenView = new View(this, pickOffscreenCamera, pickOffscreenViewport); + /** + * @private + */ + this.pickOffscreenDefaultWidth = pickOffscreenDefaultWidth; + this._defaultView = new View(this, camera, viewport); this._view = this._defaultView; @@ -1694,7 +1701,7 @@ define([ passes.depth = false; passes.postProcess = false; passes.offscreen = false; - passes.async = false; + passes.asynchronous = false; } function updateFrameNumber(scene, frameNumber, time) { @@ -3798,7 +3805,7 @@ define([ var scratchRight = new Cartesian3(); var scratchUp = new Cartesian3(); - function updateCameraFromRay(ray, camera) { + function updateOffscreenCameraFromRay(scene, ray, width, camera) { var direction = ray.direction; var orthogonalAxis = Cartesian3.mostOrthogonalAxis(direction, scratchRight); var right = Cartesian3.cross(direction, orthogonalAxis, scratchRight); @@ -3808,6 +3815,8 @@ define([ camera.direction = direction; camera.up = up; camera.right = right; + + camera.frustum.width = defaultValue(width, scene.pickOffscreenDefaultWidth); } function updateAsyncRayPick(scene, asyncRayPick) { @@ -3819,13 +3828,14 @@ define([ scene._view = view; var ray = asyncRayPick.ray; + var width = asyncRayPick.width; var primitives = asyncRayPick.primitives; - updateCameraFromRay(ray, view.camera); + updateOffscreenCameraFromRay(scene, ray, width, view.camera); updateFrameState(scene); frameState.passes.offscreen = true; - frameState.passes.async = true; + frameState.passes.asynchronous = true; uniformState.update(frameState); @@ -3844,7 +3854,7 @@ define([ } } - // Ignore commands pushed during async pass + // Ignore commands pushed during asynchronous pass commandList.length = commandsLength; scene._view = scene._defaultView; @@ -3866,7 +3876,7 @@ define([ } } - function launchAsyncRayPick(scene, ray, objectsToExclude, callback) { + function launchAsyncRayPick(scene, ray, objectsToExclude, width, callback) { var asyncPrimitives = []; var primitives = scene.primitives; var length = primitives.length; @@ -3882,7 +3892,7 @@ define([ return when.resolve(callback()); } - var asyncRayPick = new AsyncRayPick(ray, asyncPrimitives); + var asyncRayPick = new AsyncRayPick(ray, width, asyncPrimitives); scene._asyncRayPicks.push(asyncRayPick); return asyncRayPick.promise.then(function() { return callback(); @@ -3898,7 +3908,7 @@ define([ (objectsToExclude.indexOf(object.id) > -1); } - function getRayIntersection(scene, ray, objectsToExclude, requirePosition, async) { + function getRayIntersection(scene, ray, objectsToExclude, width, requirePosition, asynchronous) { var context = scene._context; var uniformState = context.uniformState; var frameState = scene._frameState; @@ -3906,7 +3916,7 @@ define([ var view = scene._pickOffscreenView; scene._view = view; - updateCameraFromRay(ray, view.camera); + updateOffscreenCameraFromRay(scene, ray, width, view.camera); scratchRectangle = BoundingRectangle.clone(view.viewport, scratchRectangle); @@ -3918,7 +3928,7 @@ define([ frameState.invertClassification = false; frameState.passes.pick = true; frameState.passes.offscreen = true; - frameState.passes.async = async; + frameState.passes.asynchronous = asynchronous; uniformState.update(frameState); @@ -3957,22 +3967,22 @@ define([ } } - function getRayIntersections(scene, ray, limit, objectsToExclude, requirePosition, async) { + function getRayIntersections(scene, ray, limit, objectsToExclude, width, requirePosition, asynchronous) { var pickCallback = function() { - return getRayIntersection(scene, ray, objectsToExclude, requirePosition, async); + return getRayIntersection(scene, ray, objectsToExclude, width, requirePosition, asynchronous); }; return drillPick(limit, pickCallback); } - function pickFromRay(scene, ray, objectsToExclude, requirePosition, async) { - var results = getRayIntersections(scene, ray, 1, objectsToExclude, requirePosition, async); + function pickFromRay(scene, ray, objectsToExclude, width, requirePosition, asynchronous) { + var results = getRayIntersections(scene, ray, 1, objectsToExclude, width, requirePosition, asynchronous); if (results.length > 0) { return results[0]; } } - function drillPickFromRay(scene, ray, limit, objectsToExclude, requirePosition, async) { - return getRayIntersections(scene, ray, limit, objectsToExclude, requirePosition, async); + function drillPickFromRay(scene, ray, limit, objectsToExclude, width, requirePosition, asynchronous) { + return getRayIntersections(scene, ray, limit, objectsToExclude, width, requirePosition, asynchronous); } /** @@ -3989,18 +3999,19 @@ define([ * * @param {Ray} ray The ray. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to exclude from the ray intersection. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Object} An object containing the object and position of the first intersection. * * @exception {DeveloperError} Ray intersections are only supported in 3D mode. */ - Scene.prototype.pickFromRay = function(ray, objectsToExclude) { + Scene.prototype.pickFromRay = function(ray, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('ray', ray); if (this._mode !== SceneMode.SCENE3D) { throw new DeveloperError('Ray intersections are only supported in 3D mode.'); } //>>includeEnd('debug'); - return pickFromRay(this, ray, objectsToExclude, false, false); + return pickFromRay(this, ray, objectsToExclude, width, false, false); }; /** @@ -4019,18 +4030,19 @@ define([ * @param {Ray} ray The ray. * @param {Number} [limit=Number.MAX_VALUE] If supplied, stop finding intersections after this many intersections. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to exclude from the ray intersection. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Object[]} List of objects containing the object and position of each intersection. * * @exception {DeveloperError} Ray intersections are only supported in 3D mode. */ - Scene.prototype.drillPickFromRay = function(ray, limit, objectsToExclude) { + Scene.prototype.drillPickFromRay = function(ray, limit, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('ray', ray); if (this._mode !== SceneMode.SCENE3D) { throw new DeveloperError('Ray intersections are only supported in 3D mode.'); } //>>includeEnd('debug'); - return drillPickFromRay(this, ray, limit, objectsToExclude, false, false); + return drillPickFromRay(this, ray, limit, objectsToExclude, width,false, false); }; /** @@ -4041,11 +4053,12 @@ define([ * * @param {Ray} ray The ray. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to exclude from the ray intersection. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Promise.} A promise that resolves to an object containing the object and position of the first intersection. * * @exception {DeveloperError} Ray intersections are only supported in 3D mode. */ - Scene.prototype.pickFromRayMostDetailed = function(ray, objectsToExclude) { + Scene.prototype.pickFromRayMostDetailed = function(ray, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('ray', ray); if (this._mode !== SceneMode.SCENE3D) { @@ -4055,8 +4068,8 @@ define([ var that = this; ray = Ray.clone(ray); objectsToExclude = defined(objectsToExclude) ? objectsToExclude.slice() : objectsToExclude; - return launchAsyncRayPick(this, ray, objectsToExclude, function() { - return pickFromRay(that, ray, objectsToExclude, false, true); + return launchAsyncRayPick(this, ray, objectsToExclude, width, function() { + return pickFromRay(that, ray, objectsToExclude, width, false, true); }); }; @@ -4069,11 +4082,12 @@ define([ * @param {Ray} ray The ray. * @param {Number} [limit=Number.MAX_VALUE] If supplied, stop finding intersections after this many intersections. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to exclude from the ray intersection. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Promise.} A promise that resolves to a list of objects containing the object and position of each intersection. * * @exception {DeveloperError} Ray intersections are only supported in 3D mode. */ - Scene.prototype.drillPickFromRayMostDetailed = function(ray, limit, objectsToExclude) { + Scene.prototype.drillPickFromRayMostDetailed = function(ray, limit, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('ray', ray); if (this._mode !== SceneMode.SCENE3D) { @@ -4083,8 +4097,8 @@ define([ var that = this; ray = Ray.clone(ray); objectsToExclude = defined(objectsToExclude) ? objectsToExclude.slice() : objectsToExclude; - return launchAsyncRayPick(this, ray, objectsToExclude, function() { - return drillPickFromRay(that, ray, limit, objectsToExclude, false, true); + return launchAsyncRayPick(this, ray, objectsToExclude, width, function() { + return drillPickFromRay(that, ray, limit, objectsToExclude, width, false, true); }); }; @@ -4122,20 +4136,20 @@ define([ return cartographic.height; } - function sampleHeightMostDetailed(scene, cartographic, objectsToExclude) { + function sampleHeightMostDetailed(scene, cartographic, objectsToExclude, width) { var ray = getRayForSampleHeight(scene, cartographic); - return launchAsyncRayPick(scene, ray, objectsToExclude, function() { - var pickResult = pickFromRay(scene, ray, objectsToExclude, true, true); + return launchAsyncRayPick(scene, ray, objectsToExclude, width, function() { + var pickResult = pickFromRay(scene, ray, objectsToExclude, width, true, true); if (defined(pickResult)) { return getHeightFromCartesian(scene, pickResult.position); } }); } - function clampToHeightMostDetailed(scene, cartesian, objectsToExclude, result) { + function clampToHeightMostDetailed(scene, cartesian, objectsToExclude, width, result) { var ray = getRayForClampToHeight(scene, cartesian); - return launchAsyncRayPick(scene, ray, objectsToExclude, function() { - var pickResult = pickFromRay(scene, ray, objectsToExclude, true, true); + return launchAsyncRayPick(scene, ray, objectsToExclude, width, function() { + var pickResult = pickFromRay(scene, ray, objectsToExclude, width, true, true); if (defined(pickResult)) { return Cartesian3.clone(pickResult.position, result); } @@ -4153,6 +4167,7 @@ define([ * * @param {Cartographic} position The cartographic position to sample height from. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not sample height from. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Number} The height. This may be undefined if there was no scene geometry to sample height from. * * @example @@ -4167,7 +4182,7 @@ define([ * @exception {DeveloperError} sampleHeight is only supported in 3D mode. * @exception {DeveloperError} sampleHeight requires depth texture support. Check sampleHeightSupported. */ - Scene.prototype.sampleHeight = function(position, objectsToExclude) { + Scene.prototype.sampleHeight = function(position, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('position', position); if (this._mode !== SceneMode.SCENE3D) { @@ -4178,7 +4193,7 @@ define([ } //>>includeEnd('debug'); var ray = getRayForSampleHeight(this, position); - var pickResult = pickFromRay(this, ray, objectsToExclude, true, false); + var pickResult = pickFromRay(this, ray, objectsToExclude, width, true, false); if (defined(pickResult)) { return getHeightFromCartesian(this, pickResult.position); } @@ -4195,6 +4210,7 @@ define([ * * @param {Cartesian3} cartesian The cartesian position. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not clamp to. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @param {Cartesian3} [result] An optional object to return the clamped position. * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. This may be undefined if there was no scene geometry to clamp to. * @@ -4210,7 +4226,7 @@ define([ * @exception {DeveloperError} clampToHeight is only supported in 3D mode. * @exception {DeveloperError} clampToHeight requires depth texture support. Check clampToHeightSupported. */ - Scene.prototype.clampToHeight = function(cartesian, objectsToExclude, result) { + Scene.prototype.clampToHeight = function(cartesian, objectsToExclude, width, result) { //>>includeStart('debug', pragmas.debug); Check.defined('cartesian', cartesian); if (this._mode !== SceneMode.SCENE3D) { @@ -4220,8 +4236,15 @@ define([ throw new DeveloperError('clampToHeight requires depth texture support. Check clampToHeightSupported.'); } //>>includeEnd('debug'); + + if (width instanceof Cartesian3) { + result = width; + width = undefined; + deprecationWarning('clampToHeight-parameter-change', 'clampToHeight now takes an optional width argument before the result argument in Cesium 1.54. The previous function definition will no longer work in 1.56.'); + } + var ray = getRayForClampToHeight(this, cartesian); - var pickResult = pickFromRay(this, ray, objectsToExclude, true, false); + var pickResult = pickFromRay(this, ray, objectsToExclude, width, true, false); if (defined(pickResult)) { return Cartesian3.clone(pickResult.position, result); } @@ -4236,6 +4259,7 @@ define([ * * @param {Cartographic[]} positions The cartographic positions to update with sampled heights. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not sample height from. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Promise.} A promise that resolves to the provided list of positions when the query has completed. * * @example @@ -4254,7 +4278,7 @@ define([ * @exception {DeveloperError} sampleHeightMostDetailed is only supported in 3D mode. * @exception {DeveloperError} sampleHeightMostDetailed requires depth texture support. Check sampleHeightSupported. */ - Scene.prototype.sampleHeightMostDetailed = function(positions, objectsToExclude) { + Scene.prototype.sampleHeightMostDetailed = function(positions, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('positions', positions); if (this._mode !== SceneMode.SCENE3D) { @@ -4268,7 +4292,7 @@ define([ var length = positions.length; var promises = new Array(length); for (var i = 0; i < length; ++i) { - promises[i] = sampleHeightMostDetailed(this, positions[i], objectsToExclude); + promises[i] = sampleHeightMostDetailed(this, positions[i], objectsToExclude, width); } return when.all(promises).then(function(heights) { var length = heights.length; @@ -4287,6 +4311,7 @@ define([ * * @param {Cartesian3[]} cartesians The cartesian positions to update with clamped positions. * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not clamp to. + * @param {Number} [width=0.1] Width of the intersection volume in meters. * @returns {Promise.} A promise that resolves to the provided list of positions when the query has completed. * * @example @@ -4305,7 +4330,7 @@ define([ * @exception {DeveloperError} clampToHeightMostDetailed is only supported in 3D mode. * @exception {DeveloperError} clampToHeightMostDetailed requires depth texture support. Check clampToHeightSupported. */ - Scene.prototype.clampToHeightMostDetailed = function(cartesians, objectsToExclude) { + Scene.prototype.clampToHeightMostDetailed = function(cartesians, objectsToExclude, width) { //>>includeStart('debug', pragmas.debug); Check.defined('cartesians', cartesians); if (this._mode !== SceneMode.SCENE3D) { @@ -4319,7 +4344,7 @@ define([ var length = cartesians.length; var promises = new Array(length); for (var i = 0; i < length; ++i) { - promises[i] = clampToHeightMostDetailed(this, cartesians[i], objectsToExclude, cartesians[i]); + promises[i] = clampToHeightMostDetailed(this, cartesians[i], objectsToExclude, width, cartesians[i]); } return when.all(promises).then(function(clampedCartesians) { var length = clampedCartesians.length; diff --git a/Specs/Scene/PickSpec.js b/Specs/Scene/PickSpec.js index 0ee351508385..138966a91839 100644 --- a/Specs/Scene/PickSpec.js +++ b/Specs/Scene/PickSpec.js @@ -25,7 +25,8 @@ defineSuite([ 'Specs/Cesium3DTilesTester', 'Specs/createCanvas', 'Specs/createScene', - 'Specs/pollToPromise' + 'Specs/pollToPromise', + 'ThirdParty/when' ], 'Scene/Pick', function( Cartesian3, Cartographic, @@ -53,7 +54,8 @@ defineSuite([ Cesium3DTilesTester, createCanvas, createScene, - pollToPromise) { + pollToPromise, + when) { 'use strict'; // It's not easily possible to mock the asynchronous pick functions @@ -69,6 +71,9 @@ defineSuite([ var primitiveRay; var offscreenRay; + var batchedTilesetUrl = 'Data/Cesium3DTiles/Batched/BatchedWithTransformBox/tileset.json'; + var pointCloudTilesetUrl = 'Data/Cesium3DTiles/PointCloud/PointCloudWithTransform/tileset.json'; + beforeAll(function() { scene = createScene({ canvas : createCanvas(10, 10) @@ -138,8 +143,7 @@ defineSuite([ return createRectangle(height, smallRectangle); } - function createTileset() { - var url = 'Data/Cesium3DTiles/Batched/BatchedWithTransformBox/tileset.json'; + function createTileset(url) { var options = { maximumScreenSpaceError : 0 }; @@ -442,7 +446,7 @@ defineSuite([ }); function picksFromRayTileset(style) { - return createTileset().then(function(tileset) { + return createTileset(batchedTilesetUrl).then(function(tileset) { tileset.style = style; expect(scene).toPickFromRayAndCall(function(result) { var primitive = result.object.primitive; @@ -561,7 +565,18 @@ defineSuite([ expect(scene).toPickFromRayAndCall(function(result) { expect(result.object.primitive).toBe(point); expect(result.position).toBeUndefined(); - }, primitiveRay); + }, primitiveRay, [], 0.01); + }); + + it('changes width', function() { + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + expect(scene).toPickFromRayAndCall(function(result) { + expect(result).toBeUndefined(); + }, primitiveRay, [], 0.1); + expect(scene).toPickFromRayAndCall(function(result) { + expect(result).toBeDefined(); + }, primitiveRay, [], 1.0); + }); }); it('throws if ray is undefined', function() { @@ -812,6 +827,17 @@ defineSuite([ }, primitiveRay, 2, [rectangle5, rectangle3]); }); + it('changes width', function() { + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + expect(scene).toDrillPickFromRayAndCall(function(result) { + expect(result.length).toBe(0); + }, primitiveRay, [], 0.1); + expect(scene).toDrillPickFromRayAndCall(function(result) { + expect(result.length).toBe(1); + }, primitiveRay, Number.POSITIVE_INFINITY, [], 1.0); + }); + }); + it('throws if ray is undefined', function() { expect(function() { scene.drillPickFromRay(undefined); @@ -840,7 +866,7 @@ defineSuite([ } var cartographic = new Cartographic(0.0, 0.0); - return createTileset().then(function(tileset) { + return createTileset(batchedTilesetUrl).then(function(tileset) { expect(scene).toSampleHeightAndCall(function(height) { expect(height).toBeGreaterThan(0.0); expect(height).toBeLessThan(20.0); // Rough height of tile @@ -940,6 +966,22 @@ defineSuite([ }, cartographic); }); + it('changes width', function() { + if (!scene.sampleHeightSupported) { + return; + } + + var cartographic = new Cartographic(0.0, 0.0); + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + expect(scene).toSampleHeightAndCall(function(height) { + expect(height).toBeUndefined(); + }, cartographic, [], 0.1); + expect(scene).toSampleHeightAndCall(function(height) { + expect(height).toBeDefined(); + }, cartographic, [], 1.0); + }); + }); + it('throws if position is undefined', function() { if (!scene.sampleHeightSupported) { return; @@ -999,7 +1041,7 @@ defineSuite([ } var cartesian = Cartesian3.fromRadians(0.0, 0.0, 100000.0); - return createTileset().then(function(tileset) { + return createTileset(batchedTilesetUrl).then(function(tileset) { expect(scene).toClampToHeightAndCall(function(position) { var minimumHeight = Cartesian3.fromRadians(0.0, 0.0).x; var maximumHeight = minimumHeight + 20.0; // Rough height of tile @@ -1105,6 +1147,22 @@ defineSuite([ }, cartesian); }); + it('changes width', function() { + if (!scene.clampToHeightSupported) { + return; + } + + var cartesian = Cartesian3.fromRadians(0.0, 0.0, 100.0); + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + expect(scene).toClampToHeightAndCall(function(clampedCartesian) { + expect(clampedCartesian).toBeUndefined(); + }, cartesian, [], 0.1); + expect(scene).toClampToHeightAndCall(function(clampedCartesian) { + expect(clampedCartesian).toBeDefined(); + }, cartesian, [], 1.0); + }); + }); + it('throws if cartesian is undefined', function() { if (!scene.clampToHeightSupported) { return; @@ -1157,10 +1215,10 @@ defineSuite([ }); }); - function pickFromRayMostDetailed(ray, objectsToExclude) { + function pickFromRayMostDetailed(ray, objectsToExclude, width) { var result; var completed = false; - scene.pickFromRayMostDetailed(ray, objectsToExclude).then(function(pickResult) { + scene.pickFromRayMostDetailed(ray, objectsToExclude, width).then(function(pickResult) { result = pickResult; completed = true; }); @@ -1173,10 +1231,10 @@ defineSuite([ }); } - function drillPickFromRayMostDetailed(ray, limit, objectsToExclude) { + function drillPickFromRayMostDetailed(ray, limit, objectsToExclude, width) { var result; var completed = false; - scene.drillPickFromRayMostDetailed(ray, limit, objectsToExclude).then(function(pickResult) { + scene.drillPickFromRayMostDetailed(ray, limit, objectsToExclude, width).then(function(pickResult) { result = pickResult; completed = true; }); @@ -1189,10 +1247,10 @@ defineSuite([ }); } - function sampleHeightMostDetailed(cartographics, objectsToExclude) { + function sampleHeightMostDetailed(cartographics, objectsToExclude, width) { var result; var completed = false; - scene.sampleHeightMostDetailed(cartographics, objectsToExclude).then(function(pickResult) { + scene.sampleHeightMostDetailed(cartographics, objectsToExclude, width).then(function(pickResult) { result = pickResult; completed = true; }); @@ -1205,10 +1263,10 @@ defineSuite([ }); } - function clampToHeightMostDetailed(cartesians, objectsToExclude) { + function clampToHeightMostDetailed(cartesians, objectsToExclude, width) { var result; var completed = false; - scene.clampToHeightMostDetailed(cartesians, objectsToExclude).then(function(pickResult) { + scene.clampToHeightMostDetailed(cartesians, objectsToExclude, width).then(function(pickResult) { result = pickResult; completed = true; }); @@ -1227,7 +1285,7 @@ defineSuite([ return; } scene.camera.setView({ destination : offscreenRectangle }); - return createTileset().then(function(tileset) { + return createTileset(batchedTilesetUrl).then(function(tileset) { return pickFromRayMostDetailed(primitiveRay).then(function(result) { var primitive = result.object.primitive; var position = result.position; @@ -1251,7 +1309,7 @@ defineSuite([ return; } scene.camera.setView({ destination : offscreenRectangle }); - return createTileset().then(function(tileset) { + return createTileset(batchedTilesetUrl).then(function(tileset) { var objectsToExclude = [tileset]; return pickFromRayMostDetailed(primitiveRay, objectsToExclude).then(function(result) { expect(result).toBeUndefined(); @@ -1264,7 +1322,7 @@ defineSuite([ return; } scene.camera.setView({ destination : offscreenRectangle }); - return createTileset().then(function(tileset) { + return createTileset(batchedTilesetUrl).then(function(tileset) { tileset.show = false; return pickFromRayMostDetailed(primitiveRay).then(function(result) { expect(result).toBeUndefined(); @@ -1345,12 +1403,27 @@ defineSuite([ }); scene.camera.setView({ destination : offscreenRectangle }); - return pickFromRayMostDetailed(primitiveRay).then(function(result) { + return pickFromRayMostDetailed(primitiveRay, [], 0.01).then(function(result) { expect(result.object.primitive).toBe(point); expect(result.position).toBeUndefined(); }); }); + it('changes width', function() { + if (webglStub) { + return; + } + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + var promise1 = pickFromRayMostDetailed(primitiveRay, [], 0.1).then(function(result) { + expect(result).toBeUndefined(); + }); + var promise2 = pickFromRayMostDetailed(primitiveRay, [], 1.0).then(function(result) { + expect(result).toBeDefined(); + }); + return when.all([promise1, promise2]); + }); + }); + it('throws if ray is undefined', function() { expect(function() { scene.pickFromRayMostDetailed(undefined); @@ -1639,6 +1712,21 @@ defineSuite([ }); }); + it('changes width', function() { + if (webglStub) { + return; + } + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + var promise1 = drillPickFromRayMostDetailed(primitiveRay, 1, [], 0.1).then(function(result) { + expect(result.length).toBe(0); + }); + var promise2 = drillPickFromRayMostDetailed(primitiveRay, 1, [], 1.0).then(function(result) { + expect(result.length).toBe(1); + }); + return when.all([promise1, promise2]); + }); + }); + it('throws if ray is undefined', function() { expect(function() { scene.drillPickFromRayMostDetailed(undefined); @@ -1667,7 +1755,7 @@ defineSuite([ } var cartographics = [new Cartographic(0.0, 0.0)]; - return createTileset().then(function() { + return createTileset(batchedTilesetUrl).then(function() { return sampleHeightMostDetailed(cartographics).then(function(updatedCartographics) { var height = updatedCartographics[0].height; expect(height).toBeGreaterThan(0.0); @@ -1829,6 +1917,24 @@ defineSuite([ }); }); + it('changes width', function() { + if (!scene.sampleHeightSupported) { + return; + } + + var cartographics1 = [new Cartographic(0.0, 0.0)]; + var cartographics2 = [new Cartographic(0.0, 0.0)]; + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + var promise1 = sampleHeightMostDetailed(cartographics1, [], 0.1).then(function(updatedCartographics1) { + expect(updatedCartographics1[0].height).toBeUndefined(); + }); + var promise2 = sampleHeightMostDetailed(cartographics2, [], 1.0).then(function(updatedCartographics2) { + expect(updatedCartographics2[0].height).toBeDefined(); + }); + return when.all([promise1, promise2]); + }); + }); + it('handles empty array', function() { if (!scene.sampleHeightSupported) { return; @@ -1899,7 +2005,7 @@ defineSuite([ } var cartesians = [Cartesian3.fromRadians(0.0, 0.0, 100000.0)]; - return createTileset().then(function() { + return createTileset(batchedTilesetUrl).then(function() { return clampToHeightMostDetailed(cartesians).then(function(updatedCartesians) { var minimumHeight = Cartesian3.fromRadians(0.0, 0.0).x; var maximumHeight = minimumHeight + 20.0; // Rough height of tile @@ -2073,6 +2179,25 @@ defineSuite([ }); }); + it('changes width', function() { + if (!scene.clampToHeightSupported) { + return; + } + + var cartesian = Cartesian3.fromRadians(0.0, 0.0, 100.0); + var cartesians1 = [Cartesian3.clone(cartesian)]; + var cartesians2 = [Cartesian3.clone(cartesian)]; + return createTileset(pointCloudTilesetUrl).then(function(tileset) { + var promise1 = clampToHeightMostDetailed(cartesians1, [], 0.1).then(function(clampedCartesians1) { + expect(clampedCartesians1[0]).toBeUndefined(); + }); + var promise2 = clampToHeightMostDetailed(cartesians2, [], 1.0).then(function(clampedCartesians2) { + expect(clampedCartesians2[0]).toBeDefined(); + }); + return when.all([promise1, promise2]); + }); + }); + it('handles empty array', function() { if (!scene.clampToHeightSupported) { return; diff --git a/Specs/addDefaultMatchers.js b/Specs/addDefaultMatchers.js index 3a9f3b46db34..a6afb9868210 100644 --- a/Specs/addDefaultMatchers.js +++ b/Specs/addDefaultMatchers.js @@ -359,9 +359,9 @@ define([ toPickFromRayAndCall : function(util, customEqualityTesters) { return { - compare : function(actual, expected, ray, objectsToExclude) { + compare : function(actual, expected, ray, objectsToExclude, width) { var scene = actual; - var result = scene.pickFromRay(ray, objectsToExclude); + var result = scene.pickFromRay(ray, objectsToExclude, width); var webglStub = !!window.webglStub; if (!webglStub) { @@ -380,9 +380,9 @@ define([ toDrillPickFromRayAndCall : function(util, customEqualityTesters) { return { - compare : function(actual, expected, ray, limit, objectsToExclude) { + compare : function(actual, expected, ray, limit, objectsToExclude, width) { var scene = actual; - var results = scene.drillPickFromRay(ray, limit, objectsToExclude); + var results = scene.drillPickFromRay(ray, limit, objectsToExclude, width); var webglStub = !!window.webglStub; if (!webglStub) { @@ -401,9 +401,9 @@ define([ toSampleHeightAndCall : function(util, customEqualityTesters) { return { - compare : function(actual, expected, position, objectsToExclude) { + compare : function(actual, expected, position, objectsToExclude, width) { var scene = actual; - var results = scene.sampleHeight(position, objectsToExclude); + var results = scene.sampleHeight(position, objectsToExclude, width); var webglStub = !!window.webglStub; if (!webglStub) { @@ -422,9 +422,9 @@ define([ toClampToHeightAndCall : function(util, customEqualityTesters) { return { - compare : function(actual, expected, cartesian, objectsToExclude) { + compare : function(actual, expected, cartesian, objectsToExclude, width) { var scene = actual; - var results = scene.clampToHeight(cartesian, objectsToExclude); + var results = scene.clampToHeight(cartesian, objectsToExclude, width); var webglStub = !!window.webglStub; if (!webglStub) {