import { useEffect, useRef, useState } from 'react'
import { WorldRendererThree } from 'renderer/viewer/lib/worldrendererThree'
import FullScreenWidget from './FullScreenWidget'
export const name = 'loaded world signs'
export default () => {
const [selected, setSelected] = useState([] as string[])
const allSignsPos = [] as string[]
const signs = viewer.world instanceof WorldRendererThree ? [...viewer.world.chunkTextures.values()].flatMap(textures => {
return Object.entries(textures).map(([signPosKey, texture]) => {
allSignsPos.push(signPosKey)
const pos = signPosKey.split(',').map(Number)
const isSelected = selected.includes(signPosKey)
return
{pos.join(', ')}
setSelected(selected.includes(signPosKey) ? selected.filter(x => x !== signPosKey) : [...selected, signPosKey])}>
})
}) : []
return
{signs.length} signs currently in the scene:
{
// toggle all
if (selected.length === allSignsPos.length) {
setSelected([])
return
}
setSelected([...allSignsPos])
}}>Select All
{selected.length && {
void navigator.clipboard.writeText(selected.join('\n'))
}}>Copy Selected Signs
}
{signs}
}
const AddElem = ({ elem }) => {
const ref = useRef(null)
useEffect(() => {
elem.style.width = '100%'
elem.style.height = '100%'
ref.current!.appendChild(elem)
return () => {
elem.remove()
}
}, [])
return
}
// for (const key of Object.keys(viewer.world.sectionObjects)) {
// const section = viewer.world.sectionObjects[key]
// for (const child of section.children) {
// if (child.name === 'mesh') child.visible = false
// }
// }