Giter Club home page Giter Club logo

threejs-gif-texture's Introduction

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;

threejs-gif-texture's People

Contributors

bandinopla avatar

Watchers

 avatar  avatar

threejs-gif-texture's Issues

Load data URI?

The gifs I have are stored in localStorage as data URIs. When I pass them into THREE_GetGifTexture they don't load (or give an error). What would you think about adding that functionality? It looks like it might be possible here:

this._promise = fetch(this.url)

One would need to detect that its a data URI and convert it to an array buffer, skipping the fetch.

Module not found: Error: Default condition should be last one

Thank you for wrapping this tech up on a nice, simple library! I ran into an issue getting it set up:

When I include the project using Webpack, I get a "Module not found: Error: Default condition should be last one" error in the terminal and it breaks my whole build. I tracked it down to this line in the package.json:

"default": "./dist/three-giftexture.mjs",

If you move this default line below the types line, it works.

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.