Download model basics.

This commit is contained in:
Viktor Kovacs 2022-11-22 19:30:16 +01:00
parent aa247e7700
commit 5ac604c172
8 changed files with 159 additions and 74 deletions

54
assets/icons/download.svg Normal file
View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
viewBox="0 0 18 18"
xml:space="preserve"
version="1.1"
id="svg4"
sodipodi:docname="download.svg"
inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"><defs
id="defs8" /><sodipodi:namedview
id="namedview6"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="true"
inkscape:zoom="23.833333"
inkscape:cx="15.713287"
inkscape:cy="13.321678"
inkscape:window-width="1920"
inkscape:window-height="1017"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="g1334"><inkscape:grid
type="xygrid"
id="grid825" /></sodipodi:namedview><g
id="g1334"><g
id="g2200"><g
id="g2196"><path
fill="none"
stroke="#263238"
stroke-linecap="round"
stroke-linejoin="round"
stroke-miterlimit="10"
d="m 1.5,3.4 v 5.7 l 5,3 5,-3 V 3.4 l -5,-2.9 z m 5,8.7 V 6.2 m -5,-2.8 5,2.8 m 0,0 5,-2.8"
id="path2"
sodipodi:nodetypes="ccccccccccccc" /></g></g><g
id="g2200-2"
transform="rotate(90,14.5,14.5)"><g
id="g2196-6"><path
fill="none"
stroke="#263238"
stroke-linecap="round"
stroke-linejoin="round"
stroke-miterlimit="10"
d="M 16.6,14.5 H 6.5 m 8,3 3,-3 m -3,-3 3,3"
id="path2-3"
sodipodi:nodetypes="cccccc" /></g></g></g></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -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');
}
}

View File

@ -1,4 +1,4 @@
export const FeatureSet =
{
DownloadModel : false
};

View File

@ -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) => {

Binary file not shown.

View File

@ -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";
}

Binary file not shown.

View File

@ -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";
}