Matrix3Node.js 1.1 KB

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