Cleaned up intro/demo.

This commit is contained in:
Michael Mainguy 2023-09-25 13:59:59 -05:00
parent 3580cf2559
commit 4f71fcefbd
2 changed files with 25 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import workerUrl from "./worker?worker&url";
import {DiagramEventType} from "./diagram/diagramEntity"; import {DiagramEventType} from "./diagram/diagramEntity";
import {PeerjsNetworkConnection} from "./integration/peerjsNetworkConnection"; import {PeerjsNetworkConnection} from "./integration/peerjsNetworkConnection";
import {DiagramExporter} from "./util/diagramExporter"; import {DiagramExporter} from "./util/diagramExporter";
import {Introduction} from "./tutorial/introduction";
export class App { export class App {
@ -76,6 +77,7 @@ export class App {
}, 2); }, 2);
config.onConfigChangedObservable.add((config) => { config.onConfigChangedObservable.add((config) => {
this.logger.debug('App', 'config changed', config); this.logger.debug('App', 'config changed', config);
worker.postMessage({config: config}); worker.postMessage({config: config});
}, 2); }, 2);
worker.onmessage = (evt) => { worker.onmessage = (evt) => {
@ -95,6 +97,10 @@ export class App {
if (evt.data.config) { if (evt.data.config) {
config.onConfigChangedObservable.notifyObservers(evt.data.config, 1); config.onConfigChangedObservable.notifyObservers(evt.data.config, 1);
if (!evt.data.config.demoCompleted) {
const intro = new Introduction(scene, config);
//intro.start();
}
} }
} }

View File

@ -28,12 +28,21 @@ export class Introduction {
private sounds: DiaSounds; private sounds: DiaSounds;
private config: AppConfig; private config: AppConfig;
private videoElement: HTMLVideoElement;
constructor(scene: Scene, config: AppConfig) { constructor(scene: Scene, config: AppConfig) {
this.sounds = new DiaSounds(scene); this.sounds = new DiaSounds(scene);
this.scene = scene; this.scene = scene;
this.config = config; this.config = config;
this.manager = new GUI3DManager(scene); this.manager = new GUI3DManager(scene);
this.physicsHelper = new PhysicsHelper(scene); this.physicsHelper = new PhysicsHelper(scene);
this.scene.onReadyObservable.add(() => {
setTimeout((s) => {
s.start()
}, 2000, this);
});
} }
public start() { public start() {
@ -50,8 +59,9 @@ export class Introduction {
}, -1, false, this, false); }, -1, false, this, false);
this.manager.addControl(this.advance); this.manager.addControl(this.advance);
this.advance.isVisible = false; this.advance.isVisible = false;
this.advance.position.y = 0; this.advance.position.y = .5;
this.advance.position.x = 2; this.advance.position.x = -2;
this.advance.position.z = -1;
this.scene.onReadyObservable.add(() => { this.scene.onReadyObservable.add(() => {
this.advance.isVisible = true; this.advance.isVisible = true;
}); });
@ -59,6 +69,7 @@ export class Introduction {
buildVideo(src: string, size: number, position: Vector3): AbstractMesh { buildVideo(src: string, size: number, position: Vector3): AbstractMesh {
const vid = document.createElement("video"); const vid = document.createElement("video");
this.videoElement = vid;
vid.setAttribute('autoplay', 'true'); vid.setAttribute('autoplay', 'true');
vid.setAttribute('playsinline', 'true'); vid.setAttribute('playsinline', 'true');
@ -148,7 +159,7 @@ export class Introduction {
this.current = this.items.slice(-2); this.current = this.items.slice(-2);
break; break;
case 1: case 1:
this.items.push(this.buildText("Let us show you", 3, 1024, new Vector3(-1.5, 16, 5))); this.items.push(this.buildText("Let us show you", 3, 1024, new Vector3(-1.6, 16, 5)));
this.items.push(this.buildText("what you can build", 4, 1200, new Vector3(2, 12, 5))); this.items.push(this.buildText("what you can build", 4, 1200, new Vector3(2, 12, 5)));
this.current = this.items.slice(-2); this.current = this.items.slice(-2);
break; break;
@ -173,6 +184,11 @@ export class Introduction {
config.demoCompleted = true; config.demoCompleted = true;
this.config.current = config; this.config.current = config;
this.items = []; this.items = [];
if (this.videoElement) {
this.videoElement.pause();
this.videoElement.remove();
this.videoElement = null;
}
} }
this.step++; this.step++;