Matrix3Node.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. return this;
  30. };
  31. Matrix3Node.prototype.toJSON = function ( meta ) {
  32. var data = this.getJSONNode( meta );
  33. if ( ! data ) {
  34. data = this.createJSONNode( meta );
  35. data.elements = this.value.elements.concat();
  36. }
  37. return data;
  38. };
  39. export { Matrix3Node };