Add camera control toggle to preview edit functions

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-11-16 10:23:36 -07:00
parent e9dc663c0f
commit 8032d0a16d
3 changed files with 30 additions and 2 deletions

View File

@@ -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