Matrix4Node.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { Matrix4 } from '../../../../build/three.module.js';
  5. import { InputNode } from '../core/InputNode.js';
  6. function Matrix4Node( matrix ) {
  7. InputNode.call( this, 'm4' );
  8. this.value = matrix || new Matrix4();
  9. }
  10. Matrix4Node.prototype = Object.create( InputNode.prototype );
  11. Matrix4Node.prototype.constructor = Matrix4Node;
  12. Matrix4Node.prototype.nodeType = "Matrix4";
  13. Object.defineProperties( Matrix4Node.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. Matrix4Node.prototype.generateReadonly = function ( builder, output, uuid, type /*, ns, needsUpdate */ ) {
  24. return builder.format( "mat4( " + this.value.elements.join( ", " ) + " )", type, output );
  25. };
  26. Matrix4Node.prototype.copy = function ( source ) {
  27. InputNode.prototype.copy.call( this, source );
  28. this.scope.value.fromArray( source.elements );
  29. return this;
  30. };
  31. Matrix4Node.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 { Matrix4Node };