Skip to content

[FR] 3D Model Viewer #8820

Closed

Description

@RedEchidnaUK

Please verify that this feature request has NOT been suggested before.

  • I checked and didn't find a similar feature request

Problem statement

It would be really nice to be able to view 3D models that are attached to parts.

Suggested solution

Option 1

Under attachments you could click the more actions and if the attachment was a supported 3D file you could choose the option to view it in a 3D viewer. Once in the viewer you could then take a 'capture' of the current view and set it as the part image.

Option 2

In the main part view you could upload a 3D model instead of a static image. You could then click on the image to open a 3D model viewer, rotate/manipulate the model to your liking and then 'capture' the current view and set it as the part image.

Describe alternatives you've considered

Not having a 3D viewer :)

Examples of other systems

I have found the Online3DViewer project that should aid in developing a solution. Although I'm not a frontend developer (or even a professional developer) it didn't look too difficult to implement (easy to say I know) in a webpage. They even give their whole site as part of the source files.

If I had time I might even look at adding it myself, but currently I have too many unfinished projects and I don't want to commit to another one. I don't think this would be a high priority feature, but it would be nice to have.

Do you want to develop this?

  • I want to develop this.

Activity

  1. added
    enhancement
    triage:not-checked
    on Jan 2, 2025
  2. SchrodingersGat commented on Jan 2, 2025

    @SchrodingersGat
    Member

    This would be an ideal candidate to be developed as a plugin. @RedEchidnaUK would this be something you would be interested in developing?

  3. RedEchidnaUK commented on Jan 2, 2025

    @RedEchidnaUK
    ContributorAuthor

    @SchrodingersGat I’m going to reluctantly say no to developing a plugin. Sadly, I really don’t have time at the moment due to other projects I’m committed to. Of course if that changes, I’ll be sure to let you know.

  4. added
    User Interface
    and removed
    triage:not-checked
    on Jan 2, 2025
  5. wolflu05 commented on Jan 2, 2025

    @wolflu05
    Member

    @SchrodingersGat It would be really cool, if we would extend the plugin system to provide custom previewers for various file types. E.g. this would be helpful for your wirewiz plugin too, or an inline pdf previewer, ...

  6. RedEchidnaUK commented on Jan 3, 2025

    @RedEchidnaUK
    ContributorAuthor

    Having done a bit more searching I see there is already a FR for preview for attachment files that I missed in my previous search. Would it make more sense that this request is part of that FR?

  7. matmair commented on Jan 3, 2025

    @matmair
    Member

    I do not think that would cover it, that will probably be addressed by making thumbnails available

  8. added this to the horizon milestone on Jan 5, 2025
  9. RedEchidnaUK commented on Feb 17, 2025

    @RedEchidnaUK
    ContributorAuthor

    Just to update this, I’ve had a bit of free time and I’ve had a bit of a play about and I think I might be able to create a plugin to preview certain 3D CAD files.

    I’ve no idea how long it will take me as I’m not very familiar with React and Typescript etc. and a 3D viewer is probably quite an ambitious thing to start with… I have also found out that the viewer I linked above is so poorly documented it’s almost impossible to work with for a newcomer. However, I still have a plan and a very basic proof of concept working, so there is still hope!

    One question I do have, which version of React does Inventree use? It looks like React 18.3.1 from looking at the frontend package.json and the plugin creator seems to specify 18.3.18 in its package.json. However, I somehow ended up with React 19 when I used the creator? This could be (probably is) something I’ve inadvertently done.

  10. SchrodingersGat commented on Feb 18, 2025

    @SchrodingersGat
    Member

    @RedEchidnaUK good point regarding react version - the plugin creator should be pinned to use the same version! I'll look into this, likely a bug with the creator itself.

    inventree/plugin-creator#26

  11. RedEchidnaUK commented on Feb 23, 2025

    @RedEchidnaUK
    ContributorAuthor

    I’m getting close to having something working, but I have a question I’m hoping you can help with.

    At some point I’m going to want to get a list of the attachments of the part and send them to my React component. This seems simple enough, but if I want my React component to send data back, such as a new image for the part, how would I go about it?

    I thought I would just use the API directly, but from what I’ve read the user would have to sign in again to get an access token, which doesn’t seem great from a UX point. I’m probably looking at the problem wrong, and apologies if it seems simple, but I’m really not used to working with web based apps. If I’ve missed some documentation, feel free to point me at it. Thanks.

  12. SchrodingersGat commented on Feb 24, 2025

    @SchrodingersGat
    Member

    @RedEchidnaUK great question! The front-end plugins get passed a lot of context data - including the currently active API object which is already authenticated against the server.

    You can use this API object to make requests to the server without any other auth interactions with the user.

    Check out how the inventree-order-history plugin achieves this, for example:

    https://github.com/inventree/inventree-order-history/blob/2f8287254283cd87a7e5fb45c91c5954b3405f4a/frontend/src/OrderHistoryPanel.tsx#L223

        const historyQuery = useQuery(
            {
                queryKey: [
                    'order-history',
                    startDate,
                    endDate,
                    period,
                    orderType,
                    context.id,
                    context.model,
                ],
                refetchOnMount: false,
                refetchOnWindowFocus: false,
                queryFn: async () => {
                    return context.api?.get(`/${ORDER_HISTORY_URL}`, {
                        params: queryParams,
                    }).then((response: any) => {
                        return response.data;
                    }).catch(() => {
                        return [];
                    }) ?? [];
                }
            },
            queryClient
        )
  13. 17 remaining items

  14. wolflu05 commented on Mar 16, 2025

    @wolflu05
    Member

    You may want to test if you only experience this error in dev mode or also in a react production build.

  15. RedEchidnaUK commented on Mar 16, 2025

    @RedEchidnaUK
    ContributorAuthor

    @wolflu05 Sorry, I probably should have been clearer. I’m doing the development work in a VM, but Inventree is running as a production Docker environment, so it is a production build. I do need to see if I get the same issue running just as a React build outside of Inventree.

  16. wolflu05 commented on Mar 16, 2025

    @wolflu05
    Member

    So your not using the react dev server for your plugin panel at all? You're always build a react prod bundle and then see the changes after manually reloading the page?

    @SchrodingersGat Is that not implemented in the plugin template? (React HMR directly inside the plugin panel) That was the first thing I setup on my plugins (haven't used the plugin creator yet).

  17. RedEchidnaUK commented on Mar 16, 2025

    @RedEchidnaUK
    ContributorAuthor

    @wolflu05 Correct. It’s not a very efficient way to work and I really should get the dev environment up and running properly. Most of the panel work was actually done outside of Inventree and then simple ported over to a plugin panel. As all the React code needs are the attachment urls from Inventree, which I do via the context.

  18. SchrodingersGat commented on Mar 18, 2025

    @SchrodingersGat
    Member

    (React HMR directly inside the plugin panel) That was the first thing I setup on my plugins (haven't used the plugin creator yet).

    @wolflu05 I don't know how to do that - this would be a fantastic addition to the plugin creator.

  19. wolflu05 commented on Mar 18, 2025

    @wolflu05
    Member

    You just have to import import "http://localhost:<your-other-dev-port-for-plugin-vite-dev-server>/@vite/client"; before invoking the frontend feature function. But now if I remember correctly, this does not work inside another react dev server (the one hosting PUI), thats why I switched to preact.

    Take a look at:

  20. RedEchidnaUK commented on Apr 21, 2025

    @RedEchidnaUK
    ContributorAuthor

    Just wanted to give an update on this.

    I've spent some (a long) time looking at why Inventree/the browser crashes after a certain amount of time running the plugin, and I'm not getting very far... The browser developer tools don't appear to show any memory leaks and I've changed the code to clean up, in multiple ways, every 3D object when the object is changed. I've even had a colleague (I work for a software development company) look at my code and they can't see anything wrong with it. My next tests will be to run the code in a standalone server to see if I still have the issue. If at that point I still have the issue I will at least know it is my code and not some weird interaction/bug the plugin is causing with Inventree.

  21. SchrodingersGat commented on Apr 21, 2025

    @SchrodingersGat
    Member

    @RedEchidnaUK thanks for the update. It will be interesting to see the results of your standalone tests

  22. matmair commented on Oct 28, 2025

    @matmair
    Member
  23. SchrodingersGat commented on Oct 28, 2025

    @SchrodingersGat
    Member

    @matmair nice find - the developer also has a .dxf plugin. We should see if they want to feature them on the .org website.

    I'm happy to close this one out now.

  24. matmair commented on Oct 28, 2025

    @matmair
    Member

    These types of plugins might benefit from a generalized preview / detail view in the attachments table instead of separate tabs.

  25. SchrodingersGat commented on Oct 28, 2025

    @SchrodingersGat
    Member

    Agree, but we'd have to provide a new hook for that.

  26. RedEchidnaUK commented on Oct 28, 2025

    @RedEchidnaUK
    ContributorAuthor

    Agree, nice find @matmair

    I know I've dropped the ball on this and I'm sorry I never managed to finish it. For what it's worth, I did spend several days looking for issues with my code and I could never find any other than on memory restricted devices. Which could just be an issue with the underlying 3D framework. If I ever manage to find the time again I will see how the other author has done it and see if the same issues exist.

    I fully agree that a new hook to allow previews in the attachments table would be awesome, but appreciate that is no small ask.

  27. matmair commented on Oct 28, 2025

    @matmair
    Member

    No worries, you do not owe anyone your free work, this is free as in beer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    User Interfaceenhancementplugin

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions