forked from Orillusion/orillusion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSample_UIVideo.ts
41 lines (31 loc) · 1.32 KB
/
Sample_UIVideo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { GUIHelp } from "@orillusion/debug/GUIHelp";
import { VideoTexture } from "@orillusion/media-extention";
import { createExampleScene } from "@samples/utils/ExampleScene";
import { Engine3D, Object3DUtil, Object3D, ViewPanel, UIImage, ImageType, makeAloneSprite } from "@orillusion/core";
export class Sample_UIVideo {
async run() {
Engine3D.setting.shadow.autoUpdate = true;
GUIHelp.init();
await Engine3D.init();
let exampleScene = createExampleScene();
Engine3D.startRenderView(exampleScene.view);
// create floor
let floor = Object3DUtil.GetSingleCube(100, 10, 50, 0.5, 0.5, 0.5);
exampleScene.scene.addChild(floor);
let canvas = exampleScene.view.enableUICanvas();
let videoTexture = new VideoTexture();
await videoTexture.load('/video/dt.mp4');
//create UI root
let panelRoot: Object3D = new Object3D();
panelRoot.addComponent(ViewPanel);
canvas.addChild(panelRoot);
{
let imageQuad = new Object3D();
panelRoot.addChild(imageQuad);
let image = imageQuad.addComponent(UIImage);
image.sprite = makeAloneSprite('dt.mp4', videoTexture);
image.imageType = ImageType.Simple;
image.uiTransform.resize(600, 400);
}
}
}