Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add thumbnail file to 3mf output #626

Merged
merged 1 commit into from
Nov 22, 2023
Merged

Conversation

pca006132
Copy link
Collaborator

For some reason files without _rel/.rels cannot be imported into openscad. Seems like an issue with lib3mf, not sure if it is stated in the standard or not.

@t-paul
Copy link

t-paul commented Nov 21, 2023

I believe that comes from the OPC spec and is referenced in the 3MF spec in 2.1.1. 3D Parts and Payload Relationships.

This declares a mandatory relationship to the 3D Model part, so the minimal content of that file is a single entry like:

<?xml version="1.0" encoding="utf-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
        <Relationship Type="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel" Target="/3D/3dmodel.model" Id="rel0" />
</Relationships>

@pca006132 pca006132 marked this pull request as ready for review November 21, 2023 16:37
Copy link
Owner

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I was trying to figure out why nothing but Cura wanted to import our 3MFs. Apparently I forgot this in the intervening 8 years since I was writing that spec...

@elalish
Copy link
Owner

elalish commented Nov 21, 2023

Huh, looks like Github is struggling today - our CI is mysteriously skipping jobs and my avatar icon is wrong. Hopefully it'll sort itself out...

@pca006132
Copy link
Collaborator Author

I think the skipped jobs are due to this PR being a draft PR when I initially opened it. Should now be fixed.

Copy link

codecov bot commented Nov 22, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6e1629d) 91.40% compared to head (2673d4c) 91.40%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #626   +/-   ##
=======================================
  Coverage   91.40%   91.40%           
=======================================
  Files          35       35           
  Lines        4512     4512           
=======================================
  Hits         4124     4124           
  Misses        388      388           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pca006132 pca006132 merged commit 10a15c1 into elalish:master Nov 22, 2023
@pca006132 pca006132 deleted the fix-3mf branch November 22, 2023 00:14
@hrgdavor
Copy link

This should not work. If you look at the example in
https://github.com/hrgdavor/jscadui/blob/main/file-format/3mf-export/testGen.js

you need to take image from canvas form util like: cavassToPngA8

/** //example how to generate thumb from canvas and add it in fflate
const pngPreviewFile = new fflate.ZipPassThrough('Metadata/thumbnail.png');
zip.add(pngPreviewFile);
pngPreviewFile.push(cavassToPngA8(canvas), true);
*/
function cavassToPngA8(canvas) {
  let url = canvas.toDataURL('image/png')
  url = url.substring(url.indexOf(',') + 1)
  // strToU8 function from fflate
  return strToU8(url)
  // string to Uint8Array taken from stackoverflow, and should work in browser
  return new Uint8Array(
    atob(url)
      .split('')
      .map(c => c.charCodeAt(0)),
  )
}

notice 2 return return statements, use only one

@pca006132
Copy link
Collaborator Author

Ah, I need to check to see if it works, I didn't run the js, I just figured out we need a file in that location to make the 3mf recognizable from other programs.

Thanks for the reminder.

@elalish elalish mentioned this pull request Jan 7, 2024
cartesian-theatrics pushed a commit to SovereignShop/manifold that referenced this pull request Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants