import { useState, useMemo, useCallback, useEffect } from "react"; import classNames from "classnames"; import { HotSpot, Krpano, ROTATE_DIRECTION, Scene, View, ZOOM_ACTION, } from "@dage/krpano"; import useUrlState from "@ahooksjs/use-url-state"; import { useNavigate } from "react-router"; import { MouseHoldView, SceneList } from "./components"; import { ISceneProps } from "./utils"; import "./App.scss"; enum SCENE_NAME { HOME = "1", SCENE_1 = "2", } function App() { const navigate = useNavigate(); const [state, setState] = useUrlState({ scene: SCENE_NAME.HOME }); const [menuVisible, setMenuVisible] = useState(false); const [fullScreen, setFullScreen] = useState(false); const [toolbarVisible, setToolbarVisible] = useState(true); const [currentScene, setCurrentScene] = useState(state.scene); const [hasPreviousPage, setHasPreviousPage] = useState(false); const isHome = useMemo( () => currentScene === SCENE_NAME.HOME, [currentScene] ); useEffect(() => { if (window.history.length > 1) { setHasPreviousPage(true); } }, [isHome]); const handleScene = useCallback( (scene: SCENE_NAME) => { setCurrentScene(scene); setState({ scene, }); }, [setState] ); useEffect(() => { if (state.scene !== currentScene) { handleScene(state.scene); } }, [state, currentScene, handleScene]); const goToScene = (m: string) => { window.location.href = `https://houseoss.4dkankan.com/project/ZHCHXS/scene/index.html#/?m=${m}&showBack=1`; }; const SCENE_LIST = useMemo( () => [ { name: "1", title: "翠湖香山1", thumbUrl: process.env.PUBLIC_URL + "/panos/1.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/1.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/1.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/1.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/1.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

), }, { name: "2", title: "翠湖香山2", thumbUrl: process.env.PUBLIC_URL + "/panos/2.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/2.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/2.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/2.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/2.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

{}} onOut={() => {}} >

翠湖高尔夫

), }, { name: "3", title: "翠湖香山3", thumbUrl: process.env.PUBLIC_URL + "/panos/3.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/3.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/3.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/3.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/3.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

{}} onOut={() => {}} >

翠湖高尔夫

), }, { name: "4", title: "翠湖香山4", thumbUrl: process.env.PUBLIC_URL + "/panos/4.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/4.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/4.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/4.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/4.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

{}} onOut={() => {}} >

翠湖高尔夫

), }, { name: "5", title: "翠湖香山5", thumbUrl: process.env.PUBLIC_URL + "/panos/5.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/5.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/5.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/5.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/5.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

{}} onOut={() => {}} >

翠湖高尔夫

), }, { name: "6", title: "翠湖香山6", thumbUrl: process.env.PUBLIC_URL + "/panos/6.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/6.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/6.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/6.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/6.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} >

翠湖高尔夫

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

), }, { name: "7", title: "翠湖香山7", thumbUrl: process.env.PUBLIC_URL + "/panos/7.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/7.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/7.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/7.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/7.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} >

翠湖高尔夫

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

), }, { name: "8", title: "翠湖香山8", thumbUrl: process.env.PUBLIC_URL + "/panos/8.tiles/thumb.jpg", previewUrl: process.env.PUBLIC_URL + "/panos/8.tiles/preview.jpg", imageTagAttributes: { type: "cube", tileSize: 512, multires: true, }, images: [ { tiledImageWidth: 4608, tiledImageHeight: 4608, url: process.env.PUBLIC_URL + "/panos/8.tiles/%s/l3/%0v/l3_%s_%0v_%0h.jpg", }, { tiledImageWidth: 2304, tiledImageHeight: 2304, url: process.env.PUBLIC_URL + "/panos/8.tiles/%s/l2/%0v/l2_%s_%0v_%0h.jpg", }, { tiledImageWidth: 1152, tiledImageHeight: 1152, url: process.env.PUBLIC_URL + "/panos/8.tiles/%s/l1/%0v/l1_%s_%0v_%0h.jpg", }, ], children: ( <> {}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-XW4mfRey6mK")} >

香园

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-5iy1XKL3pYu")} >

留香苑传统中式合院别墅(B2)

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-vrMFXRis6MK")} >

留香苑AB区归家大堂

{}} onOut={() => {}} onClick={goToScene.bind(undefined, "KJ-WqBcApJJRfd")} >

留香苑C区归家大堂

{}} onOut={() => {}} >

翠湖高尔夫

), }, ], [] ); const handleView = (direction: ROTATE_DIRECTION) => { window.ReactKrpanoActionProxy?.rotateView(direction); }; const handleZoom = (action: ZOOM_ACTION) => { window.ReactKrpanoActionProxy?.zoomView(action); }; return (
{SCENE_LIST.map( (sc) => sc.imageTagAttributes && )} {hasPreviousPage && !isHome && (
navigate(-1)} /> )}
setMenuVisible(!menuVisible)} />
{document.fullscreenEnabled && (
{ if (fullScreen) { await document.exitFullscreen(); } else { await document.getElementById("root")?.requestFullscreen(); } setFullScreen(!fullScreen); }} /> )}
{ setMenuVisible(false); setToolbarVisible(false); }} />
{!isHome && (
setState({ scene: SCENE_NAME.HOME })} /> )} {/*
*/}
setToolbarVisible(true)} />
); } export default App;