diff --git a/build/dependencies.txt b/build/dependencies.txt index b0c351fb04a..2d8b664ce82 100644 --- a/build/dependencies.txt +++ b/build/dependencies.txt @@ -71,7 +71,6 @@ ../src/scene/scene_basicmaterial.js ../src/scene/scene_depthmaterial.js ../src/scene/scene_phongmaterial.js -../src/scene/scene_pickmaterial.js ../src/scene/scene_mesh.js ../src/scene/scene_skin.js ../src/scene/scene_skinpartition.js diff --git a/src/scene/scene_mesh.js b/src/scene/scene_mesh.js index 316485a5688..76ae3571802 100644 --- a/src/scene/scene_mesh.js +++ b/src/scene/scene_mesh.js @@ -75,6 +75,7 @@ pc.extend(pc, function () { this._receiveShadow = true; this.drawToDepth = true; this.cull = true; + this.pick = true; // 64-bit integer key that defines render order of this mesh instance this.key = 0; diff --git a/src/scene/scene_pick.js b/src/scene/scene_pick.js index cfbf525ee12..2d6b6efdc2d 100644 --- a/src/scene/scene_pick.js +++ b/src/scene/scene_pick.js @@ -56,7 +56,7 @@ pc.extend(pc, function () { * x: 10, * y: 20 * }); - * + * * // Get all models in rectangle with corners at (10,20) and (20,40) * var selection = picker.getSelection({ * x: 10, @@ -110,7 +110,7 @@ pc.extend(pc, function () { * @name pc.Picker#prepare * @description Primes the pick buffer with a rendering of the specified models from the point of view * of the supplied camera. Once the pick buffer has been prepared, pc.Picker#getSelection can be - * called multiple times on the same picker object. Therefore, if the models or camera do not change + * called multiple times on the same picker object. Therefore, if the models or camera do not change * in any way, pc.Picker#prepare does not need to be called again. * @param {pc.Camera} camera The camera used to render the scene, note this is the CameraNode, not an Entity * @param {pc.Scene} scene The scene containing the pickable mesh instances. @@ -152,7 +152,7 @@ pc.extend(pc, function () { projId.setValue(projMat.data); viewProjId.setValue(viewProjMat.data); - + // copy scene drawCalls this.drawCalls = scene.drawCalls.slice(0); // sort same as forward renderer @@ -162,6 +162,7 @@ pc.extend(pc, function () { if (this.drawCalls[i].command) { this.drawCalls[i].command(); } else { + if (!this.drawCalls[i].pick) continue; meshInstance = this.drawCalls[i]; mesh = meshInstance.mesh; material = meshInstance.material; @@ -184,7 +185,7 @@ pc.extend(pc, function () { var h = meshInstance.skinInstance.boneTexture.height; boneTextureSizeId.setValue([w, h]) } else { - poseMatrixId.setValue(meshInstance.skinInstance.matrixPalette); + poseMatrixId.setValue(meshInstance.skinInstance.matrixPalette); } } @@ -214,7 +215,7 @@ pc.extend(pc, function () { * @function * @name pc.Picker#resize * @description Sets the resolution of the pick buffer. The pick buffer resolution does not need - * to match the resolution of the corresponding frame buffer use for general rendering of the + * to match the resolution of the corresponding frame buffer use for general rendering of the * 3D scene. However, the lower the resolution of the pick buffer, the less accurate the selection * results returned by pc.Picker#getSelection. On the other hand, smaller pick buffers will * yield greater performance, so there is a trade off. diff --git a/src/scene/scene_pickmaterial.js b/src/scene/scene_pickmaterial.js deleted file mode 100644 index 61e0aa79697..00000000000 --- a/src/scene/scene_pickmaterial.js +++ /dev/null @@ -1,57 +0,0 @@ -pc.extend(pc, function () { - - /** - * @name pc.PickMaterial - * @class A Pick material is for rendering a scene into the frame buffer such that different meshes - * have different colors that can be queried on a frame buffer read at a specific pixel (normally a - * click coordinate). This implements frame buffer picking. - * @property {pc.Color} color The flat color to be written to the frame buffer. RGBA, with each - * component between 0 and 1. - */ - var PickMaterial = function () { - this.color = new pc.Color(1, 1, 1, 1); - this.colorMap = null; - - this.update(); - }; - - PickMaterial = pc.inherits(PickMaterial, pc.Material); - - pc.extend(PickMaterial.prototype, { - /** - * @function - * @name pc.PickMaterial#clone - * @description Duplicates a Basic material. All properties are duplicated except textures - * where only the references are copied. - * @returns {pc.PickMaterial} A cloned Basic material. - */ - clone: function () { - var clone = new pc.PickMaterial(); - - Material.prototype._cloneInternal.call(this, clone); - - clone.color.copy(this.color); - - clone.update(); - return clone; - }, - - update: function () { - this.clearParameters(); - - this.setParameter('uColor', this.color.data); - }, - - updateShader: function (device) { - var options = { - skin: !!this.meshInstances[0].skinInstance - }; - var library = device.getProgramLibrary(); - this.shader = library.getProgram('pick', options); - } - }); - - return { - PickMaterial: PickMaterial - }; -}()); \ No newline at end of file