Кстати, выведи v[0].length. Он равен 1
Я уже говорил, что я хотел сделать в массиве v несколько объектов. Но не сделал...
CODE:function buildDots() {
perspective = 200;
scale = 2;
cx = 150;
cy = 100;
v = [];
v[0] = [0, 0, 0];
v[1] = [10, 0, 0];
v[2] = [10, 10, 0];
v[3] = [20, 10, 0];
v[4] = [20, 20, 0];
v[5] = [10, 20, 0];
v[6] = [10, 30, 0];
v[7] = [0, 30, 0];
v[8] = [0, 20, 0];
v[9] = [0, 10, 0];
v[10] = [0, 0, 10];
v[11] = [10, 0, 10];
v[12] = [10, 10, 10];
v[13] = [20, 10, 10];
v[14] = [20, 20, 10];
v[15] = [10, 20, 10];
v[16] = [10, 30, 10];
v[17] = [0, 30, 10];
v[18] = [0, 20, 10];
v[19] = [0, 10, 10];
v[20] = [-10, 10, 0];
v[21] = [-10, 20, 0];
v[22] = [-10, 10, 10];
v[23] = [-10, 20, 10];
v[24] = [0, 0, 20];
v[25] = [10, 0, 20];
v[26] = [10, 10, 20];
v[27] = [20, 10, 20];
v[28] = [20, 20, 20];
v[29] = [10, 20, 20];
v[30] = [10, 30, 20];
v[31] = [0, 30, 20];
v[32] = [0, 20, 20];
v[33] = [0, 10, 20];
v[34] = [0, 0, 30];
v[35] = [10, 0, 30];
v[36] = [10, 10, 30];
v[37] = [20, 10, 30];
v[38] = [20, 20, 30];
v[39] = [10, 20, 30];
v[40] = [10, 30, 30];
v[41] = [0, 30, 30];
v[42] = [0, 20, 30];
v[43] = [0, 10, 30];
v[44] = [-10, 10, 20];
v[45] = [-10, 20, 20];
v[46] = [-10, 10, 30];
v[47] = [-10, 20, 30];
f = [];
f[0] = [0, 1, 2, 9, true];
f[1] = [2, 3, 4, 5, true];
f[2] = [5, 6, 7, 8, true];
f[3] = [10, 11, 12, 19, false];
f[4] = [12, 13, 14, 15, false];
f[5] = [15, 16, 17, 18, false];
f[6] = [0, 1, 11, 10];
f[7] = [1, 2, 12, 11];
f[8] = [2, 3, 13, 12];
f[9] = [3, 4, 14, 13];
f[10] = [4, 5, 15, 14];
f[11] = [5, 6, 16, 15];
f[12] = [6, 7, 17, 16];
f[13] = [7, 8, 18, 17];
f[14] = [8, 5, 15, 18];
f[15] = [5, 2, 12, 15];
f[16] = [2, 9, 19, 12, false];
f[17] = [9, 0, 10, 19];
f[18] = [8, 18, 19, 9];
f[19] = [20, 22, 19, 9, true];
f[20] = [20, 22, 23, 21];
f[21] = [21, 23, 18, 8];
f[22] = [20, 9, 8, 21, true];
f[23] = [22, 19, 18, 23];
f[24] = [0+24, 1+24, 2+24, 9+24, true];
f[25] = [2+24, 3+24, 4+24, 5+24, true];
f[26] = [5+24, 6+24, 7+24, 8+24, true];
f[27] = [10+24, 11+24, 12+24, 19+24, false];
f[28] = [12+24, 13+24, 14+24, 15+24, false, [200, 0, 0]];
f[29] = [15+24, 16+24, 17+24, 18+24, false];
f[30] = [0+24, 1+24, 11+24, 10+24];
f[31] = [1+24, 2+24, 12+24, 11+24];
f[32] = [2+24, 3+24, 13+24, 12+24];
f[33] = [3+24, 4+24, 14+24, 13+24];
f[34] = [4+24, 5+24, 15+24, 14+24];
f[35] = [5+24, 6+24, 16+24, 15+24];
f[36] = [6+24, 7+24, 17+24, 16+24];
f[37] = [7+24, 8+24, 18+24, 17+24];
f[38] = [8+24, 5+24, 15+24, 18+24];
f[39] = [5+24, 2+24, 12+24, 15+24];
f[40] = [2+24, 9+24, 19+24, 12+24, false];
f[41] = [9+24, 0+24, 10+24, 19+24];
f[42] = [8+24, 18+24, 19+24, 9+24];
f[43] = [20+24, 22+24, 19+24, 9+24, true];
f[44] = [20+24, 22+24, 23+24, 21+24];
f[45] = [21+24, 23+24, 18+24, 8+24];
f[46] = [20+24, 9+24, 8+24, 21+24, true];
f[47] = [22+24, 19+24, 18+24, 23+24];
f[48] = [19, 12, 2+24, 9+24];
f[49] = [12, 15, 5+24, 2+24];
f[50] = [15, 18, 8+24, 5+24];
f[51] = [18, 19, 9+24, 8+24];
f[52] = [19, 12, 15, 18, true];
f[53] = [9+24, 2+24, 5+24, 8+24];
var c = 0;
for (var j = 0; j<v.length; j++) {
this['d_'+j] = new Object();
var o = this['d_'+j];
o.x0 = (v[j][0]-5)*scale;
o.y0 = (v[j][1]-15)*scale;
o.z0 = (v[j][2]-15)*scale;
o.depth = 1/(1-o.z0/perspective);
o._x = cx+o.x0*o.depth;
o._y = cy+o.y0*o.depth;
c++;
}
drawLines();
}
function calcShadow(colorArray, intensive) {
var r = (colorArray[0]*intensive);
r = r<0 ? 0 : (r>255 ? 255 : r);
r = r.toString(16);
r = r.length == 1 ? '0'+r : r;
var g = (colorArray[1]*intensive);
g = g<0 ? 0 : (g>255 ? 255 : g);
g = g.toString(16);
g = g.length == 1 ? '0'+g : g;
var b = (colorArray[2]*intensive);
b = b<0 ? 0 : (b>255 ? 255 : b);
b = b.toString(16);
b = b.length == 1 ? '0'+b : b;
return Number('0x'+r+''+g+''+b);
}
function drawLines() {
this.clear();
zSort = [];
zUnsort = [];
zSorted = [];
for (var j = 0; j<f.length; j++) {
o1 = this['d_'+f[j][0]];
o2 = this['d_'+f[j][1]];
o3 = this['d_'+f[j][2]];
o4 = this['d_'+f[j][3]];
vis = (o2.x*o2.depth-o1.x*o1.depth)*(o3.y*o3.depth-o1.y*o1.depth)-(o3.x*o3.depth-o1.x*o1.depth)*(o2.y*o2.depth-o1.y*o1.depth);
if ((vis>0 && !f[j][4]) || (vis<0 && f[j][4])) {
fczc = (o1.z*o1.depth+o2.z*o2.depth)/2;
zSort.push(Math.round(fczc));
zUnsort.push(Math.round(fczc));
zSorted.push(j);
}
}
for (var j = zSort.length-1; j>=0; j--) {
for (var c = 0; c<j; c++) {
if (zSort[c]>zSort[c+1]) {
tmp = zSort[c];
zSort[c] = zSort[c+1];
zSort[c+1] = tmp;
tmp = zSorted[c];
zSorted[c] = zSorted[c+1];
zSorted[c+1] = tmp;
delete tmp;
}
}
}
for (var j = 0; j<zSorted.length; j++) {
o1 = this['d_'+f[zSorted[j]][0]];
o2 = this['d_'+f[zSorted[j]][1]];
o3 = this['d_'+f[zSorted[j]][2]];
o4 = this['d_'+f[zSorted[j]][3]];
vis = (o2.x*o2.depth-o1.x*o1.depth)*(o3.y*o3.depth-o1.y*o1.depth)-(o3.x*o3.depth-o1.x*o1.depth)*(o2.y*o2.depth-o1.y*o1.depth);
shdw = vis/(scale*1500);
shdw = !f[zSorted[j]][4] ? shdw : -shdw;
this.beginFill(!f[zSorted[j]][5] ? calcShadow([100, 100, 177], shdw) : calcShadow(f[zSorted[j]][5], shdw), 100);
this.moveTo(o1._x, o1._y);
this.lineTo(o2._x, o2._y);
this.lineTo(o3._x, o3._y);
this.lineTo(o4._x, o4._y);
this.lineTo(o1._x, o1._y);
this.endFill();
}
}
buildDots();
function move3D(angX, angY, angZ, fscale) {
var angleY = angY/180*Math.PI;
var angleX = (angX+180)/180*Math.PI;
var angleZ = angZ/180*Math.PI;
for (var j = 0; j<v.length; j++) {
var o = this['d_'+j];
// z rotate
y = o.y0*Math.cos(angleZ)+o.x0*Math.sin(angleZ);
x = o.x0*Math.cos(angleZ)-o.y0*Math.sin(angleZ);
// y rotate
z = o.z0*Math.cos(angleY)-x*Math.sin(angleY);
x = x*Math.cos(angleY)+o.z0*Math.sin(angleY);
// x rotate
oy = y;
y = y*Math.cos(angleX)-z*Math.sin(angleX);
z = oy*Math.sin(angleX)+z*Math.cos(angleX);
depth = 1/(1-z/perspective);
//
o.x = x*fscale;
o.y = y*fscale;
o.z = z*fscale;
o.depth = depth;
o._x = cx+o.x*depth;
o._y = cy-o.y*depth;
}
drawLines();
}
ys = 0;
xs = 0;
zs = 20;
sc = 1;
this.createEmptyMovieClip('h', -100);
h.onEnterFrame = function() {
move3D(zs--, ys += 3.2, zs -= 0.2, 3);
};
Это тоже самое в общем-то, только проще. Но работает не быстрее (про замену MovieClip на Object я тебе уже говорил). Я уже не знаю, как сделать быстрее...