Add mvconfig tag
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -94,7 +94,7 @@ writeMetadata = function () {
|
||||
if (Object.keys(annotationsObj).length === 0) return false
|
||||
const [currentText, metadata] = extractMetadata()
|
||||
metadata.annotations = annotationsObj
|
||||
const newText = currentText.replace(/(.*?<pre>)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
const newText = currentText.replace(/(.*?<mvconfig>)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
$('#wpTextbox1').val(newText)
|
||||
return true
|
||||
}
|
||||
@@ -106,7 +106,7 @@ writeMetadata = function () {
|
||||
*/
|
||||
extractMetadata = function() {
|
||||
const editText = $('#wpTextbox1').val()
|
||||
const extractMetadata = editText.match(/<pre>([\S\s]*?)<\/pre>/)
|
||||
const extractMetadata = editText.match(/<mvconfig>([\S\s]*?)<\/mvconfig>/)
|
||||
let metadata = (extractMetadata.length >= 2) ? JSON.parse(extractMetadata[1]) : {viewerConfig: {}, annotations: {}, annotationSets: {}}
|
||||
if (metadata.annotations === undefined) {
|
||||
metadata.annotations = {}
|
||||
@@ -146,7 +146,7 @@ clickAddHotspot = function(e) {
|
||||
let targetObj = targetModel.getCameraTarget()
|
||||
hsOutput['data-target'] = `${targetObj.x.toFixed(5)}m ${targetObj.y.toFixed(5)}m ${targetObj.z.toFixed(5)}m`
|
||||
metadata.annotations['Hotspot ' + (Object.keys(metadata.annotations).length + 1)] = hsOutput
|
||||
let newText = currentText.replace(/(.*?<pre>)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
let newText = currentText.replace(/(.*?<mvconfig>)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
$('#wpTextbox1').val(newText)
|
||||
}
|
||||
readMetadata()
|
||||
@@ -376,7 +376,7 @@ releaseAnnotation = function(e) {
|
||||
"data-orbit": newOrb,
|
||||
"data-target": newTarg
|
||||
}
|
||||
const newText = currentText.replace(/(.*?<pre>)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
const newText = currentText.replace(/(.*?<mvconfig>)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
$('#wpTextbox1').val(newText)
|
||||
}
|
||||
grabHotspot = null
|
||||
@@ -481,7 +481,7 @@ limitCameraOrbit = function(axis, limit) {
|
||||
oldOrbitVals[valueIndex] = newOrbitVals[valueIndex]
|
||||
metadata.viewerConfig.default[`${limit}-camera-orbit`] = oldOrbitVals.join(' ')
|
||||
mView.setAttribute(`${limit}-camera-orbit`, oldOrbitVals.join(' '))
|
||||
const newText = currentText.replace(/(.*?<pre>)[\S\s]*?(<\/pre>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
const newText = currentText.replace(/(.*?<mvconfig>)[\S\s]*?(<\/mvconfig>.*)/,`$1\n${JSON.stringify(metadata, null, 2)}\n$2`)
|
||||
$('#wpTextbox1').val(newText)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user