npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

threex.videotexture

v1.0.0

Published

three.js helper to display video texture

Downloads

20

Readme

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.