Geometry5b.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @author mrdoob / http://mrdoob.com/
  3. */
  4. THREE.Geometry5b = function ( bufferGeometry ) {
  5. THREE.BufferGeometry.call( this );
  6. this.attributes = bufferGeometry.attributes;
  7. var verticesBuffer = this.attributes.position.array;
  8. var normalsBuffer = this.attributes.normal.array;
  9. var uvsBuffer = this.attributes.uv.array;
  10. this.vertices = [];
  11. this.normals = [];
  12. this.uvs = [];
  13. for ( var i = 0, l = verticesBuffer.length / 3; i < l; i ++ ) {
  14. this.vertices.push( new THREE.TypedVector3( verticesBuffer, i * 3 ) );
  15. this.normals.push( new THREE.TypedVector3( normalsBuffer, i * 3 ) );
  16. this.uvs.push( new THREE.TypedVector2( uvsBuffer, i * 2 ) );
  17. }
  18. };
  19. THREE.Geometry5b.prototype = Object.create( THREE.BufferGeometry.prototype );
  20. THREE.TypedVector2 = function ( array, offset ) {
  21. this.array = array;
  22. this.offset = offset;
  23. };
  24. THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
  25. Object.defineProperties( THREE.TypedVector2.prototype, {
  26. 'x': {
  27. get: function () { return this.array[ this.offset ]; },
  28. set: function ( v ) { this.array[ this.offset ] = v; }
  29. },
  30. 'y': {
  31. get: function () { return this.array[ this.offset + 1 ]; },
  32. set: function ( v ) { this.array[ this.offset + 1 ] = v; }
  33. }
  34. } );
  35. THREE.TypedVector3 = function ( array, offset ) {
  36. this.array = array;
  37. this.offset = offset;
  38. };
  39. THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
  40. Object.defineProperties( THREE.TypedVector3.prototype, {
  41. 'x': {
  42. get: function () { return this.array[ this.offset ]; },
  43. set: function ( v ) { this.array[ this.offset ] = v; }
  44. },
  45. 'y': {
  46. get: function () { return this.array[ this.offset + 1 ]; },
  47. set: function ( v ) { this.array[ this.offset + 1 ] = v; }
  48. },
  49. 'z': {
  50. get: function () { return this.array[ this.offset + 2 ]; },
  51. set: function ( v ) { this.array[ this.offset + 2 ] = v; }
  52. }
  53. } );