javascript - Dynamically Change Three.js texture in externally loaded Collada file -
i using three.js collada loader import .dae file texture (.png) image applied. need overwrite .png file new texture, , creating texture using canvas element exports .png format. if clear cache, change texture (i naming exported "new" .png texture same filename original .png texture referenced in .dae file).
how can ensure new texture recognized/rendered without having user clear cache? example: user creates new texture, , exported on original texture, , collada file re-renders after user clicks button render box.
once have javascript image object in memory, regardless of source, can assign objects' materials' textures via .image
attribute. you'll need let thre.js know alter binding. example, if have new image called, say, img
, mesh called mesh
typical material:
mesh.material.map.image = img; mesh.material.map.needsupdate = true;
should trick. no need send dom elemetn disk .png, use it.
Comments
Post a Comment