threejs-gif-texture
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

THREE.js GifTexture

npm version

Logo

Load a GIF file as a texture in three.js using gifuct-js

Based on a code sandbox written by Pawel

Install

npm install threejs-gif-texture

Usage

import * as THREE from 'three';  
import {THREE_GetGifTexture} from "threejs-gif-texture";

...

THREE_GetGifTexture("/lara.gif").then( texture => { 
    
    const cube = new THREE.Mesh( 
        new THREE.BoxGeometry(), 
        new THREE.MeshBasicMaterial({ map:texture }));

    scene.add(cube)   

});

Control

The texture returned has the following api:

texture.play = true; // if it should play the gif or not
texture.frame = 1; // get/set the frame number
texture.gif; // the gif handler object
texture.gif.isLoading; //boolean. If it is loading or not...
texture.gif.hasFailed; //boolean. If it has failed to load.
texture.gif.width;
texture.gif.height;
texture.gif.totalFrames; //total number of frames of the gif 

To access the gifuct-js#ParsedGif that loaded the gif use:

texture.gif.parsedGif;

Package Sidebar

Install

npm i threejs-gif-texture

Weekly Downloads

1

Version

1.0.1

License

BSD-2-Clause

Unpacked Size

33.7 kB

Total Files

6

Last publish

Collaborators

  • bandinopla