easy-three

create.ambientLight

create.ambientLight(props : Object) : Light

props - 設定オブジェクト。
  • color (Hex) : ライトの色 (デフォルト : 0xffffff)。
  • intensity (Number) : 光の強さ (デフォルト : 0.5)。

環境光を作成してシーンに追加します。

環境光は全体を均等に照らす光源です。
シーン全体に均等に光を当てるため、影は作成されません。

コードの例

環境光

const { camera, create, animate } = init()
camera.position.set(0, 0, 2)
create.ambientLight()

const cube = create.cube()

animate(({ delta }) => {
  cube.rotation.x += delta;
  cube.rotation.y += delta;
});

光量を変化させる

const { camera, create, animate } = init()
camera.position.set(0, 0, 2)
const ambientLight = create.ambientLight()

const cube = create.cube()

animate(({ delta, time }) => {
  cube.rotation.x += delta;
  cube.rotation.y += delta;
  ambientLight.intensity = Math.sin(time) * 0.5 + 0.5;
});