1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618 |
- THREE.WebGLRenderer.MeshRenderer = function ( lowlevelrenderer, info ) {
- THREE.WebGLRenderer.Object3DRenderer.call( this, lowlevelrenderer, info );
- };
- THREE.WebGLRenderer.MeshRenderer.prototype = Object.create( THREE.WebGLRenderer.Object3DRenderer.prototype );
- THREE.extend( THREE.WebGLRenderer.MeshRenderer.prototype, {
- createBuffers: function ( geometryGroup ) {
- var renderer = this.renderer;
- geometryGroup.__webglVertexBuffer = renderer.createBuffer();
- geometryGroup.__webglNormalBuffer = renderer.createBuffer();
- geometryGroup.__webglTangentBuffer = renderer.createBuffer();
- geometryGroup.__webglColorBuffer = renderer.createBuffer();
- geometryGroup.__webglUVBuffer = renderer.createBuffer();
- geometryGroup.__webglUV2Buffer = renderer.createBuffer();
- geometryGroup.__webglSkinIndicesBuffer = renderer.createBuffer();
- geometryGroup.__webglSkinWeightsBuffer = renderer.createBuffer();
- geometryGroup.__webglFaceBuffer = renderer.createBuffer();
- geometryGroup.__webglLineBuffer = renderer.createBuffer();
- var m, ml;
- if ( geometryGroup.numMorphTargets ) {
- geometryGroup.__webglMorphTargetsBuffers = [];
- for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
- geometryGroup.__webglMorphTargetsBuffers.push( renderer.createBuffer() );
- }
- }
- if ( geometryGroup.numMorphNormals ) {
- geometryGroup.__webglMorphNormalsBuffers = [];
- for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {
- geometryGroup.__webglMorphNormalsBuffers.push( renderer.createBuffer() );
- }
- }
- this.info.memory.geometries ++;
- },
- initBuffers: function ( geometryGroup, object ) {
- var geometry = object.geometry,
- faces3 = geometryGroup.faces3,
- faces4 = geometryGroup.faces4,
- nvertices = faces3.length * 3 + faces4.length * 4,
- ntris = faces3.length * 1 + faces4.length * 2,
- nlines = faces3.length * 3 + faces4.length * 4,
- material = this.getBufferMaterial( object, geometryGroup ),
- uvType = this.bufferGuessUVType( material ),
- normalType = this.bufferGuessNormalType( material ),
- vertexColorType = this.bufferGuessVertexColorType( material );
- //console.log( "uvType", uvType, "normalType", normalType, "vertexColorType", vertexColorType, object, geometryGroup, material );
- geometryGroup.__vertexArray = new Float32Array( nvertices * 3 );
- if ( normalType ) {
- geometryGroup.__normalArray = new Float32Array( nvertices * 3 );
- }
- if ( geometry.hasTangents ) {
- geometryGroup.__tangentArray = new Float32Array( nvertices * 4 );
- }
- if ( vertexColorType ) {
- geometryGroup.__colorArray = new Float32Array( nvertices * 3 );
- }
- if ( uvType ) {
- if ( geometry.faceUvs.length > 0 || geometry.faceVertexUvs.length > 0 ) {
- geometryGroup.__uvArray = new Float32Array( nvertices * 2 );
- }
- if ( geometry.faceUvs.length > 1 || geometry.faceVertexUvs.length > 1 ) {
- geometryGroup.__uv2Array = new Float32Array( nvertices * 2 );
- }
- }
- if ( object.geometry.skinWeights.length && object.geometry.skinIndices.length ) {
- geometryGroup.__skinIndexArray = new Float32Array( nvertices * 4 );
- geometryGroup.__skinWeightArray = new Float32Array( nvertices * 4 );
- }
- geometryGroup.__faceArray = new Uint16Array( ntris * 3 );
- geometryGroup.__lineArray = new Uint16Array( nlines * 2 );
- var m, ml;
- if ( geometryGroup.numMorphTargets ) {
- geometryGroup.__morphTargetsArrays = [];
- for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
- geometryGroup.__morphTargetsArrays.push( new Float32Array( nvertices * 3 ) );
- }
- }
- if ( geometryGroup.numMorphNormals ) {
- geometryGroup.__morphNormalsArrays = [];
- for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {
- geometryGroup.__morphNormalsArrays.push( new Float32Array( nvertices * 3 ) );
- }
- }
- geometryGroup.__webglFaceCount = ntris * 3;
- geometryGroup.__webglLineCount = nlines * 2;
- // custom attributes
- if ( material.attributes ) {
- if ( geometryGroup.__webglCustomAttributesList === undefined ) {
- geometryGroup.__webglCustomAttributesList = [];
- }
- for ( var a in material.attributes ) {
- // Do a shallow copy of the attribute object so different geometryGroup chunks use different
- // attribute buffers which are correctly indexed in the setMeshBuffers function
- var originalAttribute = material.attributes[ a ];
- var attribute = {};
- for ( var property in originalAttribute ) {
- attribute[ property ] = originalAttribute[ property ];
- }
- if ( !attribute.__webglInitialized || attribute.createUniqueBuffers ) {
- attribute.__webglInitialized = true;
- var size = 1; // "f" and "i"
- if( attribute.type === "v2" ) size = 2;
- else if( attribute.type === "v3" ) size = 3;
- else if( attribute.type === "v4" ) size = 4;
- else if( attribute.type === "c" ) size = 3;
- attribute.size = size;
- attribute.array = new Float32Array( nvertices * size );
- attribute.buffer = this.renderer.createBuffer();
- attribute.buffer.belongsToAttribute = a;
- originalAttribute.needsUpdate = true;
- attribute.__original = originalAttribute;
- }
- geometryGroup.__webglCustomAttributesList.push( attribute );
- }
- }
- geometryGroup.__inittedArrays = true;
- },
- setBuffers: function ( geometryGroup, object, dispose, material ) {
- if ( ! geometryGroup.__inittedArrays ) {
- return;
- }
- var renderer = this.renderer;
- var normalType = this.bufferGuessNormalType( material ),
- vertexColorType = this.bufferGuessVertexColorType( material ),
- uvType = this.bufferGuessUVType( material ),
- needsSmoothNormals = ( normalType === THREE.SmoothShading );
- var f, fl, fi, face,
- vertexNormals, faceNormal, normal,
- vertexColors, faceColor,
- vertexTangents,
- uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4, n1, n2, n3, n4,
- c1, c2, c3, c4,
- sw1, sw2, sw3, sw4,
- si1, si2, si3, si4,
- sa1, sa2, sa3, sa4,
- sb1, sb2, sb3, sb4,
- m, ml, i, il,
- vn, uvi, uv2i,
- vk, vkl, vka,
- nka, chf, faceVertexNormals,
- a,
- vertexIndex = 0,
- offset = 0,
- offset_uv = 0,
- offset_uv2 = 0,
- offset_face = 0,
- offset_normal = 0,
- offset_tangent = 0,
- offset_line = 0,
- offset_color = 0,
- offset_skin = 0,
- offset_morphTarget = 0,
- offset_custom = 0,
- offset_customSrc = 0,
- value,
- vertexArray = geometryGroup.__vertexArray,
- uvArray = geometryGroup.__uvArray,
- uv2Array = geometryGroup.__uv2Array,
- normalArray = geometryGroup.__normalArray,
- tangentArray = geometryGroup.__tangentArray,
- colorArray = geometryGroup.__colorArray,
- skinIndexArray = geometryGroup.__skinIndexArray,
- skinWeightArray = geometryGroup.__skinWeightArray,
- morphTargetsArrays = geometryGroup.__morphTargetsArrays,
- morphNormalsArrays = geometryGroup.__morphNormalsArrays,
- customAttributes = geometryGroup.__webglCustomAttributesList,
- customAttribute,
- faceArray = geometryGroup.__faceArray,
- lineArray = geometryGroup.__lineArray,
- geometry = object.geometry, // this is shared for all chunks
- dirtyVertices = geometry.verticesNeedUpdate,
- dirtyElements = geometry.elementsNeedUpdate,
- dirtyUvs = geometry.uvsNeedUpdate,
- dirtyNormals = geometry.normalsNeedUpdate,
- dirtyTangents = geometry.tangentsNeedUpdate,
- dirtyColors = geometry.colorsNeedUpdate,
- dirtyMorphTargets = geometry.morphTargetsNeedUpdate,
- vertices = geometry.vertices,
- chunk_faces3 = geometryGroup.faces3,
- chunk_faces4 = geometryGroup.faces4,
- obj_faces = geometry.faces,
- obj_uvs = geometry.faceVertexUvs[ 0 ],
- obj_uvs2 = geometry.faceVertexUvs[ 1 ],
- obj_colors = geometry.colors,
- obj_skinIndices = geometry.skinIndices,
- obj_skinWeights = geometry.skinWeights,
- morphTargets = geometry.morphTargets,
- morphNormals = geometry.morphNormals;
- if ( dirtyVertices ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- v1 = vertices[ face.a ];
- v2 = vertices[ face.b ];
- v3 = vertices[ face.c ];
- vertexArray[ offset ] = v1.x;
- vertexArray[ offset + 1 ] = v1.y;
- vertexArray[ offset + 2 ] = v1.z;
- vertexArray[ offset + 3 ] = v2.x;
- vertexArray[ offset + 4 ] = v2.y;
- vertexArray[ offset + 5 ] = v2.z;
- vertexArray[ offset + 6 ] = v3.x;
- vertexArray[ offset + 7 ] = v3.y;
- vertexArray[ offset + 8 ] = v3.z;
- offset += 9;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- v1 = vertices[ face.a ];
- v2 = vertices[ face.b ];
- v3 = vertices[ face.c ];
- v4 = vertices[ face.d ];
- vertexArray[ offset ] = v1.x;
- vertexArray[ offset + 1 ] = v1.y;
- vertexArray[ offset + 2 ] = v1.z;
- vertexArray[ offset + 3 ] = v2.x;
- vertexArray[ offset + 4 ] = v2.y;
- vertexArray[ offset + 5 ] = v2.z;
- vertexArray[ offset + 6 ] = v3.x;
- vertexArray[ offset + 7 ] = v3.y;
- vertexArray[ offset + 8 ] = v3.z;
- vertexArray[ offset + 9 ] = v4.x;
- vertexArray[ offset + 10 ] = v4.y;
- vertexArray[ offset + 11 ] = v4.z;
- offset += 12;
- }
- renderer.setDynamicArrayBuffer( geometryGroup.__webglVertexBuffer, vertexArray);
- }
- if ( dirtyMorphTargets ) {
- for ( vk = 0, vkl = morphTargets.length; vk < vkl; vk ++ ) {
- offset_morphTarget = 0;
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- chf = chunk_faces3[ f ];
- face = obj_faces[ chf ];
- // morph positions
- v1 = morphTargets[ vk ].vertices[ face.a ];
- v2 = morphTargets[ vk ].vertices[ face.b ];
- v3 = morphTargets[ vk ].vertices[ face.c ];
- vka = morphTargetsArrays[ vk ];
- vka[ offset_morphTarget ] = v1.x;
- vka[ offset_morphTarget + 1 ] = v1.y;
- vka[ offset_morphTarget + 2 ] = v1.z;
- vka[ offset_morphTarget + 3 ] = v2.x;
- vka[ offset_morphTarget + 4 ] = v2.y;
- vka[ offset_morphTarget + 5 ] = v2.z;
- vka[ offset_morphTarget + 6 ] = v3.x;
- vka[ offset_morphTarget + 7 ] = v3.y;
- vka[ offset_morphTarget + 8 ] = v3.z;
- // morph normals
- if ( material.morphNormals ) {
- if ( needsSmoothNormals ) {
- faceVertexNormals = morphNormals[ vk ].vertexNormals[ chf ];
- n1 = faceVertexNormals.a;
- n2 = faceVertexNormals.b;
- n3 = faceVertexNormals.c;
- } else {
- n1 = morphNormals[ vk ].faceNormals[ chf ];
- n2 = n1;
- n3 = n1;
- }
- nka = morphNormalsArrays[ vk ];
- nka[ offset_morphTarget ] = n1.x;
- nka[ offset_morphTarget + 1 ] = n1.y;
- nka[ offset_morphTarget + 2 ] = n1.z;
- nka[ offset_morphTarget + 3 ] = n2.x;
- nka[ offset_morphTarget + 4 ] = n2.y;
- nka[ offset_morphTarget + 5 ] = n2.z;
- nka[ offset_morphTarget + 6 ] = n3.x;
- nka[ offset_morphTarget + 7 ] = n3.y;
- nka[ offset_morphTarget + 8 ] = n3.z;
- }
- //
- offset_morphTarget += 9;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- chf = chunk_faces4[ f ];
- face = obj_faces[ chf ];
- // morph positions
- v1 = morphTargets[ vk ].vertices[ face.a ];
- v2 = morphTargets[ vk ].vertices[ face.b ];
- v3 = morphTargets[ vk ].vertices[ face.c ];
- v4 = morphTargets[ vk ].vertices[ face.d ];
- vka = morphTargetsArrays[ vk ];
- vka[ offset_morphTarget ] = v1.x;
- vka[ offset_morphTarget + 1 ] = v1.y;
- vka[ offset_morphTarget + 2 ] = v1.z;
- vka[ offset_morphTarget + 3 ] = v2.x;
- vka[ offset_morphTarget + 4 ] = v2.y;
- vka[ offset_morphTarget + 5 ] = v2.z;
- vka[ offset_morphTarget + 6 ] = v3.x;
- vka[ offset_morphTarget + 7 ] = v3.y;
- vka[ offset_morphTarget + 8 ] = v3.z;
- vka[ offset_morphTarget + 9 ] = v4.x;
- vka[ offset_morphTarget + 10 ] = v4.y;
- vka[ offset_morphTarget + 11 ] = v4.z;
- // morph normals
- if ( material.morphNormals ) {
- if ( needsSmoothNormals ) {
- faceVertexNormals = morphNormals[ vk ].vertexNormals[ chf ];
- n1 = faceVertexNormals.a;
- n2 = faceVertexNormals.b;
- n3 = faceVertexNormals.c;
- n4 = faceVertexNormals.d;
- } else {
- n1 = morphNormals[ vk ].faceNormals[ chf ];
- n2 = n1;
- n3 = n1;
- n4 = n1;
- }
- nka = morphNormalsArrays[ vk ];
- nka[ offset_morphTarget ] = n1.x;
- nka[ offset_morphTarget + 1 ] = n1.y;
- nka[ offset_morphTarget + 2 ] = n1.z;
- nka[ offset_morphTarget + 3 ] = n2.x;
- nka[ offset_morphTarget + 4 ] = n2.y;
- nka[ offset_morphTarget + 5 ] = n2.z;
- nka[ offset_morphTarget + 6 ] = n3.x;
- nka[ offset_morphTarget + 7 ] = n3.y;
- nka[ offset_morphTarget + 8 ] = n3.z;
- nka[ offset_morphTarget + 9 ] = n4.x;
- nka[ offset_morphTarget + 10 ] = n4.y;
- nka[ offset_morphTarget + 11 ] = n4.z;
- }
- //
- offset_morphTarget += 12;
- }
- this.renderer.setDynamicArrayBuffer( geometryGroup.__webglMorphTargetsBuffers[ vk ], morphTargetsArrays[ vk ]);
- if ( material.morphNormals ) {
- this.renderer.setDynamicArrayBuffer( geometryGroup.__webglMorphNormalsBuffers[ vk ], morphNormalsArrays[ vk ]);
- }
- }
- }
- if ( obj_skinWeights.length ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- // weights
- sw1 = obj_skinWeights[ face.a ];
- sw2 = obj_skinWeights[ face.b ];
- sw3 = obj_skinWeights[ face.c ];
- skinWeightArray[ offset_skin ] = sw1.x;
- skinWeightArray[ offset_skin + 1 ] = sw1.y;
- skinWeightArray[ offset_skin + 2 ] = sw1.z;
- skinWeightArray[ offset_skin + 3 ] = sw1.w;
- skinWeightArray[ offset_skin + 4 ] = sw2.x;
- skinWeightArray[ offset_skin + 5 ] = sw2.y;
- skinWeightArray[ offset_skin + 6 ] = sw2.z;
- skinWeightArray[ offset_skin + 7 ] = sw2.w;
- skinWeightArray[ offset_skin + 8 ] = sw3.x;
- skinWeightArray[ offset_skin + 9 ] = sw3.y;
- skinWeightArray[ offset_skin + 10 ] = sw3.z;
- skinWeightArray[ offset_skin + 11 ] = sw3.w;
- // indices
- si1 = obj_skinIndices[ face.a ];
- si2 = obj_skinIndices[ face.b ];
- si3 = obj_skinIndices[ face.c ];
- skinIndexArray[ offset_skin ] = si1.x;
- skinIndexArray[ offset_skin + 1 ] = si1.y;
- skinIndexArray[ offset_skin + 2 ] = si1.z;
- skinIndexArray[ offset_skin + 3 ] = si1.w;
- skinIndexArray[ offset_skin + 4 ] = si2.x;
- skinIndexArray[ offset_skin + 5 ] = si2.y;
- skinIndexArray[ offset_skin + 6 ] = si2.z;
- skinIndexArray[ offset_skin + 7 ] = si2.w;
- skinIndexArray[ offset_skin + 8 ] = si3.x;
- skinIndexArray[ offset_skin + 9 ] = si3.y;
- skinIndexArray[ offset_skin + 10 ] = si3.z;
- skinIndexArray[ offset_skin + 11 ] = si3.w;
- offset_skin += 12;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- // weights
- sw1 = obj_skinWeights[ face.a ];
- sw2 = obj_skinWeights[ face.b ];
- sw3 = obj_skinWeights[ face.c ];
- sw4 = obj_skinWeights[ face.d ];
- skinWeightArray[ offset_skin ] = sw1.x;
- skinWeightArray[ offset_skin + 1 ] = sw1.y;
- skinWeightArray[ offset_skin + 2 ] = sw1.z;
- skinWeightArray[ offset_skin + 3 ] = sw1.w;
- skinWeightArray[ offset_skin + 4 ] = sw2.x;
- skinWeightArray[ offset_skin + 5 ] = sw2.y;
- skinWeightArray[ offset_skin + 6 ] = sw2.z;
- skinWeightArray[ offset_skin + 7 ] = sw2.w;
- skinWeightArray[ offset_skin + 8 ] = sw3.x;
- skinWeightArray[ offset_skin + 9 ] = sw3.y;
- skinWeightArray[ offset_skin + 10 ] = sw3.z;
- skinWeightArray[ offset_skin + 11 ] = sw3.w;
- skinWeightArray[ offset_skin + 12 ] = sw4.x;
- skinWeightArray[ offset_skin + 13 ] = sw4.y;
- skinWeightArray[ offset_skin + 14 ] = sw4.z;
- skinWeightArray[ offset_skin + 15 ] = sw4.w;
- // indices
- si1 = obj_skinIndices[ face.a ];
- si2 = obj_skinIndices[ face.b ];
- si3 = obj_skinIndices[ face.c ];
- si4 = obj_skinIndices[ face.d ];
- skinIndexArray[ offset_skin ] = si1.x;
- skinIndexArray[ offset_skin + 1 ] = si1.y;
- skinIndexArray[ offset_skin + 2 ] = si1.z;
- skinIndexArray[ offset_skin + 3 ] = si1.w;
- skinIndexArray[ offset_skin + 4 ] = si2.x;
- skinIndexArray[ offset_skin + 5 ] = si2.y;
- skinIndexArray[ offset_skin + 6 ] = si2.z;
- skinIndexArray[ offset_skin + 7 ] = si2.w;
- skinIndexArray[ offset_skin + 8 ] = si3.x;
- skinIndexArray[ offset_skin + 9 ] = si3.y;
- skinIndexArray[ offset_skin + 10 ] = si3.z;
- skinIndexArray[ offset_skin + 11 ] = si3.w;
- skinIndexArray[ offset_skin + 12 ] = si4.x;
- skinIndexArray[ offset_skin + 13 ] = si4.y;
- skinIndexArray[ offset_skin + 14 ] = si4.z;
- skinIndexArray[ offset_skin + 15 ] = si4.w;
- offset_skin += 16;
- }
- if ( offset_skin > 0 ) {
- renderer.setDynamicArrayBuffer( geometryGroup.__webglSkinIndicesBuffer, skinIndexArray);
- renderer.setDynamicArrayBuffer( geometryGroup.__webglSkinWeightsBuffer, skinWeightArray);
- }
- }
- if ( dirtyColors && vertexColorType ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- vertexColors = face.vertexColors;
- faceColor = face.color;
- if ( vertexColors.length === 3 && vertexColorType === THREE.VertexColors ) {
- c1 = vertexColors[ 0 ];
- c2 = vertexColors[ 1 ];
- c3 = vertexColors[ 2 ];
- } else {
- c1 = faceColor;
- c2 = faceColor;
- c3 = faceColor;
- }
- colorArray[ offset_color ] = c1.r;
- colorArray[ offset_color + 1 ] = c1.g;
- colorArray[ offset_color + 2 ] = c1.b;
- colorArray[ offset_color + 3 ] = c2.r;
- colorArray[ offset_color + 4 ] = c2.g;
- colorArray[ offset_color + 5 ] = c2.b;
- colorArray[ offset_color + 6 ] = c3.r;
- colorArray[ offset_color + 7 ] = c3.g;
- colorArray[ offset_color + 8 ] = c3.b;
- offset_color += 9;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- vertexColors = face.vertexColors;
- faceColor = face.color;
- if ( vertexColors.length === 4 && vertexColorType === THREE.VertexColors ) {
- c1 = vertexColors[ 0 ];
- c2 = vertexColors[ 1 ];
- c3 = vertexColors[ 2 ];
- c4 = vertexColors[ 3 ];
- } else {
- c1 = faceColor;
- c2 = faceColor;
- c3 = faceColor;
- c4 = faceColor;
- }
- colorArray[ offset_color ] = c1.r;
- colorArray[ offset_color + 1 ] = c1.g;
- colorArray[ offset_color + 2 ] = c1.b;
- colorArray[ offset_color + 3 ] = c2.r;
- colorArray[ offset_color + 4 ] = c2.g;
- colorArray[ offset_color + 5 ] = c2.b;
- colorArray[ offset_color + 6 ] = c3.r;
- colorArray[ offset_color + 7 ] = c3.g;
- colorArray[ offset_color + 8 ] = c3.b;
- colorArray[ offset_color + 9 ] = c4.r;
- colorArray[ offset_color + 10 ] = c4.g;
- colorArray[ offset_color + 11 ] = c4.b;
- offset_color += 12;
- }
- if ( offset_color > 0 ) {
- renderer.setDynamicArrayBuffer( geometryGroup.__webglColorBuffer, colorArray);
- }
- }
- if ( dirtyTangents && geometry.hasTangents ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- vertexTangents = face.vertexTangents;
- t1 = vertexTangents[ 0 ];
- t2 = vertexTangents[ 1 ];
- t3 = vertexTangents[ 2 ];
- tangentArray[ offset_tangent ] = t1.x;
- tangentArray[ offset_tangent + 1 ] = t1.y;
- tangentArray[ offset_tangent + 2 ] = t1.z;
- tangentArray[ offset_tangent + 3 ] = t1.w;
- tangentArray[ offset_tangent + 4 ] = t2.x;
- tangentArray[ offset_tangent + 5 ] = t2.y;
- tangentArray[ offset_tangent + 6 ] = t2.z;
- tangentArray[ offset_tangent + 7 ] = t2.w;
- tangentArray[ offset_tangent + 8 ] = t3.x;
- tangentArray[ offset_tangent + 9 ] = t3.y;
- tangentArray[ offset_tangent + 10 ] = t3.z;
- tangentArray[ offset_tangent + 11 ] = t3.w;
- offset_tangent += 12;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- vertexTangents = face.vertexTangents;
- t1 = vertexTangents[ 0 ];
- t2 = vertexTangents[ 1 ];
- t3 = vertexTangents[ 2 ];
- t4 = vertexTangents[ 3 ];
- tangentArray[ offset_tangent ] = t1.x;
- tangentArray[ offset_tangent + 1 ] = t1.y;
- tangentArray[ offset_tangent + 2 ] = t1.z;
- tangentArray[ offset_tangent + 3 ] = t1.w;
- tangentArray[ offset_tangent + 4 ] = t2.x;
- tangentArray[ offset_tangent + 5 ] = t2.y;
- tangentArray[ offset_tangent + 6 ] = t2.z;
- tangentArray[ offset_tangent + 7 ] = t2.w;
- tangentArray[ offset_tangent + 8 ] = t3.x;
- tangentArray[ offset_tangent + 9 ] = t3.y;
- tangentArray[ offset_tangent + 10 ] = t3.z;
- tangentArray[ offset_tangent + 11 ] = t3.w;
- tangentArray[ offset_tangent + 12 ] = t4.x;
- tangentArray[ offset_tangent + 13 ] = t4.y;
- tangentArray[ offset_tangent + 14 ] = t4.z;
- tangentArray[ offset_tangent + 15 ] = t4.w;
- offset_tangent += 16;
- }
- renderer.setDynamicArrayBuffer( geometryGroup.__webglTangentBuffer, tangentArray);
- }
- if ( dirtyNormals && normalType ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- vertexNormals = face.vertexNormals;
- faceNormal = face.normal;
- if ( vertexNormals.length === 3 && needsSmoothNormals ) {
- for ( i = 0; i < 3; i ++ ) {
- vn = vertexNormals[ i ];
- normalArray[ offset_normal ] = vn.x;
- normalArray[ offset_normal + 1 ] = vn.y;
- normalArray[ offset_normal + 2 ] = vn.z;
- offset_normal += 3;
- }
- } else {
- for ( i = 0; i < 3; i ++ ) {
- normalArray[ offset_normal ] = faceNormal.x;
- normalArray[ offset_normal + 1 ] = faceNormal.y;
- normalArray[ offset_normal + 2 ] = faceNormal.z;
- offset_normal += 3;
- }
- }
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- vertexNormals = face.vertexNormals;
- faceNormal = face.normal;
- if ( vertexNormals.length === 4 && needsSmoothNormals ) {
- for ( i = 0; i < 4; i ++ ) {
- vn = vertexNormals[ i ];
- normalArray[ offset_normal ] = vn.x;
- normalArray[ offset_normal + 1 ] = vn.y;
- normalArray[ offset_normal + 2 ] = vn.z;
- offset_normal += 3;
- }
- } else {
- for ( i = 0; i < 4; i ++ ) {
- normalArray[ offset_normal ] = faceNormal.x;
- normalArray[ offset_normal + 1 ] = faceNormal.y;
- normalArray[ offset_normal + 2 ] = faceNormal.z;
- offset_normal += 3;
- }
- }
- }
- renderer.setDynamicArrayBuffer( geometryGroup.__webglNormalBuffer, normalArray);
- }
- if ( dirtyUvs && obj_uvs && uvType ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- fi = chunk_faces3[ f ];
- uv = obj_uvs[ fi ];
- if ( uv === undefined ) continue;
- for ( i = 0; i < 3; i ++ ) {
- uvi = uv[ i ];
- uvArray[ offset_uv ] = uvi.x;
- uvArray[ offset_uv + 1 ] = uvi.y;
- offset_uv += 2;
- }
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- fi = chunk_faces4[ f ];
- uv = obj_uvs[ fi ];
- if ( uv === undefined ) continue;
- for ( i = 0; i < 4; i ++ ) {
- uvi = uv[ i ];
- uvArray[ offset_uv ] = uvi.x;
- uvArray[ offset_uv + 1 ] = uvi.y;
- offset_uv += 2;
- }
- }
- if ( offset_uv > 0 ) {
- renderer.setDynamicArrayBuffer( geometryGroup.__webglUVBuffer, uvArray);
- }
- }
- if ( dirtyUvs && obj_uvs2 && uvType ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- fi = chunk_faces3[ f ];
- uv2 = obj_uvs2[ fi ];
- if ( uv2 === undefined ) continue;
- for ( i = 0; i < 3; i ++ ) {
- uv2i = uv2[ i ];
- uv2Array[ offset_uv2 ] = uv2i.x;
- uv2Array[ offset_uv2 + 1 ] = uv2i.y;
- offset_uv2 += 2;
- }
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- fi = chunk_faces4[ f ];
- uv2 = obj_uvs2[ fi ];
- if ( uv2 === undefined ) continue;
- for ( i = 0; i < 4; i ++ ) {
- uv2i = uv2[ i ];
- uv2Array[ offset_uv2 ] = uv2i.x;
- uv2Array[ offset_uv2 + 1 ] = uv2i.y;
- offset_uv2 += 2;
- }
- }
- if ( offset_uv2 > 0 ) {
- renderer.setDynamicArrayBuffer( geometryGroup.__webglUV2Buffer, uv2Array);
- }
- }
- if ( dirtyElements ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- faceArray[ offset_face ] = vertexIndex;
- faceArray[ offset_face + 1 ] = vertexIndex + 1;
- faceArray[ offset_face + 2 ] = vertexIndex + 2;
- offset_face += 3;
- lineArray[ offset_line ] = vertexIndex;
- lineArray[ offset_line + 1 ] = vertexIndex + 1;
- lineArray[ offset_line + 2 ] = vertexIndex;
- lineArray[ offset_line + 3 ] = vertexIndex + 2;
- lineArray[ offset_line + 4 ] = vertexIndex + 1;
- lineArray[ offset_line + 5 ] = vertexIndex + 2;
- offset_line += 6;
- vertexIndex += 3;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- faceArray[ offset_face ] = vertexIndex;
- faceArray[ offset_face + 1 ] = vertexIndex + 1;
- faceArray[ offset_face + 2 ] = vertexIndex + 3;
- faceArray[ offset_face + 3 ] = vertexIndex + 1;
- faceArray[ offset_face + 4 ] = vertexIndex + 2;
- faceArray[ offset_face + 5 ] = vertexIndex + 3;
- offset_face += 6;
- lineArray[ offset_line ] = vertexIndex;
- lineArray[ offset_line + 1 ] = vertexIndex + 1;
- lineArray[ offset_line + 2 ] = vertexIndex;
- lineArray[ offset_line + 3 ] = vertexIndex + 3;
- lineArray[ offset_line + 4 ] = vertexIndex + 1;
- lineArray[ offset_line + 5 ] = vertexIndex + 2;
- lineArray[ offset_line + 6 ] = vertexIndex + 2;
- lineArray[ offset_line + 7 ] = vertexIndex + 3;
- offset_line += 8;
- vertexIndex += 4;
- }
- renderer.setDynamicIndexBuffer( geometryGroup.__webglFaceBuffer, faceArray);
- renderer.setDynamicIndexBuffer( geometryGroup.__webglLineBuffer, lineArray);
- }
- if ( customAttributes ) {
- for ( i = 0, il = customAttributes.length; i < il; i ++ ) {
- customAttribute = customAttributes[ i ];
- if ( ! customAttribute.__original.needsUpdate ) continue;
- offset_custom = 0;
- offset_customSrc = 0;
- if ( customAttribute.size === 1 ) {
- if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- customAttribute.array[ offset_custom ] = customAttribute.value[ face.a ];
- customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
- customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
- offset_custom += 3;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- customAttribute.array[ offset_custom ] = customAttribute.value[ face.a ];
- customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
- customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
- customAttribute.array[ offset_custom + 3 ] = customAttribute.value[ face.d ];
- offset_custom += 4;
- }
- } else if ( customAttribute.boundTo === "faces" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces3[ f ] ];
- customAttribute.array[ offset_custom ] = value;
- customAttribute.array[ offset_custom + 1 ] = value;
- customAttribute.array[ offset_custom + 2 ] = value;
- offset_custom += 3;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces4[ f ] ];
- customAttribute.array[ offset_custom ] = value;
- customAttribute.array[ offset_custom + 1 ] = value;
- customAttribute.array[ offset_custom + 2 ] = value;
- customAttribute.array[ offset_custom + 3 ] = value;
- offset_custom += 4;
- }
- }
- } else if ( customAttribute.size === 2 ) {
- if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- v1 = customAttribute.value[ face.a ];
- v2 = customAttribute.value[ face.b ];
- v3 = customAttribute.value[ face.c ];
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v2.x;
- customAttribute.array[ offset_custom + 3 ] = v2.y;
- customAttribute.array[ offset_custom + 4 ] = v3.x;
- customAttribute.array[ offset_custom + 5 ] = v3.y;
- offset_custom += 6;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- v1 = customAttribute.value[ face.a ];
- v2 = customAttribute.value[ face.b ];
- v3 = customAttribute.value[ face.c ];
- v4 = customAttribute.value[ face.d ];
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v2.x;
- customAttribute.array[ offset_custom + 3 ] = v2.y;
- customAttribute.array[ offset_custom + 4 ] = v3.x;
- customAttribute.array[ offset_custom + 5 ] = v3.y;
- customAttribute.array[ offset_custom + 6 ] = v4.x;
- customAttribute.array[ offset_custom + 7 ] = v4.y;
- offset_custom += 8;
- }
- } else if ( customAttribute.boundTo === "faces" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces3[ f ] ];
- v1 = value;
- v2 = value;
- v3 = value;
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v2.x;
- customAttribute.array[ offset_custom + 3 ] = v2.y;
- customAttribute.array[ offset_custom + 4 ] = v3.x;
- customAttribute.array[ offset_custom + 5 ] = v3.y;
- offset_custom += 6;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces4[ f ] ];
- v1 = value;
- v2 = value;
- v3 = value;
- v4 = value;
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v2.x;
- customAttribute.array[ offset_custom + 3 ] = v2.y;
- customAttribute.array[ offset_custom + 4 ] = v3.x;
- customAttribute.array[ offset_custom + 5 ] = v3.y;
- customAttribute.array[ offset_custom + 6 ] = v4.x;
- customAttribute.array[ offset_custom + 7 ] = v4.y;
- offset_custom += 8;
- }
- }
- } else if ( customAttribute.size === 3 ) {
- var pp;
- if ( customAttribute.type === "c" ) {
- pp = [ "r", "g", "b" ];
- } else {
- pp = [ "x", "y", "z" ];
- }
- if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- v1 = customAttribute.value[ face.a ];
- v2 = customAttribute.value[ face.b ];
- v3 = customAttribute.value[ face.c ];
- customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
- offset_custom += 9;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- v1 = customAttribute.value[ face.a ];
- v2 = customAttribute.value[ face.b ];
- v3 = customAttribute.value[ face.c ];
- v4 = customAttribute.value[ face.d ];
- customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 9 ] = v4[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 10 ] = v4[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
- offset_custom += 12;
- }
- } else if ( customAttribute.boundTo === "faces" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces3[ f ] ];
- v1 = value;
- v2 = value;
- v3 = value;
- customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
- offset_custom += 9;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces4[ f ] ];
- v1 = value;
- v2 = value;
- v3 = value;
- v4 = value;
- customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 9 ] = v4[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 10 ] = v4[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
- offset_custom += 12;
- }
- } else if ( customAttribute.boundTo === "faceVertices" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces3[ f ] ];
- v1 = value[ 0 ];
- v2 = value[ 1 ];
- v3 = value[ 2 ];
- customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
- offset_custom += 9;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces4[ f ] ];
- v1 = value[ 0 ];
- v2 = value[ 1 ];
- v3 = value[ 2 ];
- v4 = value[ 3 ];
- customAttribute.array[ offset_custom ] = v1[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 1 ] = v1[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 2 ] = v1[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 3 ] = v2[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 4 ] = v2[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 5 ] = v2[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 6 ] = v3[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 7 ] = v3[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 8 ] = v3[ pp[ 2 ] ];
- customAttribute.array[ offset_custom + 9 ] = v4[ pp[ 0 ] ];
- customAttribute.array[ offset_custom + 10 ] = v4[ pp[ 1 ] ];
- customAttribute.array[ offset_custom + 11 ] = v4[ pp[ 2 ] ];
- offset_custom += 12;
- }
- }
- } else if ( customAttribute.size === 4 ) {
- if ( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces3[ f ] ];
- v1 = customAttribute.value[ face.a ];
- v2 = customAttribute.value[ face.b ];
- v3 = customAttribute.value[ face.c ];
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v1.z;
- customAttribute.array[ offset_custom + 3 ] = v1.w;
- customAttribute.array[ offset_custom + 4 ] = v2.x;
- customAttribute.array[ offset_custom + 5 ] = v2.y;
- customAttribute.array[ offset_custom + 6 ] = v2.z;
- customAttribute.array[ offset_custom + 7 ] = v2.w;
- customAttribute.array[ offset_custom + 8 ] = v3.x;
- customAttribute.array[ offset_custom + 9 ] = v3.y;
- customAttribute.array[ offset_custom + 10 ] = v3.z;
- customAttribute.array[ offset_custom + 11 ] = v3.w;
- offset_custom += 12;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- face = obj_faces[ chunk_faces4[ f ] ];
- v1 = customAttribute.value[ face.a ];
- v2 = customAttribute.value[ face.b ];
- v3 = customAttribute.value[ face.c ];
- v4 = customAttribute.value[ face.d ];
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v1.z;
- customAttribute.array[ offset_custom + 3 ] = v1.w;
- customAttribute.array[ offset_custom + 4 ] = v2.x;
- customAttribute.array[ offset_custom + 5 ] = v2.y;
- customAttribute.array[ offset_custom + 6 ] = v2.z;
- customAttribute.array[ offset_custom + 7 ] = v2.w;
- customAttribute.array[ offset_custom + 8 ] = v3.x;
- customAttribute.array[ offset_custom + 9 ] = v3.y;
- customAttribute.array[ offset_custom + 10 ] = v3.z;
- customAttribute.array[ offset_custom + 11 ] = v3.w;
- customAttribute.array[ offset_custom + 12 ] = v4.x;
- customAttribute.array[ offset_custom + 13 ] = v4.y;
- customAttribute.array[ offset_custom + 14 ] = v4.z;
- customAttribute.array[ offset_custom + 15 ] = v4.w;
- offset_custom += 16;
- }
- } else if ( customAttribute.boundTo === "faces" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces3[ f ] ];
- v1 = value;
- v2 = value;
- v3 = value;
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v1.z;
- customAttribute.array[ offset_custom + 3 ] = v1.w;
- customAttribute.array[ offset_custom + 4 ] = v2.x;
- customAttribute.array[ offset_custom + 5 ] = v2.y;
- customAttribute.array[ offset_custom + 6 ] = v2.z;
- customAttribute.array[ offset_custom + 7 ] = v2.w;
- customAttribute.array[ offset_custom + 8 ] = v3.x;
- customAttribute.array[ offset_custom + 9 ] = v3.y;
- customAttribute.array[ offset_custom + 10 ] = v3.z;
- customAttribute.array[ offset_custom + 11 ] = v3.w;
- offset_custom += 12;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces4[ f ] ];
- v1 = value;
- v2 = value;
- v3 = value;
- v4 = value;
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v1.z;
- customAttribute.array[ offset_custom + 3 ] = v1.w;
- customAttribute.array[ offset_custom + 4 ] = v2.x;
- customAttribute.array[ offset_custom + 5 ] = v2.y;
- customAttribute.array[ offset_custom + 6 ] = v2.z;
- customAttribute.array[ offset_custom + 7 ] = v2.w;
- customAttribute.array[ offset_custom + 8 ] = v3.x;
- customAttribute.array[ offset_custom + 9 ] = v3.y;
- customAttribute.array[ offset_custom + 10 ] = v3.z;
- customAttribute.array[ offset_custom + 11 ] = v3.w;
- customAttribute.array[ offset_custom + 12 ] = v4.x;
- customAttribute.array[ offset_custom + 13 ] = v4.y;
- customAttribute.array[ offset_custom + 14 ] = v4.z;
- customAttribute.array[ offset_custom + 15 ] = v4.w;
- offset_custom += 16;
- }
- } else if ( customAttribute.boundTo === "faceVertices" ) {
- for ( f = 0, fl = chunk_faces3.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces3[ f ] ];
- v1 = value[ 0 ];
- v2 = value[ 1 ];
- v3 = value[ 2 ];
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v1.z;
- customAttribute.array[ offset_custom + 3 ] = v1.w;
- customAttribute.array[ offset_custom + 4 ] = v2.x;
- customAttribute.array[ offset_custom + 5 ] = v2.y;
- customAttribute.array[ offset_custom + 6 ] = v2.z;
- customAttribute.array[ offset_custom + 7 ] = v2.w;
- customAttribute.array[ offset_custom + 8 ] = v3.x;
- customAttribute.array[ offset_custom + 9 ] = v3.y;
- customAttribute.array[ offset_custom + 10 ] = v3.z;
- customAttribute.array[ offset_custom + 11 ] = v3.w;
- offset_custom += 12;
- }
- for ( f = 0, fl = chunk_faces4.length; f < fl; f ++ ) {
- value = customAttribute.value[ chunk_faces4[ f ] ];
- v1 = value[ 0 ];
- v2 = value[ 1 ];
- v3 = value[ 2 ];
- v4 = value[ 3 ];
- customAttribute.array[ offset_custom ] = v1.x;
- customAttribute.array[ offset_custom + 1 ] = v1.y;
- customAttribute.array[ offset_custom + 2 ] = v1.z;
- customAttribute.array[ offset_custom + 3 ] = v1.w;
- customAttribute.array[ offset_custom + 4 ] = v2.x;
- customAttribute.array[ offset_custom + 5 ] = v2.y;
- customAttribute.array[ offset_custom + 6 ] = v2.z;
- customAttribute.array[ offset_custom + 7 ] = v2.w;
- customAttribute.array[ offset_custom + 8 ] = v3.x;
- customAttribute.array[ offset_custom + 9 ] = v3.y;
- customAttribute.array[ offset_custom + 10 ] = v3.z;
- customAttribute.array[ offset_custom + 11 ] = v3.w;
- customAttribute.array[ offset_custom + 12 ] = v4.x;
- customAttribute.array[ offset_custom + 13 ] = v4.y;
- customAttribute.array[ offset_custom + 14 ] = v4.z;
- customAttribute.array[ offset_custom + 15 ] = v4.w;
- offset_custom += 16;
- }
- }
- }
- renderer.setDynamicArrayBuffer( customAttribute.buffer, customAttribute.array);
- }
- }
- if ( dispose ) {
- delete geometryGroup.__inittedArrays;
- delete geometryGroup.__colorArray;
- delete geometryGroup.__normalArray;
- delete geometryGroup.__tangentArray;
- delete geometryGroup.__uvArray;
- delete geometryGroup.__uv2Array;
- delete geometryGroup.__faceArray;
- delete geometryGroup.__vertexArray;
- delete geometryGroup.__lineArray;
- delete geometryGroup.__skinIndexArray;
- delete geometryGroup.__skinWeightArray;
- }
- }
- } );
|