提交 2989defc 编写于 作者: A alteredq

First version that is at least partially working with the new model format ;).

Tons of things still broken.
上级 0dd0b90e
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
此差异已折叠。
......@@ -24,8 +24,6 @@ THREE.JSONLoader.prototype = {
load: function ( parameters ) {
console.log( parameters );
var url = parameters.model,
callback = parameters.callback,
texture_path = parameters.texture_path ? parameters.texture_path : THREE.Loader.prototype.extractUrlbase( url ),
......@@ -35,8 +33,6 @@ THREE.JSONLoader.prototype = {
worker.onmessage = function( event ) {
console.log( event.data );
THREE.JSONLoader.prototype.createModel( event.data, callback, texture_path );
};
......@@ -78,9 +74,10 @@ THREE.JSONLoader.prototype = {
var i, j,
type, offset,
offset, zLength,
isTriangle,
type,
isQuad,
hasMaterial,
hasFaceUv, hasFaceVertexUv,
hasFaceNormal, hasFaceVertexNormal,
......@@ -92,7 +89,15 @@ THREE.JSONLoader.prototype = {
vertices = json.vertices,
normals = json.normals,
nUvLayers = json.uvs.length;
nUvLayers = 0;
// discard empty arrays
for ( i = 0; i < json.uvs.length; i++ ) {
if ( json.uvs[ i ].length ) nUvLayers ++;
}
for ( i = 0; i < nUvLayers; i++ ) {
......@@ -102,8 +107,9 @@ THREE.JSONLoader.prototype = {
}
offset = 0;
zLength = vertices.length;
while ( vertices[ offset ] ) {
while ( offset < zLength ) {
vertex = new THREE.Vertex();
......@@ -116,12 +122,13 @@ THREE.JSONLoader.prototype = {
}
offset = 0;
zLength = faces.length;
while ( faces[ offset ] ) {
while ( offset < zLength ) {
type = faces[ offset ];
type = faces[ offset ++ ];
isTriangle = isBitSet( type, 0 );
isQuad = isBitSet( type, 0 );
hasMaterial = isBitSet( type, 1 );
hasFaceUv = isBitSet( type, 2 );
hasFaceVertexUv = isBitSet( type, 3 );
......@@ -130,34 +137,35 @@ THREE.JSONLoader.prototype = {
hasFaceColor = isBitSet( type, 6 );
hasFaceVertexColor = isBitSet( type, 7 );
//console.log("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
if ( isTriangle ) {
if ( isQuad ) {
face = new THREE.Face3();
face = new THREE.Face4();
face.a = faces[ offset ++ ];
face.b = faces[ offset ++ ];
face.c = faces[ offset ++ ];
face.d = faces[ offset ++ ];
nVertices = 3;
nVertices = 4;
} else {
face = new THREE.Face4();
face = new THREE.Face3();
face.a = faces[ offset ++ ];
face.b = faces[ offset ++ ];
face.c = faces[ offset ++ ];
face.d = faces[ offset ++ ];
nVertices = 4;
nVertices = 3;
}
if ( hasMaterial ) {
materialIndex = faces[ offset ++ ];
face.materials = [ scope.materials[ materialIndex ] ];
face.materials = scope.materials[ materialIndex ];
}
......
......@@ -361,7 +361,7 @@ THREE.WebGLRenderer = function ( parameters ) {
normalType = bufferGuessNormalType( materials, geometryGroup, object );
vertexColorType = bufferGuessVertexColorType( materials, geometryGroup, object );
console.log(uvType, normalType, vertexColorType, geometry, materials );
//console.log(uvType, normalType, vertexColorType, object, geometryGroup, materials );
geometryGroup.__vertexArray = new Float32Array( nvertices * 3 );
......@@ -3330,6 +3330,7 @@ THREE.WebGLRenderer = function ( parameters ) {
if ( !_gl.getShaderParameter( shader, _gl.COMPILE_STATUS ) ) {
console.error( _gl.getShaderInfoLog( shader ) );
console.error( string );
return null;
}
......@@ -3450,8 +3451,6 @@ THREE.WebGLRenderer = function ( parameters ) {
material, meshMaterial,
materials = [];
console.log( "unrollGroupMaterials", object.materials, geometryGroup );
for ( m = 0, ml = object.materials.length; m < ml; m++ ) {
meshMaterial = object.materials[ m ];
......
......@@ -167,7 +167,7 @@ var model = {
'normals': [%(normals)s],
'uvs': [%(uvs)s],
'uvs': [[%(uvs)s]],
'faces': [%(faces)s],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册