Matrix3Node.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { Matrix3 } from '../../../../build/three.module.js';
  2. import { InputNode } from '../core/InputNode.js';
  3. function Matrix3Node( matrix ) {
  4. InputNode.call( this, 'm3' );
  5. this.value = matrix || new Matrix3();
  6. }
  7. Matrix3Node.prototype = Object.create( InputNode.prototype );
  8. Matrix3Node.prototype.constructor = Matrix3Node;
  9. Matrix3Node.prototype.nodeType = 'Matrix3';
  10. Object.defineProperties( Matrix3Node.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. Matrix3Node.prototype.generateReadonly = function ( builder, output, uuid, type/*, ns, needsUpdate */ ) {
  21. return builder.format( 'mat3( ' + this.value.elements.join( ', ' ) + ' )', type, output );
  22. };
  23. Matrix3Node.prototype.copy = function ( source ) {
  24. InputNode.prototype.copy.call( this, source );
  25. this.value.fromArray( source.elements );
  26. return this;
  27. };
  28. Matrix3Node.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 { Matrix3Node };