Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for 3D/CAD file formats preview#34794

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@kerwin612
Copy link
Member

lunny, Felitendo, fldx, and sonjek reacted with thumbs up emoji
@GiteaBotGiteaBot added the lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelJun 20, 2025
@github-actionsgithub-actionsbot added modifies/goPull requests that update Go code modifies/templatesThis PR modifies the template files modifies/dependencies modifies/frontend labelsJun 20, 2025
@wxiaoguang
Copy link
Contributor

wxiaoguang commentedJun 20, 2025
edited
Loading

I think we need a pure frontend "render plugin" mechanism

  1. Register "fronend render plugin"
  2. Plugin read page information (for example: file name)
  3. If the plugin is able to render it, read the "raw" content, then replace the "fileview" element.

I don't think we should hard-code too many file types in backend.

lunny, kerwin612, and bytedream reacted with thumbs up emoji

@kerwin612kerwin612force-pushed thefeat/support-preview-3d-file branch fromeba2b22 to057ee0eCompareJune 21, 2025 06:16
@github-actionsgithub-actionsbot removed the modifies/goPull requests that update Go code labelJun 21, 2025
@kerwin612kerwin612force-pushed thefeat/support-preview-3d-file branch from057ee0e to448effbCompareJune 21, 2025 06:22
"minimatch":"10.0.2",
"monaco-editor":"0.52.2",
"monaco-editor-webpack-plugin":"7.1.0",
"online-3d-viewer":"0.16.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC it bloats the binary about 1MB

Can we introduce an config option?

For example:

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

From a user's perspective, I personally feel that direct integration is better than dynamic loading.
Because building and installation are one-time processes.
However, if we switch to dynamic loading, each time it might require dynamically loading 1MB of JavaScript.
Especially in the current Chinese network environment, sometimes even some external CDNs cannot be accessed, which would directly make the preview unavailable.

So I personally vote for integration.
Of course, the final decision is up to you.

Copy link
Contributor

Choose a reason for hiding this comment

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

However, if we switch to dynamic loading, each time it might require dynamically loading 1MB of JavaScript.

Not "each", only once, there is browser cahce.

Especially in the current Chinese network environment, sometimes even some external CDNs cannot be accessed, which would directly make the preview unavailable.

That's why a config option to let users choose, or deploy one locally.


If we build the renders into Gitea's binary, then it bloats the binary soon when we introduce more in the future.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I fully understand your original intention, but I think this still stems from the perspective of operators. From a user's point of view, such an option shouldn't exist (or there's simply no need for it at all) – the default provided to users should inherently be the optimal solution.

Of course, I recognize that Gitea, as an open-source platform, does have many "operator" users. Your original intention might be to allow them to choose freely, but personally, I wonder if such customization is getting too caught up in minor details?

Alright, I've shared my thoughts. It's up to you all. If adjustments are needed, I'll cooperate with the changes.

Copy link
Contributor

@wxiaoguangwxiaoguangJun 21, 2025
edited
Loading

Choose a reason for hiding this comment

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

Share some of my thoughts:

There are different requirements for various kinds of files to render.

  • Some are widely-used, for example: CSV, PDF, etc
  • Some are only used by some of the users: asciidoc, asciicast, console, 3d models, etc. The percentage varies.

So the question is how to make Gitea have a stable and flexible design to satisfy more renders in the future. Then we have some choices:

  1. Only make widely-used renders builtin, keep the release binary as small as possible.
  2. Make all renders builtin, then we should have some estimation about the side effects, and how large the binary would be in the future.

I haven't got a clear picture of this feature at the moment. What do other maintainers think about?

Copy link
Contributor

Choose a reason for hiding this comment

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

No

Copy link
Member

Choose a reason for hiding this comment

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

image

I think the memory hog is more the git command.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the memory hog is more the git command.

I don't understand what's the point or whether it is related to the topic.

Copy link
Contributor

@TheFox0x7TheFox0x7Jun 23, 2025
edited
Loading

Choose a reason for hiding this comment

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

That's a separate issue though and there's not much that can be done to limit it. Also it's (IMO) a very large issue for limited memory scenarios which is entirely of topic here.

I can't say I know a ton about this, but here point is that if you bloat the binary it had to be loaded and run each time hook runs which is a waste of resources - hope I got that right.
Honestly hook doesn't even have to have inits(not too sure about it though?) - it just needs to know where gitea is to do RPC.


Sorry for derailing the scope.

Copy link
Contributor

@wxiaoguangwxiaoguangJun 23, 2025
edited
Loading

Choose a reason for hiding this comment

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

Honestly hook doesn't even have to have inits(not too sure about it though?)

In history, the "gitea hook" sub commands always do various init calls (including load assets), for example:var re = regexp.MustCompile,init() { ... }, etc

When I refactor existing code, usually I also rewrite these code to something likesync.OnceValue and void unnecessary init.

About the binary size affect, it's more complicated and it depends on some OS behaviors like virtual memory/mmap management, usually the binary content should be cached in OS's shared-memory area when it runs, but it's difficult to evaluate all cases (especially when the memory is limited in a container), I am not expert either so it's just a guess.

So I also agree that "if increasing the binary size brings enough benefits, let's do it", and I think "It's fine to make this render builtin".

TheFox0x7 reacted with thumbs up emoji
@github-actionsgithub-actionsbot added the modifies/goPull requests that update Go code labelJun 21, 2025
@lunnylunny added this to the1.25.0 milestoneJun 23, 2025
@GiteaBotGiteaBot added lgtm/need 1This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2This PR needs two approvals by maintainers to be considered for merging. labelsJun 26, 2025
@wxiaoguang
Copy link
Contributor

Can we merge "initPdfViewer" into the new framework? I think it can also benefit from the new design.

lunny reacted with thumbs up emoji

@lunny
Copy link
Member

When viewing .3ds file, there is aView Rendered icon. But when viewing .mp4 or other binary files, there is no such icon. Is that normal?
image
image

@kerwin612
Copy link
MemberAuthor

b89f6858-a480-4b20-82ee-0651913a2d6a
058a8aa9-63b7-4104-a901-5aa378689a77
My suggestions:

  1. When there are no tabs to switch (as shown in Figure 2 above), this tab switch can be directly hidden, because an isolated button seems to have no meaning and may also cause users to guess and misunderstand.
  2. Is it necessary to skip the click event for the selected tab?

@wxiaoguang
Copy link
Contributor

Feel free to make more improvements.

@hiifong
Copy link
Member

I think a full screen preview of the 3d file is missing.

kerwin612 reacted with thumbs up emoji

@kerwin612
Copy link
MemberAuthor

Feel free to make more improvements.

OK, I'll find time to improve it.

@kerwin612
Copy link
MemberAuthor

I think a full screen preview of the 3d file is missing.

Yeah, this is already in the plan.

@hiifong
Copy link
Member

hiifong commentedJun 30, 2025
edited
Loading

bim, dae,brep,igs,stp,ply,off,wrl,ifc,3mf file extensions are rendered as plain text.

Please make it as draft.

@wxiaoguang
Copy link
Contributor

wxiaoguang commentedJun 30, 2025
edited
Loading

bim, dae,brep,igs,stp,ply,off,wrl,ifc,3mf file extensions are rendered as plain text.

Please make it as draft.

It is already supported. Including STL, see my comment.

This PR can't auto render them because there is no accurate detection yet.

In the future, if we have a better detection, then we can auto render them.

image

kerwin612 reacted with thumbs up emoji

@wxiaoguang
Copy link
Contributor

Feel free to make more improvements.

OK, I'll find time to improve it.

Merge this as-is and propose following up PRs, or switch to WIP to wait for more changes?

@GiteaBotGiteaBot added lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1This PR needs approval from one additional maintainer to be merged. labelsJun 30, 2025
@kerwin612
Copy link
MemberAuthor

Feel free to make more improvements.

OK, I'll find time to improve it.

Merge this as-is and propose following up PRs, or switch to WIP to wait for more changes?

Merge it first. I'll submit a PR for other optimizations or adjustments later.

wxiaoguang reacted with thumbs up emojiwxiaoguang reacted with heart emoji

@wxiaoguang
Copy link
Contributor

It is already supported. Including STL, see my comment.

This PR can't auto render them because there is no accurate detection yet.

In the future, if we have a better detection, then we can auto render them.

More details about the problem:

It needs more logic to make it overall right, we need to distinguish the ambiguous filename extensions. For example: "*.obj, *.off, *.step" might be or not be a 3D model file. So when it is a text file, we can't assume that "we only render it by 3D plugin", otherwise the end users would be impossible to view its real content when the file is not a 3D model.

@hiifong
Copy link
Member

hiifong commentedJun 30, 2025
edited
Loading

ref:https://www.spatial.com/glossary/what-is-an-stp-file

I've just checked for information on this, and the .step and .stp files are standard ISO file formats (ISO 10303-242:2014), and I think we can check from the contents of the file.

$ cat as1_pe_203.stpISO-10303-21;HEADER;FILE_DESCRIPTION((''),'2;1');FILE_NAME('AS1_PE_ASM','2008-09-04T',('mmeadows'),(''),'PRO/ENGINEER BY PARAMETRIC TECHNOLOGY CORPORATION, 2008340','PRO/ENGINEER BY PARAMETRIC TECHNOLOGY CORPORATION, 2008340','');FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));ENDSEC;DATA;#16=DIRECTION('',(0.E0,1.E0,0.E0));#17=VECTOR('',#16,2.E1);#18=CARTESIAN_POINT('',(4.E1,-2.E1,-7.5E1));#19=LINE('',#18,#17);...#2874=REPRESENTATION('centroid',(#2872),#2841);#2875=PROPERTY_DEFINITION_REPRESENTATION(#2873,#2874);ENDSEC;END-ISO-10303-21;

@hiifong
Copy link
Member

ref:https://www.spatial.com/glossary/what-is-an-stp-file

I've just checked for information on this, and the .step and .stp files are standard ISO file formats (ISO 10303-242:2014), and I think we can check from the contents of the file.

$ cat as1_pe_203.stpISO-10303-21;HEADER;FILE_DESCRIPTION((''),'2;1');FILE_NAME('AS1_PE_ASM','2008-09-04T',('mmeadows'),(''),'PRO/ENGINEER BY PARAMETRIC TECHNOLOGY CORPORATION, 2008340','PRO/ENGINEER BY PARAMETRIC TECHNOLOGY CORPORATION, 2008340','');FILE_SCHEMA(('AP203_CONFIGURATION_CONTROLLED_3D_DESIGN_OF_MECHANICAL_PARTS_AND_ASSEMBLIES_MIM_LF'));ENDSEC;DATA;#16=DIRECTION('',(0.E0,1.E0,0.E0));#17=VECTOR('',#16,2.E1);#18=CARTESIAN_POINT('',(4.E1,-2.E1,-7.5E1));#19=LINE('',#18,#17);...#2874=REPRESENTATION('centroid',(#2872),#2841);#2875=PROPERTY_DEFINITION_REPRESENTATION(#2873,#2874);ENDSEC;END-ISO-10303-21;

I don't want you to implement it in this pull request, but I want to provide some clues about it

@wxiaoguang
Copy link
Contributor

And we can also use AI:

image

@wxiaoguangwxiaoguang merged commit176962c intogo-gitea:mainJun 30, 2025
26 checks passed
@wxiaoguangwxiaoguang deleted the feat/support-preview-3d-file branchJune 30, 2025 08:12
constviewer=newOV.EmbeddedViewer(container,{
backgroundColor:newOV.RGBAColor(59,68,76,0),
defaultColor:newOV.RGBColor(65,131,196),
edgeSettings:newOV.EdgeSettings(false,newOV.RGBColor(0,0,0),1),
Copy link
Member

@silverwindsilverwindJun 30, 2025
edited
Loading

Choose a reason for hiding this comment

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

I don't think this will look good on dark theme, you need different colors on dark theme, e.g. usegetColor() fromweb_src/js/features/codeeditor.ts to get the color values from CSS variables. Likely declare new color variables.

kerwin612 reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Thank you for pointing it out. I will improve it later.

Copy link
Member

Choose a reason for hiding this comment

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

For the background, you can likely re-use--color-code-bg, e.g.getColor('--color-code-bg'), converting to thisOV.RGBAColor of course.

This comment was marked as off-topic.

zjjhot added a commit to zjjhot/gitea that referenced this pull requestJul 1, 2025
* giteaofficial/main:  Fix modal + form abuse (go-gitea#34921)  [skip ci] Updated translations via Crowdin  Follow file symlinks in the UI to their target (go-gitea#28835)  Fix issue filter (go-gitea#34914)  Fix: RPM package download routing & missing package version count (go-gitea#34909)  Add support for 3D/CAD file formats preview (go-gitea#34794)
bdruth added a commit to bdruth/gitea that referenced this pull requestJul 4, 2025
…h/gitea into feature/enhanced-workflow-runs-api* 'feature/enhanced-workflow-runs-api' of github.com:bdruth/gitea:  [skip ci] Updated translations via Crowdin  Follow file symlinks in the UI to their target (go-gitea#28835)  Fix issue filter (go-gitea#34914)  Fix: RPM package download routing & missing package version count (go-gitea#34909)  Add support for 3D/CAD file formats preview (go-gitea#34794)  Add a `login`/`login-name`/`username` disambiguation to affected endpoint parameters and response/request models (go-gitea#34901)  Improve tags list page (go-gitea#34898)  [skip ci] Updated translations via Crowdin  docs: fix typo in pull request merge warning message text (go-gitea#34899)  Refactor container package (go-gitea#34877)  [skip ci] Updated translations via Crowdin
@go-giteago-gitea locked asresolvedand limited conversation to collaboratorsSep 28, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@silverwindsilverwindsilverwind left review comments

@wxiaoguangwxiaoguangwxiaoguang approved these changes

@lunnylunnylunny approved these changes

@delvhdelvhAwaiting requested review from delvh

+2 more reviewers

@TheFox0x7TheFox0x7TheFox0x7 left review comments

@hiifonghiifonghiifong approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

lgtm/doneThis PR has enough approvals to get merged. There are no important open reservations anymore.modifies/dependenciesmodifies/frontendmodifies/goPull requests that update Go codemodifies/templatesThis PR modifies the template filestype/featureCompletely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Milestone

1.25.0

Development

Successfully merging this pull request may close these issues.

8 participants

@kerwin612@wxiaoguang@lunny@hiifong@silverwind@TheFox0x7@delvh@GiteaBot

[8]ページ先頭

©2009-2025 Movatter.jp