Skip to content

chuckfairy/THREE.WebMExporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

THREE.WebMExporter

Using toDataURL for the Three.js domElement, compile a frame array of Webp images into a WebM video for use in three.js. It is based on Whammy. Thank you mrdoob, AlteredQualia, and all those who made this happen.

NOTE: the current raytracing renderer in the example is edited very slightly to add an event listener when the render is finished.

How to use

<script src="WebMExporter.js"></script>
<script>

//For webgl use the preserveDrawingBuffer flag must be true
var renderer = new THREE.WebGLRenderer({ preserveDrawingBuffer: true });

//Exporter construct
var exporter = new THREE.WebMExporter({

    //Render options
    renderer: renderer,
    scene: scene,
    camera: camera,

    //speed in frames per second
    speed: 60,

    //Quality 1-100
    quality: 100

});

var numberOfFrames = 200;

for(var i = 0; i < numberOfFrames; i++) {

    exporter.addRenderFrame();

}

//Create output compile blob
output = exporter.compile();
var url = exporter.createObjectURL(output);

video.src = url;

//Additionally you can add from addFrame method
renderer.render(scene, camera);
exporter.addFrame(renderer.domElement);


</script>

Properties

renderer

Three.js renderer for use in addRenderFrame

scene

scene to render

camera

camera to use for render

Methods

addRenderFrame( duration )

Will render using scene and camera then add the frame Pass optional duration in milliseconds will default to fps

addFrame( canvasOrWebP, duration )

Add a frame from a canvas element or WebP image Pass optional duration in milliseconds

compile( )

output a video WebM blob

createObjectURL( blob )

create a video src URL for playing and exporting video

setQuality( quality )

Set quality from 1-100. Can also be set from quality property using int 0-1

setSpeed( speed )

Set default speed passing in int in milliseconds

Live Demos

In Action

Videos

What's next?

  • Vorbis audio adding
  • HTML page frames
  • You tell me, leave an issue or request

About

A WebM video compiler extension for threejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published