package { import alternativa.engine3d.core.Object3D; import alternativa.engine3d.loaders.ParserCollada; import alternativa.engine3d.materials.Material; import alternativa.engine3d.materials.TextureMaterial; import alternativa.engine3d.objects.Mesh; import alternativa.engine3d.resources.BitmapTextureResource; import org.libspark.alternativa3d.camera.CameraType; import org.libspark.alternativa3d.controllers.OrbitCameraController; import org.libspark.alternativa3d.view.AlternativaTemplate; [SWF(frameRate = "60")] /** * Miku Colladaオブジェクトを配置したパフォーマンステスト。 * @author clockmaker.jp */ public class MolehillMikus extends AlternativaTemplate { private static const CELL_NUM:uint = 5; [Embed(source = "/assets/miku.png")] private var ImageCls:Class; [Embed(source = "/assets/negimiku.dae", mimeType = "application/octet-stream")] private var ObjAssetCls:Class; public function MolehillMikus() { super({ antiAlias: 8, cameraType: CameraType.ORBIT, useDiagram: true }); } override protected function atInit():void { // ミクミク // マテリアル作成 var material:TextureMaterial = new TextureMaterial(); material.diffuseMap = new BitmapTextureResource(new ImageCls().bitmapData); for (var i:int = 0; i < CELL_NUM; i++) { for (var j:int = 0; j < CELL_NUM; j++) { for (var k:int = 0; k < CELL_NUM; k++) { var miku:Object3D = createMiku(material); miku.x = 300 * (i - CELL_NUM / 2) + 150; miku.y = 300 * (j - CELL_NUM / 2) + 150; miku.z = 300 * (k - CELL_NUM / 2) + 150; scene.addChild(miku); } } } } private function createMiku(material:Material):Object3D { var container:Object3D = new Object3D(); // Colladaを展開 var parser:ParserCollada = new ParserCollada(); parser.parse(new XML(new ObjAssetCls())); for (var i:int = 0; i < parser.objects.length; i++) { var mesh:Mesh = parser.objects[ i ] as Mesh; if (mesh) { mesh.setMaterialToAllSurfaces(material); mesh.scaleX = mesh.scaleY = mesh.scaleZ = 10; container.addChild(mesh); } } return container; } } }