提交 ae57c164 编写于 作者: G gero3

revert certain files

上级 fb210eb8
......@@ -13,37 +13,37 @@ var ImprovedNoise = function () {
14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,
93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180 ];
for ( var i = 0; i < 256 ; i ++ ) {
for (var i = 0; i < 256 ; i ++) {
p[ 256 + i ] = p[ i ];
p[256 + i] = p[i];
}
function fade( t ) {
function fade(t) {
return t * t * t * ( t * ( t * 6 - 15 ) + 10 );
return t * t * t * (t * (t * 6 - 15) + 10);
}
function lerp( t, a, b ) {
function lerp(t, a, b) {
return a + t * ( b - a );
return a + t * (b - a);
}
function grad( hash, x, y, z ) {
function grad(hash, x, y, z) {
var h = hash & 15;
var u = h < 8 ? x : y, v = h < 4 ? y : h == 12 || h == 14 ? x : z;
return ( ( h & 1 ) == 0 ? u : - u ) + ( ( h & 2 ) == 0 ? v : - v );
return ((h&1) == 0 ? u : -u) + ((h&2) == 0 ? v : -v);
}
return {
noise: function ( x, y, z ) {
noise: function (x, y, z) {
var floorX = ~~ x, floorY = ~~ y, floorZ = ~~ z;
var floorX = ~~x, floorY = ~~y, floorZ = ~~z;
var X = floorX & 255, Y = floorY & 255, Z = floorZ & 255;
......@@ -53,20 +53,19 @@ var ImprovedNoise = function () {
var xMinus1 = x - 1, yMinus1 = y - 1, zMinus1 = z - 1;
var u = fade( x ), v = fade( y ), w = fade( z );
var u = fade(x), v = fade(y), w = fade(z);
var A = p[ X ] + Y, AA = p[ A ] + Z, AB = p[ A + 1 ] + Z, B = p[ X + 1 ] + Y, BA = p[ B ] + Z, BB = p[ B + 1 ] + Z;
var A = p[X] + Y, AA = p[A] + Z, AB = p[A + 1] + Z, B = p[X + 1] + Y, BA = p[B] + Z, BB = p[B + 1] + Z;
return lerp( w, lerp( v, lerp( u, grad( p[ AA ], x, y, z ),
grad( p[ BA ], xMinus1, y, z ) ),
lerp( u, grad( p[ AB ], x, yMinus1, z ),
grad( p[ BB ], xMinus1, yMinus1, z ) ) ),
lerp( v, lerp( u, grad( p[ AA + 1 ], x, y, zMinus1 ),
grad( p[ BA + 1 ], xMinus1, y, z - 1 ) ),
lerp( u, grad( p[ AB + 1 ], x, yMinus1, zMinus1 ),
grad( p[ BB + 1 ], xMinus1, yMinus1, zMinus1 ) ) ) );
return lerp(w, lerp(v, lerp(u, grad(p[AA], x, y, z),
grad(p[BA], xMinus1, y, z)),
lerp(u, grad(p[AB], x, yMinus1, z),
grad(p[BB], xMinus1, yMinus1, z))),
lerp(v, lerp(u, grad(p[AA + 1], x, y, zMinus1),
grad(p[BA + 1], xMinus1, y, z - 1)),
lerp(u, grad(p[AB + 1], x, yMinus1, zMinus1),
grad(p[BB + 1], xMinus1, yMinus1, zMinus1))));
}
}
};
此差异已折叠。
......@@ -133,18 +133,18 @@ THREE.UTF8Loader.BufferGeometryCreator.prototype.create = function ( attribArray
var DEFAULT_DECODE_PARAMS = {
decodeOffsets: [ - 4095, - 4095, - 4095, 0, 0, - 511, - 511, - 511 ],
decodeScales: [ 1 / 8191, 1 / 8191, 1 / 8191, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023 ]
// TODO: normal decoding? (see walt.js)
// needs to know: input, output (from vertex format!)
//
// Should split attrib/index.
// 1) Decode position and non-normal attributes.
// 2) Decode indices, computing normals
// 3) Maybe normalize normals? Only necessary for refinement, or fixed?
// 4) Maybe refine normals? Should this be part of regular refinement?
// 5) Morphing
decodeOffsets: [ -4095, -4095, -4095, 0, 0, -511, -511, -511 ],
decodeScales: [ 1 / 8191, 1 / 8191, 1 / 8191, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023, 1 / 1023 ]
// TODO: normal decoding? (see walt.js)
// needs to know: input, output (from vertex format!)
//
// Should split attrib/index.
// 1) Decode position and non-normal attributes.
// 2) Decode indices, computing normals
// 3) Maybe normalize normals? Only necessary for refinement, or fixed?
// 4) Maybe refine normals? Should this be part of regular refinement?
// 5) Morphing
};
......@@ -163,7 +163,7 @@ THREE.UTF8Loader.prototype.decompressAttribsInner_ = function ( str, inputStart,
for ( var j = inputStart; j < inputEnd; j ++ ) {
var code = str.charCodeAt( j );
prev += ( code >> 1 ) ^ ( - ( code & 1 ) );
prev += ( code >> 1 ) ^ ( -( code & 1 ) );
output[ outputStart ] = decodeScale * ( prev + decodeOffset );
outputStart += stride;
......@@ -195,7 +195,6 @@ THREE.UTF8Loader.prototype.decompressIndices_ = function( str, inputStart, numIn
THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBoxen,
decodeOffsets, decodeScales ) {
var numFloats = 6 * numBBoxen;
var inputEnd = inputStart + numFloats;
......@@ -205,21 +204,21 @@ THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBo
for ( var i = inputStart; i < inputEnd; i += 6 ) {
var minX = str.charCodeAt( i + 0 ) + decodeOffsets[ 0 ];
var minY = str.charCodeAt( i + 1 ) + decodeOffsets[ 1 ];
var minZ = str.charCodeAt( i + 2 ) + decodeOffsets[ 2 ];
var minX = str.charCodeAt(i + 0) + decodeOffsets[0];
var minY = str.charCodeAt(i + 1) + decodeOffsets[1];
var minZ = str.charCodeAt(i + 2) + decodeOffsets[2];
var radiusX = ( str.charCodeAt( i + 3 ) + 1 ) >> 1;
var radiusY = ( str.charCodeAt( i + 4 ) + 1 ) >> 1;
var radiusZ = ( str.charCodeAt( i + 5 ) + 1 ) >> 1;
var radiusX = (str.charCodeAt(i + 3) + 1) >> 1;
var radiusY = (str.charCodeAt(i + 4) + 1) >> 1;
var radiusZ = (str.charCodeAt(i + 5) + 1) >> 1;
bboxen[ outputStart ++ ] = decodeScales[ 0 ] * ( minX + radiusX );
bboxen[ outputStart ++ ] = decodeScales[ 1 ] * ( minY + radiusY );
bboxen[ outputStart ++ ] = decodeScales[ 2 ] * ( minZ + radiusZ );
bboxen[ outputStart ++ ] = decodeScales[0] * (minX + radiusX);
bboxen[ outputStart ++ ] = decodeScales[1] * (minY + radiusY);
bboxen[ outputStart ++ ] = decodeScales[2] * (minZ + radiusZ);
bboxen[ outputStart ++ ] = decodeScales[ 0 ] * radiusX;
bboxen[ outputStart ++ ] = decodeScales[ 1 ] * radiusY;
bboxen[ outputStart ++ ] = decodeScales[ 2 ] * radiusZ;
bboxen[ outputStart ++ ] = decodeScales[0] * radiusX;
bboxen[ outputStart ++ ] = decodeScales[1] * radiusY;
bboxen[ outputStart ++ ] = decodeScales[2] * radiusZ;
}
......@@ -229,36 +228,35 @@ THREE.UTF8Loader.prototype.decompressAABBs_ = function ( str, inputStart, numBBo
THREE.UTF8Loader.prototype.decompressMesh = function ( str, meshParams, decodeParams, name, idx, callback ) {
// Extract conversion parameters from attribArrays.
// Extract conversion parameters from attribArrays.
var stride = decodeParams.decodeScales.length;
var decodeOffsets = decodeParams.decodeOffsets;
var decodeScales = decodeParams.decodeScales;
var attribStart = meshParams.attribRange[ 0 ];
var numVerts = meshParams.attribRange[ 1 ];
var attribStart = meshParams.attribRange[0];
var numVerts = meshParams.attribRange[1];
// Decode attributes.
// Decode attributes.
var inputOffset = attribStart;
var attribsOut = new Float32Array( stride * numVerts );
for ( var j = 0; j < stride; j ++ ) {
for (var j = 0; j < stride; j ++ ) {
var end = inputOffset + numVerts;
var decodeScale = decodeScales[ j ];
var decodeScale = decodeScales[j];
if ( decodeScale ) {
// Assume if decodeScale is never set, simply ignore the
// attribute.
// Assume if decodeScale is never set, simply ignore the
// attribute.
this.decompressAttribsInner_( str, inputOffset, end,
attribsOut, j, stride,
decodeOffsets[ j ], decodeScale );
decodeOffsets[j], decodeScale );
}
inputOffset = end;
......@@ -272,7 +270,7 @@ THREE.UTF8Loader.prototype.decompressMesh = function ( str, meshParams, decodeP
this.decompressIndices_( str, inputOffset, numIndices, indicesOut, 0 );
// Decode bboxen.
// Decode bboxen.
var bboxen = undefined;
var bboxOffset = meshParams.bboxes;
......@@ -280,7 +278,6 @@ THREE.UTF8Loader.prototype.decompressMesh = function ( str, meshParams, decodeP
if ( bboxOffset ) {
bboxen = this.decompressAABBs_( str, bboxOffset, meshParams.names.length, decodeOffsets, decodeScales );
}
callback( name, idx, attribsOut, indicesOut, bboxen, meshParams );
......@@ -304,12 +301,11 @@ THREE.UTF8Loader.prototype.decodeAttrib2 = function ( str, stride, decodeOffsets
for ( var j = 0; j < 5; j ++ ) {
var code = str.charCodeAt( deltaStart + numVerts * j + index );
var delta = ( code >> 1 ) ^ ( - ( code & 1 ) );
var delta = ( code >> 1) ^ (-(code & 1));
lastAttrib[ j ] += delta;
attribsOutFixed[ stride * index + j ] = lastAttrib[ j ];
attribsOut[ stride * index + j ] = decodeScales[ j ] * ( lastAttrib[ j ] + decodeOffsets[ j ] );
}
};
......@@ -358,7 +354,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
var MAX_BACKREF = 96;
// Extract conversion parameters from attribArrays.
// Extract conversion parameters from attribArrays.
var stride = decodeParams.decodeScales.length;
......@@ -393,7 +389,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
if ( code < max_backref ) {
// Parallelogram
// Parallelogram
var winding = code % 3;
var backref = i - ( code - winding );
......@@ -434,16 +430,16 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
if ( code === 0 ) {
for ( var j = 0; j < 5; j ++ ) {
for (var j = 0; j < 5; j ++ ) {
var deltaCode = str.charCodeAt( deltaStart + numVerts * j + highest );
var prediction = ( ( deltaCode >> 1 ) ^ ( - ( deltaCode & 1 ) ) ) +
attribsOutFixed[ stride * i0 + j ] +
attribsOutFixed[ stride * i1 + j ] -
attribsOutFixed[ stride * i2 + j ];
var prediction = ((deltaCode >> 1) ^ (-(deltaCode & 1))) +
attribsOutFixed[stride * i0 + j] +
attribsOutFixed[stride * i1 + j] -
attribsOutFixed[stride * i2 + j];
lastAttrib[ j ] = prediction;
lastAttrib[j] = prediction;
attribsOutFixed[ stride * highest + j ] = prediction;
attribsOut[ stride * highest + j ] = decodeScales[ j ] * ( prediction + decodeOffsets[ j ] );
......@@ -462,7 +458,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
} else {
// Simple
// Simple
var index0 = highest - ( code - max_backref );
......@@ -476,7 +472,7 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
} else {
this.copyAttrib( stride, attribsOutFixed, lastAttrib, index0 );
this.copyAttrib(stride, attribsOutFixed, lastAttrib, index0);
}
......@@ -538,10 +534,9 @@ THREE.UTF8Loader.prototype.decompressMesh2 = function( str, meshParams, decodePa
var cy = str.charCodeAt( deltaStart + 6 * numVerts + i );
var cz = str.charCodeAt( deltaStart + 7 * numVerts + i );
attribsOut[ stride * i + 5 ] = norm * nx + ( ( cx >> 1 ) ^ ( - ( cx & 1 ) ) );
attribsOut[ stride * i + 6 ] = norm * ny + ( ( cy >> 1 ) ^ ( - ( cy & 1 ) ) );
attribsOut[ stride * i + 7 ] = norm * nz + ( ( cz >> 1 ) ^ ( - ( cz & 1 ) ) );
attribsOut[ stride * i + 5 ] = norm * nx + ((cx >> 1) ^ (-(cx & 1)));
attribsOut[ stride * i + 6 ] = norm * ny + ((cy >> 1) ^ (-(cy & 1)));
attribsOut[ stride * i + 7 ] = norm * nz + ((cz >> 1) ^ (-(cz & 1)));
}
callback( name, idx, attribsOut, indicesOut, undefined, meshParams );
......@@ -576,7 +571,6 @@ THREE.UTF8Loader.prototype.downloadMesh = function ( path, name, meshEntry, deco
if ( req.responseText.length < meshEnd ) break;
loader.decompressMesh2( req.responseText, meshParams, decodeParams, name, idx, callback );
}
++ idx;
......@@ -593,7 +587,7 @@ THREE.UTF8Loader.prototype.downloadMesh = function ( path, name, meshEntry, deco
}
// TODO: handle errors.
// TODO: handle errors.
}, onprogress );
......@@ -603,7 +597,7 @@ THREE.UTF8Loader.prototype.downloadMeshes = function ( path, meshUrlMap, decodeP
for ( var url in meshUrlMap ) {
var meshEntry = meshUrlMap[ url ];
var meshEntry = meshUrlMap[url];
this.downloadMesh( path + url, url, meshEntry, decodeParams, callback );
}
......@@ -635,7 +629,7 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
var model = new THREE.Object3D();
// Prepare materials first...
// Prepare materials first...
var materialCreator = new THREE.MTLLoader.MaterialCreator( materialBaseUrl, loadModelInfo.options );
materialCreator.setMaterials( loadModelInfo.materials );
......@@ -648,14 +642,14 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
var meshCallback = function( name, idx, attribArray, indexArray, bboxen, meshParams ) {
// Got ourselves a new mesh
// Got ourselves a new mesh
// name identifies this part of the model (url)
// idx is the mesh index of this mesh of the part
// attribArray defines the vertices
// indexArray defines the faces
// bboxen defines the bounding box
// meshParams contains the material info
// name identifies this part of the model (url)
// idx is the mesh index of this mesh of the part
// attribArray defines the vertices
// indexArray defines the faces
// bboxen defines the bounding box
// meshParams contains the material info
var geometry = bufferGeometryCreator.create( attribArray, indexArray );
var material = materialCreator.create( meshParams.material );
......@@ -663,7 +657,7 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
var mesh = new THREE.Mesh( geometry, material );
modelParts[ name ].add( mesh );
//model.add(new THREE.Mesh(geometry, material));
//model.add(new THREE.Mesh(geometry, material));
decodedMeshesPerUrl[ name ] ++;
......@@ -675,7 +669,7 @@ THREE.UTF8Loader.prototype.createMeshCallback = function( materialBaseUrl, loadM
if ( nCompletedUrls === nExpectedUrls ) {
// ALL DONE!!!
// ALL DONE!!!
allDoneCallback( model );
......@@ -755,47 +749,33 @@ function getHttpRequest( url, onload, opt_onprogress ) {
var LISTENERS = {
load: function( e ) {
onload( req, e );
load: function( e ) { onload( req, e ); },
progress: function( e ) { opt_onprogress( req, e ); }
},
progress: function( e ) {
opt_onprogress( req, e );
}
};
};
var req = new XMLHttpRequest();
addListeners( req, LISTENERS );
req.open( 'GET', url, true );
req.send( null );
}
function getJsonRequest( url, onjson ) {
getHttpRequest( url,
function( e ) {
onjson( JSON.parse( e.responseText ) );
},
function( e ) { onjson( JSON.parse( e.responseText ) ); },
function() {} );
}
function addListeners( dom, listeners ) {
// TODO: handle event capture, object binding.
// TODO: handle event capture, object binding.
for ( var key in listeners ) {
dom.addEventListener( key, listeners[ key ] );
}
}
{
"preset": "mdcs",
"disallowNewlineBeforeBlockStatements": true,
"excludeFiles": [
"../../.c9/",
"../../.c9version/",
......@@ -20,7 +21,10 @@
"../../examples/js/libs/",
"../../examples/js/loaders/ctm/",
"../../examples/js/loaders/gltf/",
"../../examples/js/loaders/sea3d/"
"../../examples/js/loaders/sea3d/",
"../../examples/js/ImprovedNoise.js",
"../../examples/js/SimplexNoise.js",
"../../examples/js/loaders/UTF8Loader.js"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册