ModelViewProjectionNode.js 738 B

123456789101112131415161718192021222324252627282930
  1. import Node from '../core/Node.js';
  2. import CameraNode from '../accessors/CameraNode.js';
  3. import ModelNode from '../accessors/ModelNode.js';
  4. import OperatorNode from '../math/OperatorNode.js';
  5. import PositionNode from '../accessors/PositionNode.js';
  6. class ModelViewProjectionNode extends Node {
  7. constructor( position = new PositionNode() ) {
  8. super( 'vec4' );
  9. this.position = position;
  10. }
  11. generate( builder ) {
  12. const position = this.position;
  13. const mvpMatrix = new OperatorNode( '*', new CameraNode( CameraNode.PROJECTION_MATRIX ), new ModelNode( ModelNode.VIEW_MATRIX ) );
  14. const mvpNode = new OperatorNode( '*', mvpMatrix, position );
  15. return mvpNode.build( builder );
  16. }
  17. }
  18. export default ModelViewProjectionNode;