scene introduction

This commit is contained in:
2025-11-08 11:51:15 +02:00
parent 49dc4e9f7c
commit 168fb5b770
9 changed files with 46 additions and 30 deletions
@@ -22,13 +22,12 @@ const InteractiveObjectsImports = {
class InteractiveObject {
constructor(gameEngine, obj) {
this.name = obj.name;
this.ready = new Promise(async (resolve, reject) => {
return new Promise(async (resolve, reject) => {
switch (obj.type || 'GenericObject') {
case 'Group':
this.object = new Group();
for (let g of obj.group){
let go = new InteractiveObject(gameEngine, g);
let gameMesh = await go.ready;
let gameMesh = await new InteractiveObject(gameEngine, g);
this.object.add(gameMesh.object);
}
break;
@@ -78,9 +77,8 @@ class InteractiveObject {
this.object.game = game;
break;
case 'VideoPlayer':
let vp = new VideoPlayer(gameEngine, gameEngine.assetPath + obj.$go.asset.name);
this.source = await vp.ready;
this.object = vp.object;
this.source = await new VideoPlayer(gameEngine, obj.$go.asset.name, gameEngine.assetPath);
this.object = this.source.object;
break;
case 'PuzzleGame1':
case 'PuzzleGame2':
@@ -110,8 +110,7 @@ class MazeObject {
//console.log('loadingggg', def.objects)
def.objects?.forEach(async obj => {
obj.room = room;
let go = new InteractiveObject(engine, obj)
await go.ready;
let go = await new InteractiveObject(engine, obj)
go.object.scale.multiplyScalar(wallSize)
go.object.position.multiplyScalar(wallSize)
go.object.applyMatrix4(def.matrix);
@@ -4,7 +4,6 @@ import { assignParams } from "@/lib/MeshUtils";
class TextObject {
constructor(engine, obj) {
console.log('OBJ', obj)
const txt = new Text();
// Set properties to configure:
txt.text = obj.text;
@@ -2,12 +2,11 @@ import * as THREE from 'three';
class VideoPlayer {
constructor(engine, src){
let vi, plane, data;
this.ready = new Promise((resolve, reject)=>{
constructor(engine, src, path = ''){
let vi, plane;
return new Promise((resolve, reject)=>{
vi = document.createElement('video');
vi.src = src;
vi.src = path + src;
vi.addEventListener('loadedmetadata', ()=>{
this.aspect = vi.videoWidth / vi.videoHeight;
let geometry = new THREE.PlaneGeometry( this.aspect, 1 );
@@ -23,23 +22,27 @@ class VideoPlayer {
plane = new THREE.Mesh( geometry, material );
this.object = plane;
engine.clickable.add(plane, ()=>{
material.opacity = 1
if (vi.paused){
vi.play();
}else{
vi.pause();
}
});
vi.addEventListener('play', ()=>{
material.opacity = 1
if (engine.dashboard?.active){
engine.dashboard.attach(plane);
}
})
vi.addEventListener('pause', ()=>{
material.opacity = 0.5;
engine.dashboard?.detach(plane);
})
this.video = vi;
resolve(this);
})
vi.addEventListener('play', ()=>{
if (engine.dashboard?.active){
engine.dashboard.attach(plane);
}
})
vi.addEventListener('pause', ()=>{
engine.dashboard?.detach(plane);
})
})
}
}
@@ -5,7 +5,7 @@
<div class="text-caption text-center">{{ modelValue.title }}</div>
</v-card-item>
</v-card>
<asset-selector @select="assignVideoObject" :type="['Descriptive']">
<asset-selector @select="assignVideoObject" :type="['Video']">
<template v-slot:activator="props">
<v-btn v-bind="props" prepend-icon="mdi-video-box" color="deep-orange-darken-4" block>Choose video object</v-btn>
</template>
+10
View File
@@ -23,6 +23,13 @@
</template>
</asset-selector>
<v-img v-if="modelValue.intro" :src="`/asset/thumb/${modelValue.intro}.webp`" />
<asset-selector @select="assignIntro" :type="['Video']">
<template v-slot:activator="props">
<v-btn v-bind="props" prepend-icon="mdi-filmstrip" block color="deep-orange-darken-4" class="my-4">Select introduction</v-btn>
</template>
</asset-selector>
<v-form class="py-4">
<v-text-field density="compact" :label="l.name" v-model="modelValue.title"></v-text-field>
<v-textarea :label="l.description" v-model="modelValue.description"></v-textarea>
@@ -78,6 +85,9 @@ export default {
this.modelValue.title = e.name
}
},
assignIntro(e){
this.modelValue.intro = e.id;
},
}
}
</script>
+1 -1
View File
@@ -11,7 +11,7 @@
</g>
</teleport>
<v-card v-if="selected" :title="modelValue.title" class="mx-2" variant="text">
<asset-selector @select="assignTaskIntro" :type="['Descriptive']">
<asset-selector @select="assignTaskIntro" :type="['Video']">
<template v-slot:activator="props">
<v-btn v-bind="props" prepend-icon="mdi-panorama-outline" color="success" block>Choose task description</v-btn>
</template>