mirror of
https://github.com/xibyte/jsketcher
synced 2026-02-10 17:34:14 +01:00
reduced size of wasm
This commit is contained in:
parent
6d5788df52
commit
35b6366cc3
3 changed files with 17 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ import {CraftEngine} from "./craftEngine";
|
|||
import {createOCCService, OCCService} from "cad/craft/e0/occService";
|
||||
|
||||
|
||||
|
||||
declare module 'context' {
|
||||
interface CoreContext {
|
||||
occService: OCCService;
|
||||
|
|
@ -22,9 +23,17 @@ export function activate(ctx) {
|
|||
ctx.occService = createOCCService(ctx);
|
||||
}
|
||||
|
||||
function instantiateEngine(importObject, callback) {
|
||||
const url = './wasm/e0/main.wasm';
|
||||
WebAssembly.instantiateStreaming(fetch(url), importObject).then(results => {
|
||||
async function instantiateEngine(importObject, callback) {
|
||||
const url = './wasm/e0/main.wasm.gz';
|
||||
const buffer = pako.ungzip(await(await fetch(url)).arrayBuffer());
|
||||
|
||||
// A fetched response might be decompressed twice on Firefox.
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=610679
|
||||
if (buffer[0] === 0x1f && buffer[1] === 0x8b) {
|
||||
buffer = ungzip(buffer);
|
||||
}
|
||||
|
||||
const result = await WebAssembly.instantiate(buffer, importObject).then(results => {
|
||||
callback(results.instance);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Web CAD / Part Designer</title>
|
||||
<script src="./lib/pako.min.js"></script>
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext">
|
||||
<link rel="stylesheet" href="lib/font-awesome/css/font-awesome.min.css?modeler">
|
||||
|
|
|
|||
2
web/lib/pako.min.js
vendored
Normal file
2
web/lib/pako.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue