First commit
This commit is contained in:
commit
7fe5d03a09
33 changed files with 6524 additions and 0 deletions
29
app/three/utils/build-default-lights.ts
Normal file
29
app/three/utils/build-default-lights.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { AmbientLight, DirectionalLight, Scene } from "three";
|
||||
|
||||
const DEG2RAD = Math.PI / 180;
|
||||
export function buildDefaultLights(scene: Scene) {
|
||||
// ambient light
|
||||
scene.add(new AmbientLight(0x999999));
|
||||
|
||||
// directional lights
|
||||
const opt = {
|
||||
azimuth: 220,
|
||||
altitude: 45,
|
||||
};
|
||||
|
||||
const lambda = (90 - opt.azimuth) * DEG2RAD;
|
||||
const phi = opt.altitude * DEG2RAD;
|
||||
|
||||
const x = Math.cos(phi) * Math.cos(lambda);
|
||||
const y = Math.cos(phi) * Math.sin(lambda);
|
||||
const z = Math.sin(phi);
|
||||
|
||||
const light1 = new DirectionalLight(0xffffff, 0.5);
|
||||
light1.position.set(x, y, z);
|
||||
scene.add(light1);
|
||||
|
||||
// thin light from the opposite direction
|
||||
const light2 = new DirectionalLight(0xffffff, 0.1);
|
||||
light2.position.set(-x, -y, -z);
|
||||
scene.add(light2);
|
||||
}
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue