Matrix4Node.js 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { Matrix4 } from '../../../../build/three.module.js';
  2. import { InputNode } from '../core/InputNode.js';
  3. class Matrix4Node extends InputNode {
  4. constructor( matrix ) {
  5. super( 'm4' );
  6. this.value = matrix || new Matrix4();
  7. }
  8. get elements() {
  9. return this.value.elements;
  10. }
  11. set elements( val ) {
  12. this.value.elements = val;
  13. }
  14. generateReadonly( builder, output, uuid, type /*, ns, needsUpdate */ ) {
  15. return builder.format( 'mat4( ' + this.value.elements.join( ', ' ) + ' )', type, output );
  16. }
  17. copy( source ) {
  18. super.copy( source );
  19. this.scope.value.fromArray( source.elements );
  20. return this;
  21. }
  22. toJSON( meta ) {
  23. let data = this.getJSONNode( meta );
  24. if ( ! data ) {
  25. data = this.createJSONNode( meta );
  26. data.elements = this.value.elements.concat();
  27. }
  28. return data;
  29. }
  30. }
  31. Matrix4Node.prototype.nodeType = 'Matrix4';
  32. export { Matrix4Node };