MCPcopy Create free account
hub / github.com/nwutils/nw-sample-apps / initMeshBuffers

Function initMeshBuffers

webgl/js/three.min.js:15429–15581  ·  view source on GitHub ↗
( geometryGroup, object )

Source from the content-addressed store, hash-verified

15427 };
15428
15429 function initMeshBuffers ( geometryGroup, object ) {
15430
15431 var geometry = object.geometry,
15432 faces3 = geometryGroup.faces3,
15433 faces4 = geometryGroup.faces4,
15434
15435 nvertices = faces3.length * 3 + faces4.length * 4,
15436 ntris = faces3.length * 1 + faces4.length * 2,
15437 nlines = faces3.length * 3 + faces4.length * 4,
15438
15439 material = getBufferMaterial( object, geometryGroup ),
15440
15441 uvType = bufferGuessUVType( material ),
15442 normalType = bufferGuessNormalType( material ),
15443 vertexColorType = bufferGuessVertexColorType( material );
15444
15445 //console.log( "uvType", uvType, "normalType", normalType, "vertexColorType", vertexColorType, object, geometryGroup, material );
15446
15447 geometryGroup.__vertexArray = new Float32Array( nvertices * 3 );
15448
15449 if ( normalType ) {
15450
15451 geometryGroup.__normalArray = new Float32Array( nvertices * 3 );
15452
15453 }
15454
15455 if ( geometry.hasTangents ) {
15456
15457 geometryGroup.__tangentArray = new Float32Array( nvertices * 4 );
15458
15459 }
15460
15461 if ( vertexColorType ) {
15462
15463 geometryGroup.__colorArray = new Float32Array( nvertices * 3 );
15464
15465 }
15466
15467 if ( uvType ) {
15468
15469 if ( geometry.faceUvs.length > 0 || geometry.faceVertexUvs.length > 0 ) {
15470
15471 geometryGroup.__uvArray = new Float32Array( nvertices * 2 );
15472
15473 }
15474
15475 if ( geometry.faceUvs.length > 1 || geometry.faceVertexUvs.length > 1 ) {
15476
15477 geometryGroup.__uv2Array = new Float32Array( nvertices * 2 );
15478
15479 }
15480
15481 }
15482
15483 if ( object.geometry.skinWeights.length && object.geometry.skinIndices.length ) {
15484
15485 geometryGroup.__skinVertexAArray = new Float32Array( nvertices * 4 );
15486 geometryGroup.__skinVertexBArray = new Float32Array( nvertices * 4 );

Callers 1

addObjectFunction · 0.85

Calls 4

getBufferMaterialFunction · 0.85
bufferGuessUVTypeFunction · 0.85
bufferGuessNormalTypeFunction · 0.85

Tested by

no test coverage detected