GithubHelp home page GithubHelp logo

nileshv123 / threex.dynamictexture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeromeetienne/threex.dynamictexture

0.0 0.0 0.0 727 KB

three.js helper to handle dynamically generated texture.

Home Page: http://jeromeetienne.github.io/threex.dynamictexture/examples/basic.html

License: MIT License

Makefile 5.12% JavaScript 94.88%

threex.dynamictexture's Introduction

threex.dynamictexture

threex.dynamictexture is a threex game extension for three.js. It provides an easy way to handle dynamically generated texture. Inspiration came from the excelent babylon.js which got BABYLON.DynamicTexture. It is mainly used to write text in texture. Say you got a character which says something, you may want to put that in a texture and display that above your character. threex.dynamictexture will make it easy for you.

Show Don't Tell

A Screenshot

screenshot

How To Install It

You can install it manually or with bower. for the manual version, first include threex.dynamictexture.js with the usual

<script src='threex.dynamictexture.js'></script>

or with bower you type the following to install the package.

bower install threex.dynamictexture

then you add that in your html

<script src="bower_components/threex.dynamictexture/threex.dynamictexture.js"></script>

How To Use It ?

You instanciate the texture, say it is 512 pixel width, and 512 pixel high.

var dynamicTexture	= new THREEx.DynamicTexture(512,512)
  • dynamicTexture.canvas the underlying canvas
  • dynamicTexture.context the context of the underlying canvas
  • dynamicTexture.texture the THREE.Texture created

To use the texture on a THREE.Material

var geometry	= new THREE.CubeGeometry( 1, 1, 1);
var material	= new THREE.MeshBasicMaterial({
	map	: dynamicTexture.texture
})
var mesh	= new THREE.Mesh( geometry, material );
scene.add( mesh );

When you update a texture be sure to do

dynamicTexture.texture.needsUpdate	= true

Helpers Functions

Some helpers functions are provided to draw in this canvas.

To clear the underlying canvas

dynamicTexture.clear();

To Draw a Text to draw a text

dynamicTexture.drawText('Hello', 32, 256, 'red')

To Draw a Image to draw an image, build an Image element and call this function. the arguments are the same as the official function

var image  = document.createElement('img')
image.src  = 'image.jpg'
dynamicTexture.drawBackground(image, 0, 0)

threex.dynamictexture's People

Contributors

jeromeetienne avatar

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.