Skip to content

Commit

Permalink
KTX2Loader: Add UMD ktx-parse build (mrdoob#24260)
Browse files Browse the repository at this point in the history
* Add UMD build of ktx-parse

* Fix lint
  • Loading branch information
donmccurdy authored and snagy committed Sep 21, 2022
1 parent 6582cd3 commit 8aa6589
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/js/libs/ktx-parse.umd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions examples/jsm/loaders/KTX2Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ import {
UnsignedByteType
} from 'three';
import { WorkerPool } from '../utils/WorkerPool.js';
import {
import * as KTX from '../libs/ktx-parse.module.js';

const {
read,
KHR_DF_FLAG_ALPHA_PREMULTIPLIED,
KHR_DF_TRANSFER_SRGB,
VK_FORMAT_UNDEFINED,
VK_FORMAT_R16_SFLOAT,
VK_FORMAT_R16G16_SFLOAT,
Expand All @@ -53,10 +57,8 @@ import {
VK_FORMAT_R8G8_UNORM,
VK_FORMAT_R8G8B8A8_SRGB,
VK_FORMAT_R8G8B8A8_UNORM,
} from '../libs/ktx-parse.module.js';
} = KTX; // eslint-disable-line no-undef

const KTX2TransferSRGB = 2;
const KTX2_ALPHA_PREMULTIPLIED = 1;
const _taskCache = new WeakMap();

let _activeLoaders = 0;
Expand Down Expand Up @@ -242,8 +244,8 @@ class KTX2Loader extends Loader {
texture.magFilter = LinearFilter;
texture.generateMipmaps = false;
texture.needsUpdate = true;
texture.encoding = dfdTransferFn === KTX2TransferSRGB ? sRGBEncoding : LinearEncoding;
texture.premultiplyAlpha = !! ( dfdFlags & KTX2_ALPHA_PREMULTIPLIED );
texture.encoding = dfdTransferFn === KHR_DF_TRANSFER_SRGB ? sRGBEncoding : LinearEncoding;
texture.premultiplyAlpha = !! ( dfdFlags & KHR_DF_FLAG_ALPHA_PREMULTIPLIED );

return texture;

Expand Down

0 comments on commit 8aa6589

Please sign in to comment.