Difference between revisions of "3D Space Example.as"
m |
(Make a simple rotating toroid as test case) |
||
Line 4: | Line 4: | ||
// Instantiate a new 3D-space | // Instantiate a new 3D-space | ||
− | createEmptyMovieClip( 'test', 1 ); | + | //createEmptyMovieClip( 'test', 1 ); |
− | initialiseSpace( test ); | + | //initialiseSpace( test ); |
− | test._x = width/2; | + | //test._x = width/2; |
− | test._y = height/2; | + | //test._y = height/2; |
+ | |||
+ | // testing z-ordering algorithm | ||
+ | var balls = 5; | ||
+ | for ( var i = 1; i <= balls; i++ ) attachMovie( 'ball', 'ball'+i ); | ||
+ | |||
// Per frame | // Per frame | ||
Line 13: | Line 18: | ||
now = new Date(); | now = new Date(); | ||
time = now.getTime(); | time = now.getTime(); | ||
− | if (_root.ctr++ < 2) | + | //if (_root.ctr++ < 2) |
− | + | // for ( var i = 0; i < allSpaces.length; i++ ) | |
− | + | // if ( allSpaces[i].active ) allSpaces[i].frame(); | |
+ | |||
+ | // testing z-ordering algorithm | ||
+ | a += 0.01; | ||
+ | for ( var i = 1; i <= balls; i++ ) { | ||
+ | ball = _root['ball'+i]; | ||
+ | ball._x = width/2+Math.sin(a)*width/2; | ||
+ | ball.z = ball._xscale = ball._yscale = 50+Math.cos(a)*25; | ||
+ | ball._y = height/2; | ||
+ | } | ||
+ | |||
} | } | ||
Revision as of 03:52, 20 March 2006
- include "Space.as"
// Instantiate a new 3D-space //createEmptyMovieClip( 'test', 1 ); //initialiseSpace( test ); //test._x = width/2; //test._y = height/2;
// testing z-ordering algorithm var balls = 5; for ( var i = 1; i <= balls; i++ ) attachMovie( 'ball', 'ball'+i );
// Per frame
function reduce() {
now = new Date();
time = now.getTime();
//if (_root.ctr++ < 2)
// for ( var i = 0; i < allSpaces.length; i++ )
// if ( allSpaces[i].active ) allSpaces[i].frame();
// testing z-ordering algorithm a += 0.01; for ( var i = 1; i <= balls; i++ ) { ball = _root['ball'+i]; ball._x = width/2+Math.sin(a)*width/2; ball.z = ball._xscale = ball._yscale = 50+Math.cos(a)*25; ball._y = height/2; }
}
createTextField( 'debug', 2, 0, 0, width, height ); with ( debug) { selectable = true; border = false; multiline = true; wordWrap = true; html = true; }
// Test object test.create( [ 0, 0, , 'torus', 5, 200, 5000 ] );