EXT_texture_avif.js 1.4 KB

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