Skip to content

案例展示

在场景中添加视频面板

<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添加视频面板

参数说明:

参数名类型是否必选描述
domHTMLVideoElementvideo 标签
modelInfomodelInfoParams模型参数