CesiumGS / CesiumGS/cesium

Check file headers instead of filename regex to determine image format

Open
#9,640 0 comments 0 reactions 0 assignees View on GitHub
type - cleanup
Dominant language
JavaScript
Stars
15.7k
Forks
3.9k
Avg merge
4d 6h
Merged PRs (30d)
34

Description

This came up in https://github.com/CesiumGS/cesium/pull/9513 - files like `Material.js` have code along the lines of:

```js
var ktx2Regex = /\.ktx2$/i;

function createTexture2DUpdateFunction(uniformId) {
...

if (ktx2Regex.test(resource.url)) {
promise = loadKTX2(resource.url);
} else {
promise = resource.fetchImage();
}

...
}
```

We should update these checks to check .ktx2 header info since not all files will have the .ktx2 extension.

Contributor guide

Open the contributing guide

Research direction

Start with the filename-based KTX2 check shown in Material.js, then trace how loadKTX2 and resource.fetchImage are selected. Done means the relevant image-format checks use KTX2 header information so files without a .ktx2 extension still use the correct loader.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.