平面を作成してシーンに追加します。
size については、通常2つの値を持つ配列で指定します。
配列でなく1つの数値を指定した場合、その値を2つ持つ配列として扱います。
(例 : size: 2 は [2, 2] と同じ)
option.material には、マテリアルの種類を文字列で指定します。
マテリアルの種類については、Three.js で定義されているものから 「THREE.」と「Mesh」を除いたものになります。
(例 : "Physical" は THREE.MeshPhysicalMaterial を意味します。)
例外として、THREE.NormalMaterial は "Normal" として指定します。
平面には表裏があり、裏面はデフォルトで描画されません。
裏面も描画する場合は、option に side: THREE.DoubleSide を指定します (init メソッドから THREE を取得できます)。
具体例は下記の「アニメーション」のコードを参照してください。
const { camera, create, animate } = init()
camera.position.set(0, 1, 1)
create.ambientLight()
create.directionalLight()
create.plane()
animate()
const { camera, create, animate, THREE, Default } = init()
camera.position.set(0, 0, 2)
create.ambientLight()
create.directionalLight()
const plane = create.plane({
option: {
side: THREE.DoubleSide,
color: Default.color,
}
})
animate(({ delta }) => {
plane.rotation.x += delta
})
const { camera, create, animate, THREE, Default } = init()
camera.position.set(0, 0, 4);
create.ambientLight();
create.directionalLight();
const plane1 = create.plane({
size: 1,
position: [-1, 0, 0],
material: "Normal",
option: {
side: THREE.DoubleSide,
},
});
const plane2 = create.plane({
size: 1.5,
position: [1, 0, 0],
option: {
// material settings
color: 0x00ff00,
metalness: 0.6,
roughness: 0,
transparent: true,
opacity: 0.5,
side: THREE.DoubleSide,
},
});
const plane3 = create.plane({
size: 3,
position: [0, 0, -3],
option: {
side: THREE.DoubleSide,
color: Default.color,
},
});
animate(({ time, delta }) => {
plane1.rotation.x += delta;
plane2.rotation.y += delta;
plane3.rotation.x += delta;
plane3.rotation.z += delta;
plane3.position.y = Math.sin(time) * 2;
});