Spaces:
Runtime error
Runtime error
Julian Bilcke commited on
Commit ·
fd6f6bd
1
Parent(s): f436f13
fix for the update of the spherical renderer
Browse files
src/app/layout.tsx
CHANGED
|
@@ -5,8 +5,8 @@ import { Inter } from 'next/font/google'
|
|
| 5 |
const inter = Inter({ subsets: ['latin'] })
|
| 6 |
|
| 7 |
export const metadata: Metadata = {
|
| 8 |
-
title: '
|
| 9 |
-
description: '
|
| 10 |
}
|
| 11 |
|
| 12 |
export default function RootLayout({
|
|
|
|
| 5 |
const inter = Inter({ subsets: ['latin'] })
|
| 6 |
|
| 7 |
export const metadata: Metadata = {
|
| 8 |
+
title: 'VideoQuest: A generative AI adventure!',
|
| 9 |
+
description: 'VideoQuest: A generative AI adventure!',
|
| 10 |
}
|
| 11 |
|
| 12 |
export default function RootLayout({
|
src/components/business/spherical-image.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { ReactPhotoSphereViewer } from "react-photo-sphere-viewer"
|
|
| 2 |
|
| 3 |
import { SceneEventHandler } from "./types"
|
| 4 |
import { RenderedScene } from "@/app/types"
|
|
|
|
| 5 |
|
| 6 |
export function SphericalImage({
|
| 7 |
rendered,
|
|
@@ -14,6 +15,61 @@ export function SphericalImage({
|
|
| 14 |
className?: string
|
| 15 |
debug?: boolean
|
| 16 |
}) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
if (!rendered.assetUrl) {
|
| 19 |
return null
|
|
@@ -22,30 +78,15 @@ export function SphericalImage({
|
|
| 22 |
return (
|
| 23 |
<ReactPhotoSphereViewer
|
| 24 |
src={rendered.assetUrl}
|
| 25 |
-
|
| 26 |
container=""
|
| 27 |
containerClass={className}
|
| 28 |
//
|
| 29 |
height="100vh"
|
| 30 |
width="100%"
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
overlay={rendered.maskUrl || undefined}
|
| 35 |
-
overlayOpacity={debug ? 0.5 : 0}
|
| 36 |
-
|
| 37 |
-
panoData={{
|
| 38 |
-
fullWidth: 1300,
|
| 39 |
-
fullHeight: 700,
|
| 40 |
-
croppedWidth: 1024,
|
| 41 |
-
croppedHeight: 512,
|
| 42 |
-
croppedX: 0,
|
| 43 |
-
croppedY: 120,
|
| 44 |
-
// poseHeading: 0, // 0 to 360
|
| 45 |
-
posePitch: 0, // -90 to 90
|
| 46 |
-
// poseRoll: 0, // -180 to 180
|
| 47 |
-
}}
|
| 48 |
-
|
| 49 |
onClick={(data, instance) => {
|
| 50 |
console.log("on click:")
|
| 51 |
const position = data.target.getPosition()
|
|
|
|
| 2 |
|
| 3 |
import { SceneEventHandler } from "./types"
|
| 4 |
import { RenderedScene } from "@/app/types"
|
| 5 |
+
import { useEffect, useRef, useState } from "react"
|
| 6 |
|
| 7 |
export function SphericalImage({
|
| 8 |
rendered,
|
|
|
|
| 15 |
className?: string
|
| 16 |
debug?: boolean
|
| 17 |
}) {
|
| 18 |
+
const sceneConfig = JSON.stringify({ rendered, debug })
|
| 19 |
+
const [lastSceneConfig, setLastSceneConfig] = useState<string>(sceneConfig)
|
| 20 |
+
const ref = useRef<{
|
| 21 |
+
needsUpdate: () => void
|
| 22 |
+
setPanorama: (src: string, options: Record<string, any>) => Promise<void>
|
| 23 |
+
setOptions: (options: Record<string, any>) => void
|
| 24 |
+
}>(null)
|
| 25 |
+
|
| 26 |
+
const options = {
|
| 27 |
+
defaultZoomLvl: 1,
|
| 28 |
+
overlay: rendered.maskUrl || undefined,
|
| 29 |
+
overlayOpacity: debug ? 0.5 : 0,
|
| 30 |
+
/*
|
| 31 |
+
panoData: {
|
| 32 |
+
fullWidth: 2000,
|
| 33 |
+
fullHeight: 1200,
|
| 34 |
+
croppedWidth: 1024,
|
| 35 |
+
croppedHeight: 512,
|
| 36 |
+
croppedX: 0,
|
| 37 |
+
croppedY: 200,
|
| 38 |
+
// poseHeading: 0, // 0 to 360
|
| 39 |
+
posePitch: 0, // -90 to 90
|
| 40 |
+
// poseRoll: 0, // -180 to 180
|
| 41 |
+
}
|
| 42 |
+
*/
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
useEffect(() => {
|
| 46 |
+
const task = async () => {
|
| 47 |
+
// console.log("SphericalImage: useEffect")
|
| 48 |
+
if (sceneConfig !== lastSceneConfig) {
|
| 49 |
+
// console.log("SphericalImage: scene config changed!")
|
| 50 |
+
|
| 51 |
+
if (!ref.current) {
|
| 52 |
+
// console.log("SphericalImage: no ref!")
|
| 53 |
+
setLastSceneConfig(sceneConfig)
|
| 54 |
+
return
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
// console.log("SphericalImage: calling setOptions")
|
| 58 |
+
// console.log("SphericalImage: changing the panorama to: " + rendered.assetUrl.slice(0, 120))
|
| 59 |
+
|
| 60 |
+
await ref.current.setPanorama(rendered.assetUrl, {
|
| 61 |
+
...options,
|
| 62 |
+
showLoader: false,
|
| 63 |
+
})
|
| 64 |
+
ref.current.setOptions(options)
|
| 65 |
+
// console.log("SphericalImage: asking to re-render")
|
| 66 |
+
ref.current.needsUpdate()
|
| 67 |
+
|
| 68 |
+
setLastSceneConfig(sceneConfig)
|
| 69 |
+
}
|
| 70 |
+
}
|
| 71 |
+
task()
|
| 72 |
+
}, [sceneConfig, rendered.assetUrl, ref.current])
|
| 73 |
|
| 74 |
if (!rendered.assetUrl) {
|
| 75 |
return null
|
|
|
|
| 78 |
return (
|
| 79 |
<ReactPhotoSphereViewer
|
| 80 |
src={rendered.assetUrl}
|
| 81 |
+
ref={ref}
|
| 82 |
container=""
|
| 83 |
containerClass={className}
|
| 84 |
//
|
| 85 |
height="100vh"
|
| 86 |
width="100%"
|
| 87 |
|
| 88 |
+
{...options}
|
| 89 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
onClick={(data, instance) => {
|
| 91 |
console.log("on click:")
|
| 92 |
const position = data.target.getPosition()
|