Update
This commit is contained in:
parent
5e58724654
commit
7850b3bb40
|
@ -25,19 +25,19 @@ t = [0,1];
|
||||||
f = [0,1];
|
f = [0,1];
|
||||||
fp = [-1,-1];
|
fp = [-1,-1];
|
||||||
|
|
||||||
var hermite = new Hermite.Polynom(t, f, fp);
|
var hermite = new Hermite.special.Polynom(0, 1, -1);
|
||||||
|
|
||||||
print('M = [');
|
print('M = [');
|
||||||
for (var t = 0; t < 1; t += 0.01) {
|
for (var t = 0; t < 1; t += 0.01) {
|
||||||
var res = hermite.eval(t);
|
var res = hermite.eval(t);
|
||||||
print(t + ',' + toString(res) + ';');
|
print("\t" + t + ',' + toString(res) + ';');
|
||||||
}
|
}
|
||||||
print('];');
|
print('];');
|
||||||
|
|
||||||
print('MP = [');
|
print('MP = [');
|
||||||
for (var t = 0; t < 1; t += 0.01) {
|
for (var t = 0; t < 1; t += 0.01) {
|
||||||
var res = hermite.prime(t);
|
var res = hermite.prime(t);
|
||||||
print(t + ',' + toString(res) + ';');
|
print("\t" + t + ',' + toString(res) + ';');
|
||||||
}
|
}
|
||||||
print('];');
|
print('];');
|
||||||
|
|
||||||
|
|
|
@ -129,12 +129,12 @@ FixedCamera.prototype.update = function(mainCamera) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update opacity
|
// Update opacity
|
||||||
this.mesh.material.transparent = new_value < 0.9;
|
this.object3D.traverse(function(elt) {
|
||||||
this.border.material.transparent = new_value < 0.9;
|
if (elt instanceof THREE.Mesh) {
|
||||||
this.arrow.material.transparent = new_value < 0.9;
|
elt.material.transparent = new_value < 0.9;
|
||||||
this.mesh.material.opacity = new_value;
|
elt.material.opacity = new_value;
|
||||||
this.border.material.opacity = new_value;
|
}
|
||||||
this.arrow.material.opacity = new_value;
|
});
|
||||||
|
|
||||||
this.regenerateArrow(mainCamera);
|
this.regenerateArrow(mainCamera);
|
||||||
}
|
}
|
||||||
|
@ -151,9 +151,17 @@ FixedCamera.prototype.regenerateArrow = function(mainCamera) {
|
||||||
var hermite = new Hermite.Polynom(t,f,fp);
|
var hermite = new Hermite.Polynom(t,f,fp);
|
||||||
|
|
||||||
var up = this.up.clone();
|
var up = this.up.clone();
|
||||||
for (var i = this.fullArrow ? 0 : 0.5; i <= 1.001; i += 0.05) {
|
var point;
|
||||||
var point = hermite.eval(i);
|
var deriv;
|
||||||
var deriv = hermite.prime(i);
|
// for (var i = this.fullArrow ? 0 : 0.5; i <= 1.001; i += 0.05) {
|
||||||
|
for (var i = 1; this.fullArrow ? i > 0 : i > 0.5; i -= 0.05) {
|
||||||
|
point = hermite.eval(i);
|
||||||
|
deriv = hermite.prime(i);
|
||||||
|
up.cross(deriv);
|
||||||
|
up.cross(deriv);
|
||||||
|
up.multiplyScalar(-1);
|
||||||
|
up.normalize();
|
||||||
|
|
||||||
var left = Tools.cross(up, deriv); left.normalize(); left.multiplyScalar(0.1);
|
var left = Tools.cross(up, deriv); left.normalize(); left.multiplyScalar(0.1);
|
||||||
var other = Tools.cross(deriv, left); other.normalize(); other.multiplyScalar(0.1);
|
var other = Tools.cross(deriv, left); other.normalize(); other.multiplyScalar(0.1);
|
||||||
|
|
||||||
|
@ -166,10 +174,6 @@ FixedCamera.prototype.regenerateArrow = function(mainCamera) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var faces = new Array();
|
var faces = new Array();
|
||||||
faces.push(
|
|
||||||
new THREE.Face3(0,1,2),
|
|
||||||
new THREE.Face3(0,2,3)
|
|
||||||
);
|
|
||||||
|
|
||||||
for (var i = 0; i < vertices.length - 4; i+= 4) {
|
for (var i = 0; i < vertices.length - 4; i+= 4) {
|
||||||
faces.push(new THREE.Face3(i,i+1,i+5),new THREE.Face3(i,i+5,i+4),
|
faces.push(new THREE.Face3(i,i+1,i+5),new THREE.Face3(i,i+5,i+4),
|
||||||
|
@ -178,6 +182,9 @@ FixedCamera.prototype.regenerateArrow = function(mainCamera) {
|
||||||
new THREE.Face3(i,i+7,i+3), new THREE.Face3(i,i+4,i+7));
|
new THREE.Face3(i,i+7,i+3), new THREE.Face3(i,i+4,i+7));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var len = vertices.length;
|
||||||
|
faces.push(new THREE.Face3(len-4,len-3,len-2), new THREE.Face3(len-4,len-2,len-1));
|
||||||
|
|
||||||
|
|
||||||
this.arrow.geometry.vertices = vertices;
|
this.arrow.geometry.vertices = vertices;
|
||||||
this.arrow.geometry.faces = faces;
|
this.arrow.geometry.faces = faces;
|
||||||
|
|
|
@ -169,3 +169,33 @@ Hermite.BaseFunction.prototype.prime = function(t) {
|
||||||
|
|
||||||
return this.eval(t) * ret;
|
return this.eval(t) * ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Hermite.special = {};
|
||||||
|
|
||||||
|
// This polynom interpolates with two coords and one derivative
|
||||||
|
// t = [0,1]
|
||||||
|
Hermite.special.Polynom = function(P0, P1, PP1) {
|
||||||
|
this.tools = {};
|
||||||
|
if (P0 instanceof THREE.Vector3) {
|
||||||
|
this.tools.sum = Tools.sum;
|
||||||
|
this.tools.mul = Tools.mul;
|
||||||
|
this.tools.diff = Tools.diff;
|
||||||
|
this.c = P0.clone();
|
||||||
|
} else {
|
||||||
|
this.tools.sum = function(a,b) { return a+b; };
|
||||||
|
this.tools.mul = function(a,b) { return a*b; };
|
||||||
|
this.tools.diff = function(a,b) { return a-b; };
|
||||||
|
this.c = P0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.a = this.tools.sum(PP1, this.tools.diff(P0, P1));
|
||||||
|
this.b = this.tools.diff(this.tools.mul(this.tools.diff(P1,P0), 2), PP1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Hermite.special.Polynom.prototype.eval = function(t) {
|
||||||
|
return this.tools.sum(this.tools.mul(this.a, t*t), this.tools.sum(this.tools.mul(this.b, t), this.c));
|
||||||
|
}
|
||||||
|
|
||||||
|
Hermite.special.Polynom.prototype.prime = function(t) {
|
||||||
|
return this.tools.sum(this.tools.mul(this.a,2*t), this.b);
|
||||||
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ var ProgessiveSphere = function(loader, res) {
|
||||||
res = 5;
|
res = 5;
|
||||||
|
|
||||||
(function(self) {
|
(function(self) {
|
||||||
loader.load('/data/spheres/' + res + '.obj', function(object) {
|
loader.load(static_path + 'data/spheres/' + res + '.obj', function(object) {
|
||||||
object.traverse(function(child) {
|
object.traverse(function(child) {
|
||||||
if (child instanceof THREE.Mesh) {
|
if (child instanceof THREE.Mesh) {
|
||||||
child.up = new THREE.Vector3(0,0,1);
|
child.up = new THREE.Vector3(0,0,1);
|
||||||
|
|
Loading…
Reference in New Issue