Any interest in shared KTX 2.0 parser?
See original GitHub issueDiscussed this briefly with @bghgary recently, but I think the current state of (non-WASM) KTX 2.0 parsers for web is:
- three.js has a custom plain JS parser, THREE.KTX2Loader. Parses KTX2 wrapper and decodes using MSC Transcoder.
- babylon.js has a TypeScript port KTX2 Decoder. Parses KTX2 wrapper using combination of MSC Transcoder and lightweight AssemblyScript transcoders.
- (new) I’ve started a TypeScript KTX2 parser + serializer, ktx-parse. It’s a standalone repository with an npm package, so that I can use it in other projects like glTF-Transform. My intention (open to discuss) was to keep it focused on parsing the container, not transcoding, so that it could be used with any of the various Basis transcoders or other GPU texture formats.
three.js does not bring in production dependencies from NPM, so my ability to package that code for reuse is a bit limited. If you’re interested though, I’d be glad to collaborate on a repo/package for the other two, and for future users. Currently the code I’ve written in read.ts
is very similar to your own ktx2FileReader.ts
, and outputs a nearly-identical container interface. I’ve added support for key/value data, otherwise I think they’re functionally equivalent. I intend to include serialization as well (not functional yet), which will be tree-shakeable if you don’t need it:
import { read, write } from 'ktx-parse';
// Load.
const data = await fetch('./input.ktx2').then(r => r.arrayBuffer());
// Parse.
const container = read(new Uint8Array(data));
// Serialize.
write(container); // → Uint8Array
Open to ideas on how to structure this, or let me know if this doesn’t make sense. 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top GitHub Comments
Closing this, since it is more of an open-ended idea than an actual issue. The repo is currently at https://github.com/donmccurdy/KTX-Parse, if you would like to use it and are having any issues let me know!
Yeah, we don’t bring in npm dependencies either. Would it be possible to create a standalone js file that we distribute? For example, Draco has the js file directly commited in their repo and we just copy it. Another example is glTF-Validator where we use browersify to build a standalone js.
That is what we were thinking for the KTX2 Decoder. It would live in its own repo and we would bring in a pre-built js file. Open to other ideas though.