Add stl download for OpenSCAD and CadQuery IDEs #331

Merged
Irev-Dev merged 1 commits from kurt/330-stl-download into main 2021-05-30 00:47:32 +02:00
Irev-Dev commented 2021-05-30 00:24:03 +02:00 (Migrated from github.com)

Everything always takes longer that expected. Few things to note.

  • in the browser I'm doing less checks for ideType === 'openScad' and now more data type === geometry or png, since now openscad can display 3d in preview as well.
  • When a user wants to download an openscad stl, than we might as well display it properly in the browser instead of just images since we're already doing so for CadQuery.
  • Also in terms of caching the openscad preview also checks if there is an stl cached not only images since if a user has already downloaded that shape, might as well give them the better experience of full 3d

Some things that are not ideal:

  • There is a difference in the coord system between the OpenScad images and the 3d result, so it suddenly jumps when it changes from image to 3d, it's bearable but not great
  • The stl generation for OpenSCAD does not log anything to stdout which means I have nothing to show in the console. I'm not sure why at this point

Resolves #330.

Everything always takes longer that expected. Few things to note. - in the browser I'm doing less checks for `ideType === 'openScad'` and now more data type === geometry or png, since now openscad can display 3d in preview as well. - When a user wants to download an openscad stl, than we might as well display it properly in the browser instead of just images since we're already doing so for CadQuery. - Also in terms of caching the openscad preview also checks if there is an stl cached not only images since if a user has already downloaded that shape, might as well give them the better experience of full 3d Some things that are not ideal: - There is a difference in the coord system between the OpenScad images and the 3d result, so it suddenly jumps when it changes from image to 3d, it's bearable but not great - The stl generation for OpenSCAD does not log anything to stdout which means I have nothing to show in the console. I'm not sure why at this point Resolves #330.
franknoirot (Migrated from github.com) reviewed 2021-05-30 00:24:03 +02:00
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:28:57 +02:00
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:28:57 +02:00

This is a bit messy. This is for the OpenSCAD preview, but now it check for both an image cache as well as an stl cache, if it finds either it will return one but with preference for the stl, so that if someone else has cached the 3d output by downloading it than users looking at the preview for the same shape will get the 3d view. It's only if they change the code it will fallback to images again.

This is a bit messy. This is for the OpenSCAD preview, but now it check for both an image cache as well as an stl cache, if it finds either it will return one but with preference for the stl, so that if someone else has cached the 3d output by downloading it than users looking at the preview for the same shape will get the 3d view. It's only if they change the code it will fallback to images again.
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:29:57 +02:00
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:29:57 +02:00

I'm not getting console messages from the stl generation, I've had a go a debugging it but it seems like openscad just isn't outputting anything. Might have to dive deeper again later.

I'm not getting console messages from the stl generation, I've had a go a debugging it but it seems like openscad just isn't outputting anything. Might have to dive deeper again later.
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:31:22 +02:00
@@ -8,1 +8,3 @@
import { flow } from 'lodash/fp'
import { flow, identity } from 'lodash/fp'
import { fileSave } from 'browser-fs-access'
import { MeshBasicMaterial, Mesh, Scene } from 'three'
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:31:21 +02:00

nice library that abstracts a bunch browser compatibility issues with saving files from the browser.
more context : https://github.com/zalo/CascadeStudio/pull/39#issuecomment-766911556

nice library that abstracts a bunch browser compatibility issues with saving files from the browser. more context : https://github.com/zalo/CascadeStudio/pull/39#issuecomment-766911556
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:32:16 +02:00
@@ -83,0 +95,4 @@
)
}
const handleStlDownload = (({ geometry, fileName, type }) => () => {
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:32:15 +02:00

not needed, but didn't want the {256 hash}.stl to be the file name, so if there's a comment as the first line it will use that for the title.

not needed, but didn't want the `{256 hash}.stl` to be the file name, so if there's a comment as the first line it will use that for the title.
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:32:47 +02:00
@@ -19,3 +17,3 @@
const mesh = useRef()
const ref = useUpdate((geometry) => {
geometry.attributes = loadedGeometry.attributes
geometry.attributes = incomingGeo.attributes
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:32:47 +02:00

Asset component is much cleaner now as we're making the three geometry higher in the stack.

Asset component is much cleaner now as we're making the three geometry higher in the stack.
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:34:14 +02:00
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:34:14 +02:00

pretty messy. this is so that running the stl function rather than preview for openscad when the user want's to download the stl.

pretty messy. this is so that running the stl function rather than preview for openscad when the user want's to download the stl.
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:36:09 +02:00
@@ -83,0 +86,4 @@
return createHealthyResponse({
type: 'geometry',
data: geometry,
consoleMessage: data.consoleMessage,
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:36:09 +02:00

Previously we were storing the aws url here and than was downloading and managing the geometry, but instead doing that here, it's much easier to grab that geometry again to download the stl

Previously we were storing the aws url here and than <Asset /> was downloading and managing the geometry, but instead doing that here, it's much easier to grab that geometry again to download the stl
Irev-Dev (Migrated from github.com) reviewed 2021-05-30 00:37:29 +02:00
@@ -83,0 +125,4 @@
requestRender({
state,
dispatch,
code: state.code,
Irev-Dev (Migrated from github.com) commented 2021-05-30 00:37:29 +02:00

if we're currently showing 3d in the preview than we're golden, if not than it must be openscad, so we should trigger an stl download.

if we're currently showing 3d in the preview than we're golden, if not than it must be openscad, so we should trigger an stl download.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: h3n3/cadhub#331