You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds the glue code to enable DumpData usage in BN with the glTF
exporter.
Changes:
- Factor out core image encoding to a separate function matching
NativeEncoding's own exposed function name. This follows the current
nativeOverride pattern for module-level functions (see the MathHelper
class.)
- Remove the `bitmaprenderer` path. I initially planned for Native to
polyfill this, but that turned out to be not a good idea.
- Fix case in glTF exporter where exporting images to a specific format
could lead to invalid images if the browser or platform didn't support
it.
@@ -28,14 +30,11 @@ async function _CreateDumpResourcesAsync(): Promise<DumpResources> {
28
30
Logger.Warn("DumpData: OffscreenCanvas will be used for dumping data. This may result in lossy alpha values.");
29
31
}
30
32
31
-
// If WebGL via ThinEngine is not available (e.g. Native), use the BitmapRenderer.
33
+
// If WebGL via ThinEngine is not available, we cannot encode the data.
32
34
// If https://github.com/whatwg/html/issues/10142 is resolved, we can migrate to just BitmapRenderer and avoid an engine dependency altogether.
reject(newError("EncodeImageAsync: Failed to convert canvas to blob."));
116
+
}else{
117
+
resolve(blob);
118
+
}
119
+
},
120
+
mimeType,
121
+
quality
122
+
);
123
+
});
124
+
}
125
+
}
126
+
127
+
/**
128
+
* Encodes pixel data to an image
129
+
* @param pixelData 8-bit RGBA pixel data
130
+
* @param width the width of the image
131
+
* @param height the height of the image
132
+
* @param mimeType the requested MIME type
133
+
* @param invertY true to invert the image in the Y direction
134
+
* @param quality the quality of the image if lossy mimeType is used (e.g. image/jpeg, image/webp). See {@link https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob | HTMLCanvasElement.toBlob()}'s `quality` parameter.
135
+
* @returns a promise that resolves to the encoded image data. Note that the `blob.type` may differ from `mimeType` if it was not supported.
0 commit comments