mrdoob/three.js — Issue #873: strange Lorenc attractor
Author: vladimir123
Created: 2011-12-08 07:44:11+00:00
State: open

Hi!
I have need to build Lorenca strange-attractor ...
i have found it realization on WebGL without three.js... but how i can rebuild it to three.js?
Here is the code:
[code]
function createObjects() {

var iterations = me.iterations,
vertices = [],
colors = [];

var x = 0.1, y = 0.1, z = 0.1,
a = me.a, b = me.b, c = me.c,
newX = x, newY = y, newZ = z,
interval = me.interval,
minX = minY = minZ = Number.POSITIVE_INFINITY,
maxX = maxY = maxZ = Number.NEGATIVE_INFINITY;

while(iterations--) {

switch(me.fn) {

case LORENZ:
newX = x - (a * x) * interval + (a * y) * interval;
newY = y + (b * x) * interval - y * interval - (z * x) * interval;
newZ = z - (c * z) * interval + (x * y) * interval;
break;

}

minX = Math.min(minX, newX);
minY = Math.min(minY, newY);
minZ = Math.min(minZ, newZ);

maxX = Math.max(maxX, newX);
maxY = Math.max(maxY, newY);
maxZ = Math.max(maxZ, newZ);

vertices.push(new A3.Vertex(newX, newY, newZ - b));
x = newX, y = newY, z = newZ;
}

var rangeX = (maxX - minX) * .45;
var rangeY = (maxY - minY) * .5;
var rangeZ = (maxZ - minZ);

for(var v = 0; v < me.iterations; v++) {
colors.push(
new A3.V3(Math.pow(0.07, Math.abs(vertices[v].position.x / rangeX)) * .3,
Math.pow(0.003, Math.abs(vertices[v].position.y / rangeY)) * .3,
Math.pow(0.007, Math.abs((vertices[v].position.z - a)/ rangeZ)) * .3)
);
};
}

[/code]

P.S sorry for my bad English