setUVsToFace を実行していない Face に TextureMaterial を適応しようとすると次の画像のように正しくテクスチャを貼り付けることが出来ません。

createVertex や createFace, createSurface を利用してメッシュを作成した後に TextureMaterial を正しく適応させるためには setUVsToFace の実行が必要です。

setUVsToFaceとは

public function setUVsToFace(aUV:Point, bUV:Point, cUV:Point, face:Object):void

Set UV-coordinates to a given face. Transformation matrix is being calculated using first three vertices of the face.

作成したフェイスにUVマッピングを行ないます。

UVマッピングに関する詳しい解説は、 テクスチャ座標 – ゲームプログラミングWikiAdobe ActionScript 3.0 * UV マッピングを参照してください。



mesh.setUVsToFace(new Point(0,0), new Point(0,1), new Point(0,1), "face");
mesh.setMaterialToSurface(new TextureMaterial(new Texture(BitmapData)), "surface");

なお、BoxやCone, Planeなどのメッシュは、インスタンス作成時にUVマッピングが行われているため、setUVsToFaceは、必要ありません。

前の記事
次の記事