ris-framework 0.2.0-dev.13 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +6 -0
- package/dist/api/IFramework.d.ts +3 -3
- package/dist/api/IFramework.d.ts.map +1 -1
- package/dist/api/content/ContentManager.d.ts +2 -2
- package/dist/api/content/ContentManager.d.ts.map +1 -1
- package/dist/api/content/IContentManager.d.ts +2 -2
- package/dist/api/content/IContentManager.d.ts.map +1 -1
- package/dist/api/rendering/IRenderer.d.ts +11 -6
- package/dist/api/rendering/IRenderer.d.ts.map +1 -1
- package/dist/api/rendering/enums.d.ts +5 -5
- package/dist/api/rendering/enums.d.ts.map +1 -1
- package/dist/api/rendering/texture/ITextureDescriptor.d.ts +49 -0
- package/dist/api/rendering/texture/ITextureDescriptor.d.ts.map +1 -0
- package/dist/api/rendering/texture/ITextureFactory.d.ts +2 -2
- package/dist/api/rendering/texture/ITextureFactory.d.ts.map +1 -1
- package/dist/api/rendering/texture/TextureUtilities.d.ts +22 -21
- package/dist/api/rendering/texture/TextureUtilities.d.ts.map +1 -1
- package/dist/api/rendering/texture/_export-texture.d.ts +1 -1
- package/dist/api/rendering/texture/_export-texture.d.ts.map +1 -1
- package/dist/core/rendering/ARenderer.d.ts +3 -0
- package/dist/core/rendering/ARenderer.d.ts.map +1 -1
- package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts +14 -0
- package/dist/core/rendering/texture/TextureDescriptorUtilities.d.ts.map +1 -0
- package/dist/core/rendering/texture/texture.d.ts +3 -2
- package/dist/core/rendering/texture/texture.d.ts.map +1 -1
- package/dist/index.js +277 -290
- package/dist/webgl/texture/WebGlTexture2D.d.ts +3 -2
- package/dist/webgl/texture/WebGlTexture2D.d.ts.map +1 -1
- package/dist/webgl/texture/WebGlTextureFactory.d.ts +2 -9
- package/dist/webgl/texture/WebGlTextureFactory.d.ts.map +1 -1
- package/dist/webgl/utilities/WebGlErrorUtilities.d.ts.map +1 -1
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts +3 -2
- package/dist/webgpu/texture/WebGpuTexture2D.d.ts.map +1 -1
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts +2 -2
- package/dist/webgpu/texture/WebGpuTextureFactory.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Framework.ts +2 -2
- package/src/api/IFramework.ts +3 -3
- package/src/api/content/ContentManager.ts +9 -7
- package/src/api/content/IContentManager.ts +2 -2
- package/src/api/rendering/IRenderer.ts +12 -6
- package/src/api/rendering/enums.ts +5 -5
- package/src/api/rendering/texture/ITextureDescriptor.ts +57 -0
- package/src/api/rendering/texture/ITextureFactory.ts +2 -2
- package/src/api/rendering/texture/TextureUtilities.ts +43 -61
- package/src/api/rendering/texture/_export-texture.ts +1 -1
- package/src/core/rendering/ARenderer.ts +6 -2
- package/src/core/rendering/texture/TextureDescriptorUtilities.ts +27 -0
- package/src/core/rendering/texture/texture.ts +2 -2
- package/src/main.ts +5 -4
- package/src/webgl/texture/WebGlTexture2D.ts +9 -8
- package/src/webgl/texture/WebGlTextureFactory.ts +50 -64
- package/src/webgl/utilities/WebGlErrorUtilities.ts +3 -2
- package/src/webgpu/texture/WebGpuTexture2D.ts +10 -9
- package/src/webgpu/texture/WebGpuTextureFactory.ts +19 -16
- package/dist/api/rendering/texture/TextureDescriptor.d.ts +0 -42
- package/dist/api/rendering/texture/TextureDescriptor.d.ts.map +0 -1
- package/src/api/rendering/texture/TextureDescriptor.ts +0 -52
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type IFramework, type ITextureView, type TextureViewDescriptor } from "../../api/index.js";
|
|
2
2
|
import { ATexture2D } from "../../core/rendering/texture/texture.js";
|
|
3
|
+
import { type ResolvedTextureDescriptor } from "../../core/rendering/texture/TextureDescriptorUtilities.js";
|
|
3
4
|
/**
|
|
4
5
|
* The WebGL implementation of ITexture2D.
|
|
5
6
|
*/
|
|
@@ -13,7 +14,7 @@ export declare class WebGlTexture2D extends ATexture2D {
|
|
|
13
14
|
* @param _framework The framework instance.
|
|
14
15
|
* @param textureDescriptor The texture descriptor.
|
|
15
16
|
*/
|
|
16
|
-
constructor(_framework: IFramework, textureDescriptor:
|
|
17
|
+
constructor(_framework: IFramework, textureDescriptor: ResolvedTextureDescriptor);
|
|
17
18
|
/**
|
|
18
19
|
* Gets the underlying WebGL texture.
|
|
19
20
|
* @returns The WebGL texture.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGlTexture2D.d.ts","sourceRoot":"","sources":["../../../src/webgl/texture/WebGlTexture2D.ts"],"names":[],"mappings":"AACA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"WebGlTexture2D.d.ts","sourceRoot":"","sources":["../../../src/webgl/texture/WebGlTexture2D.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,OAAO,EAAC,KAAK,yBAAyB,EAA2B,MAAM,4DAA4D,CAAC;AAEpI;;GAEG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAYtC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAV/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAsB;IACtD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAyB;IAC7C,OAAO,CAAC,UAAU,CAA6B;IAE/C;;;;OAIG;gBAEkB,UAAU,EAAE,UAAU,EACvC,iBAAiB,EAAE,yBAAyB;IAOhD;;;OAGG;IACH,IAAW,SAAS,IAAI,YAAY,CAEnC;IAED,kBAAkB;IACX,UAAU,IAAI,IAAI;IA2CzB,kBAAkB;IACX,UAAU,CAAC,WAAW,CAAC,EAAE,qBAAqB,GAAG,YAAY;IAKpE,kBAAkB;IACX,OAAO,IAAI,IAAI;IAgBtB,iHAAiH;IACjH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAA6C;IAEnF;;;;;;OAMG;WACW,kBAAkB,CAAC,SAAS,EAAE,UAAU,GAAG,cAAc;IAoBvE;;;OAGG;WACW,cAAc,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI;CAM5D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color, type IFramework, type ITexture2D, type ITextureFactory,
|
|
1
|
+
import { Color, type IFramework, type ITexture2D, type ITextureFactory, type ITextureDescriptor, TextureFormat } from "../../api/index.js";
|
|
2
2
|
import { type IKtx2Texture } from "ris-ktx2";
|
|
3
3
|
export declare class WebGlTextureFactory implements ITextureFactory {
|
|
4
4
|
private readonly _framework;
|
|
@@ -8,14 +8,7 @@ export declare class WebGlTextureFactory implements ITextureFactory {
|
|
|
8
8
|
*/
|
|
9
9
|
constructor(_framework: IFramework);
|
|
10
10
|
/** @inheritDoc */
|
|
11
|
-
createFromKtx2(ktxTexture: IKtx2Texture, descriptor?:
|
|
12
|
-
/** Whether the Vulkan format is an sRGB format. */
|
|
13
|
-
private static _isSrgbVkFormat;
|
|
14
|
-
/**
|
|
15
|
-
* Falls back to the linear variant (with a warning) when the GPU cannot sample the sRGB format.
|
|
16
|
-
* Only S3TC sRGB (BC1/BC3) has its own WebGL extension; BC7, ETC2 and ASTC sRGB ship with their base extension.
|
|
17
|
-
*/
|
|
18
|
-
private _ensureSrgbSupported;
|
|
11
|
+
createFromKtx2(ktxTexture: IKtx2Texture, descriptor?: ITextureDescriptor): ITexture2D;
|
|
19
12
|
/** @inheritdoc */
|
|
20
13
|
create(width: number, height: number, data?: Uint8Array | HTMLImageElement, channels?: number, label?: string | null | undefined, textureUsage?: number, textureFormat?: TextureFormat, useMipMaps?: boolean): ITexture2D;
|
|
21
14
|
/** @inheritdoc */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGlTextureFactory.d.ts","sourceRoot":"","sources":["../../../src/webgl/texture/WebGlTextureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,
|
|
1
|
+
{"version":3,"file":"WebGlTextureFactory.d.ts","sourceRoot":"","sources":["../../../src/webgl/texture/WebGlTextureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,aAAa,EAGhB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAC,KAAK,YAAY,EAAiE,MAAM,UAAU,CAAC;AAK3G,qBAAa,mBAAoB,YAAW,eAAe;IAM3C,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJvC;;;OAGG;gBAC0B,UAAU,EAAE,UAAU;IAGnD,kBAAkB;IACX,cAAc,CAAC,UAAU,EAAE,YAAY,EAAE,UAAU,CAAC,EAAE,kBAAkB,GAAG,UAAU;IA8F5F,kBAAkB;IACX,MAAM,CACT,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,IAAI,CAAC,EAAE,UAAU,GAAG,gBAAgB,EACpC,QAAQ,GAAE,MAAU,EACpB,KAAK,GAAE,MAAM,GAAG,IAAI,GAAG,SAAgB,EACvC,YAAY,SAAuD,EACnE,aAAa,gBAA4B,EACzC,UAAU,UAAQ,GAAG,UAAU;IAiCnC,kBAAkB;IACX,WAAW,CACd,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,GAAE,KAAK,GAAG,IAAW,EAC1B,YAAY,SAAuD,EACnE,aAAa,gBAA0B,EACvC,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,SAAS,UAAQ,GAAG,UAAU;CA2CrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGlErrorUtilities.d.ts","sourceRoot":"","sources":["../../../src/webgl/utilities/WebGlErrorUtilities.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"WebGlErrorUtilities.d.ts","sourceRoot":"","sources":["../../../src/webgl/utilities/WebGlErrorUtilities.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAmB;IAE5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAGpB;IAED;;;;OAIG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAG3C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type IFramework,
|
|
1
|
+
import { type IFramework, type ITextureView, TextureViewDescriptor } from "../../api/index.js";
|
|
2
2
|
import { ATexture2D } from "../../core/rendering/texture/texture.js";
|
|
3
3
|
import { type GpuTexture, type GpuTextureView } from "../WebGpuTypes.js";
|
|
4
|
+
import { type ResolvedTextureDescriptor } from "../../core/rendering/texture/TextureDescriptorUtilities.js";
|
|
4
5
|
/**
|
|
5
6
|
* The WebGPU 2D texture.
|
|
6
7
|
*
|
|
@@ -19,7 +20,7 @@ export declare class WebGpuTexture2D extends ATexture2D {
|
|
|
19
20
|
* @param descriptor The texture descriptor.
|
|
20
21
|
* @param image An optional image to upload instead of `descriptor.data`.
|
|
21
22
|
*/
|
|
22
|
-
constructor(framework: IFramework, descriptor:
|
|
23
|
+
constructor(framework: IFramework, descriptor: ResolvedTextureDescriptor, image?: HTMLImageElement);
|
|
23
24
|
/** The WebGPU texture. */
|
|
24
25
|
get gpuTexture(): GpuTexture;
|
|
25
26
|
/** The default WebGPU view of the whole texture. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGpuTexture2D.d.ts","sourceRoot":"","sources":["../../../src/webgpu/texture/WebGpuTexture2D.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"WebGpuTexture2D.d.ts","sourceRoot":"","sources":["../../../src/webgpu/texture/WebGpuTexture2D.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,UAAU,EAIf,KAAK,YAAY,EACjB,qBAAqB,EAExB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,UAAU,EAAC,MAAM,yCAAyC,CAAC;AAEnE,OAAO,EAAkB,KAAK,UAAU,EAAE,KAAK,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAGxF,OAAO,EAAC,KAAK,yBAAyB,EAA2B,MAAM,4DAA4D,CAAC;AAEpI;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,UAAU;IAE3C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAmB;IAC3C,OAAO,CAAC,WAAW,CAA2B;IAC9C,OAAO,CAAC,eAAe,CAA+B;IAEtD;;;;;OAKG;gBACgB,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,yBAAyB,EAAE,KAAK,CAAC,EAAE,gBAAgB;IAMzG,0BAA0B;IAC1B,IAAW,UAAU,IAAI,UAAU,CAKlC;IAED,oDAAoD;IACpD,IAAW,cAAc,IAAI,cAAc,CAK1C;IAED,kBAAkB;IACX,UAAU,IAAI,IAAI;IAyEzB,kBAAkB;IACX,UAAU,CAAC,UAAU,CAAC,EAAE,qBAAqB,GAAG,YAAY;IAanE,kBAAkB;IACX,OAAO,IAAI,IAAI;IAetB,yCAAyC;IACzC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAA8C;IAEpF;;;;OAIG;WACW,kBAAkB,CAAC,SAAS,EAAE,UAAU,GAAG,eAAe;IAkBxE;;;OAGG;WACW,cAAc,CAAC,SAAS,EAAE,UAAU,GAAG,IAAI;CAK5D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Color, type IFramework, type ITexture2D, type ITextureFactory,
|
|
1
|
+
import { Color, type IFramework, type ITexture2D, type ITextureFactory, type ITextureDescriptor, TextureFormat } from "../../api/index.js";
|
|
2
2
|
import type { IKtx2Texture } from "ris-ktx2";
|
|
3
3
|
/**
|
|
4
4
|
* The WebGPU texture factory.
|
|
@@ -12,7 +12,7 @@ export declare class WebGpuTextureFactory implements ITextureFactory {
|
|
|
12
12
|
*/
|
|
13
13
|
constructor(_framework: IFramework);
|
|
14
14
|
/** @inheritDoc */
|
|
15
|
-
createFromKtx2(_ktxTexture: IKtx2Texture, _descriptor?:
|
|
15
|
+
createFromKtx2(_ktxTexture: IKtx2Texture, _descriptor?: ITextureDescriptor): ITexture2D;
|
|
16
16
|
/** @inheritDoc */
|
|
17
17
|
create(width: number, height: number, data?: number[] | HTMLImageElement | ArrayBufferView, channels?: number, label?: string | null | undefined, textureUsage?: number, textureFormat?: TextureFormat, useMipMaps?: boolean): ITexture2D;
|
|
18
18
|
/** @inheritDoc */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebGpuTextureFactory.d.ts","sourceRoot":"","sources":["../../../src/webgpu/texture/WebGpuTextureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,
|
|
1
|
+
{"version":3,"file":"WebGpuTextureFactory.d.ts","sourceRoot":"","sources":["../../../src/webgpu/texture/WebGpuTextureFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,aAAa,EAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAI3C;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IAMrC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAJ9C;;;OAGG;gBACiC,UAAU,EAAE,UAAU;IAG1D,kBAAkB;IACX,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,kBAAkB,GAAG,UAAU;IAI9F,kBAAkB;IACX,MAAM,CACT,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,GAAG,eAAe,EACpD,QAAQ,GAAE,MAAU,EACpB,KAAK,GAAE,MAAM,GAAG,IAAI,GAAG,SAAgB,EACvC,YAAY,SAAuD,EACnE,aAAa,gBAA6B,EAC1C,UAAU,UAAQ,GAAG,UAAU;IAuCnC,kBAAkB;IACX,WAAW,CACd,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAC7B,KAAK,GAAE,KAAK,GAAG,IAAW,EAC1B,YAAY,SAAuD,EACnE,aAAa,gBAA0B,EACvC,KAAK,GAAE,MAAM,GAAG,IAAW,EAC3B,SAAS,UAAQ,GAAG,UAAU;CAmCrC"}
|
package/package.json
CHANGED
package/src/Framework.ts
CHANGED
|
@@ -54,7 +54,7 @@ import {WebGpuRenderPipelineFactory} from "./webgpu/render-pipelines/WebGpuRende
|
|
|
54
54
|
import {WebGpuShaderModuleLoader} from "./webgpu/shader/WebGpuShaderModuleLoader.ts";
|
|
55
55
|
import {WebGpuBuffersFactory} from "./webgpu/buffers/WebGpuBuffersFactory.ts";
|
|
56
56
|
import {WebGpuTexture2D} from "./webgpu/texture/WebGpuTexture2D.ts";
|
|
57
|
-
import {
|
|
57
|
+
import {ColorSpace} from "./api/rendering/enums.ts";
|
|
58
58
|
|
|
59
59
|
/** The Ris framework */
|
|
60
60
|
export class Framework implements IFramework {
|
|
@@ -100,7 +100,7 @@ export class Framework implements IFramework {
|
|
|
100
100
|
textureFiltering: this._configuration.textureFiltering ?? TextureSamplerFilteringPreset.BILINEAR,
|
|
101
101
|
alpha: this._configuration.alpha ?? false,
|
|
102
102
|
powerPreference: this._configuration.powerPreference ?? PowerPreferenceType.DEFAULT,
|
|
103
|
-
textureColorSpace: this._configuration.textureColorSpace ??
|
|
103
|
+
textureColorSpace: this._configuration.textureColorSpace ?? ColorSpace.SRGB
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
|
package/src/api/IFramework.ts
CHANGED
|
@@ -23,7 +23,7 @@ import type { IDisposable } from "./core/IDisposable.ts";
|
|
|
23
23
|
import type {vec2} from "gl-matrix";
|
|
24
24
|
import type {TextureSamplerFilteringPreset} from "../core/rendering/enums.ts";
|
|
25
25
|
import type {PowerPreferenceType} from "./rendering/PowerPreference.ts";
|
|
26
|
-
import type {
|
|
26
|
+
import type {ColorSpace} from "./rendering/enums.ts";
|
|
27
27
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -41,8 +41,8 @@ export class IFrameworkConfiguration {
|
|
|
41
41
|
/** The texture filtering to configure */
|
|
42
42
|
textureFiltering?: TextureSamplerFilteringPreset;
|
|
43
43
|
|
|
44
|
-
/** The texture color space to use by default. By default, it is {@link
|
|
45
|
-
textureColorSpace?:
|
|
44
|
+
/** The texture color space to use by default. By default, it is {@link ColorSpace.SRGB}. */
|
|
45
|
+
textureColorSpace?: ColorSpace;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* The HTMLCanvasElement to use for rendering.
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
type IShaderModuleLoader,
|
|
5
5
|
type ITexture2D,
|
|
6
6
|
type IFramework,
|
|
7
|
-
|
|
7
|
+
type ITextureDescriptor,
|
|
8
8
|
TextureFormat,
|
|
9
9
|
ContentConfig,
|
|
10
10
|
TextureUsage,
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import {ObjGeometryMapper} from "../loaders/ObjGeometryMapper.ts";
|
|
19
19
|
import {ObjLoader} from "../loaders/ObjLoader.ts";
|
|
20
20
|
import {Ktx2Factory} from "ris-ktx2";
|
|
21
|
+
import {resolveTextureDescriptor} from "../../core/rendering/texture/TextureDescriptorUtilities.ts";
|
|
21
22
|
import type {IKtx2Texture} from "ris-ktx2";
|
|
22
23
|
|
|
23
24
|
const KTX2_EXTENSION = ".ktx2";
|
|
@@ -76,16 +77,17 @@ export class ContentManager implements IContentManager {
|
|
|
76
77
|
|
|
77
78
|
/** @inheritDoc */
|
|
78
79
|
public async loadTexture2DAsync(path: string,
|
|
79
|
-
textureDescriptor?:
|
|
80
|
+
textureDescriptor?: ITextureDescriptor,
|
|
80
81
|
contentConfig?: ContentConfig,
|
|
81
82
|
): Promise<ITexture2D> {
|
|
82
83
|
|
|
84
|
+
const desc = resolveTextureDescriptor(textureDescriptor);
|
|
85
|
+
|
|
83
86
|
// TODO: check texture cache
|
|
84
87
|
if (path.endsWith(KTX2_EXTENSION)) {
|
|
85
88
|
|
|
86
89
|
const ktx2Texture = await this.loadKtx2Async(path);
|
|
87
|
-
|
|
88
|
-
const tex = this._framework.textureFactory.createFromKtx2(ktx2Texture, textureDescriptor);
|
|
90
|
+
const tex = this._framework.textureFactory.createFromKtx2(ktx2Texture, desc);
|
|
89
91
|
if (contentConfig?.keepDataCached !== true) {
|
|
90
92
|
ktx2Texture.delete();
|
|
91
93
|
}
|
|
@@ -94,8 +96,8 @@ export class ContentManager implements IContentManager {
|
|
|
94
96
|
|
|
95
97
|
let format = this._framework.renderer.preferredTextureFormat;
|
|
96
98
|
|
|
97
|
-
if (
|
|
98
|
-
format =
|
|
99
|
+
if (desc.textureFormat != TextureFormat.UNDEFINED) {
|
|
100
|
+
format = desc.textureFormat;
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
const imageLoader = this._framework.imageLoader;
|
|
@@ -109,7 +111,7 @@ export class ContentManager implements IContentManager {
|
|
|
109
111
|
path,
|
|
110
112
|
TextureUsage.TEXTURE_BINDING | TextureUsage.COPY_SRC,
|
|
111
113
|
format,
|
|
112
|
-
|
|
114
|
+
desc.generateMipmaps
|
|
113
115
|
);
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -4,7 +4,7 @@ import type { IRenderableMesh } from "../meshes/IRenderableMesh.ts";
|
|
|
4
4
|
import type { IShaderModuleLoader } from "../shader/IShaderModuleLoader.ts";
|
|
5
5
|
import type { IShaderModule } from "../shader/IShaderModule.ts";
|
|
6
6
|
import type { ITexture2D } from "../rendering/texture/ITexture2D.ts";
|
|
7
|
-
import {
|
|
7
|
+
import type {ITextureDescriptor} from "../rendering/texture/ITextureDescriptor.ts";
|
|
8
8
|
import {ContentConfig} from "./ContentConfig.ts";
|
|
9
9
|
import type { IKtx2Texture } from "ris-ktx2";
|
|
10
10
|
import type {IMesh} from "../meshes/IMesh.ts";
|
|
@@ -42,7 +42,7 @@ export interface IContentManager {
|
|
|
42
42
|
* @param contentConfig - The content config.
|
|
43
43
|
* @returns The Texture2D.
|
|
44
44
|
*/
|
|
45
|
-
loadTexture2DAsync(path: string, desc?:
|
|
45
|
+
loadTexture2DAsync(path: string, desc?: ITextureDescriptor, contentConfig?: ContentConfig): Promise<ITexture2D>;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* Loads a plain mesh (geometry and buffers only, no material or transform) from an OBJ (Wavefront) file,
|
|
@@ -5,7 +5,7 @@ import {RenderingBackend} from "./RenderingBackend.ts";
|
|
|
5
5
|
import {vec2} from "gl-matrix";
|
|
6
6
|
import type {PowerPreferenceType} from "./PowerPreference.ts";
|
|
7
7
|
import type {TextureSamplerFilteringPreset} from "../../core/rendering/enums.ts";
|
|
8
|
-
import type {
|
|
8
|
+
import type {ColorSpace} from "./enums.ts";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -31,7 +31,7 @@ export interface IRendererConfiguration {
|
|
|
31
31
|
textureFiltering: TextureSamplerFilteringPreset;
|
|
32
32
|
|
|
33
33
|
/** The desired texture color space. */
|
|
34
|
-
textureColorSpace:
|
|
34
|
+
textureColorSpace: ColorSpace;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -46,13 +46,19 @@ export interface IRenderer {
|
|
|
46
46
|
readonly graphicsDevice: IGraphicsDevice;
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* The preferred texture format.
|
|
50
|
-
*
|
|
51
|
-
* - {@link TextureFormat.}
|
|
52
|
-
* - {@link TextureFormat.}
|
|
49
|
+
* The preferred texture format, chosen from {@link IRendererConfiguration.textureColorSpace}.
|
|
50
|
+
* Textures that do not specify a texture format are created with it:
|
|
51
|
+
* - {@link TextureFormat.RGBA_8_UNORM_SRGB} when the color space is {@link ColorSpace.SRGB} (the default).
|
|
52
|
+
* - {@link TextureFormat.RGBA_8_UNORM} when the color space is {@link ColorSpace.LINEAR}.
|
|
53
53
|
*/
|
|
54
54
|
readonly preferredTextureFormat: TextureFormat;
|
|
55
55
|
|
|
56
|
+
/**
|
|
57
|
+
* The preferred texture color space, taken from {@link IRendererConfiguration.textureColorSpace}.
|
|
58
|
+
* Textures that do not specify a format are treated as being in this color space.
|
|
59
|
+
*/
|
|
60
|
+
readonly preferredColorSpace: ColorSpace;
|
|
61
|
+
|
|
56
62
|
/**
|
|
57
63
|
* The preferred depth stencil format.
|
|
58
64
|
*/
|
|
@@ -19,12 +19,12 @@ export enum Culling {
|
|
|
19
19
|
Front
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
export enum
|
|
22
|
+
/** The color space. */
|
|
23
|
+
export enum ColorSpace
|
|
24
24
|
{
|
|
25
|
-
/**
|
|
25
|
+
/** The linear color space. */
|
|
26
26
|
LINEAR = "LINEAR",
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
SRGB = "
|
|
28
|
+
/** The sRGB color space. */
|
|
29
|
+
SRGB = "SRGB",
|
|
30
30
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type {TextureFormat} from "./TextureFormat.ts";
|
|
2
|
+
import type {TextureUsage} from "./TextureUsage.ts";
|
|
3
|
+
import type {vec2} from "gl-matrix";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The texture descriptor. Every field is optional; factories fill in the defaults for missing fields.
|
|
7
|
+
*/
|
|
8
|
+
export interface ITextureDescriptor {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The texture width.
|
|
12
|
+
* By default, it is 0.
|
|
13
|
+
*/
|
|
14
|
+
width?: number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The texture height.
|
|
18
|
+
* By default, it is 0.
|
|
19
|
+
*/
|
|
20
|
+
height?: number;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The texture format.
|
|
24
|
+
* By default, it is UNDEFINED.
|
|
25
|
+
*/
|
|
26
|
+
textureFormat?: TextureFormat;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The texture usage.
|
|
30
|
+
* By default, it is TEXTURE_BINDING | COPY_DST.
|
|
31
|
+
*/
|
|
32
|
+
textureUsage?: TextureUsage;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The texture label.
|
|
36
|
+
* By default, it is null.
|
|
37
|
+
*/
|
|
38
|
+
label?: string | null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The data per mip level.
|
|
42
|
+
* By default, it is undefined.
|
|
43
|
+
*/
|
|
44
|
+
data?: Uint8Array[];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Should mipmaps be generated.
|
|
48
|
+
* By default, it is false.
|
|
49
|
+
*/
|
|
50
|
+
generateMipmaps?: boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The block size of a texture, which must be set for compressed textures.
|
|
54
|
+
* By default, it is undefined.
|
|
55
|
+
*/
|
|
56
|
+
blockSize?: vec2;
|
|
57
|
+
}
|
|
@@ -2,7 +2,7 @@ import {Color} from "../../data/Color.ts";
|
|
|
2
2
|
import {TextureUsage} from "./TextureUsage.ts";
|
|
3
3
|
import {TextureFormat} from "./TextureFormat.ts";
|
|
4
4
|
import type { ITexture2D } from "./ITexture2D.ts";
|
|
5
|
-
import {
|
|
5
|
+
import type {ITextureDescriptor} from "./ITextureDescriptor.ts";
|
|
6
6
|
import type {IKtx2Texture} from "ris-ktx2";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -52,5 +52,5 @@ export interface ITextureFactory {
|
|
|
52
52
|
* @param descriptor - The optional texture descriptor.
|
|
53
53
|
* @returns The 2D texture.
|
|
54
54
|
*/
|
|
55
|
-
createFromKtx2(ktxTexture: IKtx2Texture, descriptor?:
|
|
55
|
+
createFromKtx2(ktxTexture: IKtx2Texture, descriptor?: ITextureDescriptor): ITexture2D;
|
|
56
56
|
}
|
|
@@ -204,77 +204,33 @@ export class TextureUtilities {
|
|
|
204
204
|
};
|
|
205
205
|
|
|
206
206
|
private static readonly _mapKtxTranscodeFormatVkFormat: { [key: number]: number } = {
|
|
207
|
-
[KtxTranscodeFormat.
|
|
207
|
+
[KtxTranscodeFormat.ETC1_RGB]: VkFormat.ETC2_R8G8B8_UNORM_BLOCK,
|
|
208
208
|
[KtxTranscodeFormat.ETC2_RGBA]: VkFormat.ETC2_R8G8B8A8_UNORM_BLOCK,
|
|
209
|
-
[KtxTranscodeFormat.
|
|
209
|
+
[KtxTranscodeFormat.BC1_RGB]: VkFormat.BC1_RGB_UNORM_BLOCK,
|
|
210
210
|
[KtxTranscodeFormat.BC3_RGBA]: VkFormat.BC3_UNORM_BLOCK,
|
|
211
|
-
[KtxTranscodeFormat.
|
|
212
|
-
[KtxTranscodeFormat.
|
|
211
|
+
[KtxTranscodeFormat.BC4_R]: VkFormat.BC4_UNORM_BLOCK,
|
|
212
|
+
[KtxTranscodeFormat.BC5_RG]: VkFormat.BC5_UNORM_BLOCK,
|
|
213
213
|
[KtxTranscodeFormat.BC7_RGBA]: VkFormat.BC7_UNORM_BLOCK,
|
|
214
|
-
[KtxTranscodeFormat.
|
|
214
|
+
[KtxTranscodeFormat.PVRTC1_4_RGB]: VkFormat.PVRTC1_4BPP_UNORM_BLOCK_IMG,
|
|
215
215
|
[KtxTranscodeFormat.PVRTC1_4_RGBA]: VkFormat.PVRTC1_4BPP_UNORM_BLOCK_IMG,
|
|
216
216
|
[KtxTranscodeFormat.ASTC_4X4_RGBA]: VkFormat.ASTC_4X4_UNORM_BLOCK,
|
|
217
217
|
[KtxTranscodeFormat.RGBA32]: VkFormat.R8G8B8A8_UNORM,
|
|
218
|
-
[KtxTranscodeFormat.
|
|
219
|
-
[KtxTranscodeFormat.
|
|
220
|
-
[KtxTranscodeFormat.
|
|
221
|
-
[KtxTranscodeFormat.
|
|
218
|
+
[KtxTranscodeFormat.RGB565]: VkFormat.R5G6B5_UNORM_PACK16,
|
|
219
|
+
[KtxTranscodeFormat.BGR565]: VkFormat.B5G6R5_UNORM_PACK16,
|
|
220
|
+
[KtxTranscodeFormat.RGBA4444]: VkFormat.R4G4B4A4_UNORM_PACK16,
|
|
221
|
+
[KtxTranscodeFormat.PVRTC2_4_RGB]: VkFormat.PVRTC2_4BPP_UNORM_BLOCK_IMG,
|
|
222
222
|
[KtxTranscodeFormat.PVRTC2_4_RGBA]: VkFormat.PVRTC2_4BPP_UNORM_BLOCK_IMG,
|
|
223
|
-
[KtxTranscodeFormat.
|
|
224
|
-
[KtxTranscodeFormat.
|
|
223
|
+
[KtxTranscodeFormat.ETC2_EAC_R11]: VkFormat.EAC_R11_UNORM_BLOCK,
|
|
224
|
+
[KtxTranscodeFormat.ETC2_EAC_RG11]: VkFormat.EAC_R11G11_UNORM_BLOCK,
|
|
225
225
|
};
|
|
226
226
|
|
|
227
|
-
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
public static isSrgbFormat(format: TextureFormat): boolean {
|
|
232
|
-
return format.endsWith("_SRGB");
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
/**
|
|
236
|
-
* Gets the sRGB variant of a linear format, or the format itself if it has none or is already sRGB.
|
|
237
|
-
* @param format The texture format.
|
|
238
|
-
*/
|
|
239
|
-
public static toSrgbFormat(format: TextureFormat): TextureFormat {
|
|
240
|
-
return this._srgbVariant[format] ?? format;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* Gets the linear variant of an sRGB format, or the format itself.
|
|
245
|
-
* @param format The texture format.
|
|
246
|
-
*/
|
|
247
|
-
public static toLinearFormat(format: TextureFormat): TextureFormat {
|
|
248
|
-
for (const linear in this._srgbVariant) {
|
|
249
|
-
if (this._srgbVariant[linear] === format) return linear as TextureFormat;
|
|
250
|
-
}
|
|
251
|
-
return format;
|
|
252
|
-
}
|
|
227
|
+
/** sRGB format → its linear variant. */
|
|
228
|
+
private static readonly _linearVariant: { [key: string]: TextureFormat } = Object.fromEntries(
|
|
229
|
+
Object.entries(TextureUtilities._srgbVariant).map(([linear, srgb]) => [srgb, linear as TextureFormat])
|
|
230
|
+
);
|
|
253
231
|
|
|
254
|
-
/**
|
|
255
|
-
|
|
256
|
-
* Returns null for formats it does not know.
|
|
257
|
-
* @param format The texture format.
|
|
258
|
-
*/
|
|
259
|
-
public static getBlockSize(format: TextureFormat): [number, number] | null {
|
|
260
|
-
if (!this.isCompressedTextureFormat(format)) {
|
|
261
|
-
return [1, 1];
|
|
262
|
-
}
|
|
263
|
-
const astc = /^ASTC_(\d+)X(\d+)_/.exec(format);
|
|
264
|
-
if (astc) {
|
|
265
|
-
return [Number(astc[1]), Number(astc[2])];
|
|
266
|
-
}
|
|
267
|
-
if (format.startsWith("BC") || format.startsWith("ETC2")) {
|
|
268
|
-
return [4, 4];
|
|
269
|
-
}
|
|
270
|
-
if (format.startsWith("PVRTC_2BPP")) {
|
|
271
|
-
return [8, 4];
|
|
272
|
-
}
|
|
273
|
-
if (format.startsWith("PVRTC_4BPP")) {
|
|
274
|
-
return [4, 4];
|
|
275
|
-
}
|
|
276
|
-
return null;
|
|
277
|
-
}
|
|
232
|
+
/** Every sRGB format. */
|
|
233
|
+
private static readonly _srgbFormats: TextureFormat[] = Object.values(TextureUtilities._srgbVariant);
|
|
278
234
|
|
|
279
235
|
/**
|
|
280
236
|
* Checks if the given texture format is a compressed texture format.
|
|
@@ -361,4 +317,30 @@ export class TextureUtilities {
|
|
|
361
317
|
return format;
|
|
362
318
|
}
|
|
363
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Maps the linear format to the srgb variant.
|
|
322
|
+
* @param textureFormat The linear format.
|
|
323
|
+
* @return The srgb variant, or the format itself if it is already sRGB or has no sRGB variant (e.g. PVRTC).
|
|
324
|
+
*/
|
|
325
|
+
public static convertToSrgbVariant(textureFormat: TextureFormat) : TextureFormat {
|
|
326
|
+
return this._srgbVariant[textureFormat] ?? textureFormat;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Maps the srgb format to the linear variant.
|
|
331
|
+
* @param textureFormat The srgb format.
|
|
332
|
+
* @return The linear variant, or the format itself if it is already linear.
|
|
333
|
+
*/
|
|
334
|
+
public static convertToLinearVariant(textureFormat: TextureFormat) : TextureFormat {
|
|
335
|
+
return this._linearVariant[textureFormat] ?? textureFormat;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Checks whether the texture format is an sRGB format.
|
|
340
|
+
* @param textureFormat The texture format to check.
|
|
341
|
+
* @return True if srgb texture format.
|
|
342
|
+
*/
|
|
343
|
+
public static isSrgbFormat(textureFormat: TextureFormat) : boolean {
|
|
344
|
+
return this._srgbFormats.includes(textureFormat);
|
|
345
|
+
}
|
|
364
346
|
}
|
|
@@ -5,5 +5,5 @@ export * from "./TextureViewDimension.ts";
|
|
|
5
5
|
export * from "./TextureFormat.ts";
|
|
6
6
|
export * from "./ITextureView.ts";
|
|
7
7
|
export * from "./ITextureFactory.ts";
|
|
8
|
-
export * from "./
|
|
8
|
+
export * from "./ITextureDescriptor.ts";
|
|
9
9
|
export * from "./TextureUtilities.ts";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
TextureFormat,
|
|
19
19
|
TextureUsage
|
|
20
20
|
} from "../../api/index.ts";
|
|
21
|
-
import {
|
|
21
|
+
import {ColorSpace} from "../../api/rendering/enums.ts";
|
|
22
22
|
|
|
23
23
|
export abstract class ARenderer implements ITempRenderer {
|
|
24
24
|
|
|
@@ -69,6 +69,9 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
69
69
|
/** @inheritdoc */
|
|
70
70
|
public readonly preferredTextureFormat: TextureFormat;
|
|
71
71
|
|
|
72
|
+
/** @inheritDoc */
|
|
73
|
+
public readonly preferredColorSpace: ColorSpace;
|
|
74
|
+
|
|
72
75
|
/** @inheritdoc */
|
|
73
76
|
public get preferredDepthStencilFormat(): TextureFormat {
|
|
74
77
|
return this._preferredDepthStencilFormat;
|
|
@@ -108,7 +111,8 @@ export abstract class ARenderer implements ITempRenderer {
|
|
|
108
111
|
this._windowManager = framework.windowManager;
|
|
109
112
|
this._currentBackBufferSize[0] = this._windowManager.canvas.width;
|
|
110
113
|
this._currentBackBufferSize[1] = this._windowManager.canvas.height;
|
|
111
|
-
this.
|
|
114
|
+
this.preferredColorSpace = configuration.textureColorSpace;
|
|
115
|
+
this.preferredTextureFormat = configuration.textureColorSpace == ColorSpace.SRGB
|
|
112
116
|
? TextureFormat.RGBA_8_UNORM_SRGB : TextureFormat.RGBA_8_UNORM;
|
|
113
117
|
}
|
|
114
118
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {type ITextureDescriptor, TextureFormat, TextureUsage} from "../../../api/index.ts";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A texture descriptor with all defaults applied. Only `data` and `blockSize` stay optional.
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export type ResolvedTextureDescriptor =
|
|
8
|
+
Required<Omit<ITextureDescriptor, "data" | "blockSize">> & Pick<ITextureDescriptor, "data" | "blockSize">;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Fills in the defaults for every missing field of a texture descriptor.
|
|
12
|
+
* @param desc The descriptor, possibly partial or missing.
|
|
13
|
+
* @returns A new descriptor with the defaults applied.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export function resolveTextureDescriptor(desc?: ITextureDescriptor): ResolvedTextureDescriptor {
|
|
17
|
+
return {
|
|
18
|
+
width: desc?.width ?? 0,
|
|
19
|
+
height: desc?.height ?? 0,
|
|
20
|
+
textureFormat: desc?.textureFormat ?? TextureFormat.UNDEFINED,
|
|
21
|
+
textureUsage: desc?.textureUsage ?? (TextureUsage.TEXTURE_BINDING | TextureUsage.COPY_DST),
|
|
22
|
+
label: desc?.label ?? null,
|
|
23
|
+
data: desc?.data,
|
|
24
|
+
generateMipmaps: desc?.generateMipmaps ?? false,
|
|
25
|
+
blockSize: desc?.blockSize,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ITexture2D, type ITextureView,
|
|
3
3
|
State,
|
|
4
|
-
type TextureDescriptor,
|
|
5
4
|
type TextureFormat,
|
|
6
5
|
TextureUsage,
|
|
7
6
|
TextureViewDescriptor
|
|
8
7
|
} from "../../../api/index.ts";
|
|
9
8
|
import {vec2} from "gl-matrix";
|
|
9
|
+
import type {ResolvedTextureDescriptor} from "./TextureDescriptorUtilities.ts";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* The ATexture2D class is an abstract base class that implements the ITexture2D interface. It provides common properties and a constructor for initializing a 2D texture, but it does not implement the actual texture creation and management logic, which must be provided by subclasses that extend this base class.
|
|
@@ -30,7 +30,7 @@ export abstract class ATexture2D implements ITexture2D {
|
|
|
30
30
|
* @param descriptor - The texture descriptor.
|
|
31
31
|
*/
|
|
32
32
|
protected constructor(
|
|
33
|
-
descriptor:
|
|
33
|
+
descriptor: ResolvedTextureDescriptor,
|
|
34
34
|
) {
|
|
35
35
|
|
|
36
36
|
if (!descriptor.textureFormat) {
|
package/src/main.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
type ITexture2D,
|
|
12
12
|
Rect,
|
|
13
13
|
SamplerDescriptor,
|
|
14
|
-
SamplerFilter,
|
|
14
|
+
SamplerFilter, type ITextureDescriptor, TextureFormat
|
|
15
15
|
} from "./api/index.ts";
|
|
16
16
|
|
|
17
17
|
document.querySelector<HTMLDivElement>('#app')!.innerHTML = `
|
|
@@ -46,9 +46,10 @@ let sampler: ISampler;
|
|
|
46
46
|
framework.addOnLoadContentListener(async () =>
|
|
47
47
|
{
|
|
48
48
|
|
|
49
|
-
const texDesc =
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
const texDesc: ITextureDescriptor = {
|
|
50
|
+
generateMipmaps: true,
|
|
51
|
+
textureFormat: TextureFormat.RGBA_8_UNORM,
|
|
52
|
+
};
|
|
52
53
|
|
|
53
54
|
tex = await framework.content.loadTexture2DAsync("/assets/test.png", texDesc);
|
|
54
55
|
tex2 = await framework.content.loadTexture2DAsync("/assets/cat.jpg", texDesc);
|