Add view config selection to preview editor
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
"oojs-ui-core",
|
||||
"oojs-ui-toolbars",
|
||||
"oojs-ui.styles.icons-interactions",
|
||||
"oojs-ui.styles.icons-accessibility",
|
||||
"oojs-ui.styles.icons-media",
|
||||
"oojs-ui.styles.icons-location"
|
||||
],
|
||||
|
||||
@@ -152,8 +152,29 @@ const setLims = new OO.ui.PopupButtonWidget({
|
||||
})
|
||||
setLims.setDisabled(true)
|
||||
|
||||
const setViewConfig = [...Object.keys(origMetadata.viewerConfig)]
|
||||
let setViewItems = []
|
||||
setViewConfig.forEach(opt => {
|
||||
setViewItems.push(new OO.ui.MenuOptionWidget({data: opt, label: opt}))
|
||||
})
|
||||
|
||||
const selectVC = new OO.ui.ButtonMenuSelectWidget({
|
||||
icon: 'eye',
|
||||
label: 'Select view configuration',
|
||||
invisibleLabel: true,
|
||||
menu: {
|
||||
items: setViewItems,
|
||||
width: 'min-content'
|
||||
},
|
||||
$overlay: $('#bodyContent')
|
||||
})
|
||||
selectVC.getMenu().on( 'choose', selSet => {
|
||||
selectViewConfig(selSet.data)
|
||||
})
|
||||
selectVC.setDisabled(true)
|
||||
|
||||
const cameraButtons = new OO.ui.ButtonGroupWidget({
|
||||
items: [ downloadViewerImage, setControl, setView, setLims ]
|
||||
items: [ downloadViewerImage, setControl, setView, setLims, selectVC ]
|
||||
})
|
||||
|
||||
//Main Menu
|
||||
|
||||
@@ -471,7 +471,7 @@ toggleFullScreen = function(glCont) {
|
||||
*/
|
||||
toggleCameraControl = function(view) {
|
||||
let [currentText, mvconfig] = extractMetadata()
|
||||
let currentView = (mvconfig.viewerConfig[view]) ? view : 'default'
|
||||
const currentView = (mvconfig.viewerConfig[view]) ? view : 'default'
|
||||
const newControl = !mvconfig.viewerConfig[currentView]['camera-controls']
|
||||
if (newControl) {
|
||||
mvconfig.viewerConfig[currentView]['camera-controls'] = newControl
|
||||
@@ -483,6 +483,47 @@ toggleCameraControl = function(view) {
|
||||
return newControl
|
||||
}
|
||||
|
||||
selectViewConfig = function(view) {
|
||||
const mView = $('model-viewer')[0]
|
||||
let [_, mvconfig] = extractMetadata()
|
||||
const selectView = (mvconfig.viewerConfig[view]) ? view : 'default'
|
||||
const viewConfig = mvconfig.viewerConfig[selectView]
|
||||
const settings = [
|
||||
"camera-controls",
|
||||
"disable-pan",
|
||||
"disable-tap",
|
||||
"touch-action",
|
||||
"disable-zoom",
|
||||
"orbit-sensitivity",
|
||||
"zoom-sensitivity",
|
||||
"pan-sensitivity",
|
||||
"auto-rotate",
|
||||
"auto-rotate-delay",
|
||||
"rotation-per-second",
|
||||
"interaction-prompt-style",
|
||||
"interaction-prompt-threshold",
|
||||
"camera-orbit",
|
||||
"camera-target",
|
||||
"field-of-view",
|
||||
"max-camera-orbit",
|
||||
"min-camera-orbit",
|
||||
"max-field-of-view",
|
||||
"min-field-of-view",
|
||||
"poster",
|
||||
"ar",
|
||||
"ar-modes",
|
||||
"ar-scale",
|
||||
"ar-placement"
|
||||
]
|
||||
settings.forEach(s => {
|
||||
if (viewConfig[s]) {
|
||||
mView.setAttribute(s,viewConfig[s])
|
||||
} else {
|
||||
mView.removeAttribute(s)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new default camera orbit and send values to the preview
|
||||
* editor
|
||||
|
||||
Reference in New Issue
Block a user