diff --git a/.version b/.version index ae672e0..f9947e1 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -v10.6.2 +v10.6.3 diff --git a/package.json b/package.json index 208d49c..76494a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ohzi-core", - "version": "10.6.2", + "version": "10.6.3", "description": "OHZI Core Library", "source": "src/index.js", "module": "build/index.module.js", diff --git a/src/resource_loader/AsyncTextureLoader.js b/src/resource_loader/AsyncTextureLoader.js index 063b04b..2fecf65 100644 --- a/src/resource_loader/AsyncTextureLoader.js +++ b/src/resource_loader/AsyncTextureLoader.js @@ -1,18 +1,22 @@ +import { Browser } from '../Browser'; import { AbstractLoader } from './AbstractLoader'; -import { Texture } from 'three'; -import { Browser } from '../Browser'; +import { NoColorSpace, SRGBColorSpace, Texture } from 'three'; class AsyncTextureLoader extends AbstractLoader { - constructor(resource_id, url, size) + constructor(resource_id, url, size, flipY = true, premultiplyAlpha = false, colorSpaceConversion = true) { super(resource_id, url, size); + + this.colorSpaceConversion = colorSpaceConversion; + this.premultiplyAlpha = premultiplyAlpha; + this.flipY = flipY; } on_preloaded_finished(resource_container) { - if (Browser.is_safari && Browser.version < 15) + if (Browser.is_safari) // && Browser.version < 15 { this.load_with_old_method(resource_container); } @@ -34,6 +38,9 @@ class AsyncTextureLoader extends AbstractLoader image.onload = () => { texture.image = image; + texture.flipY = this.flipY; + texture.premultiplyAlpha = this.premultiplyAlpha; + texture.colorSpace = this.colorSpaceConversion ? SRGBColorSpace : NoColorSpace; texture.needsUpdate = true; resource_container.set_resource(this.resource_id, this.url, texture); @@ -69,7 +76,11 @@ class AsyncTextureLoader extends AbstractLoader return res.blob(); }).then((blob) => { - return createImageBitmap(blob, { colorSpaceConversion: 'none' }); + return createImageBitmap(blob, { + colorSpaceConversion: this.colorSpaceConversion ? 'default' : 'none', + imageOrientation: this.flipY ? 'flipY' : 'none', + premultiplyAlpha: this.premultiplyAlpha ? 'premultiply' : 'none' + }); }).then((imageBitmap) => { const texture = new Texture(imageBitmap); diff --git a/types/resource_loader/AsyncTextureLoader.d.ts b/types/resource_loader/AsyncTextureLoader.d.ts index 0a7f72f..979b109 100644 --- a/types/resource_loader/AsyncTextureLoader.d.ts +++ b/types/resource_loader/AsyncTextureLoader.d.ts @@ -1,5 +1,8 @@ export class AsyncTextureLoader extends AbstractLoader { - constructor(resource_id: any, url: any, size: any); + constructor(resource_id: any, url: any, size: any, flipY?: boolean, premultiplyAlpha?: boolean, colorSpaceConversion?: boolean); + colorSpaceConversion: boolean; + premultiplyAlpha: boolean; + flipY: boolean; on_preloaded_finished(resource_container: any): void; load_with_old_method(resource_container: any): void; load_with_new_method(resource_container: any): void; diff --git a/types/resource_loader/AsyncTextureLoader.ts b/types/resource_loader/AsyncTextureLoader.ts deleted file mode 100644 index abd4fe0..0000000 --- a/types/resource_loader/AsyncTextureLoader.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { AbstractLoader } from "./AbstractLoader"; - -export class AsyncTextureLoader extends AbstractLoader { - constructor(resource_id: any, url: any, size: any); - loader: any; -}