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

@@ -114,7 +114,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
$annotations = $metadata['annotations']; $annotations = $metadata['annotations'];
} }
//Apply any request transformations //Apply any requested transformations
if ($this->transform) { if ($this->transform) {
if (in_array('rand',$this->transform)) { if (in_array('rand',$this->transform)) {
$subKey = array_search('rand',$this->transform); $subKey = array_search('rand',$this->transform);

View File

@@ -70,6 +70,14 @@ const setView = new OO.ui.ButtonWidget({
setView.on('click', writeCameraOrbit) setView.on('click', writeCameraOrbit)
setView.setDisabled(true) 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 //View Limit Controls
const setMinYaw = new OO.ui.ButtonWidget({ const setMinYaw = new OO.ui.ButtonWidget({
label: 'Min' label: 'Min'
@@ -145,7 +153,7 @@ const setLims = new OO.ui.PopupButtonWidget({
setLims.setDisabled(true) setLims.setDisabled(true)
const cameraButtons = new OO.ui.ButtonGroupWidget({ const cameraButtons = new OO.ui.ButtonGroupWidget({
items: [ downloadViewerImage, setView, setLims ] items: [ downloadViewerImage, setControl, setView, setLims ]
}) })
//Main Menu //Main Menu

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 * Set new default camera orbit and send values to the preview
* editor * editor