babylonjs 3D WebGL ライブラリを使用しています。
これは素晴らしいライブラリですが、THREE.JS ライブラリに存在する同じものが見つかりません。
たとえば、データベースに 2D ポリゴンがあり、そこからポリゴン データを取得し、カスタム メッシュを作成して押し出しています。
THREE.JS では、問題はありません。いくつかの配列に追加できます。
...
points.push( new THREE.Vector2( part.x, -part.y ) );
...
var shape = new THREE.Shape( points );
var extrusion = {
amount: building.height,
bevelEnabled: false
};
var geometry = new THREE.ExtrudeGeometry( shape, extrusion );
var mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial({
ambient: 0xbbbbb,
color: 0xff0000
});
...
scene.add( mesh );
とても簡単です。同じことをする方法、私は見つけることができませんでした。
ここでいくつかの情報しか見つかりませんでした:
そのような例では (msdn から Ctrl + F -> You can also create a mesh from a list of vertices and faces
):
var plane = new BABYLON.Mesh(name, scene);
var indices = [];
var positions = [];
var normals = [];
var uvs = [];
// Vertices
var halfSize = size / 2.0;
positions.push(-halfSize, -halfSize, 0);
normals.push(0, 0, -1.0);
uvs.push(0.0, 0.0);
positions.push(halfSize, -halfSize, 0);
normals.push(0, 0, -1.0);
uvs.push(1.0, 0.0);
positions.push(halfSize, halfSize, 0);
normals.push(0, 0, -1.0);
uvs.push(1.0, 1.0);
positions.push(-halfSize, halfSize, 0);
normals.push(0, 0, -1.0);
uvs.push(0.0, 1.0);
// Indices
indices.push(0);
indices.push(1);
indices.push(2);
indices.push(0);
indices.push(2);
indices.push(3);
plane.setVerticesData(positions, BABYLON.VertexBuffer.PositionKind);
plane.setVerticesData(normals, BABYLON.VertexBuffer.NormalKind);
plane.setVerticesData(uvs, BABYLON.VertexBuffer.UVKind);
plane.setIndices(indices);
return plane;
しかし、それは THREE.JS と同じではありません。たとえば、THREE.JS では必要ないインデックス バッファーを手動でカウントする必要があります。また、平面のみのサンプルであり、正確な押し出しに関する情報が見つかりませんでした。
だから...多分、BabylonJSにはいくつかの簡単な方法がありますか?