S3System
3DCGシステム全体を管理するクラス
3DCGのための座標変換やシーン管理、基本的な生成処理・ユーティリティ関数などをまとめて提供します。 頂点やメッシュ、マテリアルなど各種オブジェクトのファクトリ機能も持ちます。
Static Method Summary
Static Public Methods | ||
public static |
calcAspect(width: number, height: number): number アスペクト比を計算します。 |
|
public static |
視体積の上下方向の視野角を求めます。 |
Constructor Summary
Public Constructor | ||
public |
S3Systemインスタンスを作成します。 描画モードや背景色などを初期化します。 |
Member Summary
Public Members | ||
public |
背景色(RGBAベクトル) |
|
public |
canvas: HTMLCanvasElement 描画に使うcanvas要素 |
|
public |
context2d: {"context": *, "drawLine": *, "drawLinePolygon": *, "setLineWidth": *, "setLineColor": *, "clear": *} 2D描画用のユーティリティオブジェクト(drawLine, drawLinePolygonなど) |
|
public |
カリングモード(面の非表示除去方法) |
|
public |
深度バッファのモード(OpenGL/DirectX) |
|
public |
座標系モード(右手系/左手系) |
|
public |
前面判定の面の向き(時計回り/反時計回り) |
|
public |
現在のシステムモード(OpenGL/DirectX) |
|
public |
ベクトル型のモード(VECTOR4x1 / VECTOR1x4) |
Private Members | ||
private |
_CREATE_ID: number[] 内部で一意なIDを発行するためのカウンタ配列 |
Method Summary
Public Methods | ||
public |
clear() 2Dキャンバスの内容をクリアします。 |
|
public |
新しいカメラインスタンスを生成します。 |
|
public |
新しいライトインスタンスを生成します。 |
|
public |
createMaterial(name: string): S3Material 新しいマテリアルインスタンスを生成します。 |
|
public |
createMesh(): S3Mesh 新しいメッシュインスタンスを生成します。 |
|
public |
新しいモデルインスタンスを生成します。 |
|
public |
新しいシーンインスタンスを生成します。 |
|
public |
createTexture(name: string | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement): S3Texture 新しいテクスチャインスタンスを生成します。 |
|
public |
createTriangleIndex(i1: number, i2: number, i3: number, indexlist: Array<number>, materialIndex: number, uvlist: Array<S3Vector>): S3TriangleIndex 新しい三角形インデックスインスタンスを生成します。 |
|
public |
createVertex(position: S3Vector): S3Vertex 新しい頂点インスタンスを生成します。 |
|
public |
X, Y, Zの座標軸を描画します(デバッグ用)。 |
|
public |
シーン全体を描画します。 |
|
public |
背景色を取得します。 |
|
public |
単位行列を生成します。 |
|
public |
getMatrixLookAt(eye: S3Vector, at: S3Vector, up: S3Vector): S3Matrix カメラのビュー行列を生成します。 |
|
public |
視野角(FOVY)から射影行列を生成します。 |
|
public |
getMatrixRotateX(degree: number): S3Matrix X軸周りの回転行列を生成します。 |
|
public |
getMatrixRotateY(degree: number): S3Matrix Y軸周りの回転行列を生成します。 |
|
public |
getMatrixRotateZ(degree: number): S3Matrix Z軸周りの回転行列を生成します。 |
|
public |
getMatrixRotateZXY(z: number, x: number, y: number): S3Matrix 航空機の姿勢制御 ZXY(ロール・ピッチ・ヨー)の順で回転行列を作成します。 |
|
public |
getMatrixScale(x: number, y: number, z: number): S3Matrix 拡大縮小行列を生成します。 |
|
public |
getMatrixTranslate(x: number, y: number, z: number): S3Matrix 平行移動行列を生成します。 |
|
public |
getMatrixViewport(x: number, y: number, Width: number, Height: number, MinZ: number, MaxZ: number): S3Matrix ビューポート行列を生成します。 |
|
public |
getMatrixWorldTransform(model: S3Model): S3Matrix 指定モデルのワールド変換行列を生成します(スケール→回転→移動の順)。 |
|
public |
縦型/横型を踏まえて2つの行列を掛けます。 |
|
public |
縦型/横型を踏まえて行列とベクトルを掛けます。 |
|
public |
setBackgroundColor(color: S3Vector) 背景色を設定します。 |
|
public |
setCanvas(canvas: HTMLCanvasElement) 描画に使うCanvasを関連付け、2D描画用Contextを内部にセットします。 |
|
public |
setCullMode(cullmode: number) カリング(非表示面除去)の方法を設定します。 |
|
public |
setDepthMode(depthmode: number) 深度(Z値の扱い)のモードを設定します。 |
|
public |
setDimensionMode(dimensionmode: number) 座標系(右手/左手系)を設定します。 |
|
public |
setFrontMode(frontface: number) 前面と判定する面の頂点順序(時計回り/反時計回り)を設定します。 |
|
public |
setSystemMode(mode: number) システムモードを設定します(OpenGL/DIRECT_Xなど)。 各種描画パラメータも合わせて設定されます。 |
|
public |
setVectorMode(vectormode: number) ベクトル表現のモードを設定します(縦型/横型)。 |
|
public |
三角形がカリング対象かどうか判定します。 |
Private Methods | ||
private |
_calcVertexTransformation(vertexlist: Array<S3Vertex>, MVP: S3Matrix, Viewport: S3Matrix): Array<S3Vertex> 頂点リストをMVP変換・射影して新しい頂点配列を返します。 |
|
private |
ユニークなID文字列を発行します(テクスチャなどの管理用途)。 |
|
private |
_disposeObject(obj: Object): void 不要になったリソースを解放します(未実装)。 |
|
private |
画像やテキストファイルをダウンロードします。 画像拡張子ならImage要素、それ以外はテキストとして取得しコールバックします。 |
|
private |
_drawPolygon(vetexlist: Array<S3Vertex>, triangleindexlist: Array<S3TriangleIndex>) ポリゴン(三角形群)を描画します(ラインで表示)。 |
|
private |
_init() 内部状態を初期化します(描画モードや背景色のリセット)。 |
|
private |
任意の値を数値に変換します。 |
|
private |
任意の値をS3Vectorに変換します。 |
Static Public Methods
Public Constructors
Public Members
public context2d: {"context": *, "drawLine": *, "drawLinePolygon": *, "setLineWidth": *, "setLineColor": *, "clear": *} source
2D描画用のユーティリティオブジェクト(drawLine, drawLinePolygonなど)
Properties:
Name | Type | Attribute | Description |
context | CanvasRenderingContext2D | 2D描画コンテキスト |
|
drawLine | function(prm1: S3Vector, prm2: S3Vector): void | 2点間の直線を描画 |
|
drawLinePolygon | function(prm1: S3Vector, prm2: S3Vector, prm3: S3Vector): void | 3点から三角形(線のみ)を描画 |
|
setLineWidth | function(prm1: number): void | 線の太さを設定 |
|
setLineColor | function(prm1: string): void | 線の色を設定 |
|
clear | function(prm1: ): void | キャンバス全体を背景色で塗りつぶし |
Private Members
Public Methods
public createMaterial(name: string): S3Material source
新しいマテリアルインスタンスを生成します。
Params:
Name | Type | Attribute | Description |
name | string |
|
マテリアル名 |
public createTexture(name: string | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement): S3Texture source
新しいテクスチャインスタンスを生成します。
Params:
Name | Type | Attribute | Description |
name | string | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement |
|
テクスチャ名や画像データ |
public createTriangleIndex(i1: number, i2: number, i3: number, indexlist: Array<number>, materialIndex: number, uvlist: Array<S3Vector>): S3TriangleIndex source
新しい三角形インデックスインスタンスを生成します。
public createVertex(position: S3Vector): S3Vertex source
新しい頂点インスタンスを生成します。
Params:
Name | Type | Attribute | Description |
position | S3Vector | 頂点座標 |
public drawAxis(scene: S3Scene) source
X, Y, Zの座標軸を描画します(デバッグ用)。
Params:
Name | Type | Attribute | Description |
scene | S3Scene | 対象シーン |
public drawScene(scene: S3Scene) source
シーン全体を描画します。
Params:
Name | Type | Attribute | Description |
scene | S3Scene | 描画対象のシーン |
public getMatrixPerspectiveFov(fovY: number, Aspect: number, Near: number, Far: number): S3Matrix source
視野角(FOVY)から射影行列を生成します。
public getMatrixRotateX(degree: number): S3Matrix source
X軸周りの回転行列を生成します。
Params:
Name | Type | Attribute | Description |
degree | number | 角度(度) |
public getMatrixRotateY(degree: number): S3Matrix source
Y軸周りの回転行列を生成します。
Params:
Name | Type | Attribute | Description |
degree | number | 角度(度) |
public getMatrixRotateZ(degree: number): S3Matrix source
Z軸周りの回転行列を生成します。
Params:
Name | Type | Attribute | Description |
degree | number | 角度(度) |
public getMatrixRotateZXY(z: number, x: number, y: number): S3Matrix source
航空機の姿勢制御 ZXY(ロール・ピッチ・ヨー)の順で回転行列を作成します。
public getMatrixViewport(x: number, y: number, Width: number, Height: number, MinZ: number, MaxZ: number): S3Matrix source
ビューポート行列を生成します。
public getMatrixWorldTransform(model: S3Model): S3Matrix source
指定モデルのワールド変換行列を生成します(スケール→回転→移動の順)。
Params:
Name | Type | Attribute | Description |
model | S3Model | 対象モデル |
public setBackgroundColor(color: S3Vector) source
背景色を設定します。
Params:
Name | Type | Attribute | Description |
color | S3Vector | RGBAで指定する背景色 |
public setCanvas(canvas: HTMLCanvasElement) source
描画に使うCanvasを関連付け、2D描画用Contextを内部にセットします。
Params:
Name | Type | Attribute | Description |
canvas | HTMLCanvasElement | 使用するcanvas要素 |
public setCullMode(cullmode: number) source
カリング(非表示面除去)の方法を設定します。
Params:
Name | Type | Attribute | Description |
cullmode | number | S3System.CULL_MODE |
public setDepthMode(depthmode: number) source
深度(Z値の扱い)のモードを設定します。
Params:
Name | Type | Attribute | Description |
depthmode | number | S3System.DEPTH_MODE |
public setDimensionMode(dimensionmode: number) source
座標系(右手/左手系)を設定します。
Params:
Name | Type | Attribute | Description |
dimensionmode | number | S3System.DIMENSION_MODE |
public setFrontMode(frontface: number) source
前面と判定する面の頂点順序(時計回り/反時計回り)を設定します。
Params:
Name | Type | Attribute | Description |
frontface | number | S3System.FRONT_FACE |
public setSystemMode(mode: number) source
システムモードを設定します(OpenGL/DIRECT_Xなど)。 各種描画パラメータも合わせて設定されます。
Params:
Name | Type | Attribute | Description |
mode | number | S3System.SYSTEM_MODE で定義される値 |
public setVectorMode(vectormode: number) source
ベクトル表現のモードを設定します(縦型/横型)。
Params:
Name | Type | Attribute | Description |
vectormode | number | S3System.VECTOR_MODE |
Private Methods
private _calcVertexTransformation(vertexlist: Array<S3Vertex>, MVP: S3Matrix, Viewport: S3Matrix): Array<S3Vertex> source
頂点リストをMVP変換・射影して新しい頂点配列を返します。
private _disposeObject(obj: Object): void source
不要になったリソースを解放します(未実装)。
Params:
Name | Type | Attribute | Description |
obj | Object | 解放対象のオブジェクト |
Return:
void |
private _download(url: string, callback: function) source
画像やテキストファイルをダウンロードします。 画像拡張子ならImage要素、それ以外はテキストとして取得しコールバックします。
private _drawPolygon(vetexlist: Array<S3Vertex>, triangleindexlist: Array<S3TriangleIndex>) source
ポリゴン(三角形群)を描画します(ラインで表示)。
Params:
Name | Type | Attribute | Description |
vetexlist | Array<S3Vertex> | 頂点配列 |
|
triangleindexlist | Array<S3TriangleIndex> | インデックス配列 |