|
|
(90 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
− | #include "Space.as" | + | {{legacy}} |
− | | + | <source lang="js"> |
− | | + | Mouse.hide(); |
| + | #include "space.as" |
| | | |
| // Instantiate a new 3D-space | | // Instantiate a new 3D-space |
− | //createEmptyMovieClip( 'test', 1 ); | + | // - extends createEmptyMovieClip( name, layer ) |
− | //initialiseSpace( test );
| + | createSymbol( _root, 'space', 'mySpace', 0 ); |
− | //test._x = width/2;
| |
− | //test._y = height/2;
| |
− | | |
− | // testing z-ordering algorithm
| |
− | n = 5;
| |
− | balls = [];
| |
− | for ( var i = 0; i < n; i++ ) {
| |
− | attachMovie( 'ball', 'ball'+i, i );
| |
− | o = _root['ball'+i];
| |
− | j = i + 1;
| |
− | r = (j & 1) ? 0xff : 0;
| |
− | g = (j & 2) ? 0xff : 0;
| |
− | b = (j & 4) ? 0xff : 0;
| |
− | c = new Color(o);
| |
− | c.setTransform( { ra:r, ga:g, ba:b } );
| |
− | }
| |
− | | |
− | | |
− | // 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;
| |
− | c = 2*Math.PI/n;
| |
− | for ( var i = 0; i < n; i++ ) {
| |
− | obj = _root['ball'+i];
| |
− | b = a + c * i;
| |
− | obj._x = width/2+Math.sin(b)*width/3;
| |
− | obj.az = obj._xscale = obj._yscale = 50+Math.cos(b)*25;
| |
− | obj.az = -obj.az;
| |
− | obj._y = height/2;
| |
− | }
| |
− | | |
− | // Sort buffer by Z and synchronise rendering levels
| |
− | for ( var i = 0; i < n-1; i++ ) {
| |
− | obj = _root['ball'+i];
| |
− | var maxz = obj.az, maxp = i;
| |
− | for ( var j = i+1; j < n; j++ ) if ( _root['ball'+j].az > maxz ) {
| |
− | maxz = _root['ball'+j].az;
| |
− | maxp = j;
| |
− | }
| |
− | if ( maxp != i ) {
| |
− | obj.swapDepths( _root['ball'+maxp] );
| |
− | _root['ball'+i] = _root['ball'+maxp];
| |
− | _root['ball'+maxp] = obj;
| |
− | }
| |
− | }
| |
− | | |
− | | |
− | }
| |
− | | |
− | //createTextField( 'debug', 0, 0, 0, width, height );
| |
− | with ( debug ) {
| |
− | selectable = true;
| |
− | border = false;
| |
− | multiline = true;
| |
− | wordWrap = true;
| |
− | html = true;
| |
− | }
| |
| | | |
| // Test object | | // Test object |
− | //test.create( [ 0, 0, '', 'torus', 5, 200, 5000 ] );
| + | mySpace.create( [ 'torus', 'myTorus', 5, 200, 2000 ] ); |
| + | </source> |
Latest revision as of 13:19, 6 August 2024
|
Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, now this page is for historic record only.
|
|
Mouse.hide();
#include "space.as"
createSymbol( _root, 'space', 'mySpace', 0 );
mySpace.create( [ 'torus', 'myTorus', 5, 200, 2000 ] );