refactoring
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
//for now this will be dummy
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -1,7 +1,4 @@
|
||||
//import { Hint } from "./Hint";
|
||||
import { Group, AnimationMixer, LoopPingPong, Vector3 } from "three";
|
||||
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";
|
||||
import { assignMaterial, assignParams } from "@/lib/MeshUtils";
|
||||
import { Group } from "three";
|
||||
import { PuzzleGame1 } from "./PuzzleGame1";
|
||||
import { PuzzleGame2 } from "./PuzzleGame2";
|
||||
// import { Game3 } from "./games/Game3";
|
||||
@@ -19,8 +16,8 @@ class InteractiveObject {
|
||||
this.name = obj.name;
|
||||
this.ready = new Promise((resolve, reject) => {
|
||||
let mesh;
|
||||
switch (obj.id) {
|
||||
case 'group':
|
||||
switch (obj.type || 'GenericObject') {
|
||||
case 'Group':
|
||||
mesh = new Group();
|
||||
obj.group.forEach(g => {
|
||||
let go = new InteractiveObject(g, context);
|
||||
@@ -30,51 +27,18 @@ class InteractiveObject {
|
||||
});
|
||||
resolve(mesh);
|
||||
break;
|
||||
case 'text':
|
||||
case 'Text':
|
||||
let text = new TextObject(obj, context);
|
||||
resolve(text.object);
|
||||
break;
|
||||
case 'mesh':
|
||||
mesh = obj.value;
|
||||
resolve(mesh);
|
||||
break;
|
||||
case 'image':
|
||||
case 'Image':
|
||||
let imo = new ImageObject(obj, context);
|
||||
mesh = imo.object;
|
||||
resolve(mesh);
|
||||
break;
|
||||
case 'hint':
|
||||
let hint = new Hint(obj, context);
|
||||
mesh = hint.object;
|
||||
resolve(mesh);
|
||||
break;
|
||||
case 'gltf':
|
||||
//console.log('loadingg', obj.value)
|
||||
new GLTFLoader().load(obj.value, (gltf) => {
|
||||
let gltfObj = gltf.scene;
|
||||
gltf.scene.traverse(function (object) {
|
||||
object.frustumCulled = false;
|
||||
if (obj.name && obj.name == object.name) {
|
||||
gltfObj = object;
|
||||
}
|
||||
// object.castShadow = true;
|
||||
// object.receiveShadow = true;
|
||||
});
|
||||
assignMaterial(gltfObj, obj, context);
|
||||
if (gltf.animations && gltf.animations.length) {
|
||||
let mixer = new AnimationMixer(gltfObj);
|
||||
context.mixers.push(mixer);
|
||||
let action = mixer.clipAction(gltf.animations[0]);
|
||||
action.setLoop(LoopPingPong);
|
||||
action.play();
|
||||
}
|
||||
resolve(gltfObj);
|
||||
});
|
||||
break;
|
||||
case 'asset':
|
||||
mesh = context.assets[obj.value].clone();
|
||||
assignMaterial(mesh, obj, context);
|
||||
resolve(mesh);
|
||||
case 'GenericObject':
|
||||
let promise = context.load(`/asset/default/${obj.$go.asset.name}`);
|
||||
promise.then(resolve);
|
||||
break;
|
||||
case 'PuzzleGame1':
|
||||
case 'PuzzleGame2':
|
||||
@@ -94,41 +58,6 @@ class InteractiveObject {
|
||||
}
|
||||
});
|
||||
this.ready.then((mesh) => {
|
||||
mesh.go = {};
|
||||
// let restriction;
|
||||
// if (!context.disableRestrictions && obj.restriction) {
|
||||
// restriction = {
|
||||
// type: 'deny',
|
||||
// a: [obj.room.localToWorld(new Vector3().fromArray(obj.restriction[0])), obj.room.localToWorld(new Vector3().fromArray(obj.restriction[1]))]
|
||||
// };
|
||||
// context.areas.push(restriction);
|
||||
// }
|
||||
mesh.go.finish = () => {
|
||||
if (obj.finish) {
|
||||
var f;
|
||||
if (obj.finish.nextAction) {
|
||||
var next = obj.finish.nextAction;
|
||||
delete obj.finish.nextAction;
|
||||
f = () => {
|
||||
if (next.activate) {
|
||||
context.activate(next.activate);
|
||||
}
|
||||
};
|
||||
}
|
||||
var me = obj.finish._ || {};
|
||||
delete obj.finish._;
|
||||
context.motionEngine.add({ o: mesh, a: obj.finish, t: me.t || 1, f: me.f || f, d: me.d || 0 });
|
||||
}
|
||||
if (restriction) context.areas.splice(context.areas.indexOf(restriction), 1);
|
||||
};
|
||||
if (mesh.object) mesh.object.onfinish = mesh.go.finish;
|
||||
assignParams(mesh, obj);
|
||||
obj.animation && context.motionEngine.add({
|
||||
o: mesh,
|
||||
a: obj.animation.motion,
|
||||
r: obj.animation.repeat,
|
||||
t: obj.animation.duration || 1
|
||||
});
|
||||
this.object = mesh;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class VideoPlayer {
|
||||
vi.pause();
|
||||
}
|
||||
});
|
||||
resolve(plane);
|
||||
resolve(this);
|
||||
})
|
||||
vi.addEventListener('play', ()=>{
|
||||
if (context.dashboard?.active){
|
||||
@@ -48,7 +48,7 @@ class VideoPlayer {
|
||||
scale: plane.scale.clone()
|
||||
}
|
||||
}
|
||||
console.log(data.location)
|
||||
//console.log(data.location)
|
||||
context.dashboard.group.attach(plane);
|
||||
//plane.applyMatrix4(m.invert())
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<template>
|
||||
<asset-selector @select="assignVideoObject" :type="['Descriptive']">
|
||||
<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>
|
||||
</asset-selector>
|
||||
<v-card v-if="modelValue.go">
|
||||
<v-card-item>
|
||||
<v-img :src="`/asset/thumb/${modelValue.go}.webp`" />
|
||||
<div class="text-caption text-center">{{ modelValue.title }}</div>
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
<asset-selector @select="assignVideoObject" :type="['Descriptive']">
|
||||
<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>
|
||||
</asset-selector>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
</v-form>
|
||||
</v-card>
|
||||
|
||||
<v-container v-if="selected && modelValue.io">
|
||||
<component :is="modelValue.io.id" v-model="modelValue.io"></component>
|
||||
<v-container v-if="selected && modelValue.type">
|
||||
<component :is="modelValue.type" v-model="mv"></component>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
@@ -35,10 +35,11 @@ import Utils from '@/lib/Utils';
|
||||
import VideoPlayer from '../InteractiveObjects/VideoPlayer.vue';
|
||||
import PuzzleGame1 from '../InteractiveObjects/PuzzleGame1.vue';
|
||||
import MazeQuizGame from '../InteractiveObjects/MazeQuizGame/MazeQuizGame.vue';
|
||||
import GenericObject from '../InteractiveObjects/GenericObject.vue';
|
||||
|
||||
export default {
|
||||
emits:['target', 'preview'],
|
||||
components: { SvgIcon, VideoPlayer, PuzzleGame1, MazeQuizGame },
|
||||
components: { SvgIcon, VideoPlayer, PuzzleGame1, MazeQuizGame, GenericObject },
|
||||
data(){
|
||||
return {
|
||||
active: false
|
||||
@@ -60,6 +61,9 @@ export default {
|
||||
showInView(){
|
||||
this.vd.__showInView = this.visible && this.parent.visible;
|
||||
return this.vd.__showInView;
|
||||
},
|
||||
mv(){
|
||||
return this.modelValue
|
||||
}
|
||||
},
|
||||
steps: [['x1', 'y1']],
|
||||
@@ -76,9 +80,9 @@ export default {
|
||||
delete this.modelValue.io;
|
||||
}
|
||||
if (e.type == 'InteractiveObject'){
|
||||
this.modelValue.io = {
|
||||
id: e.id
|
||||
};
|
||||
this.modelValue.type = e.id;
|
||||
}else{
|
||||
this.modelValue.type = 'Object3D'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user