package { import flash.display.BitmapData; import alternativa.engine3d.core.Object3D; import alternativa.engine3d.materials.TextureMaterial; import alternativa.engine3d.primitives.Plane; import alternativa.engine3d.resources.BitmapTextureResource; import assets.FontAsset; import assets.LogoAsset; import org.libspark.alternativa3d.view.AlternativaTemplate; import org.libspark.betweenas3.BetweenAS3; import org.libspark.betweenas3.easing.Cubic; import org.libspark.betweenas3.easing.Expo; import org.libspark.betweenas3.tweens.ITween; [SWF(frameRate = "60")] public class Main extends AlternativaTemplate { public function Main():void { super({ antiAlias: 2, useDiagram: true }); } override protected function atInit():void { // create letter var text:LogoAsset = new LogoAsset(); var cap:BitmapData = new BitmapData(text.width, text.height, true, 0xFFFFFFFF); cap.draw(text); // マテリアル作成 var materialList:Vector. = new Vector.(); var fontAsset:FontAsset = new FontAsset(); // A-Z for (var i:int = 0; i < 25; i++) { var char:String = String.fromCharCode(65 + i); fontAsset.label_txt.text = char; var bmd:BitmapData = new BitmapData(128, 128, true, 0x0); bmd.draw(fontAsset); var texture1:BitmapTextureResource = new BitmapTextureResource(new BitmapData(2, 2, false, 0xFFFFFFFF)); var texture:BitmapTextureResource = new BitmapTextureResource(bmd); var material:TextureMaterial = new TextureMaterial(texture1, texture); materialList[ i ] = material; } // particle motion var wrap:Object3D = new Object3D(); scene.addChild(wrap); var tweenArr:Array = []; var cnt:int = 0; for (i = 0; i < cap.width; i++) { for (var j:int = 0; j < cap.height; j++) { if (cap.getPixel(i, j) == 0xFFFFFF) continue; // letter material = materialList[ materialList.length * Math.random() >> 0 ]; var word:Plane = new Plane(60, 60, 1, 1, false, false, null, material); word.rotationX = Math.PI / 2; wrap.addChild(word); var toObj:Object = { x: (i - text.width / 2) * 30, y: 0, z: (text.height / 2 - j) * 30, rotationY: Math.PI * Math.random() }; var fromObj:Object = { x: 1000 * Math.random() - 500 - 500, y: -11000, z: 1000 * Math.random() - 500, rotationY: 8 * Math.PI * Math.random() }; var tw:ITween = BetweenAS3.delay( BetweenAS3.bezier(word, toObj, fromObj, { x: 2000 }, 4.5, Expo.easeInOut), cnt++ * 0.0035); tweenArr.push(tw); } } // wrap motion tweenArr.push(BetweenAS3.tween(wrap, { y: -1000 }, { y: 10000 }, 8, Cubic.easeIn)); var masterTw:ITween = BetweenAS3.parallelTweens(tweenArr); masterTw.stopOnComplete = false; masterTw.play(); } } }