Skip to content

Commit 04cc960

Browse files
fix: kt2x compression
1 parent 1e290f5 commit 04cc960

3 files changed

Lines changed: 47 additions & 9 deletions

File tree

extra-resources/basis/basis_encoder.js

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.65 MB
Binary file not shown.

src/lib/workers/export.worker.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { dedup, prune } from "@gltf-transform/functions";
2626
import { addOBJ } from "../../trees/lib/obj.js";
2727
import { addGLB } from "../../trees/lib/gltf.js";
2828
import { generateFlowMap } from '../flowmap.js';
29+
import { EXTRA_RESOURCE_PATH } from '../app.js';
2930

3031

3132
function decodeImage(data) {
@@ -71,7 +72,8 @@ async function compressTextures(glbBuffer) {
7172
ktx2({
7273
isUASTC: true,
7374
generateMipmap: true,
74-
imageDecoder: decodeImage
75+
imageDecoder: decodeImage,
76+
wasmUrl: path.join(EXTRA_RESOURCE_PATH, 'basis/basis_encoder.wasm'),
7577
// imageDecoder: async (data) => {
7678
// return decodeImage(data);
7779
// const { info, data: raw } = await sharp(Buffer.from(data))
@@ -157,15 +159,16 @@ export async function exportTreePackage(inputFiles, outputFile) {
157159
ktx2({
158160
isUASTC: true,
159161
generateMipmap: true,
160-
imageDecoder: decodeImage
162+
imageDecoder: decodeImage,
163+
wasmUrl: path.join(EXTRA_RESOURCE_PATH, 'basis/basis_encoder.wasm'),
161164
// imageDecoder: async (data) => {
162-
// const { info, data: raw } = await sharp(Buffer.from(data))
163-
// .ensureAlpha()
164-
// .raw()
165-
// .toBuffer({ resolveWithObject: true });
166-
// const pixels = new Uint8Array(raw.length);
167-
// pixels.set(raw);
168-
// return { width: info.width, height: info.height, data: pixels };
165+
// const { info, data: raw } = await sharp(Buffer.from(data))
166+
// .ensureAlpha()
167+
// .raw()
168+
// .toBuffer({ resolveWithObject: true });
169+
// const pixels = new Uint8Array(raw.length);
170+
// pixels.set(raw);
171+
// return { width: info.width, height: info.height, data: pixels };
169172
// }
170173
})
171174
);

0 commit comments

Comments
 (0)