案例展示
在场景中添加视频面板
<template>
<div id="TO"></div>
</template>
<script setup>
import { onMounted } from 'vue';
onMounted(() => {
const TO = new ThingOrigin(
'videoTest',
document.getElementById('TO'),
{
helper: {
axes: {
active: false,
},
grid: {
active: false,
},
},
}
);
const videoElement = document.createElement('video');
// 动态获取基础路径并设置视频源
videoElement.src = `${import.meta.env.BASE_URL}video/weld.mp4`;
videoElement.autoplay = true;
videoElement.loop = true;
const video = TO.model.initVideoPlane(
videoElement,
{
modelName: "videoPlane-" + new Date().getTime(),
base: {
width: 250,
height: 200,
},
position: {
x: 1,
y: 1,
z: 1,
},
scale: {
x: 1.2,
y: 1,
z: 1,
},
rotation: {
x: -0.4,
y: 0,
z: 0,
},
}
);
TO.scene.add(video);
});
</script>
<style scoped>
#TO {
width: 100%;
height: 400px;
position: relative;
}
</style>
API 介绍
model.initVideoPlane
方法签名 | 返回值 | 描述 |
---|---|---|
initVideoPlane(dom: HTMLVideoElement, modelInfo?: modelInfoParams) | Object3D | 添加视频面板 |
参数说明:
参数名 | 类型 | 是否必选 | 描述 |
---|---|---|---|
dom | HTMLVideoElement | 是 | video 标签 |
modelInfo | modelInfoParams | 否 | 模型参数 |