Geometry5b.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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.Geometry5b.prototype.constructor = THREE.Geometry5b;
  21. THREE.TypedVector2 = function ( array, offset ) {
  22. this.array = array;
  23. this.offset = offset;
  24. };
  25. THREE.TypedVector2.prototype = Object.create( THREE.Vector2.prototype );
  26. THREE.TypedVector2.prototype.constructor = THREE.TypedVector2;
  27. Object.defineProperties( THREE.TypedVector2.prototype, {
  28. 'x': {
  29. get: function () { return this.array[ this.offset ]; },
  30. set: function ( v ) { this.array[ this.offset ] = v; }
  31. },
  32. 'y': {
  33. get: function () { return this.array[ this.offset + 1 ]; },
  34. set: function ( v ) { this.array[ this.offset + 1 ] = v; }
  35. }
  36. } );
  37. THREE.TypedVector3 = function ( array, offset ) {
  38. this.array = array;
  39. this.offset = offset;
  40. };
  41. THREE.TypedVector3.prototype = Object.create( THREE.Vector3.prototype );
  42. THREE.TypedVector3.prototype.constructor = THREE.TypedVector3;
  43. Object.defineProperties( THREE.TypedVector3.prototype, {
  44. 'x': {
  45. get: function () { return this.array[ this.offset ]; },
  46. set: function ( v ) { this.array[ this.offset ] = v; }
  47. },
  48. 'y': {
  49. get: function () { return this.array[ this.offset + 1 ]; },
  50. set: function ( v ) { this.array[ this.offset + 1 ] = v; }
  51. },
  52. 'z': {
  53. get: function () { return this.array[ this.offset + 2 ]; },
  54. set: function ( v ) { this.array[ this.offset + 2 ] = v; }
  55. }
  56. } );