Matrix3Node.js 1.2 KB

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