MCPcopy
hub / github.com/CesiumGS/cesium / createPickTexture

Function createPickTexture

packages/engine/Source/Scene/BatchTexture.js:452–485  ·  view source on GitHub ↗
(batchTexture, context)

Source from the content-addressed store, hash-verified

450}
451
452function 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
487function updateBatchTexture(batchTexture) {
488 const dimensions = batchTexture._textureDimensions;

Callers 1

BatchTexture.jsFile · 0.85

Calls 5

getByteLengthFunction · 0.85
floatToByteMethod · 0.80
createTextureFunction · 0.70
definedFunction · 0.50
getFeatureMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…