Matrix4Node.js 1.2 KB

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