Coder Social home page Coder Social logo

sermonis / three-threex.videotexture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeromeetienne/threex.videotexture

0.0 0.0 0.0 6.68 MB

three.js helper to display video texture.

Home Page: http://jeromeetienne.github.io/threex.videotexture/examples/videotexture.html

License: MIT License

Makefile 15.50% JavaScript 84.50%

three-threex.videotexture's Introduction

threex.videotexture

threex.videotexture is a threex game extension for three.js. It provides help to handle videos in texture. It is possible to put html5 <video> output in texture with threex.videotexture.js. You can even put the webcam in a texture with threex.webcamtexture.js. It is cool if you want to make a tv screen in your game, You can easily use this extension. You pick the video to play and you are ready to go. The screen surface will use your video texture making it look like a TV set. If you need it, you can try threex.audiovideotexture.js where the video is mapped on the texture and additionnally the sound of the video is handled via web audio API. Thus you can have localized sound, which is neat in the 3d environment.

Show Don't Tell

  • Here is a videotexture example and its source. It read the video from a file via video dom element and display it in a texture
  • Here is a audio/video texture example with WebAudio APIand its source. It shows how to plug the video sound into the WebAudio API because you get localised sounds. This is particularly useful in 3D. "Audio/Video" texture is a texture where the sound comes from the object3d on which the texture is mapped.
  • Here is another webcam example and its source. It reads the webcam thru getUserMedia and put it in a texture.

A Screenshot

screenshot

How To Install It

You can install it manually. Just do

<script src='threex.videotexture.js'></script>

You can install with bower.

bower install threex.videotexture

then you add that in your html

<script src="bower_components/threex.videotexture/threex.videotexture.js"></script>

How To Use it

threex.videotexture.js

First you instanciate the texture itself

// create the videoTexture
var videoTexture= new THREEx.VideoTexture('videos/sintel.ogv')
updateFcts.push(function(delta, now){
	// to update the texture are every frame
	videoTexture.update(delta, now)
})

Then you use it in a mesh like this.

// use the texture in a THREE.Mesh
var geometry	= new THREE.CubeGeometry(1,1,1);
var material	= new THREE.MeshBasicMaterial({
	map	: videoTexture.texture
});
var mesh	= new THREE.Mesh( geometry, material );
scene.add( mesh );

Here is the detailled API:

  • videoTexture.video: the video dom element from which the video is used
  • videoTexture.texture: the generated THREE.Texture
  • videoTexture.update(delta, now): update the texture from the video element
  • videoTexture.destroy(): destroy the object

threex.webcamtexture.js

It will read the webcam using getUserMedia. The browser will likely ask for permissions to the users. Let's see how to use it. You instanciate the texture itself.

var webcamTexture	= new THREEx.WebcamTexture()
updateFcts.push(function(delta, now){
	// to update the texture are every frame
	webcamTexture.update(delta, now)
})

Then you use it in a mesh

// use the texture in a THREE.Mesh
var geometry	= new THREE.CubeGeometry(1,1,1);
var material	= new THREE.MeshBasicMaterial({
	map	: videoTexture.texture
});
var mesh	= new THREE.Mesh( geometry, material );
scene.add( mesh );

Here is the detailled API:

  • videoTexture.video: the video dom element from which the video is used
  • videoTexture.texture: the generated THREE.Texture
  • videoTexture.update(delta, now): update the texture from the video element
  • videoTexture.destroy(): destroy the object
  • THREEx.WebcamTexture.available: true if getUserMedia is available on this browser, false otherwise.

three-threex.videotexture's People

Contributors

jeromeetienne avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.