You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
739 B
36 lines
739 B
6 months ago
|
import TempNode from '../core/TempNode.js';
|
||
|
import { addNodeClass } from '../core/Node.js';
|
||
|
import { addNodeElement, nodeProxy, vec2 } from '../shadernode/ShaderNode.js';
|
||
|
|
||
|
class RotateUVNode extends TempNode {
|
||
|
|
||
|
constructor( uvNode, rotationNode, centerNode = vec2( 0.5 ) ) {
|
||
|
|
||
|
super( 'vec2' );
|
||
|
|
||
|
this.uvNode = uvNode;
|
||
|
this.rotationNode = rotationNode;
|
||
|
this.centerNode = centerNode;
|
||
|
|
||
|
}
|
||
|
|
||
|
setup() {
|
||
|
|
||
|
const { uvNode, rotationNode, centerNode } = this;
|
||
|
|
||
|
const vector = uvNode.sub( centerNode );
|
||
|
|
||
|
return vector.rotate( rotationNode ).add( centerNode );
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
export default RotateUVNode;
|
||
|
|
||
|
export const rotateUV = nodeProxy( RotateUVNode );
|
||
|
|
||
|
addNodeElement( 'rotateUV', rotateUV );
|
||
|
|
||
|
addNodeClass( 'RotateUVNode', RotateUVNode );
|