Add camera control toggle to preview edit functions
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -114,7 +114,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
||||
$annotations = $metadata['annotations'];
|
||||
}
|
||||
|
||||
//Apply any request transformations
|
||||
//Apply any requested transformations
|
||||
if ($this->transform) {
|
||||
if (in_array('rand',$this->transform)) {
|
||||
$subKey = array_search('rand',$this->transform);
|
||||
|
||||
@@ -70,6 +70,14 @@ const setView = new OO.ui.ButtonWidget({
|
||||
setView.on('click', writeCameraOrbit)
|
||||
setView.setDisabled(true)
|
||||
|
||||
const setControl = new OO.ui.ButtonWidget({
|
||||
icon: 'hand',
|
||||
label: 'Toggle camera control',
|
||||
invisibleLabel: true
|
||||
})
|
||||
setControl.on('click', () => $('model-viewer')[0].toggleAttribute('camera-controls', toggleCameraControl()))
|
||||
setControl.setDisabled(true)
|
||||
|
||||
//View Limit Controls
|
||||
const setMinYaw = new OO.ui.ButtonWidget({
|
||||
label: 'Min'
|
||||
@@ -145,7 +153,7 @@ const setLims = new OO.ui.PopupButtonWidget({
|
||||
setLims.setDisabled(true)
|
||||
|
||||
const cameraButtons = new OO.ui.ButtonGroupWidget({
|
||||
items: [ downloadViewerImage, setView, setLims ]
|
||||
items: [ downloadViewerImage, setControl, setView, setLims ]
|
||||
})
|
||||
|
||||
//Main Menu
|
||||
|
||||
@@ -463,6 +463,26 @@ toggleFullScreen = function(glCont) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set camera control setting for the current view
|
||||
*
|
||||
* @param {string} view
|
||||
* @return {bool} new camera-controls setting
|
||||
*/
|
||||
toggleCameraControl = function(view) {
|
||||
let [currentText, mvconfig] = extractMetadata()
|
||||
let currentView = (mvconfig.viewerConfig[view]) ? view : 'default'
|
||||
const newControl = !mvconfig.viewerConfig[currentView]['camera-controls']
|
||||
if (newControl) {
|
||||
mvconfig.viewerConfig[currentView]['camera-controls'] = newControl
|
||||
} else {
|
||||
delete mvconfig.viewerConfig[currentView]['camera-controls']
|
||||
}
|
||||
const textUpdate = currentText.replace(/(?<=<mvconfig>)([\S\s]*?)(?=<\/mvconfig>)/gm,`\n${JSON.stringify(mvconfig, null, 2)}\n`)
|
||||
$('#wpTextbox1').val(textUpdate)
|
||||
return newControl
|
||||
}
|
||||
|
||||
/**
|
||||
* Set new default camera orbit and send values to the preview
|
||||
* editor
|
||||
|
||||
Reference in New Issue
Block a user