Matrix4Node.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. };
  30. Matrix4Node.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 { Matrix4Node };