Add set starting view button

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2024-11-05 20:40:13 -07:00
parent 37ca6cd017
commit b241f20796
2 changed files with 18 additions and 1 deletions

View File

@@ -97,11 +97,17 @@ class GlModelHooks {
'onclick' => 'downloadImage("' . $title . '")' 'onclick' => 'downloadImage("' . $title . '")'
); );
$orbButtonAttr = array(
'class' => 'preview-button SetOrbit',
'onclick' => 'writeCameraOrbit()'
);
$addHsButton = array( $addHsButton = array(
Html::rawElement('button',$addButtonAttr,'Add a new hotspot'), Html::rawElement('button',$addButtonAttr,'Add a new hotspot'),
Html::rawElement('button',$readButtonAttr,'Update hotspots'), Html::rawElement('button',$readButtonAttr,'Update hotspots'),
Html::rawElement('button',$delButtonAttr,'Delete hotspot'), Html::rawElement('button',$delButtonAttr,'Delete hotspot'),
Html::rawElement('button',$dldButtonAttr,'Download image') Html::rawElement('button',$dldButtonAttr,'Download image'),
Html::rawElement('button',$orbButtonAttr,'Set start view')
); );
$previewHTML = Html::rawElement('div',NULL,$previewViewer.implode($addHsButton)); $previewHTML = Html::rawElement('div',NULL,$previewViewer.implode($addHsButton));

View File

@@ -427,3 +427,14 @@ toggleFullScreen = function(glCont) {
glCont.requestFullscreen() glCont.requestFullscreen()
} }
} }
/**
* Send new default camera orbit values to the preview editor
*/
writeCameraOrbit = function() {
const mView = $('model-viewer')[0]
let newOrbit = mView.getCameraOrbit().toString()
newOrbit = newOrbit.replaceAll(/(\d{2})(\d*?rad)/g,"$1rad")
const textUpdate = $('#wpTextbox1').val().replace(/([\S\s]*?default[\S\s]*?"camera-orbit": ")(.*?)(",$[\S\s]*)/gm,'$1' + newOrbit + '$3')
$('#wpTextbox1').val(textUpdate)
}