(batchTexture, context)
| 450 | } |
| 451 | |
| 452 | function createPickTexture(batchTexture, context) { |
| 453 | const featuresLength = batchTexture._featuresLength; |
| 454 | if (!defined(batchTexture._pickTexture) && featuresLength > 0) { |
| 455 | const pickIds = batchTexture._pickIds; |
| 456 | const byteLength = getByteLength(batchTexture); |
| 457 | const bytes = new Uint8Array(byteLength); |
| 458 | const owner = batchTexture._owner; |
| 459 | const statistics = batchTexture._statistics; |
| 460 | |
| 461 | // PERFORMANCE_IDEA: we could skip the pick texture completely by allocating |
| 462 | // a continuous range of pickIds and then converting the base pickId + batchId |
| 463 | // to RGBA in the shader. The only consider is precision issues, which might |
| 464 | // not be an issue in WebGL 2. |
| 465 | for (let i = 0; i < featuresLength; ++i) { |
| 466 | const pickId = context.createPickId(owner.getFeature(i)); |
| 467 | pickIds.push(pickId); |
| 468 | |
| 469 | const pickColor = pickId.color; |
| 470 | const offset = i * 4; |
| 471 | bytes[offset] = Color.floatToByte(pickColor.red); |
| 472 | bytes[offset + 1] = Color.floatToByte(pickColor.green); |
| 473 | bytes[offset + 2] = Color.floatToByte(pickColor.blue); |
| 474 | bytes[offset + 3] = Color.floatToByte(pickColor.alpha); |
| 475 | } |
| 476 | |
| 477 | batchTexture._pickTexture = createTexture(batchTexture, context, bytes); |
| 478 | |
| 479 | // Make sure the tileset statistics are updated the frame when the pick |
| 480 | // texture is created. |
| 481 | if (defined(statistics)) { |
| 482 | statistics.batchTableByteLength += batchTexture._pickTexture.sizeInBytes; |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | function updateBatchTexture(batchTexture) { |
| 488 | const dimensions = batchTexture._textureDimensions; |
no test coverage detected
searching dependent graphs…