easy-three

create.rectAreaLight

create.rectAreaLight(props : Object) : Light

props - 設定オブジェクト。
  • color (Hex) : ライトの色 (デフォルト : 0xffffff)。
  • intensity (Number) : 光の強さ (デフォルト : 1)。
  • size (Array) : ライトのサイズ (デフォルト : 1)。
  • position (Array) : ライトの位置 (デフォルト : [0, 0, 0])。
  • rotation (Array) : ライトの回転 (デフォルト : [0, 0, 0])。
  • helper (Boolean) : ヘルパーの表示 (デフォルト : false)。

矩形の領域で光るライトを作成してシーンに追加します。

rectAreaLightは、指定した位置と回転で矩形の領域で光るライトを作成します。
明るい窓や蛍光灯などの表現に利用できます。
このライトは、影を作成しません。
このライトは他のライトと比べて計算コストが高いので、大量に設置するとパフォーマンスが低下します。

コードの例

矩形の光 (ヘルパーあり)

ヘルパーを使うことで、ライト部分を可視化できます。

const { camera, controls, create, animate } = init()

controls.connect();
camera.position.set(0, 2, 3);

create.cube({
  position: [0, 0.5, 0],
  rotation: [0, Math.PI / 4, 0],
  option: {
    color: 0xffffff,
  },
});

create.plane({
  size: 10,
  rotation: [-Math.PI / 2, 0, 0],
  option: {
    color: 0xffffff,
  },
});

create.rectAreaLight({
  intensity: 3,
  color: 0xff0000,
  size: [1, 2],
  position: [1.5, 1, -1],
  rotation: [0, (3 * Math.PI) / 4, 0],
  helper: true,
});

create.rectAreaLight({
  intensity: 3,
  color: 0x0000ff,
  size: [1, 2],
  position: [-1.5, 1, -1],
  rotation: [0, -(3 * Math.PI) / 4, 0],
  helper: true,
});

animate();

矩形の光 (ヘルパーなし)

const { camera, controls, create, animate } = init()

controls.connect();
camera.position.set(0, 2, 3);

create.cube({
  position: [0, 0.5, 0],
  rotation: [0, Math.PI / 4, 0],
  option: {
    color: 0xffffff,
  },
});

create.plane({
  size: 10,
  rotation: [-Math.PI / 2, 0, 0],
  option: {
    color: 0xffffff,
  },
});

create.rectAreaLight({
  intensity: 3,
  color: 0xff0000,
  size: [1, 2],
  position: [1.5, 1, -1],
  rotation: [0, (3 * Math.PI) / 4, 0],
});

create.rectAreaLight({
  intensity: 3,
  color: 0x0000ff,
  size: [1, 2],
  position: [-1.5, 1, -1],
  rotation: [0, -(3 * Math.PI) / 4, 0],
});

animate();