diff --git a/includes/GlModelTransformOutput.php b/includes/GlModelTransformOutput.php index 6d7167d..c521e22 100644 --- a/includes/GlModelTransformOutput.php +++ b/includes/GlModelTransformOutput.php @@ -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); diff --git a/modules/glmv-prev.js b/modules/glmv-prev.js index 4ef6dbc..3a806f6 100644 --- a/modules/glmv-prev.js +++ b/modules/glmv-prev.js @@ -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 diff --git a/modules/glmv.js b/modules/glmv.js index af609a4..531b7ce 100644 --- a/modules/glmv.js +++ b/modules/glmv.js @@ -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(/(?<=)([\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