KHR_texture_basisu.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
  2. const NAME = "KHR_texture_basisu";
  3. /**
  4. * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md)
  5. */
  6. // eslint-disable-next-line @typescript-eslint/naming-convention
  7. export class KHR_texture_basisu {
  8. /**
  9. * @internal
  10. */
  11. constructor(loader) {
  12. /** The name of this extension. */
  13. this.name = NAME;
  14. this._loader = loader;
  15. this.enabled = loader.isExtensionUsed(NAME);
  16. }
  17. /** @internal */
  18. dispose() {
  19. this._loader = null;
  20. }
  21. /**
  22. * @internal
  23. */
  24. _loadTextureAsync(context, texture, assign) {
  25. return GLTFLoader.LoadExtensionAsync(context, texture, this.name, (extensionContext, extension) => {
  26. const sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get(`${context}/sampler`, this._loader.gltf.samplers, texture.sampler);
  27. const image = ArrayItem.Get(`${extensionContext}/source`, this._loader.gltf.images, extension.source);
  28. return this._loader._createTextureAsync(context, sampler, image, (babylonTexture) => {
  29. assign(babylonTexture);
  30. }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined, !texture._textureInfo.nonColorData);
  31. });
  32. }
  33. }
  34. GLTFLoader.RegisterExtension(NAME, (loader) => new KHR_texture_basisu(loader));
  35. //# sourceMappingURL=KHR_texture_basisu.js.map