You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
3.8 KiB
82 lines
3.8 KiB
function filterPackedMapVisualMetaJSON( contentFilename ){
|
|
let file = filesWithMetadata[contentFilename]
|
|
if (!file) return
|
|
|
|
let contentType = file.contentType
|
|
|
|
let openingOptions = filesWithMetadata[contentFilename].openingOptions
|
|
|
|
// could overwrite via URL
|
|
const scale = 1/1000
|
|
const xOffset = 0
|
|
const yOffset = 1
|
|
|
|
const idprefix = 'visualmetaexport_'
|
|
|
|
if ( contentType.includes("zip") && contentFilename.includes("dynamicviewvisualmetaexport.jsons") ) {
|
|
// naming issue due to WordPress
|
|
console.log('it is a packed map visualmeta export file', contentFilename)
|
|
fetch( contentFilename )
|
|
// see for packed filters/docx_packed.xml.js
|
|
.then( r => r.blob(r) )
|
|
.then( file => zip.loadAsync(file) )
|
|
.then( f => {
|
|
// console.log(f.files)
|
|
// check for optional export directory
|
|
let filenameDynamicView = Object.entries( f.files ).filter( i => i[0].includes("_dynamicviewvisualmetaexport.json") ).map( i => i[0] )[0]
|
|
let filenameGlossary = Object.entries( f.files ).filter( i => i[0].includes("_glossaryvisualmetaexport.json") ).map( i => i[0] )[0]
|
|
f.files[filenameDynamicView].async("string").then( dyn_content => {
|
|
json = JSON.parse( dyn_content )
|
|
f.files[filenameGlossary].async("string").then( gloss_content => {
|
|
let sidecarjson = JSON.parse( gloss_content )
|
|
let glossary = Object.entries( sidecarjson.entries ).map( i => i[1].phrase )
|
|
|
|
console.log( json, sidecarjson )
|
|
//console.log( glossary )
|
|
|
|
json.nodes.map( n => {
|
|
let x = json.layout.nodePositions[ n.identifier ].x * scale + xOffset
|
|
let y = -json.layout.nodePositions[ n.identifier ].y * scale + yOffset
|
|
let z = -1/2
|
|
let el = addNewNote( n.title, "" + x + " " + y + " " + z )
|
|
el.id = "visualmetaexport_"+n.title.toLowerCase().replaceAll(" ","_").replaceAll(".","_").replaceAll("'","_")
|
|
el.setAttribute("outline-width", 0)
|
|
// optional background color "#7c7c7c"
|
|
// could use onpicked/onreleased to show links from glossary
|
|
// check if any word from title is in glossary
|
|
// if so, display line or highlight visually by removing outline
|
|
// reset onreleased
|
|
|
|
let definitionFound = Object.entries( sidecarjson.entries ).filter( i => i[1].phrase == n.title ).map( f => f[1].entry )
|
|
if (openingOptions.showDefinitions && definitionFound ){ el.setAttribute("annotation", "content", definitionFound[0] ) }
|
|
})
|
|
|
|
Object.entries( sidecarjson.entries ).map( i => i[1].phrase ).map( n => {
|
|
Object.entries( sidecarjson.entries )
|
|
.map( i => { return {phrase:i[1].phrase, entry:i[1].entry} } )
|
|
.filter( i => i.entry.toLowerCase().includes(n.toLowerCase()) )
|
|
.map( i => {
|
|
let el = document.createElement("a-entity")
|
|
el.setAttribute('live-selector-line',
|
|
'start: #'+(idprefix+n.toLowerCase().replaceAll(' ','_').replaceAll(".","_").replaceAll("'","_"))
|
|
+'; end: #'+(idprefix+i.phrase.toLowerCase().replaceAll(' ','_').replaceAll(".","_").replaceAll("'","_"))
|
|
+';' )
|
|
el.classList.add('visualmeta_export_link')
|
|
AFRAME.scenes[0].appendChild(el)
|
|
})
|
|
|
|
})
|
|
Array.from( document.querySelectorAll("[line]") ).map( el => el.setAttribute("line", "color", "black"))
|
|
// should filter a bit better otherwise take lines from other components and elements e.g. raycaster
|
|
|
|
AFRAME.scenes[0].emit('mapvisualmetajsonloaded', contentFilename)
|
|
// to use the event consider :
|
|
//AFRAME.scenes[0].addEventListener("mapvisualmetajsonloaded", e => console.log(e))
|
|
})
|
|
} )
|
|
})
|
|
}
|
|
applyNextFilter( contentFilename )
|
|
}
|
|
|
|
sequentialFilters.push( filterPackedMapVisualMetaJSON )
|
|
|