diff --git a/Source/Renderer/DrawCommand.js b/Source/Renderer/DrawCommand.js index d9fc70db0d4e..b45e86c7144a 100644 --- a/Source/Renderer/DrawCommand.js +++ b/Source/Renderer/DrawCommand.js @@ -39,6 +39,7 @@ define([ this._castShadows = defaultValue(options.castShadows, false); this._receiveShadows = defaultValue(options.receiveShadows, false); this._pickId = options.pickId; + this._pickOnly = defaultValue(options.pickOnly, false); this.dirty = true; this.lastDirtyTime = 0; @@ -471,6 +472,19 @@ define([ this.dirty = true; } } + }, + /** + * Whether this command should be executed in the pick pass only. + * + * @memberof DrawCommand.prototype + * @type {Boolean} + * @default false + * @readonly + */ + pickOnly : { + get : function() { + return this._pickOnly; + } } }); @@ -506,6 +520,7 @@ define([ result._castShadows = command._castShadows; result._receiveShadows = command._receiveShadows; result._pickId = command._pickId; + result._pickOnly = command._pickOnly; result.dirty = true; result.lastDirtyTime = 0; diff --git a/Source/Scene/ClassificationPrimitive.js b/Source/Scene/ClassificationPrimitive.js index 675e2f9d5ef5..edbe1a840460 100644 --- a/Source/Scene/ClassificationPrimitive.js +++ b/Source/Scene/ClassificationPrimitive.js @@ -802,7 +802,8 @@ define([ if (!defined(command)) { command = pickCommands[j] = new DrawCommand({ owner : classificationPrimitive, - primitiveType : primitive._primitiveType + primitiveType : primitive._primitiveType, + pickOnly : true }); } @@ -820,7 +821,8 @@ define([ if (!defined(command)) { command = pickCommands[j + 1] = new DrawCommand({ owner : classificationPrimitive, - primitiveType : primitive._primitiveType + primitiveType : primitive._primitiveType, + pickOnly : true }); } @@ -838,7 +840,8 @@ define([ if (!defined(command)) { command = pickCommands[j + 2] = new DrawCommand({ owner : classificationPrimitive, - primitiveType : primitive._primitiveType + primitiveType : primitive._primitiveType, + pickOnly : true }); } diff --git a/Source/Scene/EllipsoidPrimitive.js b/Source/Scene/EllipsoidPrimitive.js index 8b1ca28e4043..c5250a58fd92 100644 --- a/Source/Scene/EllipsoidPrimitive.js +++ b/Source/Scene/EllipsoidPrimitive.js @@ -209,7 +209,8 @@ define([ owner : defaultValue(options._owner, this) }); this._pickCommand = new DrawCommand({ - owner : defaultValue(options._owner, this) + owner : defaultValue(options._owner, this), + pickOnly : true }); var that = this; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 5a7ff2e75670..895c1b9df938 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -1518,11 +1518,9 @@ define([ } } - if (frameState.passes.pick && !defined(command.pickId)) { - return; + if (!command.pickOnly) { + derivedCommands.depth = DerivedCommand.createDepthOnlyDerivedCommand(this, command, context, derivedCommands.depth); } - - derivedCommands.depth = DerivedCommand.createDepthOnlyDerivedCommand(this, command, context, derivedCommands.depth); } }; diff --git a/Source/Scene/Vector3DTilePrimitive.js b/Source/Scene/Vector3DTilePrimitive.js index 91cee93c9a62..41459814c3a5 100644 --- a/Source/Scene/Vector3DTilePrimitive.js +++ b/Source/Scene/Vector3DTilePrimitive.js @@ -819,7 +819,8 @@ define([ var stencilPreloadCommand = pickCommands[j * 3]; if (!defined(stencilPreloadCommand)) { stencilPreloadCommand = pickCommands[j * 3] = new DrawCommand({ - owner : primitive + owner : primitive, + pickOnly : true }); } @@ -835,7 +836,8 @@ define([ var stencilDepthCommand = pickCommands[j * 3 + 1]; if (!defined(stencilDepthCommand)) { stencilDepthCommand = pickCommands[j * 3 + 1] = new DrawCommand({ - owner : primitive + owner : primitive, + pickOnly : true }); } @@ -851,7 +853,8 @@ define([ var colorCommand = pickCommands[j * 3 + 2]; if (!defined(colorCommand)) { colorCommand = pickCommands[j * 3 + 2] = new DrawCommand({ - owner : primitive + owner : primitive, + pickOnly : true }); }