We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Changing UVs

Home Forums Programming Changing UVs

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #40693
    illyavangils
    Participant

    I’m attempting to change UVs of an object loaded from a blender scene. I based my code on another example that works with three.js.

    blender scene

    https://jsfiddle.net/9xy4k1o0/

    
    var obj = app.scene.getObjectByName(VARS['object']);
    
    if (obj.hasOwnProperty('geometry')) 
    {
        var UVatribs = obj.geometry.getAttribute("uv"); 
        // Modify UV map			
        for (var i = 0; i < UVatribs.count; i++) 
        {
            
            var u = UVatribs.getX(i);
            var v = UVatribs.getY(i);
            
            // do something with uv
            u = Math.random();
            v = Math.random();
                
            // write new values to attribs
            UVatribs.setXY(i, u, v);
        }
        UVatribs.needsUpdate = true;
        
        obj.geometry.setAttribute("uv", UVatribs);
    }
    
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.