forked from webaverse/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cards-manager.js
37 lines (35 loc) · 1.07 KB
/
cards-manager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import offscreenEngineManager from './offscreen-engine-manager.js';
const _generateObjectUrlCardRemote = (() => {
let generateObjectUrlCardRemoteFn = null;
return async function() {
if (!generateObjectUrlCardRemoteFn) {
generateObjectUrlCardRemoteFn = offscreenEngineManager.createFunction([
`\
import {generateObjectUrlCard} from './card-renderer.js';
`,
async function(o) {
const imageBitmap = await generateObjectUrlCard(o);
return imageBitmap;
}
]);
}
const result = await generateObjectUrlCardRemoteFn.apply(this, arguments);
return result;
};
})();
class CardsManager {
async getCardsImage(start_url, {width, flipY, signal} = {}) {
const imageBitmap = await _generateObjectUrlCardRemote([
{
start_url,
width,
flipY,
}
], {
signal,
});
return imageBitmap;
}
}
const cardsManager = new CardsManager();
export default cardsManager;