Riddle 7
This commit is contained in:
1 parent
c56377406b
commit
f4fdd6cac4
2 files changed
+85
-115
No files matched your search
@@ -27,39 +27,37 @@ export default function Riddle_7_AR_View() {
|
|||||||
const arSystem = sceneEl.systems['mindar-image-system'];
|
const arSystem = sceneEl.systems['mindar-image-system'];
|
||||||
|
|
||||||
sceneEl.addEventListener('renderstart', () => {
|
sceneEl.addEventListener('renderstart', () => {
|
||||||
arSystem.start();
|
arSystem.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Attach target tracking listeners for each target entity
|
|
||||||
targetsRef.current.forEach((targetEl, index) => {
|
targetsRef.current.forEach((targetEl, index) => {
|
||||||
if (!targetEl) return;
|
if (!targetEl) return;
|
||||||
|
|
||||||
const videoEl = videosRef.current[index];
|
const videoEl = videosRef.current[index];
|
||||||
|
|
||||||
const handleTargetFound = () => {
|
const handleTargetFound = () => {
|
||||||
if (videoEl) {
|
if (videoEl) {
|
||||||
// Reset video if lost for > 10 seconds
|
const lostTime = lostTimesRef.current[index];
|
||||||
const lostTime = lostTimesRef.current[index];
|
if (lostTime && Date.now() - lostTime > 10000) {
|
||||||
if (lostTime && Date.now() - lostTime > 10000) {
|
videoEl.currentTime = 0;
|
||||||
videoEl.currentTime = 0;
|
}
|
||||||
}
|
lostTimesRef.current[index] = null;
|
||||||
lostTimesRef.current[index] = null;
|
|
||||||
|
|
||||||
videoEl.play().catch((err) => {
|
videoEl.play().catch((err) => {
|
||||||
console.log(`Autoplay blocked on target ${index}:`, err);
|
console.log(`Autoplay blocked on target ${index}:`, err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTargetLost = () => {
|
const handleTargetLost = () => {
|
||||||
if (videoEl) {
|
if (videoEl) {
|
||||||
videoEl.pause();
|
videoEl.pause();
|
||||||
lostTimesRef.current[index] = Date.now();
|
lostTimesRef.current[index] = Date.now();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
targetEl.addEventListener('targetFound', handleTargetFound);
|
targetEl.addEventListener('targetFound', handleTargetFound);
|
||||||
targetEl.addEventListener('targetLost', handleTargetLost);
|
targetEl.addEventListener('targetLost', handleTargetLost);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -70,9 +68,8 @@ export default function Riddle_7_AR_View() {
|
|||||||
console.warn('MindAR stopped after DOM teardown:', error);
|
console.warn('MindAR stopped after DOM teardown:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}, []);
|
}}, []);
|
||||||
|
|
||||||
// Set width dynamically based on video aspect ratio
|
|
||||||
const handleLoadedMetadata = (index, videoEl) => {
|
const handleLoadedMetadata = (index, videoEl) => {
|
||||||
if (videoEl) {
|
if (videoEl) {
|
||||||
const aspect = videoEl.videoWidth / videoEl.videoHeight;
|
const aspect = videoEl.videoWidth / videoEl.videoHeight;
|
||||||
@@ -86,19 +83,6 @@ export default function Riddle_7_AR_View() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// User interaction handler to unlock web audio context on mobile devices
|
|
||||||
const handleUserStart = () => {
|
|
||||||
setHasInteracted(true);
|
|
||||||
Object.values(videosRef.current).forEach((videoEl) => {
|
|
||||||
if (videoEl) {
|
|
||||||
videoEl
|
|
||||||
.play()
|
|
||||||
.then(() => videoEl.pause())
|
|
||||||
.catch((err) => console.log('Audio unlock error:', err));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
@@ -111,82 +95,59 @@ export default function Riddle_7_AR_View() {
|
|||||||
backgroundColor: '#000',
|
backgroundColor: '#000',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!hasInteracted && (
|
|
||||||
<button
|
<a-scene
|
||||||
onClick={handleUserStart}
|
ref={sceneRef}
|
||||||
style={{
|
mindar-image="imageTargetSrc: /res/tour/riddle_7/targets.mind; autoStart: false; uiLoading: no; uiError: no; uiScanning: no; filterMinCF: 0.0001; filterBeta: 0.001;"
|
||||||
position: 'absolute',
|
color-space="sRGB"
|
||||||
zIndex: 9999,
|
embedded
|
||||||
top: '50%',
|
renderer="colorManagement: true, physicallyCorrectLights; antialias: true"
|
||||||
left: '50%',
|
vr-mode-ui="enabled: false"
|
||||||
transform: 'translate(-50%, -50%)',
|
device-orientation-permission-ui="enabled: false"
|
||||||
padding: '14px 28px',
|
style={{ width: '100%', height: '100%' }}
|
||||||
fontSize: '16px',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
backgroundColor: '#007bff',
|
|
||||||
color: '#fff',
|
|
||||||
border: 'none',
|
|
||||||
borderRadius: '8px',
|
|
||||||
boxShadow: '0 4px 12px rgba(0,0,0,0.3)',
|
|
||||||
cursor: 'pointer',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Tap to Start AR with Audio
|
<a-assets>
|
||||||
</button>
|
{TARGET_CONFIG.map((target) => (
|
||||||
)}
|
<video
|
||||||
|
key={target.videoId}
|
||||||
|
id={target.videoId}
|
||||||
|
ref={(el) => (videosRef.current[target.targetIndex] = el)}
|
||||||
|
src={target.videoSrc}
|
||||||
|
preload="auto"
|
||||||
|
loop
|
||||||
|
crossOrigin="anonymous"
|
||||||
|
playsInline
|
||||||
|
onLoadedMetadata={(e) =>
|
||||||
|
handleLoadedMetadata(target.targetIndex, e.target)
|
||||||
|
}
|
||||||
|
></video>
|
||||||
|
))}
|
||||||
|
</a-assets>
|
||||||
|
|
||||||
<a-scene
|
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
|
||||||
ref={sceneRef}
|
|
||||||
mindar-image="imageTargetSrc: /res/tour/riddle_7/targets.mind; autoStart: false; uiLoading: no; uiError: no; uiScanning: no; filterMinCF: 0.0001; filterBeta: 0.001;"
|
|
||||||
color-space="sRGB"
|
|
||||||
embedded
|
|
||||||
renderer="colorManagement: true, physicallyCorrectLights; antialias: true"
|
|
||||||
vr-mode-ui="enabled: false"
|
|
||||||
device-orientation-permission-ui="enabled: false"
|
|
||||||
style={{ width: '100%', height: '100%' }}
|
|
||||||
>
|
|
||||||
<a-assets>
|
|
||||||
{TARGET_CONFIG.map((target) => (
|
|
||||||
<video
|
|
||||||
key={target.videoId}
|
|
||||||
id={target.videoId}
|
|
||||||
ref={(el) => (videosRef.current[target.targetIndex] = el)}
|
|
||||||
src={target.videoSrc}
|
|
||||||
preload="auto"
|
|
||||||
loop
|
|
||||||
crossOrigin="anonymous"
|
|
||||||
playsInline
|
|
||||||
onLoadedMetadata={(e) =>
|
|
||||||
handleLoadedMetadata(target.targetIndex, e.target)
|
|
||||||
}
|
|
||||||
></video>
|
|
||||||
))}
|
|
||||||
</a-assets>
|
|
||||||
|
|
||||||
<a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
|
{TARGET_CONFIG.map((target) => {
|
||||||
|
const dims = videoDimensions[target.targetIndex] || {
|
||||||
{TARGET_CONFIG.map((target) => {
|
width: 1,
|
||||||
const dims = videoDimensions[target.targetIndex] || {
|
height: TARGET_HEIGHT,
|
||||||
width: 1,
|
};
|
||||||
height: TARGET_HEIGHT,
|
return (
|
||||||
};
|
<a-entity
|
||||||
return (
|
key={target.targetIndex}
|
||||||
<a-entity
|
ref={(el) => (targetsRef.current[target.targetIndex] = el)}
|
||||||
key={target.targetIndex}
|
mindar-image-target={`targetIndex: ${target.targetIndex}`}
|
||||||
ref={(el) => (targetsRef.current[target.targetIndex] = el)}
|
>
|
||||||
mindar-image-target={`targetIndex: ${target.targetIndex}`}
|
<a-video
|
||||||
>
|
src={`#${target.videoId}`}
|
||||||
<a-video
|
width={dims.width}
|
||||||
src={`#${target.videoId}`}
|
height={dims.height}
|
||||||
width={dims.width}
|
position="0 0 0"
|
||||||
height={dims.height}
|
rotation="0 0 0"
|
||||||
position="0 0 0"
|
></a-video>
|
||||||
rotation="0 0 0"
|
</a-entity>
|
||||||
></a-video>
|
);
|
||||||
</a-entity>
|
})}
|
||||||
);
|
</a-scene>
|
||||||
})}
|
|
||||||
</a-scene>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -7,6 +7,7 @@ import { RiddleScreenControls } from "../RiddleScreen";
|
|||||||
import SelectionButton from "../SelectionButton";
|
import SelectionButton from "../SelectionButton";
|
||||||
import extraStyles from "@/components/riddles-css/Riddle_7.module.css";
|
import extraStyles from "@/components/riddles-css/Riddle_7.module.css";
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
|
import RiddleCompleteBanner from "../RiddleCompleteBanner";
|
||||||
|
|
||||||
const Riddle_7_AR_View = dynamic(
|
const Riddle_7_AR_View = dynamic(
|
||||||
() => import('../Riddle_7_AR_View'),
|
() => import('../Riddle_7_AR_View'),
|
||||||
@@ -101,7 +102,11 @@ export default function Riddle_7({
|
|||||||
(
|
(
|
||||||
<div key={4}>
|
<div key={4}>
|
||||||
<div className={styles["content"]}>
|
<div className={styles["content"]}>
|
||||||
<p>Richtig</p>
|
<RiddleCompleteBanner points={1000} win={true}></RiddleCompleteBanner>
|
||||||
|
<p>Euer Urteil ist gesprochen. Für einen Augenblick herrscht Stille, dann richtet sich Lancelots Blick auf den Mann, den ihr beschuldigt habt: Edmund, den Schreiber.</p>
|
||||||
|
<p>Noch einmal werden seine Worte mit den Spuren am Tatort verglichen – mit dem Blut an der aufgebrochenen Schatulle, den übrigen Beweisen und seiner eigenen Aussage. Schließlich bleibt kein Zweifel mehr: Edmund hat Sir Lancelots Siegelring gestohlen.</p>
|
||||||
|
<p>Ihr habt euch weder von Vermutungen noch vom ersten Eindruck leiten lassen, sondern zugehört, die Spuren geprüft und erst dann euer Urteil gefällt. Sir Lancelot nimmt seinen Ring wieder an sich.</p>
|
||||||
|
<p>„Ein Schwert zu führen ist leicht“, sagt er. „Gerecht über Menschen zu richten, ist weitaus schwerer.“ Sein Misstrauen ist nicht verschwunden, doch ihr habt euch seinen Respekt verdient, und Lancelot ist bereit, sich dem neuen Bund der Tafelrunde anzuschließen.</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["buttons"]}>
|
<div className={styles["buttons"]}>
|
||||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||||
@@ -111,7 +116,11 @@ export default function Riddle_7({
|
|||||||
(
|
(
|
||||||
<div key={5}>
|
<div key={5}>
|
||||||
<div className={styles["content"]}>
|
<div className={styles["content"]}>
|
||||||
<p>Falsch</p>
|
<RiddleCompleteBanner points={100} win={false}></RiddleCompleteBanner>
|
||||||
|
<p>Euer Urteil ist gesprochen, doch Lancelot schweigt. Er legt die Beweise noch einmal vor euch: den trockenen Boden, das Blut an der aufgebrochenen Schatulle und die Aussagen von Mara, Oswin, Sir Garrick und Edmund.</p>
|
||||||
|
<p>Nun erkennt ihr, was euch entgangen ist. Ihr habt den Falschen beschuldigt; der wahre Dieb war Edmund, der Schreiber, und seine Aussage hätte ihn zusammen mit den Spuren am Tatort überführen können.</p>
|
||||||
|
<p>Lancelots Miene verhärtet sich. „Genau deshalb darf ein Herrscher niemals urteilen, bevor er alle Spuren verstanden hat.“ Edmund wird abgeführt und der Siegelring kehrt zu seinem Besitzer zurück, doch euer Fehlurteil bleibt nicht ohne Folgen.</p>
|
||||||
|
<p>Ein Unschuldiger stand durch eure Entscheidung unter falschem Verdacht, und solche Fehler sprechen sich herum. Euer Ruf leidet darunter. Lancelot wird euren weiteren Weg dennoch beobachten; ob ihr sein Vertrauen vollständig zurückgewinnen könnt, müssen eure nächsten Taten zeigen.</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={styles["buttons"]}>
|
<div className={styles["buttons"]}>
|
||||||
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
<OldButton red={false} disabled={false} onAction={() => exitFunction()}>ZURÜCK ZUR KARTE</OldButton>
|
||||||
|
|||||||
Reference in new issue
Block a user