wgsl-renderer 0.1.0 → 0.1.2
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/dist/cjs/index.js +3 -2
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +3 -2
- package/package.json +4 -5
package/dist/cjs/index.js
CHANGED
|
@@ -497,7 +497,7 @@ var WGSLRenderer = class {
|
|
|
497
497
|
addressModeV: "clamp-to-edge"
|
|
498
498
|
}, options));
|
|
499
499
|
}
|
|
500
|
-
async loadImageTexture(image) {
|
|
500
|
+
async loadImageTexture(image, format) {
|
|
501
501
|
if (typeof image === "string") if (image.startsWith("data:")) {
|
|
502
502
|
const base64Data = image.split(",")[1];
|
|
503
503
|
const binaryString = atob(base64Data);
|
|
@@ -523,12 +523,13 @@ var WGSLRenderer = class {
|
|
|
523
523
|
imgBitmap.height,
|
|
524
524
|
1
|
|
525
525
|
],
|
|
526
|
-
format: "rgba8unorm",
|
|
526
|
+
format: format || "rgba8unorm",
|
|
527
527
|
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
|
|
528
528
|
});
|
|
529
529
|
this.device.queue.copyExternalImageToTexture({ source: imgBitmap }, { texture }, [imgBitmap.width, imgBitmap.height]);
|
|
530
530
|
return {
|
|
531
531
|
texture,
|
|
532
|
+
bitMap: imgBitmap,
|
|
532
533
|
width: imgBitmap.width,
|
|
533
534
|
height: imgBitmap.height
|
|
534
535
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -210,8 +210,9 @@ declare class WGSLRenderer {
|
|
|
210
210
|
* Create a sampler
|
|
211
211
|
*/
|
|
212
212
|
createSampler(options?: GPUSamplerDescriptor): GPUSampler;
|
|
213
|
-
loadImageTexture(image: Blob | string): Promise<{
|
|
213
|
+
loadImageTexture(image: Blob | string, format?: GPUTextureFormat): Promise<{
|
|
214
214
|
texture: GPUTexture;
|
|
215
|
+
bitMap: ImageBitmap;
|
|
215
216
|
width: number;
|
|
216
217
|
height: number;
|
|
217
218
|
}>;
|
|
@@ -223,4 +224,4 @@ declare class WGSLRenderer {
|
|
|
223
224
|
}
|
|
224
225
|
declare function createWGSLRenderer(cvs: HTMLCanvasElement, options?: WGSLRendererOptions): Promise<WGSLRenderer>;
|
|
225
226
|
//#endregion
|
|
226
|
-
export { MultiPassDescriptor, createWGSLRenderer };
|
|
227
|
+
export { MultiPassDescriptor, type WGSLRenderer, createWGSLRenderer };
|
package/dist/esm/index.js
CHANGED
|
@@ -496,7 +496,7 @@ var WGSLRenderer = class {
|
|
|
496
496
|
addressModeV: "clamp-to-edge"
|
|
497
497
|
}, options));
|
|
498
498
|
}
|
|
499
|
-
async loadImageTexture(image) {
|
|
499
|
+
async loadImageTexture(image, format) {
|
|
500
500
|
if (typeof image === "string") if (image.startsWith("data:")) {
|
|
501
501
|
const base64Data = image.split(",")[1];
|
|
502
502
|
const binaryString = atob(base64Data);
|
|
@@ -522,12 +522,13 @@ var WGSLRenderer = class {
|
|
|
522
522
|
imgBitmap.height,
|
|
523
523
|
1
|
|
524
524
|
],
|
|
525
|
-
format: "rgba8unorm",
|
|
525
|
+
format: format || "rgba8unorm",
|
|
526
526
|
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT
|
|
527
527
|
});
|
|
528
528
|
this.device.queue.copyExternalImageToTexture({ source: imgBitmap }, { texture }, [imgBitmap.width, imgBitmap.height]);
|
|
529
529
|
return {
|
|
530
530
|
texture,
|
|
531
|
+
bitMap: imgBitmap,
|
|
531
532
|
width: imgBitmap.width,
|
|
532
533
|
height: imgBitmap.height
|
|
533
534
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wgsl-renderer",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A multi-pass renderer based on WebGPU and WGSL.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
7
7
|
"module": "./dist/esm/index.js",
|
|
@@ -33,12 +33,11 @@
|
|
|
33
33
|
"files": [
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"@webgpu/types": "^0.1.66"
|
|
38
|
-
},
|
|
36
|
+
"dependencies": {},
|
|
39
37
|
"devDependencies": {
|
|
40
38
|
"@taiyuuki/eslint-config": "^1.4.14",
|
|
41
39
|
"@types/node": "^20.14.2",
|
|
40
|
+
"@webgpu/types": "^0.1.66",
|
|
42
41
|
"eslint": "^9.5.0",
|
|
43
42
|
"rimraf": "^6.1.2",
|
|
44
43
|
"rolldown": "1.0.0-beta.52",
|