How to properly load Texture Atlas in Three.JS? -
i'd load texture atlas , cut several materials use in three.js scene. i've built following works program slows down after using few materials. i'm building them 1024x2048 texture, think problem textures each taking memory. if load them individually, program keeps chugging along fine.
var atlastexture = three.imageutils.loadtexture( imagepath, undefined, function() { (var key in json.frames) { var tex = atlastexture.clone(); var frame = json.frames[key].frame; tex.repeat.x = ( frame.w / atlastexture.image.width ); tex.repeat.y = ( frame.h / atlastexture.image.height ); tex.offset.x = ( math.abs( frame.x ) / atlastexture.image.width ); tex.offset.y = ( math.abs( frame.y )/ atlastexture.image.height ); tex.needsupdate = true; var material = new three.meshphongmaterial( { transparent:true, map: tex, side: three.doubleside} ); scope.materials.push( material ); } } );
is there way crop textures size need?
Comments
Post a Comment