Matrix4Node.js 1.2 KB

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