Texture Mapping: Missing Rotation

Hi,

in the meta model, i.e. the data model from which I create my ThreeJS scenes, I’m using the X3D texture mapping manipulation as defined here: http://doc.x3dom.org/author/Texturing/TextureTransform.html

while scaling and offset seem to be there, rotation is missing. Is there any chance to get the rotation in the future?

Thx and BR.

Ekki

Author: Fantashit

2 thoughts on “Texture Mapping: Missing Rotation

  1. @WestLangley I agree we shouldn’t use a Matrix3 as the interface. BTW here is the code I wrote for Clara.io to transform the UVs (influenced by our conversations on this issue):

      getUVTransform: function( rotation, tiling, useScale, scale, translation, pivotCenter ) {
    
        var result = new THREE.Matrix4();
    
        result.multiply( new THREE.Matrix4().makeTranslation( -pivotCenter.x, -pivotCenter.y, 0 ) );
        result.multiply( new THREE.Matrix4().makeRotationZ( THREE.Math.degToRad( rotation ) ) );
        if( useScale ) {
          result.multiply( new THREE.Matrix4().makeScale( scale.x, scale.y, 0 ) );
        }
        else {
          var safeInverse = function( v ) {
            if( v == 0 ) {
              return 1;
            }
            return 1 / v;
          }
          result.multiply( new THREE.Matrix4().makeScale( safeInverse( tiling.x ), safeInverse( tiling.y ), 0 ) );      
        }
        result.multiply( new THREE.Matrix4().makeTranslation( pivotCenter.x, pivotCenter.y, 0 ) );
        result.multiply( new THREE.Matrix4().makeTranslation( translation.x, translation.y, 0 ) );
    
        return result;
    
      },
    
    var applyUVTransform = function() {
      var tempVec3 = new THREE.Vector3();
      return function( uv, matrix ) {
        tempVec3.set( uv.x, uv.y, 0 );
        tempVec3.applyMatrix4( matrix );
        uv.set( tempVec3.x, tempVec3.y );      
      }
    }();
    

    I used a Matrix4 because Matrix3 didn’t have the necessary tools (makeRotation, makeTranslation, makeScale.)

Comments are closed.