merged upstream master

This commit is contained in:
timk
2011-08-15 01:17:02 +02:00
parent e06a811f5a
commit 2d5d984e62
2 changed files with 65 additions and 21 deletions
+4 -13
View File
@@ -33,11 +33,11 @@
var particleLight, pointLight;
var dae;
DAE.load('./models/skin_and_morph.dae', colladaReady);
DAE.load('./models/monster.dae', colladaReady);
function colladaReady(collada) {
dae = collada.scene;
dae.scale.x = dae.scale.y = dae.scale.z = 0.03;
dae.scale.x = dae.scale.y = dae.scale.z = 0.002;
dae.updateMatrix();
init();
@@ -217,20 +217,11 @@
var timer = new Date().getTime() * 0.0005;
camera.position.x = Math.cos( timer ) * 10;
camera.position.y = 5;
camera.position.y = 2;
camera.position.z = Math.sin( timer ) * 10;
for ( var i = 0, l = objects.length; i < l; i++ ) {
var object = objects[ i ];
// object.rotation.x += 0.01;
// object.rotation.y += 0.005;
}
particleLight.position.x = Math.sin( timer * 4 ) * 300;
particleLight.position.y = 800;//Math.cos( timer * 5 ) * 400;
particleLight.position.y = Math.cos( timer * 5 ) * 400;
particleLight.position.z = Math.cos( timer * 4 ) * 300;
pointLight.position.x = particleLight.position.x;
+61 -8
View File
@@ -70,7 +70,7 @@ var DAE = (function() {
for (var i = 0; i < daeScene.nodes.length; i++) {
scene.addChild(createSceneGraph(daeScene.nodes[i]));
}
createAnimations();
var result = {
@@ -274,10 +274,9 @@ var DAE = (function() {
}
}
}
var mat = new THREE.MeshLambertMaterial( {
map: texture,
color: diffuse.hex,
color: diffuse.getHex(),
opacity: opacity,
transparent: use_transparency,
shading: THREE.SmoothShading } );
@@ -285,9 +284,9 @@ var DAE = (function() {
if (shader.type != 'lambert' && shader.shininess && specular && ambient) {
mat = new THREE.MeshPhongMaterial( {
map: texture,
ambient: ambient.hex,
color: diffuse.hex,
specular: specular.hex,
ambient: ambient.getHex(),
color: diffuse.getHex(),
specular: specular.getHex(),
shininess: shader.shininess,
shading: THREE.SmoothShading,
opacity: opacity,
@@ -913,7 +912,6 @@ var DAE = (function() {
if (v.length < 3) continue;
var va = v[0];
var na = n[0];
for (j = 1; j < v.length - 1; j++) {
var vb = v[j];
var vc = v[j+1];
@@ -976,6 +974,7 @@ var DAE = (function() {
v = new THREE.Vertex(new THREE.Vector3(source.data[idx32+0], source.data[idx32+1], source.data[idx32+2]));
v.daeId = vs.length;
vs.push(v);
break;
case 'NORMAL':
n = new THREE.Vector3(source.data[idx32+0], source.data[idx32+1], source.data[idx32+2]);
@@ -998,6 +997,7 @@ var DAE = (function() {
if (has_v) {
var c = this.geometry.vertices.length;
this.geometry.vertices.push(vs[0], vs[1], vs[2]);
this.geometry.faces.push( new THREE.Face3(c+0, c+1, c+2, ns ) );
if (has_t) {
for (k = 0; k < texture_sets.length; k++) {
@@ -1011,7 +1011,7 @@ var DAE = (function() {
this.geometry.computeCentroids();
this.geometry.computeFaceNormals();
this.geometry.computeVertexNormals();
this.geometry.computeBoundingBox();
this.geometry.computeBoundingBox();
}
Triangles.prototype.setVertices = function(vertices) {
for (var i = 0; i < this.inputs.length; i++) {
@@ -1613,6 +1613,59 @@ var DAE = (function() {
}
}
function _format_float(f, num) {
if (f === undefined) {
var s = '0.';
while (s.length < num + 2) {
s += '0';
}
return s;
}
var parts = f.toString().split('.');
num = num || 2;
parts[1] = parts.length > 1 ? parts[1].substr(0, num) : "0";
while(parts[1].length < num) {
parts[1] += '0';
}
return parts.join('.');
}
function _hash_vertex(v, n, t0, t1, precision) {
precision = precision || 2;
var s = v instanceof THREE.Vertex ? _hash_vector3(v.position, precision) : _hash_vector3(v, precision);
if (n === undefined) {
s += '_0.00,0.00,0.00';
} else {
s += '_' + _hash_vector3(n, precision);
}
if (t0 === undefined) {
s += '_0.00,0.00';
} else {
s += '_' + _hash_uv(t0, precision);
}
if (t1 === undefined) {
s += '_0.00,0.00';
} else {
s += '_' + _hash_uv(t1, precision);
}
return s;
}
function _hash_uv(uv, num) {
var s = '';
s += _format_float(uv.u, num) + ',';
s += _format_float(uv.v, num);
return s;
}
function _hash_vector3(vec, num) {
var s = '';
s += _format_float(vec.x, num) + ',';
s += _format_float(vec.y, num) + ',';
s += _format_float(vec.z, num);
return s;
}
function evaluateXPath(node, query) {
var instances = COLLADA.evaluate(query,
node,