-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhandler.js
63 lines (60 loc) · 2.49 KB
/
handler.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import * as OV from './engine/main.js';
export class ExporterWorker {
constructor(storage) {
this.storage = storage
this.settings = new OV.ImportSettings()
this.loader = new OV.ThreeModelLoader()
this.exporterSettings = new OV.ExporterSettings()
this.exporter = new OV.Exporter();
}
export (req) {
let file_name = req.file_name
this.storage.startExport(req.gid, req.request_id, req.convert_type)
let inputFiles = []
if (req.urlType == 2) {
inputFiles = [new OV.InputFile(file_name, OV.FileSource.File, req.url)]
} else {
inputFiles = [new OV.InputFile(file_name, OV.FileSource.Url, req.url)]
}
this.loader.LoadModel(inputFiles, this.settings, {
onLoadStart: () => { },
onFileListProgress: (current, total) => {
let msg = current + "," + total
this.storage.exportStage(req.gid, "FileListProgress", msg)
},
onFileLoadProgress: (current, total) => {
let msg = current + "," + total
this.storage.exportStage(req.gid, "FileLoadProgress", msg)
},
onImportStart: () => {
let msg = "Importing model..."
this.storage.exportStage(req.gid, "ImportStart", msg)
},
onSelectMainFile: (fileNames, selectFile) => {
},
onImportSuccess: (importResult) => {
},
onModelFinished: (importResult, threeObject) => {
let msg = "Exporting model..."
this.storage.exportStage(req.gid, "ExportStart", msg)
let model = importResult.model;
this.exporter.Export(model, this.exporterSettings, OV.FileFormat.Binary, req.convert_type, {
onError: () => {
this.storage.executionErr(req.gid, "ExportStart", "")
},
onSuccess: (files) => {
if (files.length < 1) {
return
}
let file = files[0];
this.storage.executionSuccess(req.gid, req.save_path, Buffer.from(file.GetBufferContent()))
}
})
},
onLoadError: (importError) => {
this.storage.executionErr(req.gid, "importError", importError)
},
onVisualizationStart: () => { }
})
}
}