In this guide we will explore how to import and use video files in nunuStudio. Video files can be used as textures for objects.
To load a new video file select Texture and then Video texture, this will create two thing first a video resource that contains the video file select, and a Video texture that uses the video resource to display the file. Alternatively you can drag and drop a video file to the explorer or directly to an object.
It is possible to load external files from their URL. When using external files if they are a diferent domain don't forget to make sure that the server has the appropiate CORS configuration. The code bellow demonstrates how to create a VideoTexture from an external URL and to use it as a texture for the default material.
You can choose between a Video resource and a VideoStream resource, the main difference is that Video preloads the whole video files into memory and VideoStream loads the video as it goes.
{
var texture = new VideoTexture(new VideoStream("sample.mp4"));
var material = program.getMaterialByName("default");
material.emissiveMap = texture;
material.emissive.setHex(0xFFFFFF);
}
To try this example in the editor you can download the project file or open it on the Web Editor.