-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathscan-obb-aligner.pug
152 lines (147 loc) · 6.48 KB
/
scan-obb-aligner.pug
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
doctype html
html(lang="en")
head
title= "Scan OBB Alignment"
meta(charset= "UTF-8")
link(rel='stylesheet', href='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css')
link(rel='stylesheet', href='https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css')
link(rel='stylesheet', href='https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.3/themes/default/style.min.css')
link(rel='stylesheet', href='//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.min.css')
link(rel='stylesheet', href='//cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.4.2/jquery.contextMenu.min.css')
link(rel='stylesheet', href=`${baseUrl}/css/common.css`)
link(rel='stylesheet', href=`${baseUrl}/css/search-panel.css`)
link(rel='stylesheet', href=`${baseUrl}/css/model-viewer.css`)
body
// UI Markup
#main
#canvas
#alert.alert(style="display:none")
button.close(type="button", onclick="hideAlert()") ×
span#alertMessage
#accordion.overlay.panel-group(style='top:80px; left:10px; max-height:100vh; overflow:auto;')
.panel.panel-default
h4.panel-heading.panel-title.collapsed(data-toggle='collapse', data-target='#partsPanel') Parts
#partsPanel.panel-body.panel-collapse.collapse
p#partTypeSelectDiv
label(for="partType") Part Type
select#partType
p#labelTypeSelectDiv
label(for="labelType") Label
select#labelType
p#showSegmentsDiv
.panel.panel-default
h4.panel-heading.panel-title.collapsed(data-toggle='collapse', data-target='#images') Images
#images.panel-collapse.collapse
.panel-body
#imagesPanel(style='height:450px; width:300px;')
#instructionsPanel.roundBorder.grayBackground
span Instructions
p#instructions
#namesPanel.overlay.btn-group.btn-group-vertical
#nameButtonsDiv.btn-group.btn-group-vertical
script(src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js")
script(src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js")
script(src="//cdnjs.cloudflare.com/ajax/libs/jquery-contextmenu/2.4.2/jquery.contextMenu.min.js")
script(src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js")
// Special bootbox
script(src=`${baseUrl}/client/js/vendor/bootbox.form.min.js`)
script(src=`${baseUrl}/three.min.js`)
script(src=`${baseUrl}/STK.bundle.js`)
link(rel='stylesheet', href=`${baseUrl}/css/datgui-light.css`)
script.
var defaultPaletteName = 'd3_category19p';
var paletteName = STK.util.getUrlParam('palette') || defaultPaletteName;
var partType = STK.util.getUrlParam('partType') || 'surfaces';
STK.Constants.defaultPalette = STK.Colors.palettes[paletteName] || STK.Colors.palettes[defaultPaletteName];
var canvas = document.getElementById('canvas');
var modelViewer = new STK.ModelViewer({
appId: 'ScanObbAligner.v1-20220823',
container: canvas,
sources: ['vf'],
showSearchOptions: false,
allowCameraControlToggle: false,
allowPrevNext: false,
useNewImages: true,
saveImageModifierKey: 'ctrl',
partsPanel: {
partTypes: ['none', partType],
labelTypes: ['Raw', 'Neutral', 'Normal', 'Category', 'Object'],
defaultPartType: partType,
defaultLabelType: 'Object',
neutralColor: STK.util.getUrlParam('neutralColor'),
useColorSequence: true,
showOBBs: true,
allowObbAdjustment: true
}
});
function setLabelColors(labelMappings, cb) {
var labelMappingsFile = STK.Constants.assetsDir + 'data/labels/label-mappings.tsv';
var remapCategoryField = 'category';
var categoryField = 'category';
var indexField = 'index';
if (labelMappings) {
labelMappingsFile = labelMappings.path || labelMappingsFile;
remapCategoryField = labelMappings.remapCategoryField || remapCategoryField;
categoryField = labelMappings.categoryField || categoryField;
indexField = labelMappings.indexField || indexField;
}
STK.FileUtil.loadDelimited(labelMappingsFile, null, function(err, parsed) {
if (parsed) {
var index = _.keyBy(parsed.data, categoryField);
index = _.mapValues(index, function (v) {
return v[indexField];
});
modelViewer.partsPanel.initLabelRemaps(_.keyBy(parsed.data, remapCategoryField), remapCategoryField);
modelViewer.partsPanel.setLabelColorIndex('Category', index);
modelViewer.partsPanel.setLabelColorIndex('voxels-labeled', index);
modelViewer.partsPanel.labeledVoxels.setLabelColorIndex(index);
modelViewer.partsPanel.setLabelColorIndex('Label', index);
}
if (cb) {
cb();
}
});
}
modelViewer.Subscribe('Launch', modelViewer, function () {
modelViewer.showLoadingIcon(true);
});
var modelId = STK.util.getUrlParam('modelId');
modelViewer.launch();
modelViewer.assetManager.registerCustomAssetGroups({
assetFiles: STK.Constants.scanAssetsFile,
filterByAssetId: modelId,
callback: function(err, res) {
//console.log(res);
var labelMappings;
if (res) {
for (var i = 0; i < res.length; i++) {
if (res[i].labelMappings) {
labelMappings = res[i].labelMappings;
break;
}
}
}
setLabelColors(labelMappings, function() {
if (!err) {
if (modelId != undefined) {
var modelIdParts = modelId.split('.');
modelViewer.setSourceAndSearch(modelViewer.modelSearchController, modelIdParts[0], 'fullId:' + modelId);
} else {
modelViewer.showLoadingIcon(false);
}
}
});
}
});
$('#partsPanel').collapse('show')
$('#images').on('shown.bs.collapse', function () {
modelViewer.modelImagesPanel.onResize();
});
$('#instructions').hide();
$('#instructionsPanel').click(function () {
$('#instructions').toggle();
});
// Make various components draggable
$('#namesPanel').draggable();
$('#instructionsPanel').draggable();
window.app = modelViewer; // For console debugging