/// var main:Main; window.onload = function () { main = new Main(); } window.onresize = function (e) { if (main) { main.resize(e); } } class Main { private view:away.containers.View3D; private raf:away.utils.RequestAnimationFrame; private meshList:away.entities.Mesh[] = []; constructor() { away.Debug.THROW_ERRORS = false; away.Debug.LOG_PI_ERRORS = false; var lightDir:away.lights.DirectionalLight = new away.lights.DirectionalLight(); lightDir.ambient = 0.2; lightDir.ambientColor = 0xFFFFFF; this.view = new away.containers.View3D() this.view.backgroundColor = 0x000000; this.view.antiAlias = 2; this.view.camera.lens.far = 10000; var matTx:away.materials.ColorMaterial = new away.materials.ColorMaterial(0xFFFFFF); matTx.lightPicker = new away.materials.StaticLightPicker([lightDir]); var geometry:away.primitives.CubeGeometry = new away.primitives.CubeGeometry(100, 100, 100); for (var i = 0; i < 50; i++) { var mesh:away.entities.Mesh = new away.entities.Mesh(geometry, matTx); mesh.x = 2000 * (Math.random() - 0.5); mesh.y = 2000 * (Math.random() - 0.5); mesh.z = 4000 * (Math.random() - 0.5); mesh.scale(Math.random() + 0.5); mesh.rotationX = 360 * (Math.random() - 0.5); mesh.rotationY = 360 * (Math.random() - 0.5); mesh.rotationZ = 360 * (Math.random() - 0.5); this.view.scene.addChild(mesh); this.meshList[i] = mesh; } this.raf = new away.utils.RequestAnimationFrame(this.tick, this); this.raf.start(); this.resize(null); } private tick(e) { for (var i = 0; i < this.meshList.length; i++) { var mesh:away.entities.Mesh = this.meshList[i]; mesh.z -= 20; mesh.rotationX ++; mesh.rotationY ++; mesh.rotationZ ++; if (mesh.z < -2000) mesh.z = +2000; } this.view.render(); } public resize(e) { this.view.width = window.innerWidth; this.view.height = window.innerHeight; this.view.render(); } }