mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-11-04 00:11:04 +00:00 
			
		
		
		
	## Motivation The GLTF (`.gltf`, `.glb`) 3D model format is very popular for game development and visual productions. For an indie game studio, it would be convenient for a team to view textured 3D models directly from the Forgejo interface (otherwise they need to be downloaded and opened). [Perforce](https://www.perforce.com/products/helix-dam), [Diversion](https://www.diversion.dev/), and GitHub all have this capability to differing extents. Some discussion on 3D file support here: https://codeberg.org/forgejo/forgejo/issues/5188 ## Changes Adds a model viewer similar to [GitHub STL viewer](https://github.com/assimp/assimp/blob/master/test/models/STL/Spider_ascii.stl) for `.glb` model files, and lays some groundwork to support future files. Uses the [model-viewer](https://modelviewer.dev/) library by Google and three.js. The model viewer is interactive and can be rotated and scaled.  ## How to Test 1) Create a new repository or use an existing one. 2) Upload a `.glb` file such as `tests/testdata/data/viewer/Unicode❤♻Test.glb` (CC0 1.0 Universal) 3) View the file in the repository. - Similar to image files, the 3D model should be rendered in a viewer. - Use mouse clicks to turn and zoom. ## Licenses Libraries used for this change include three.js and @google/model-viewer, which are MIT and Apache-2.0 licenses respectively. Both of these are compatible with Forgejo's GPL3.0 license. ## Future Plans 1) `.gltf` was not attempted because it is a multiple file format, referencing other files in the same directory. Still need to experiment with this to see if it can work. `.glb` is a single file containing a `.gltf` and all of its other file/texture dependencies so was easier to implement. 2) The PR diff still shows the model as an unviewable bin file, but clicking the "View File" button takes you to a view screen where this model viewer is used. It would be nice to view the before and after of the model in two side-by-side model viewers, akin to reviewing a change in an image. 3) Also inserted stubs for adding contexts for GLTF, STL, OBJ, and 3MF. These ultimately don't do anything yet as only `.glb` files can be detected by the type sniffer of all of these. ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for checking GLB file content using the first few bytes. - [x] in their respective `typesniffer_test.go` for unit tests. ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [ ] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. <!--start release-notes-assistant--> ## Release notes <!--URL:https://codeberg.org/forgejo/forgejo--> - User Interface features - [PR](https://codeberg.org/forgejo/forgejo/pulls/8111): <!--number 8111 --><!--line 0 --><!--description YWRkIG1vZGVsIHZpZXdlciBmb3IgYC5nbGJgIChHTFRGKSBtb2RlbCBpbiBmaWxlIHZpZXc=-->add model viewer for `.glb` (GLTF) model in file view<!--description--> <!--end release-notes-assistant--> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8111 Reviewed-by: oliverpool <oliverpool@noreply.codeberg.org> Co-authored-by: Alex Smith <amsmith.pro@pm.me> Co-committed-by: Alex Smith <amsmith.pro@pm.me>
		
			
				
	
	
		
			194 lines
		
	
	
	
		
			7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			194 lines
		
	
	
	
		
			7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
// bootstrap module must be the first one to be imported, it handles webpack lazy-loading and global errors
 | 
						|
import './bootstrap.js';
 | 
						|
 | 
						|
import {initRepoActivityTopAuthorsChart} from './components/RepoActivityTopAuthors.vue';
 | 
						|
import {initScopedAccessTokenCategories} from './components/ScopedAccessTokenSelector.vue';
 | 
						|
import {initDashboardRepoList} from './components/DashboardRepoList.vue';
 | 
						|
 | 
						|
import {initGlobalCopyToClipboardListener} from './features/clipboard.js';
 | 
						|
import {initContextPopups} from './features/contextpopup.js';
 | 
						|
import {initRepoGraphGit} from './features/repo-graph.js';
 | 
						|
import {initHeatmap} from './features/heatmap.js';
 | 
						|
import {initImageDiff} from './features/imagediff.js';
 | 
						|
import {initRepoMigration} from './features/repo-migration.js';
 | 
						|
import {initRepoProject} from './features/repo-projects.js';
 | 
						|
import {initTableSort} from './features/tablesort.js';
 | 
						|
import {initAutoFocusEnd} from './features/autofocus-end.js';
 | 
						|
import {initAdminUserListSearchForm} from './features/admin/users.js';
 | 
						|
import {initAdminConfigs} from './features/admin/config.js';
 | 
						|
import {initMarkupAnchors} from './markup/anchors.js';
 | 
						|
import {initNotificationCount, initNotificationsTable} from './features/notification.js';
 | 
						|
import {initRepoIssueContentHistory} from './features/repo-issue-content.js';
 | 
						|
import {initStopwatch} from './features/stopwatch.js';
 | 
						|
import {initFindFileInRepo} from './features/repo-findfile.js';
 | 
						|
import {initCommentContent, initMarkupContent} from './markup/content.js';
 | 
						|
import {initPdfViewer} from './render/pdf.js';
 | 
						|
import {initGltfViewer} from './render/gltf.js';
 | 
						|
 | 
						|
import {initUserAuthOauth2, initUserAuth} from './features/user-auth.js';
 | 
						|
import {
 | 
						|
  initRepoIssueDue,
 | 
						|
  initRepoIssueReferenceRepositorySearch,
 | 
						|
  initRepoIssueTimeTracking,
 | 
						|
  initRepoIssueWipTitle,
 | 
						|
  initRepoPullRequestAllowMaintainerEdit,
 | 
						|
  initRepoPullRequestReview, initRepoIssueSidebarList, initArchivedLabelHandler,
 | 
						|
} from './features/repo-issue.js';
 | 
						|
import {initRepoEllipsisButton, initCommitStatuses, initCommitNotes} from './features/repo-commit.js';
 | 
						|
import {
 | 
						|
  initFootLanguageMenu,
 | 
						|
  initGlobalButtonClickOnEnter,
 | 
						|
  initGlobalButtons,
 | 
						|
  initGlobalCommon,
 | 
						|
  initGlobalDropzone,
 | 
						|
  initGlobalEnterQuickSubmit,
 | 
						|
  initGlobalFormDirtyLeaveConfirm,
 | 
						|
  initGlobalLinkActions,
 | 
						|
  initHeadNavbarContentToggle,
 | 
						|
} from './features/common-global.js';
 | 
						|
import {initRepoTopicBar} from './features/repo-home.js';
 | 
						|
import {initAdminEmails} from './features/admin/emails.js';
 | 
						|
import {initAdminCommon} from './features/admin/common.js';
 | 
						|
import {initRepoTemplateSearch} from './features/repo-template.js';
 | 
						|
import {initRepoCodeView} from './features/repo-code.js';
 | 
						|
import {initSshKeyFormParser} from './features/sshkey-helper.js';
 | 
						|
import {initRepoArchiveLinks} from './features/repo-common.js';
 | 
						|
import {initRepoMigrationStatusChecker} from './features/repo-migrate.js';
 | 
						|
import {
 | 
						|
  initRepoSettingGitHook,
 | 
						|
  initRepoSettingsCollaboration,
 | 
						|
  initRepoSettingSearchTeamBox,
 | 
						|
} from './features/repo-settings.js';
 | 
						|
import {initRepoDiffView} from './features/repo-diff.js';
 | 
						|
import {initOrgTeamSearchRepoBox} from './features/org-team.js';
 | 
						|
import {initUserAuthWebAuthn, initUserAuthWebAuthnRegister} from './features/user-auth-webauthn.js';
 | 
						|
import {initRepoRelease, initRepoReleaseNew} from './features/repo-release.js';
 | 
						|
import {initRepoEditor} from './features/repo-editor.js';
 | 
						|
import {initCompSearchUserBox} from './features/comp/SearchUserBox.js';
 | 
						|
import {initInstall} from './features/install.js';
 | 
						|
import {initCompWebHookEditor} from './features/comp/WebHookEditor.js';
 | 
						|
import {initRepoBranchButton} from './features/repo-branch.js';
 | 
						|
import {initCommonOrganization} from './features/common-organization.js';
 | 
						|
import {initRepoWikiForm} from './features/repo-wiki.js';
 | 
						|
import {initRepoCommentForm, initRepository} from './features/repo-legacy.js';
 | 
						|
import {initCopyContent} from './features/copycontent.js';
 | 
						|
import {initCaptcha} from './features/captcha.js';
 | 
						|
import {initRepositoryActionView} from './components/RepoActionView.vue';
 | 
						|
import {initGlobalTooltips} from './modules/tippy.js';
 | 
						|
import {initGiteaFomantic} from './modules/fomantic.js';
 | 
						|
import {onDomReady} from './utils/dom.js';
 | 
						|
import {initRepoIssueList} from './features/repo-issue-list.js';
 | 
						|
import {initCommonIssueListQuickGoto} from './features/common-issue-list.js';
 | 
						|
import {initRepoContributors} from './features/contributors.js';
 | 
						|
import {initRepoCodeFrequency} from './features/code-frequency.js';
 | 
						|
import {initRepoRecentCommits} from './features/recent-commits.js';
 | 
						|
import {initRepoDiffCommitBranchesAndTags} from './features/repo-diff-commit.js';
 | 
						|
import {initDirAuto} from './modules/dirauto.js';
 | 
						|
import {initRepositorySearch} from './features/repo-search.js';
 | 
						|
import {initColorPickers} from './features/colorpicker.js';
 | 
						|
import {initRepoMilestoneEditor} from './features/repo-milestone.js';
 | 
						|
 | 
						|
// Init Gitea's Fomantic settings
 | 
						|
initGiteaFomantic();
 | 
						|
initDirAuto();
 | 
						|
 | 
						|
onDomReady(() => {
 | 
						|
  initGlobalCommon();
 | 
						|
 | 
						|
  initGlobalTooltips();
 | 
						|
  initGlobalButtonClickOnEnter();
 | 
						|
  initGlobalButtons();
 | 
						|
  initGlobalCopyToClipboardListener();
 | 
						|
  initGlobalDropzone();
 | 
						|
  initGlobalEnterQuickSubmit();
 | 
						|
  initGlobalFormDirtyLeaveConfirm();
 | 
						|
  initGlobalLinkActions();
 | 
						|
 | 
						|
  initCommonOrganization();
 | 
						|
  initCommonIssueListQuickGoto();
 | 
						|
 | 
						|
  initCompSearchUserBox();
 | 
						|
  initCompWebHookEditor();
 | 
						|
 | 
						|
  initInstall();
 | 
						|
 | 
						|
  initHeadNavbarContentToggle();
 | 
						|
  initFootLanguageMenu();
 | 
						|
 | 
						|
  initCommentContent();
 | 
						|
  initContextPopups();
 | 
						|
  initHeatmap();
 | 
						|
  initImageDiff();
 | 
						|
  initMarkupAnchors();
 | 
						|
  initMarkupContent();
 | 
						|
  initSshKeyFormParser();
 | 
						|
  initStopwatch();
 | 
						|
  initTableSort();
 | 
						|
  initAutoFocusEnd();
 | 
						|
  initFindFileInRepo();
 | 
						|
  initCopyContent();
 | 
						|
 | 
						|
  initAdminCommon();
 | 
						|
  initAdminEmails();
 | 
						|
  initAdminUserListSearchForm();
 | 
						|
  initAdminConfigs();
 | 
						|
 | 
						|
  initDashboardRepoList();
 | 
						|
 | 
						|
  initNotificationCount();
 | 
						|
  initNotificationsTable();
 | 
						|
 | 
						|
  initOrgTeamSearchRepoBox();
 | 
						|
 | 
						|
  initRepoActivityTopAuthorsChart();
 | 
						|
  initRepoArchiveLinks();
 | 
						|
  initRepoBranchButton();
 | 
						|
  initRepoCodeView();
 | 
						|
  initRepoCommentForm();
 | 
						|
  initRepoEllipsisButton();
 | 
						|
  initRepoDiffCommitBranchesAndTags();
 | 
						|
  initRepoEditor();
 | 
						|
  initRepoGraphGit();
 | 
						|
  initRepoIssueContentHistory();
 | 
						|
  initRepoIssueDue();
 | 
						|
  initRepoIssueList();
 | 
						|
  initRepoIssueSidebarList();
 | 
						|
  initArchivedLabelHandler();
 | 
						|
  initRepoIssueReferenceRepositorySearch();
 | 
						|
  initRepoIssueTimeTracking();
 | 
						|
  initRepoIssueWipTitle();
 | 
						|
  initRepoMigration();
 | 
						|
  initRepoMigrationStatusChecker();
 | 
						|
  initRepoProject();
 | 
						|
  initRepoPullRequestAllowMaintainerEdit();
 | 
						|
  initRepoPullRequestReview();
 | 
						|
  initRepoRelease();
 | 
						|
  initRepoReleaseNew();
 | 
						|
  initRepoSettingGitHook();
 | 
						|
  initRepoSettingSearchTeamBox();
 | 
						|
  initRepoSettingsCollaboration();
 | 
						|
  initRepoTemplateSearch();
 | 
						|
  initRepoTopicBar();
 | 
						|
  initRepoWikiForm();
 | 
						|
  initRepository();
 | 
						|
  initRepositoryActionView();
 | 
						|
  initRepositorySearch();
 | 
						|
  initRepoContributors();
 | 
						|
  initRepoCodeFrequency();
 | 
						|
  initRepoRecentCommits();
 | 
						|
  initRepoMilestoneEditor();
 | 
						|
 | 
						|
  initCommitStatuses();
 | 
						|
  initCommitNotes();
 | 
						|
  initCaptcha();
 | 
						|
 | 
						|
  initUserAuthOauth2();
 | 
						|
  initUserAuthWebAuthn();
 | 
						|
  initUserAuthWebAuthnRegister();
 | 
						|
  initUserAuth();
 | 
						|
  initRepoDiffView();
 | 
						|
  initPdfViewer();
 | 
						|
  initGltfViewer();
 | 
						|
  initScopedAccessTokenCategories();
 | 
						|
  initColorPickers();
 | 
						|
});
 |