Matrix3Node.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.Matrix3Node = function ( matrix ) {
  5. THREE.InputNode.call( this, 'm3' );
  6. this.value = matrix || new THREE.Matrix3();
  7. };
  8. THREE.Matrix3Node.prototype = Object.create( THREE.InputNode.prototype );
  9. THREE.Matrix3Node.prototype.constructor = THREE.Matrix3Node;
  10. THREE.Matrix3Node.prototype.nodeType = "Matrix3";
  11. Object.defineProperties( THREE.Matrix3Node.prototype, {
  12. elements: {
  13. set: function (val) {
  14. this.value.elements = val;
  15. },
  16. get: function () {
  17. return this.value.elements;
  18. }
  19. }
  20. } );
  21. THREE.Matrix3Node.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  22. return builder.format( "mat3( " + this.value.elements.join( ", " ) + " )", type, output );
  23. };
  24. THREE.Matrix3Node.prototype.copy = function ( source ) {
  25. THREE.InputNode.prototype.copy.call( this, source );
  26. this.value.fromArray( source.elements );
  27. };
  28. THREE.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. };