Matrix4Node.js 1.2 KB

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