Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to make VideoTexture? #82

Closed
siz0001 opened this issue Aug 30, 2021 · 3 comments
Closed

how to make VideoTexture? #82

siz0001 opened this issue Aug 30, 2021 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@siz0001
Copy link

siz0001 commented Aug 30, 2021

Hi!
There are no VideoTexture props in Trois.
Can you add it? 😀

@oneWaveAdrian
Copy link

oneWaveAdrian commented Aug 30, 2021

Do it the same way as in ThreeJS:

HTML

<video
          ref="aboutvideo"
          controls
          src="/assets/videos/about.mp4?url"
          muted
          autoplay
          loop
        />

[...]

<Plane>
              <LambertMaterial ref="aboutscreen" color="#fff" />
</Plane>

JS

import {VideoTexture} from 'three' 

[...]

const vidtex = new VideoTexture(this.$refs.aboutvideo)
this.$refs.aboutscreen.setTexture(vidtex)

@siz0001
Copy link
Author

siz0001 commented Aug 30, 2021

thank you for your prompt reply, and is it right? 😂😂

<template>
  <div>
    <video
      ref="aboutvideo"
      controls
      :src="require('../assets/BTS.mp4')"
      loop
      style="width: 100%"
    />
    <v-btn @click="play"> play </v-btn>
    <Renderer
      ref="renderer"
      antialias
      resize
      :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }"
    >
      <Camera :position="{ x: -0, y: -100, z: 30 }" />
      <Scene background="#000000">
        <Plane>
          <LambertMaterial ref="aboutscreen" color="#fff" />
        </Plane>
      </Scene>
    </Renderer>
  </div>
</template>

<script>
import { VideoTexture } from "three";

import { Plane, LambertMaterial } from "troisjs";

export default {
  components: {
    Plane,
    LambertMaterial,
  },
  methods: {
    play() {
      this.$refs.aboutvideo.play();
    },
  },
  mounted() {
    
    const renderer = this.$refs.renderer;

    //  const mesh = this.$refs.mesh.mesh;
    renderer.onBeforeRender(() => {
const vidtex = new VideoTexture(this.$refs.aboutvideo);
    this.$refs.aboutscreen.setTexture(vidtex);
    });
  },
};
</script>

@xcchcaptain
Copy link
Contributor

thank you for your prompt reply, and is it right? 😂😂

<template>
  <div>
    <video
      ref="aboutvideo"
      controls
      :src="require('../assets/BTS.mp4')"
      loop
      style="width: 100%"
    />
    <v-btn @click="play"> play </v-btn>
    <Renderer
      ref="renderer"
      antialias
      resize
      :orbit-ctrl="{ enableDamping: true, dampingFactor: 0.05 }"
    >
      <Camera :position="{ x: -0, y: -100, z: 30 }" />
      <Scene background="#000000">
        <Plane>
          <LambertMaterial ref="aboutscreen" color="#fff" />
        </Plane>
      </Scene>
    </Renderer>
  </div>
</template>

<script>
import { VideoTexture } from "three";

import { Plane, LambertMaterial } from "troisjs";

export default {
  components: {
    Plane,
    LambertMaterial,
  },
  methods: {
    play() {
      this.$refs.aboutvideo.play();
    },
  },
  mounted() {
    
    const renderer = this.$refs.renderer;

    //  const mesh = this.$refs.mesh.mesh;
    renderer.onBeforeRender(() => {
const vidtex = new VideoTexture(this.$refs.aboutvideo);
    this.$refs.aboutscreen.setTexture(vidtex);
    });
  },
};
</script>

don't need to set VideoTexture in onBeforeRender,just move them into the method play,will make that work

@klevron klevron self-assigned this Sep 8, 2021
@klevron klevron added the enhancement New feature or request label Sep 8, 2021
@klevron klevron added this to the 0.3.3 milestone Sep 8, 2021
@klevron klevron modified the milestones: 0.3.3, 0.3.4 Oct 30, 2021
@klevron klevron added documentation Improvements or additions to documentation and removed enhancement New feature or request labels Feb 16, 2022
This was referenced Feb 16, 2022
@klevron klevron closed this as completed Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants