scene introduction
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user