Skip to content

Commit

Permalink
real fix for 3MF export (#627)
Browse files Browse the repository at this point in the history
* real fix

* formatting

* updated jscadui/3mf-export
  • Loading branch information
pca006132 authored Nov 22, 2023
1 parent 10a15c1 commit 1f8e803
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions bindings/wasm/examples/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bindings/wasm/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@gltf-transform/core": "^3.8.0",
"@gltf-transform/extensions": "^3.8.0",
"@gltf-transform/functions": "^3.8.0",
"@jscadui/3mf-export": "^0.4.2",
"@jscadui/3mf-export": "^0.5.0",
"fflate": "^0.8.0",
"gl-matrix": "^3.4.3",
"simple-dropzone": "0.8.3",
Expand All @@ -29,4 +29,4 @@
"vite": "^4.5.0",
"vitest": "^0.31.1"
}
}
}
10 changes: 7 additions & 3 deletions bindings/wasm/examples/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import {Accessor, Animation, Document, mat4, Material, Node, WebIO} from '@gltf-transform/core';
import {KHRMaterialsUnlit, KHRONOS_EXTENSIONS} from '@gltf-transform/extensions';
import {fileForContentTypes, fileForRelThumbnail, to3dmodel} from '@jscadui/3mf-export';
import {fileForContentTypes, FileForRelThumbnail, to3dmodel} from '@jscadui/3mf-export';
import {strToU8, Zippable, zipSync} from 'fflate'
import * as glMatrix from 'gl-matrix';

Expand Down Expand Up @@ -166,7 +166,8 @@ const nodes = new Array<GLTFNode>();
const id2material = new Map<number, GLTFMaterial>();
const materialCache = new Map<GLTFMaterial, Material>();
const object2globalID = new Map<GLTFNode|Manifold, number>();
let nextGlobalID = 0;
// lib3mf doesn't like objectid=0
let nextGlobalID = 1;
let animation: Animation;
let timesAccessor: Accessor;
let hasAnimation: boolean;
Expand All @@ -179,7 +180,7 @@ function cleanup() {
id2material.clear();
materialCache.clear();
object2globalID.clear();
nextGlobalID = 0;
nextGlobalID = 1;
}

interface Mesh3MF {
Expand Down Expand Up @@ -641,6 +642,9 @@ async function exportModels(defaults: GlobalDefaults, manifold?: Manifold) {
const glb = await io.writeBinary(doc);
const blobGLB = new Blob([glb], {type: 'application/octet-stream'});

const fileForRelThumbnail = new FileForRelThumbnail();
fileForRelThumbnail.add3dModel('3D/3dmodel.model')

const model = to3dmodel(to3mf);
const files: Zippable = {};
files['3D/3dmodel.model'] = strToU8(model);
Expand Down

0 comments on commit 1f8e803

Please sign in to comment.