ModelNode.js 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import Node from '../core/Node.js';
  2. import Vector3Node from '../inputs/Vector3Node.js';
  3. import Matrix4Node from '../inputs/Matrix4Node.js';
  4. import { NodeUpdateType } from '../core/constants.js';
  5. class ModelNode extends Node {
  6. static VIEW = 'view';
  7. constructor( scope = ModelNode.VIEW ) {
  8. super( 'mat4' );
  9. this.scope = scope;
  10. this.updateType = NodeUpdateType.Object;
  11. this._inputNode = null;
  12. }
  13. update( frame ) {
  14. const object = frame.object;
  15. const inputNode = this._inputNode;
  16. inputNode.value = object.modelViewMatrix;
  17. }
  18. generate( builder, output ) {
  19. const nodeData = builder.getDataFromNode( this );
  20. let inputNode = this._inputNode;
  21. if ( nodeData.inputNode === undefined ) {
  22. inputNode = new Matrix4Node( null );
  23. this._inputNode = inputNode;
  24. nodeData.inputNode = inputNode;
  25. }
  26. return inputNode.build( builder, output );
  27. }
  28. }
  29. export default ModelNode;