javascript - Resize multiple PlaneBufferGeometries according to size of images with Three.js -
javascript - Resize multiple PlaneBufferGeometries according to size of images with Three.js -
here simple job do: i'm displaying decent amount (100+) of jpgs mapped on planegeometries using three.js. of these jpgs vertical, others horizontal , sizes tend vary slightly. here's loop simplified
for (i = 0; < projectsnb; i++) { var texture = new three.meshbasicmaterial({ map: three.imageutils.loadtexture("images/" + xmlprojects[i].getattribute('img') + ".jpg") }); var geometry = new three.planebuffergeometry( 1, 0.75 ); //width , height of plane geometry.name = xmlprojects[i].getattribute('nom'); var planproj = new three.mesh( geometry, texture ); planproj.position.x = xmlprojects[i].getattribute('x'); planproj.position.y = xmlprojects[i].getattribute('y'); planproj.position.z = xmlprojects[i].getattribute('z'); scene.add( planproj ); }
therefore, need able alter dimensions of plane geometries: width , height value. seems jquery needs load image sec time, cannot read value of file such as:
var newimg = new image(); newimg.src = ("images/" + xmlprojects[i].getattribute('img') + ".jpg"); console.log( newimg.width );
and 3 js cannot access pixels of image such as
var texture = new three.meshbasicmaterial({ map: three.imageutils.loadtexture("images/" + xmlprojects[i].getattribute('img') + ".jpg") }); console.log( texture.map.image.width );
i've looked on web answer. seems impossible in reasonable manner :(
any thought ? :)
javascript three.js
Comments
Post a Comment