| 7655 | |
| 7656 | |
| 7657 | function parseModel( scale ) { |
| 7658 | |
| 7659 | function isBitSet( value, position ) { |
| 7660 | |
| 7661 | return value & ( 1 << position ); |
| 7662 | |
| 7663 | } |
| 7664 | |
| 7665 | var i, j, fi, |
| 7666 | |
| 7667 | offset, zLength, nVertices, |
| 7668 | |
| 7669 | colorIndex, normalIndex, uvIndex, materialIndex, |
| 7670 | |
| 7671 | type, |
| 7672 | isQuad, |
| 7673 | hasMaterial, |
| 7674 | hasFaceUv, hasFaceVertexUv, |
| 7675 | hasFaceNormal, hasFaceVertexNormal, |
| 7676 | hasFaceColor, hasFaceVertexColor, |
| 7677 | |
| 7678 | vertex, face, color, normal, |
| 7679 | |
| 7680 | uvLayer, uvs, u, v, |
| 7681 | |
| 7682 | faces = json.faces, |
| 7683 | vertices = json.vertices, |
| 7684 | normals = json.normals, |
| 7685 | colors = json.colors, |
| 7686 | |
| 7687 | nUvLayers = 0; |
| 7688 | |
| 7689 | // disregard empty arrays |
| 7690 | |
| 7691 | for ( i = 0; i < json.uvs.length; i++ ) { |
| 7692 | |
| 7693 | if ( json.uvs[ i ].length ) nUvLayers ++; |
| 7694 | |
| 7695 | } |
| 7696 | |
| 7697 | for ( i = 0; i < nUvLayers; i++ ) { |
| 7698 | |
| 7699 | geometry.faceUvs[ i ] = []; |
| 7700 | geometry.faceVertexUvs[ i ] = []; |
| 7701 | |
| 7702 | } |
| 7703 | |
| 7704 | offset = 0; |
| 7705 | zLength = vertices.length; |
| 7706 | |
| 7707 | while ( offset < zLength ) { |
| 7708 | |
| 7709 | vertex = new THREE.Vector3(); |
| 7710 | |
| 7711 | vertex.x = vertices[ offset ++ ] * scale; |
| 7712 | vertex.y = vertices[ offset ++ ] * scale; |
| 7713 | vertex.z = vertices[ offset ++ ] * scale; |
| 7714 | |