vendor: 9,934 bytes, lines 1-359
1( function () { 2 3 function computeTangents( geometry ) { 4 5 geometry.computeTangents(); 6 console.warn( 'THREE.BufferGeometryUtils: .computeTangents() has been removed. Use THREE.BufferGeometry.computeTangents() instead.' ); 7 8 } 9 /** 10 * @param {Array<BufferGeometry>} geometries 11 * @param {Boolean} useGroups 12 * @return {BufferGeometry} 13 */ 14 15 16 function mergeBufferGeometries( geometries, useGroups = false ) { 17 18 const isIndexed = geometries[ 0 ].index !== null; 19 const attributesUsed = new Set( Object.keys( geometries[ 0 ].attributes ) ); 20 const morphAttributesUsed = new Set( Object.keys( geometries[ 0 ].morphAttributes ) ); 21 const attributes = {}; 22 const morphAttributes = {}; 23 const morphTargetsRelative = geometries[ 0 ].morphTargetsRelative; 24 const mergedGeometry = new THREE.BufferGeometry(); 25 let offset = 0; 26 27 for ( let i = 0; i < geometries.length; ++ i ) { 28 29 const geometry = geometries[ i ]; 30 let attributesCount = 0; // ensure that all geometries are indexed, or none 31 32 if ( isIndexed !== ( geometry.index !== null ) ) { 33 34 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.' ); 35 return null; 36 37 } // gather attributes, exit early if they're different 38 39 40 for ( const name in geometry.attributes ) { 41 42 if ( ! attributesUsed.has( name ) ) { 43 44 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. All geometries must have compatible attributes; make sure "' + name + '" attribute exists among all geometries, or in none of them.' ); 45 return null; 46 47 } 48 49 if ( attributes[ name ] === undefined ) attributes[ name ] = []; 50 attributes[ name ].push( geometry.attributes[ name ] ); 51 attributesCount ++; 52 53 } // ensure geometries have the same number of attributes 54 55 56 if ( attributesCount !== attributesUsed.size ) { 57 58 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. Make sure all geometries have the same number of attributes.' ); 59 return null; 60 61 } // gather morph attributes, exit early if they're different 62 63 64 if ( morphTargetsRelative !== geometry.morphTargetsRelative ) { 65 66 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphTargetsRelative must be consistent throughout all geometries.' ); 67 return null; 68 69 } 70 71 for ( const name in geometry.morphAttributes ) { 72 73 if ( ! morphAttributesUsed.has( name ) ) { 74 75 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. .morphAttributes must be consistent throughout all geometries.' ); 76 return null; 77 78 } 79 80 if ( morphAttributes[ name ] === undefined ) morphAttributes[ name ] = []; 81 morphAttributes[ name ].push( geometry.morphAttributes[ name ] ); 82 83 } // gather .userData 84 85 86 mergedGeometry.userData.mergedUserData = mergedGeometry.userData.mergedUserData || []; 87 mergedGeometry.userData.mergedUserData.push( geometry.userData ); 88 89 if ( useGroups ) { 90 91 let count; 92 93 if ( isIndexed ) { 94 95 count = geometry.index.count; 96 97 } else if ( geometry.attributes.position !== undefined ) { 98 99 count = geometry.attributes.position.count; 100 101 } else { 102 103 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index ' + i + '. The geometry must have either an index or a position attribute' ); 104 return null; 105 106 } 107 108 mergedGeometry.addGroup( offset, count, i ); 109 offset += count; 110 111 } 112 113 } // merge indices 114 115 116 if ( isIndexed ) { 117 118 let indexOffset = 0; 119 const mergedIndex = []; 120 121 for ( let i = 0; i < geometries.length; ++ i ) { 122 123 const index = geometries[ i ].index; 124 125 for ( let j = 0; j < index.count; ++ j ) { 126 127 mergedIndex.push( index.getX( j ) + indexOffset ); 128 129 } 130 131 indexOffset += geometries[ i ].attributes.position.count; 132 133 } 134 135 mergedGeometry.setIndex( mergedIndex ); 136 137 } // merge attributes 138 139 140 for ( const name in attributes ) { 141 142 const mergedAttribute = mergeBufferAttributes( attributes[ name ] ); 143 144 if ( ! mergedAttribute ) { 145 146 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' attribute.' ); 147 return null; 148 149 } 150 151 mergedGeometry.setAttribute( name, mergedAttribute ); 152 153 } // merge morph attributes 154 155 156 for ( const name in morphAttributes ) { 157 158 const numMorphTargets = morphAttributes[ name ][ 0 ].length; 159 if ( numMorphTargets === 0 ) break; 160 mergedGeometry.morphAttributes = mergedGeometry.morphAttributes || {}; 161 mergedGeometry.morphAttributes[ name ] = []; 162 163 for ( let i = 0; i < numMorphTargets; ++ i ) { 164 165 const morphAttributesToMerge = []; 166 167 for ( let j = 0; j < morphAttributes[ name ].length; ++ j ) { 168 169 morphAttributesToMerge.push( morphAttributes[ name ][ j ][ i ] ); 170 171 } 172 173 const mergedMorphAttribute = mergeBufferAttributes( morphAttributesToMerge ); 174 175 if ( ! mergedMorphAttribute ) { 176 177 console.error( 'THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the ' + name + ' morphAttribute.' ); 178 return null; 179 180 } 181 182 mergedGeometry.morphAttributes[ name ].push( mergedMorphAttribute ); 183 184 } 185 186 } 187 188 return mergedGeometry; 189 190 } 191 /** 192 * @param {Array<BufferAttribute>} attributes 193 * @return {BufferAttribute} 194 */ 195 196 197 function mergeBufferAttributes( attributes ) { 198 199 let TypedArray; 200 let itemSize; 201 let normalized; 202 let arrayLength = 0; 203 204 for ( let i = 0; i < attributes.length; ++ i ) { 205 206 const attribute = attributes[ i ]; 207 208 if ( attribute.isInterleavedBufferAttribute ) { 209 210 console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported.' ); 211 return null; 212 213 } 214 215 if ( TypedArray === undefined ) TypedArray = attribute.array.constructor; 216 217 if ( TypedArray !== attribute.array.constructor ) { 218 219 console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. THREE.BufferAttribute.array must be of consistent array types across matching attributes.' ); 220 return null; 221 222 } 223 224 if ( itemSize === undefined ) itemSize = attribute.itemSize; 225 226 if ( itemSize !== attribute.itemSize ) { 227 228 console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. THREE.BufferAttribute.itemSize must be consistent across matching attributes.' ); 229 return null; 230 231 } 232 233 if ( normalized === undefined ) normalized = attribute.normalized; 234 235 if ( normalized !== attribute.normalized ) { 236 237 console.error( 'THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. THREE.BufferAttribute.normalized must be consistent across matching attributes.' ); 238 return null; 239 240 } 241 242 arrayLength += attribute.array.length; 243 244 } 245 246 const array = new TypedArray( arrayLength ); 247 let offset = 0; 248 249 for ( let i = 0; i < attributes.length; ++ i ) { 250 251 array.set( attributes[ i ].array, offset ); 252 offset += attributes[ i ].array.length; 253 254 } 255 256 return new THREE.BufferAttribute( array, itemSize, normalized ); 257 258 } 259 /** 260 * @param {Array<BufferAttribute>} attributes 261 * @return {Array<InterleavedBufferAttribute>} 262 */ 263 264 265 function interleaveAttributes( attributes ) { 266 267 // Interleaves the provided attributes into an THREE.InterleavedBuffer and returns 268 // a set of InterleavedBufferAttributes for each attribute 269 let TypedArray; 270 let arrayLength = 0; 271 let stride = 0; // calculate the the length and type of the interleavedBuffer 272 273 for ( let i = 0, l = attributes.length; i < l; ++ i ) { 274 275 const attribute = attributes[ i ]; 276 if ( TypedArray === undefined ) TypedArray = attribute.array.constructor; 277 278 if ( TypedArray !== attribute.array.constructor ) { 279 280 console.error( 'AttributeBuffers of different types cannot be interleaved' ); 281 return null; 282 283 } 284 285 arrayLength += attribute.array.length; 286 stride += attribute.itemSize; 287 288 } // Create the set of buffer attributes 289 290 291 const interleavedBuffer = new THREE.InterleavedBuffer( new TypedArray( arrayLength ), stride ); 292 let offset = 0; 293 const res = []; 294 const getters = [ 'getX', 'getY', 'getZ', 'getW' ]; 295 const setters = [ 'setX', 'setY', 'setZ', 'setW' ]; 296 297 for ( let j = 0, l = attributes.length; j < l; j ++ ) { 298 299 const attribute = attributes[ j ]; 300 const itemSize = attribute.itemSize; 301 const count = attribute.count; 302 const iba = new THREE.InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, attribute.normalized ); 303 res.push( iba ); 304 offset += itemSize; // Move the data for each attribute into the new interleavedBuffer 305 // at the appropriate offset 306 307 for ( let c = 0; c < count; c ++ ) { 308 309 for ( let k = 0; k < itemSize; k ++ ) { 310 311 iba[ setters[ k ] ]( c, attribute[ getters[ k ] ]( c ) ); 312 313 } 314 315 } 316 317 } 318 319 return res; 320 321 } 322 /** 323 * @param {Array<BufferGeometry>} geometry 324 * @return {number} 325 */ 326 327 328 function estimateBytesUsed( geometry ) { 329 330 // Return the estimated memory used by this geometry in bytes 331 // Calculate using itemSize, count, and BYTES_PER_ELEMENT to account 332 // for InterleavedBufferAttributes. 333 let mem = 0; 334 335 for ( const name in geometry.attributes ) { 336 337 const attr = geometry.getAttribute( name ); 338 mem += attr.count * attr.itemSize * attr.array.BYTES_PER_ELEMENT; 339 340 } 341 342 const indices = geometry.getIndex(); 343 mem += indices ? indices.count * indices.itemSize * indices.array.BYTES_PER_ELEMENT : 0; 344 return mem; 345 346 } 347 /** 348 * @param {BufferGeometry} geometry 349 * @param {number} tolerance 350 * @return {BufferGeometry>} 351 */ 352 353 354 function mergeVertices( geometry, tolerance = 1e-4 ) { 355 356 tolerance = Math.max( tolerance, Number.EPSILON ); // Generate an index buffer if the geometry doesn't have one, or optimize it 357 // if it's already available. 358 359 const hashToIndex = {};
360 const indices = geometry.getIndex(); 361 const positions = geometry.getAttribute( 'position' ); 362 const vertexCount = indices ? indices.count : positions.count; // next value for triangle indices 363 364 let nextIndex = 0; // attributes and new attribute arrays 365 366 const attributeNames = Object.keys( geometry.attributes ); 367 const attrArrays = {}; 368 const morphAttrsArrays = {}; 369 const newIndices = []; 370 const getters = [ 'getX', 'getY', 'getZ', 'getW' ]; // initialize the arrays 371 372 for ( let i = 0, l = attributeNames.length; i < l; i ++ ) { 373 374 const name = attributeNames[ i ]; 375 attrArrays[ name ] = []; 376 const morphAttr = geometry.morphAttributes[ name ]; 377 378 if ( morphAttr ) { 379 380 morphAttrsArrays[ name ] = new Array( morphAttr.length ).fill().map( () => [] ); 381 382 } 383 384 } // convert the error tolerance to an amount of decimal places to truncate to 385 386 387 const decimalShift = Math.log10( 1 / tolerance ); 388 const shiftMultiplier = Math.pow( 10, decimalShift ); 389 390 for ( let i = 0; i < vertexCount; i ++ ) { 391 392 const index = indices ? indices.getX( i ) : i; // Generate a hash for the vertex attributes at the current index 'i' 393 394 let hash = ''; 395 396 for ( let j = 0, l = attributeNames.length; j < l; j ++ ) { 397 398 const name = attributeNames[ j ]; 399 const attribute = geometry.getAttribute( name ); 400 const itemSize = attribute.itemSize; 401 402 for ( let k = 0; k < itemSize; k ++ ) { 403 404 // double tilde truncates the decimal value 405 hash += `${~ ~ ( attribute[ getters[ k ] ]( index ) * shiftMultiplier )},`; 406 407 } 408 409 } // Add another reference to the vertex if it's already 410 // used by another index 411 412 413 if ( hash in hashToIndex ) { 414 415 newIndices.push( hashToIndex[ hash ] ); 416 417 } else { 418 419 // copy data to the new index in the attribute arrays 420 for ( let j = 0, l = attributeNames.length; j < l; j ++ ) { 421 422 const name = attributeNames[ j ]; 423 const attribute = geometry.getAttribute( name ); 424 const morphAttr = geometry.morphAttributes[ name ]; 425 const itemSize = attribute.itemSize; 426 const newarray = attrArrays[ name ]; 427 const newMorphArrays = morphAttrsArrays[ name ]; 428 429 for ( let k = 0; k < itemSize; k ++ ) { 430 431 const getterFunc = getters[ k ]; 432 newarray.push( attribute[ getterFunc ]( index ) ); 433 434 if ( morphAttr ) { 435 436 for ( let m = 0, ml = morphAttr.length; m < ml; m ++ ) { 437 438 newMorphArrays[ m ].push( morphAttr[ m ][ getterFunc ]( index ) ); 439 440 } 441 442 } 443 444 } 445 446 } 447 448 hashToIndex[ hash ] = nextIndex; 449 newIndices.push( nextIndex ); 450 nextIndex ++; 451 452 } 453 454 } // Generate typed arrays from new attribute arrays and update 455 // the attributeBuffers 456 457 458 const result = geometry.clone(); 459 460 for ( let i = 0, l = attributeNames.length; i < l; i ++ ) { 461 462 const name = attributeNames[ i ]; 463 const oldAttribute = geometry.getAttribute( name ); 464 const buffer = new oldAttribute.array.constructor( attrArrays[ name ] ); 465 const attribute = new THREE.BufferAttribute( buffer, oldAttribute.itemSize, oldAttribute.normalized ); 466 result.setAttribute( name, attribute ); // Update the attribute arrays 467 468 if ( name in morphAttrsArrays ) { 469 470 for ( let j = 0; j < morphAttrsArrays[ name ].length; j ++ ) { 471 472 const oldMorphAttribute = geometry.morphAttributes[ name ][ j ]; 473 const buffer = new oldMorphAttribute.array.constructor( morphAttrsArrays[ name ][ j ] ); 474 const morphAttribute = new THREE.BufferAttribute( buffer, oldMorphAttribute.itemSize, oldMorphAttribute.normalized ); 475 result.morphAttributes[ name ][ j ] = morphAttribute; 476 477 } 478 479 } 480 481 } // indices 482 483 484 result.setIndex( newIndices ); 485 return result; 486 487 } 488 /** 489 * @param {BufferGeometry} geometry 490 * @param {number} drawMode 491 * @return {BufferGeometry>} 492 */ 493 494 495 function toTrianglesDrawMode( geometry, drawMode ) { 496 497 if ( drawMode === THREE.TrianglesDrawMode ) { 498 499 console.warn( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles.' ); 500 return geometry; 501 502 } 503 504 if ( drawMode === THREE.TriangleFanDrawMode || drawMode === THREE.TriangleStripDrawMode ) { 505 506 let index = geometry.getIndex(); // generate index if not present 507 508 if ( index === null ) { 509 510 const indices = []; 511 const position = geometry.getAttribute( 'position' ); 512 513 if ( position !== undefined ) { 514 515 for ( let i = 0; i < position.count; i ++ ) { 516 517 indices.push( i ); 518 519 } 520 521 geometry.setIndex( indices ); 522 index = geometry.getIndex(); 523 524 } else { 525 526 console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible.' ); 527 return geometry; 528 529 } 530 531 } // 532 533 534 const numberOfTriangles = index.count - 2;
vendor: 4,418 bytes, lines 535-713
535 const newIndices = []; 536 537 if ( drawMode === THREE.TriangleFanDrawMode ) { 538 539 // gl.TRIANGLE_FAN 540 for ( let i = 1; i <= numberOfTriangles; i ++ ) { 541 542 newIndices.push( index.getX( 0 ) ); 543 newIndices.push( index.getX( i ) ); 544 newIndices.push( index.getX( i + 1 ) ); 545 546 } 547 548 } else { 549 550 // gl.TRIANGLE_STRIP 551 for ( let i = 0; i < numberOfTriangles; i ++ ) { 552 553 if ( i % 2 === 0 ) { 554 555 newIndices.push( index.getX( i ) ); 556 newIndices.push( index.getX( i + 1 ) ); 557 newIndices.push( index.getX( i + 2 ) ); 558 559 } else { 560 561 newIndices.push( index.getX( i + 2 ) ); 562 newIndices.push( index.getX( i + 1 ) ); 563 newIndices.push( index.getX( i ) ); 564 565 } 566 567 } 568 569 } 570 571 if ( newIndices.length / 3 !== numberOfTriangles ) { 572 573 console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.' ); 574 575 } // build final geometry 576 577 578 const newGeometry = geometry.clone(); 579 newGeometry.setIndex( newIndices ); 580 newGeometry.clearGroups(); 581 return newGeometry; 582 583 } else { 584 585 console.error( 'THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:', drawMode ); 586 return geometry; 587 588 } 589 590 } 591 /** 592 * Calculates the morphed attributes of a morphed/skinned THREE.BufferGeometry. 593 * Helpful for Raytracing or Decals. 594 * @param {Mesh | Line | Points} object An instance of Mesh, Line or Points. 595 * @return {Object} An Object with original position/normal attributes and morphed ones. 596 */ 597 598 599 function computeMorphedAttributes( object ) { 600 601 if ( object.geometry.isBufferGeometry !== true ) { 602 603 console.error( 'THREE.BufferGeometryUtils: Geometry is not of type THREE.BufferGeometry.' ); 604 return null; 605 606 } 607 608 const _vA = new THREE.Vector3(); 609 610 const _vB = new THREE.Vector3(); 611 612 const _vC = new THREE.Vector3(); 613 614 const _tempA = new THREE.Vector3(); 615 616 const _tempB = new THREE.Vector3(); 617 618 const _tempC = new THREE.Vector3(); 619 620 const _morphA = new THREE.Vector3(); 621 622 const _morphB = new THREE.Vector3(); 623 624 const _morphC = new THREE.Vector3(); 625 626 function _calculateMorphedAttributeData( object, material, attribute, morphAttribute, morphTargetsRelative, a, b, c, modifiedAttributeArray ) { 627 628 _vA.fromBufferAttribute( attribute, a ); 629 630 _vB.fromBufferAttribute( attribute, b ); 631 632 _vC.fromBufferAttribute( attribute, c ); 633 634 const morphInfluences = object.morphTargetInfluences; 635 636 if ( material.morphTargets && morphAttribute && morphInfluences ) { 637 638 _morphA.set( 0, 0, 0 ); 639 640 _morphB.set( 0, 0, 0 ); 641 642 _morphC.set( 0, 0, 0 ); 643 644 for ( let i = 0, il = morphAttribute.length; i < il; i ++ ) { 645 646 const influence = morphInfluences[ i ]; 647 const morph = morphAttribute[ i ]; 648 if ( influence === 0 ) continue; 649 650 _tempA.fromBufferAttribute( morph, a ); 651 652 _tempB.fromBufferAttribute( morph, b ); 653 654 _tempC.fromBufferAttribute( morph, c ); 655 656 if ( morphTargetsRelative ) { 657 658 _morphA.addScaledVector( _tempA, influence ); 659 660 _morphB.addScaledVector( _tempB, influence ); 661 662 _morphC.addScaledVector( _tempC, influence ); 663 664 } else { 665 666 _morphA.addScaledVector( _tempA.sub( _vA ), influence ); 667 668 _morphB.addScaledVector( _tempB.sub( _vB ), influence ); 669 670 _morphC.addScaledVector( _tempC.sub( _vC ), influence ); 671 672 } 673 674 } 675 676 _vA.add( _morphA ); 677 678 _vB.add( _morphB ); 679 680 _vC.add( _morphC ); 681 682 } 683 684 if ( object.isSkinnedMesh ) { 685 686 object.boneTransform( a, _vA ); 687 object.boneTransform( b, _vB ); 688 object.boneTransform( c, _vC ); 689 690 } 691 692 modifiedAttributeArray[ a * 3 + 0 ] = _vA.x; 693 modifiedAttributeArray[ a * 3 + 1 ] = _vA.y; 694 modifiedAttributeArray[ a * 3 + 2 ] = _vA.z; 695 modifiedAttributeArray[ b * 3 + 0 ] = _vB.x; 696 modifiedAttributeArray[ b * 3 + 1 ] = _vB.y; 697 modifiedAttributeArray[ b * 3 + 2 ] = _vB.z; 698 modifiedAttributeArray[ c * 3 + 0 ] = _vC.x; 699 modifiedAttributeArray[ c * 3 + 1 ] = _vC.y; 700 modifiedAttributeArray[ c * 3 + 2 ] = _vC.z; 701 702 } 703 704 const geometry = object.geometry; 705 const material = object.material; 706 let a, b, c; 707 const index = geometry.index; 708 const positionAttribute = geometry.attributes.position; 709 const morphPosition = geometry.morphAttributes.position; 710 const morphTargetsRelative = geometry.morphTargetsRelative; 711 const normalAttribute = geometry.attributes.normal; 712 const morphNormal = geometry.morphAttributes.position; 713 const groups = geometry.groups;
714 const drawRange = geometry.drawRange; 715 let i, j, il, jl; 716 let group, groupMaterial; 717 let start, end; 718 const modifiedPosition = new Float32Array( positionAttribute.count * positionAttribute.itemSize ); 719 const modifiedNormal = new Float32Array( normalAttribute.count * normalAttribute.itemSize ); 720 721 if ( index !== null ) { 722 723 // indexed buffer geometry 724 if ( Array.isArray( material ) ) { 725 726 for ( i = 0, il = groups.length; i < il; i ++ ) { 727 728 group = groups[ i ]; 729 groupMaterial = material[ group.materialIndex ]; 730 start = Math.max( group.start, drawRange.start ); 731 end = Math.min( group.start + group.count, drawRange.start + drawRange.count ); 732 733 for ( j = start, jl = end; j < jl; j += 3 ) { 734 735 a = index.getX( j ); 736 b = index.getX( j + 1 ); 737 c = index.getX( j + 2 ); 738 739 _calculateMorphedAttributeData( object, groupMaterial, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition ); 740 741 _calculateMorphedAttributeData( object, groupMaterial, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal ); 742 743 } 744 745 } 746 747 } else { 748 749 start = Math.max( 0, drawRange.start ); 750 end = Math.min( index.count, drawRange.start + drawRange.count ); 751 752 for ( i = start, il = end; i < il; i += 3 ) { 753 754 a = index.getX( i ); 755 b = index.getX( i + 1 ); 756 c = index.getX( i + 2 ); 757 758 _calculateMorphedAttributeData( object, material, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition ); 759 760 _calculateMorphedAttributeData( object, material, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal ); 761 762 } 763 764 } 765 766 } else if ( positionAttribute !== undefined ) { 767 768 // non-indexed buffer geometry 769 if ( Array.isArray( material ) ) { 770 771 for ( i = 0, il = groups.length; i < il; i ++ ) { 772 773 group = groups[ i ]; 774 groupMaterial = material[ group.materialIndex ]; 775 start = Math.max( group.start, drawRange.start ); 776 end = Math.min( group.start + group.count, drawRange.start + drawRange.count ); 777 778 for ( j = start, jl = end; j < jl; j += 3 ) { 779 780 a = j; 781 b = j + 1; 782 c = j + 2; 783 784 _calculateMorphedAttributeData( object, groupMaterial, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition ); 785 786 _calculateMorphedAttributeData( object, groupMaterial, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal ); 787 788 } 789 790 } 791 792 } else { 793 794 start = Math.max( 0, drawRange.start ); 795 end = Math.min( positionAttribute.count, drawRange.start + drawRange.count ); 796 797 for ( i = start, il = end; i < il; i += 3 ) { 798 799 a = i; 800 b = i + 1; 801 c = i + 2; 802 803 _calculateMorphedAttributeData( object, material, positionAttribute, morphPosition, morphTargetsRelative, a, b, c, modifiedPosition ); 804 805 _calculateMorphedAttributeData( object, material, normalAttribute, morphNormal, morphTargetsRelative, a, b, c, modifiedNormal ); 806 807 } 808 809 } 810 811 } 812 813 const morphedPositionAttribute = new THREE.Float32BufferAttribute( modifiedPosition, 3 ); 814 const morphedNormalAttribute = new THREE.Float32BufferAttribute( modifiedNormal, 3 ); 815 return { 816 positionAttribute: positionAttribute, 817 normalAttribute: normalAttribute, 818 morphedPositionAttribute: morphedPositionAttribute, 819 morphedNormalAttribute: morphedNormalAttribute 820 }; 821 822 } 823 824 THREE.BufferGeometryUtils = {}; 825 THREE.BufferGeometryUtils.computeMorphedAttributes = computeMorphedAttributes; 826 THREE.BufferGeometryUtils.computeTangents = computeTangents; 827 THREE.BufferGeometryUtils.estimateBytesUsed = estimateBytesUsed; 828 THREE.BufferGeometryUtils.interleaveAttributes = interleaveAttributes; 829 THREE.BufferGeometryUtils.mergeBufferAttributes = mergeBufferAttributes; 830 THREE.BufferGeometryUtils.mergeBufferGeometries = mergeBufferGeometries; 831 THREE.BufferGeometryUtils.mergeVertices = mergeVertices; 832 THREE.BufferGeometryUtils.toTrianglesDrawMode = toTrianglesDrawMode; 833 834} )();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.