2
0

IntNode.js 963 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.IntNode = function ( value ) {
  5. THREE.InputNode.call( this, 'iv1' );
  6. this.value = [ Math.floor( value || 0 ) ];
  7. };
  8. THREE.IntNode.prototype = Object.create( THREE.InputNode.prototype );
  9. THREE.IntNode.prototype.constructor = THREE.IntNode;
  10. THREE.IntNode.prototype.nodeType = "Int";
  11. Object.defineProperties( THREE.IntNode.prototype, {
  12. number: {
  13. get: function () {
  14. return this.value[ 0 ];
  15. },
  16. set: function ( val ) {
  17. this.value[ 0 ] = Math.floor( val );
  18. }
  19. }
  20. } );
  21. THREE.IntNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns, needsUpdate ) {
  22. return builder.format( this.number, type, output );
  23. };
  24. THREE.IntNode.prototype.toJSON = function ( meta ) {
  25. var data = this.getJSONNode( meta );
  26. if ( ! data ) {
  27. data = this.createJSONNode( meta );
  28. data.number = this.number;
  29. if ( this.readonly === true ) data.readonly = true;
  30. }
  31. return data;
  32. };