REGZAのCMのあれ
今回はAway3Dを使用しました。
REGZAのCMのあれをちょっとだけ再現。
http://www.youtube.com/watch?v=ELUan2q6o3E
文字を立体にするのが結構厄介ですね。
↓参考までに
http://www.brighthub.com/hubfolio/matthew-casperson/articles/48051.aspx
/**
* Copyright axcel_work ( http://wonderfl.net/user/axcel_work )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/Awgb
*/
package {
import flash.utils.ByteArray;
import flash.system.LoaderContext;
import flash.system.ApplicationDomain;
import flash.net.URLRequest;
import flash.display.Loader;
import wumedia.vector.VectorText;
import away3d.cameras.Camera3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import fl.motion.easing.Back;
import com.flashdynamix.motion.Tweensy;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.utils.Timer;
[SWF(width="465", height="465", backgroundColor="0x0", frameRate="60")]
/**
* @author yamaji
*/
public class Index extends Sprite {
private var _loader:Loader;
private var _view:View3D = new View3D();
private var _camera:Camera3D = new Camera3D();
private var _scene:Scene3D = new Scene3D();
private var _timer:Timer;
private var _line1:Line;
private var _line2:Line;
private var _line3:Line;
private var _line4:Line;
private var _line5:Line;
private var _dial:Dial = new Dial(600);
/**
*
*/
public function Index() {
if(stage) this.atInit();
else this.addEventListener(Event.ADDED_TO_STAGE, atInit);
}
private function atInit(e:Event = null):void {
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
this._loader = new Loader();
//this._loader.load(new URLRequest("../swc/SmapleModel.swf"), context);
this._loader.load(new URLRequest("http://shift-style.org/labo/away3d/SmapleModel.swf"));
this._loader.contentLoaderInfo.addEventListener(Event.COMPLETE, complete);
}
private function complete(event:Event):void {
trace("Complete");
var ArialEmbedded:ByteArray = this._loader.contentLoaderInfo.bytes;
//var ArialEmbedded:Class = ApplicationDomain.currentDomain.getDefinition("Arial") as Class;
VectorText.extractFont(ArialEmbedded, null, false);
// View の設置
this._view.x = this.stage.stageWidth / 2;
this._view.y = this.stage.stageHeight / 2;
this.addChild(this._view);
// Camera の設置
//this._camera.zoom = 1;
//this._camera.focus = 250;
this._camera.z = -2300;
this._view.camera = this._camera;
// Scene の設置
this._view.scene = this._scene;
this._line1 = new Line(250, 0.8);
this._line2 = new Line(400, 0.9);
this._line3 = new Line(400, 0.9);
this._line4 = new Line(520, 1.6);
this._line5 = new Line(700, 1.4);
this._view.scene.addChild(this._line1);
this._view.scene.addChild(this._line2);
this._view.scene.addChild(this._line3);
this._view.scene.addChild(this._line4);
this._view.scene.addChild(this._line5);
this._line1.y = 350;
this._line1.rotationZ = -15;
this._line2.y = 100;
this._line2.rotationZ = 3;
this._line3.y = 0;
this._line3.rotationZ = -3;
this._line4.y = -200;
this._line4.rotationZ = 2;
this._line5.y = -150;
this._dial.y = -400;
this._view.scene.addChild(this._dial);
this._timer = new Timer(1000);
this._timer.addEventListener(TimerEvent.TIMER, clocks);
this._timer.start();
this.stage.addEventListener(Event.EXIT_FRAME, render);
}
private function render(e:Event):void {
this._view.render();
}
private function clocks(e:TimerEvent):void {
Tweensy.to(this._line1, {rotationY: this._line1.rotationY - 10}, 0.45, Back.easeOut);
Tweensy.to(this._line2, {rotationY: this._line2.rotationY + 10}, 0.45, Back.easeOut);
Tweensy.to(this._line3, {rotationY: this._line3.rotationY - 10}, 0.45, Back.easeOut);
Tweensy.to(this._line4, {rotationY: this._line4.rotationY + 10}, 0.45, Back.easeOut);
Tweensy.to(this._line5, {rotationY: this._line5.rotationY - 10}, 0.45, Back.easeOut);
}
}
}
import away3d.primitives.data.CubeMaterialsData;
import away3d.primitives.Cube;
import away3d.containers.ObjectContainer3D;
import away3d.extrusions.TextExtrusion;
import away3d.materials.ColorMaterial;
import away3d.primitives.TextField3D;
class Line extends ObjectContainer3D {
private var _cnt:int = 12;
//[Embed(source="http://shift-style.org/labo/away3d/extrusionfonts.swf", mimeType="application/octet-stream")]
/**
*
*/
public function Line(length:int, scale:Number = 1) {
for (var i:int = 0;i < this._cnt;i++) {
var rot:Number = 360 * i / this._cnt;
var plane:TextField3D = new TextField3D("Arial");
plane.material = new ColorMaterial(0xFFFF00);
plane.text = String(i + 1);
plane.size = 80;
var extrusion:TextExtrusion = new TextExtrusion(plane, {subdivisionsXY:1, subdivisionsZ:1, bothsides:true, depth:7});
var container:ObjectContainer3D = new ObjectContainer3D(plane, extrusion);
container.x = length * Math.sin(rot * Math.PI / 180);
container.y = 0;
container.z = length * Math.cos(rot * Math.PI / 180);
container.rotationY = rot;
container.scale(scale);
this.addChild(container);
}
this.rotationY = Math.random() * 200;
}
}
class Dial extends ObjectContainer3D {
private var _cnt:int = 60;
/**
*
*/
public function Dial(length:int) {
var _depth:int = 0;
for (var i:int = 0;i < this._cnt;i++) {
var rot:Number = 360 * i / this._cnt;
//trace(rot);
if(i % 5 == 0) {
_depth = 80;
} else {
_depth = 20;
}
var bar:Cube = new Cube({width:10, height:5, depth:_depth, faces:new CubeMaterialsData({
front:new ColorMaterial(0xFFFF00), back:new ColorMaterial(0xFFFF00), right:new ColorMaterial(0xFFFF00), left:new ColorMaterial(0xFFFF00), top:new ColorMaterial(0xFFFF00), bottom:new ColorMaterial(0xFFFF00)
})});
bar.x = length * Math.sin(rot * Math.PI / 180);
bar.z = length * Math.cos(rot * Math.PI / 180);
bar.rotationY = rot;
this.addChild(bar);
}
}
}