diff --git a/assets/icons/download.svg b/assets/icons/download.svg new file mode 100644 index 0000000..e6ca668 --- /dev/null +++ b/assets/icons/download.svg @@ -0,0 +1,54 @@ + + diff --git a/source/website/exportdialog.js b/source/website/exportdialog.js index 51c7711..65cd15d 100644 --- a/source/website/exportdialog.js +++ b/source/website/exportdialog.js @@ -196,3 +196,21 @@ export function ShowExportDialog (model, viewer, callbacks) let exportDialog = new ExportDialog (callbacks); exportDialog.Open (model, viewer); } + +export function DownloadModel (importer) +{ + let fileList = importer.GetFileList ().GetFiles (); + if (fileList.length === 0) { + return; + } else if (fileList.length === 1) { + let file = fileList[0]; + DownloadArrayBufferAsFile (file.content, file.name); + } else { + let filesInZip = {}; + for (let file of fileList) { + filesInZip[file.name] = new Uint8Array (file.content); + } + let zippedContent = fflate.zipSync (filesInZip); + DownloadArrayBufferAsFile (zippedContent.buffer, 'model.zip'); + } +} diff --git a/source/website/featureset.js b/source/website/featureset.js index 1590268..f70b5ac 100644 --- a/source/website/featureset.js +++ b/source/website/featureset.js @@ -1,4 +1,4 @@ export const FeatureSet = { - + DownloadModel : false }; diff --git a/source/website/website.js b/source/website/website.js index 2f61027..a06fcf5 100644 --- a/source/website/website.js +++ b/source/website/website.js @@ -12,7 +12,7 @@ import { Sidebar } from './sidebar.js'; import { ThemeHandler } from './themehandler.js'; import { ThreeModelLoaderUI } from './threemodelloaderui.js'; import { Toolbar } from './toolbar.js'; -import { ShowExportDialog } from './exportdialog.js'; +import { DownloadModel, ShowExportDialog } from './exportdialog.js'; import { ShowSnapshotDialog } from './snapshotdialog.js'; import { AddSmallWidthChangeEventListener, AddSvgIconElement, GetFilesFromDataTransfer, InstallTooltip, IsSmallWidth } from './utils.js'; import { ShowOpenUrlDialog } from './openurldialog.js'; @@ -23,6 +23,7 @@ import { CookieGetBoolVal, CookieSetBoolVal } from './cookiehandler.js'; import { MeasureTool } from './measuretool.js'; import { CloseAllDialogs } from './dialog.js'; import { EnumeratePlugins, PluginType } from './pluginregistry.js'; +import { FeatureSet } from './featureset.js'; import * as THREE from 'three'; @@ -583,6 +584,12 @@ export class Website AddButton (this.toolbar, 'snapshot', 'Create snapshot', ['only_full_width', 'only_on_model'], () => { ShowSnapshotDialog (this.viewer); }); + if (FeatureSet.DownloadModel) { + AddButton (this.toolbar, 'download', 'Download model', ['only_full_width', 'only_on_model'], () => { + let importer = this.modelLoaderUI.GetImporter (); + DownloadModel (importer); + }); + } AddButton (this.toolbar, 'export', 'Export model', ['only_full_width', 'only_on_model'], () => { ShowExportDialog (this.model, this.viewer, { isMeshVisible : (meshInstanceId) => { diff --git a/website/css/O3DVIcons/O3DVIcons.woff b/website/css/O3DVIcons/O3DVIcons.woff index f9a0812..c97af57 100644 Binary files a/website/css/O3DVIcons/O3DVIcons.woff and b/website/css/O3DVIcons/O3DVIcons.woff differ diff --git a/website/css/icons.css b/website/css/icons.css index 9ae640b..4689010 100644 --- a/website/css/icons.css +++ b/website/css/icons.css @@ -1,6 +1,6 @@ @font-face { font-family: "O3DVIcons"; - src: url("O3DVIcons/O3DVIcons.woff?0e003e02b86912dd45c396f7eaa4349e") format("woff"); + src: url("O3DVIcons/O3DVIcons.woff?c0e5a84e0c3367514518abbacd6417d6") format("woff"); } i[class^="icon-"]:before, i[class*=" icon-"]:before { @@ -47,108 +47,111 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before { .icon-donate:before { content: "\f10b"; } -.icon-expand:before { +.icon-download:before { content: "\f10c"; } -.icon-export:before { +.icon-expand:before { content: "\f10d"; } -.icon-feedback:before { +.icon-export:before { content: "\f10e"; } -.icon-file_download:before { +.icon-feedback:before { content: "\f10f"; } -.icon-files:before { +.icon-file_download:before { content: "\f110"; } -.icon-fit:before { +.icon-files:before { content: "\f111"; } -.icon-fix_up_off:before { +.icon-fit:before { content: "\f112"; } -.icon-fix_up_on:before { +.icon-fix_up_off:before { content: "\f113"; } -.icon-flat_list:before { +.icon-fix_up_on:before { content: "\f114"; } -.icon-flip:before { +.icon-flat_list:before { content: "\f115"; } -.icon-github:before { +.icon-flip:before { content: "\f116"; } -.icon-hidden:before { +.icon-github:before { content: "\f117"; } -.icon-info:before { +.icon-hidden:before { content: "\f118"; } -.icon-isolate:before { +.icon-info:before { content: "\f119"; } -.icon-materials:before { +.icon-isolate:before { content: "\f11a"; } -.icon-measure_angle:before { +.icon-materials:before { content: "\f11b"; } -.icon-measure_distance_parallel:before { +.icon-measure_angle:before { content: "\f11c"; } -.icon-measure_distance:before { +.icon-measure_distance_parallel:before { content: "\f11d"; } -.icon-measure:before { +.icon-measure_distance:before { content: "\f11e"; } -.icon-meshes:before { +.icon-measure:before { content: "\f11f"; } -.icon-missing_files:before { +.icon-meshes:before { content: "\f120"; } -.icon-model:before { +.icon-missing_files:before { content: "\f121"; } -.icon-open_url:before { +.icon-model:before { content: "\f122"; } -.icon-open:before { +.icon-open_url:before { content: "\f123"; } -.icon-print3d:before { +.icon-open:before { content: "\f124"; } -.icon-settings:before { +.icon-print3d:before { content: "\f125"; } -.icon-share:before { +.icon-settings:before { content: "\f126"; } -.icon-snapshot:before { +.icon-share:before { content: "\f127"; } -.icon-tree_mesh:before { +.icon-snapshot:before { content: "\f128"; } -.icon-tree_view:before { +.icon-tree_mesh:before { content: "\f129"; } -.icon-twitter:before { +.icon-tree_view:before { content: "\f12a"; } -.icon-up_y:before { +.icon-twitter:before { content: "\f12b"; } -.icon-up_z:before { +.icon-up_y:before { content: "\f12c"; } -.icon-visible:before { +.icon-up_z:before { content: "\f12d"; } -.icon-warning:before { +.icon-visible:before { content: "\f12e"; } +.icon-warning:before { + content: "\f12f"; +} diff --git a/website/info/css/O3DVIcons.woff b/website/info/css/O3DVIcons.woff index f9a0812..c97af57 100644 Binary files a/website/info/css/O3DVIcons.woff and b/website/info/css/O3DVIcons.woff differ diff --git a/website/info/css/icons.css b/website/info/css/icons.css index fd259b5..10d2cea 100644 --- a/website/info/css/icons.css +++ b/website/info/css/icons.css @@ -1,6 +1,6 @@ @font-face { font-family: "O3DVIcons"; - src: url("./O3DVIcons.woff?0e003e02b86912dd45c396f7eaa4349e") format("woff"); + src: url("./O3DVIcons.woff?c0e5a84e0c3367514518abbacd6417d6") format("woff"); } i[class^="icon-"]:before, i[class*=" icon-"]:before { @@ -47,108 +47,111 @@ i[class^="icon-"]:before, i[class*=" icon-"]:before { .icon-donate:before { content: "\f10b"; } -.icon-expand:before { +.icon-download:before { content: "\f10c"; } -.icon-export:before { +.icon-expand:before { content: "\f10d"; } -.icon-feedback:before { +.icon-export:before { content: "\f10e"; } -.icon-file_download:before { +.icon-feedback:before { content: "\f10f"; } -.icon-files:before { +.icon-file_download:before { content: "\f110"; } -.icon-fit:before { +.icon-files:before { content: "\f111"; } -.icon-fix_up_off:before { +.icon-fit:before { content: "\f112"; } -.icon-fix_up_on:before { +.icon-fix_up_off:before { content: "\f113"; } -.icon-flat_list:before { +.icon-fix_up_on:before { content: "\f114"; } -.icon-flip:before { +.icon-flat_list:before { content: "\f115"; } -.icon-github:before { +.icon-flip:before { content: "\f116"; } -.icon-hidden:before { +.icon-github:before { content: "\f117"; } -.icon-info:before { +.icon-hidden:before { content: "\f118"; } -.icon-isolate:before { +.icon-info:before { content: "\f119"; } -.icon-materials:before { +.icon-isolate:before { content: "\f11a"; } -.icon-measure_angle:before { +.icon-materials:before { content: "\f11b"; } -.icon-measure_distance_parallel:before { +.icon-measure_angle:before { content: "\f11c"; } -.icon-measure_distance:before { +.icon-measure_distance_parallel:before { content: "\f11d"; } -.icon-measure:before { +.icon-measure_distance:before { content: "\f11e"; } -.icon-meshes:before { +.icon-measure:before { content: "\f11f"; } -.icon-missing_files:before { +.icon-meshes:before { content: "\f120"; } -.icon-model:before { +.icon-missing_files:before { content: "\f121"; } -.icon-open_url:before { +.icon-model:before { content: "\f122"; } -.icon-open:before { +.icon-open_url:before { content: "\f123"; } -.icon-print3d:before { +.icon-open:before { content: "\f124"; } -.icon-settings:before { +.icon-print3d:before { content: "\f125"; } -.icon-share:before { +.icon-settings:before { content: "\f126"; } -.icon-snapshot:before { +.icon-share:before { content: "\f127"; } -.icon-tree_mesh:before { +.icon-snapshot:before { content: "\f128"; } -.icon-tree_view:before { +.icon-tree_mesh:before { content: "\f129"; } -.icon-twitter:before { +.icon-tree_view:before { content: "\f12a"; } -.icon-up_y:before { +.icon-twitter:before { content: "\f12b"; } -.icon-up_z:before { +.icon-up_y:before { content: "\f12c"; } -.icon-visible:before { +.icon-up_z:before { content: "\f12d"; } -.icon-warning:before { +.icon-visible:before { content: "\f12e"; } +.icon-warning:before { + content: "\f12f"; +}