Skip to content

Commit d5dc832

Browse files
committed
top level async for io init
1 parent e7a2b7b commit d5dc832

File tree

2 files changed

+37
-42
lines changed

2 files changed

+37
-42
lines changed

sage/lib/eqg/gltf-export/v3.js

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,25 @@ import { writeMetadata } from './common';
88
import { draco, DRACO_DEFAULTS } from '@gltf-transform/functions';
99
import draco3d from 'draco3dgltf';
1010

11-
let io;
12-
(async () => {
13-
io = new WebIO()
14-
.registerDependencies({
15-
'draco3d.decoder': await draco3d.createDecoderModule({
16-
locateFile: (file) => {
17-
return `/static/${file}`;
18-
},
19-
print : console.log,
20-
printErr: console.error,
21-
}),
22-
'draco3d.encoder': await draco3d.createEncoderModule({
23-
locateFile: (file) => {
24-
return `/static/${file}`;
25-
},
26-
print : console.log,
27-
printErr: console.error,
28-
}),
29-
})
30-
.registerExtensions(ALL_EXTENSIONS);
31-
})();
3211

12+
const io = new WebIO()
13+
.registerDependencies({
14+
'draco3d.decoder': await draco3d.createDecoderModule({
15+
locateFile: (file) => {
16+
return `/static/${file}`;
17+
},
18+
print : console.log,
19+
printErr: console.error,
20+
}),
21+
'draco3d.encoder': await draco3d.createEncoderModule({
22+
locateFile: (file) => {
23+
return `/static/${file}`;
24+
},
25+
print : console.log,
26+
printErr: console.error,
27+
}),
28+
})
29+
.registerExtensions(ALL_EXTENSIONS);
3330
// Helper function to convert uint32 (assumed format 0xAARRGGBB) to normalized [r, g, b, a]
3431
function uint32ToRGBA(color) {
3532
const a = ((color >> 24) & 0xFF) / 255;

sage/lib/s3d/s3d-decoder.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,25 @@ import { Wld, WldType } from './wld/wld';
2727
import { ActorType } from './animation/actor';
2828
import { globals } from '../globals';
2929
import { optimizeBoundingBoxes } from './bsp/region-utils';
30-
let io;
31-
(async () => {
32-
io = new WebIO()
33-
.registerDependencies({
34-
'draco3d.decoder': await draco3d.createDecoderModule({
35-
locateFile: (file) => {
36-
return `/static/${file}`;
37-
},
38-
print : console.log,
39-
printErr: console.error,
40-
}),
41-
'draco3d.encoder': await draco3d.createEncoderModule({
42-
locateFile: (file) => {
43-
return `/static/${file}`;
44-
},
45-
print : console.log,
46-
printErr: console.error,
47-
}),
48-
})
49-
.registerExtensions(ALL_EXTENSIONS);
50-
})();
30+
31+
const io = new WebIO()
32+
.registerDependencies({
33+
'draco3d.decoder': await draco3d.createDecoderModule({
34+
locateFile: (file) => {
35+
return `/static/${file}`;
36+
},
37+
print : console.log,
38+
printErr: console.error,
39+
}),
40+
'draco3d.encoder': await draco3d.createEncoderModule({
41+
locateFile: (file) => {
42+
return `/static/${file}`;
43+
},
44+
print : console.log,
45+
printErr: console.error,
46+
}),
47+
})
48+
.registerExtensions(ALL_EXTENSIONS);
5149

5250

5351
export class S3DDecoder {

0 commit comments

Comments
 (0)