hrgdavor / jscadui

MIT License
30 stars 9 forks source link

3MF export #70

Closed pca006132 closed 11 months ago

pca006132 commented 11 months ago

From elalish/manifold#626

Hi, it seems that the object id has to be at least 1, lib3mf cannot recognize things with id 0. The _rels/.rels is mandatory, we can remove the thumbnail line if we don't want a thumbnail.

pca006132 commented 11 months ago

oh the object id thing is set by us, but maybe you can add a documentation about the id has to be non-zero

hrgdavor commented 11 months ago

ok, thanks for the hints, I could even throw an error if id is zero and add a bit in docs.

pca006132 commented 11 months ago

Do you plan to fix them and release a version soon? If yes, I can wait for your release without having to use this ugly workaround:

  files[fileForRelThumbnail.name] = strToU8(
      // remove the thumbnail line
      fileForRelThumbnail.content.split('\n')
          .filter((line: string) => line.indexOf('thumbnail') == -1)
          .join('\n'));
hrgdavor commented 11 months ago

oh, ok I see. You are currently removing the thumbnail from 3mf export... I thought you were adding the thumbnail :)

.. np, I can make a version today, tomorrow that allows export without thumbnail, and keeps the mandatory rel file.

pca006132 commented 11 months ago

Thanks. In order to make a thumbnail we need access to the canvas, but we are currently making the 3mf file in a worker. I am not familiar with js stuff so I just decided to remove the thumbnail :)

hrgdavor commented 11 months ago

@pca006132 I created 0.5.0 version that handles ref differently.

instead of it being a static file thre is new class: FileForRelThumbnail that has getter for proeprties name and content, but the content is generated based on sate (added files).

instad of just importing fileForRelThumbnail, import anduse FileForRelThumbnail class

const fileForRelThumbnail = new FileForRelThumbnail()
//...
fileForRelThumbnail.add3dModel('3D/3dmodel.model')
//.. if you have thumbnail, add it
fileForRelThumbnail.addThumbnail('Metadata/thumbnail.png')

this way only refs actually used will be present in _rels/.rels

pca006132 commented 11 months ago

Thanks. Updated in manifold now.