-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5918 from mozilla/BitECSAmbientLight
Add AmbientLights to bitecs
- Loading branch information
Showing
3 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { addComponent } from "bitecs"; | ||
import { addObject3DComponent } from "../utils/jsx-entity"; | ||
import { AmbientLightTag, LightTag } from "../bit-components"; | ||
import { AmbientLight } from "three"; | ||
import { HubsWorld } from "../app"; | ||
|
||
export type AmbientLightParams = { | ||
color: string; | ||
intensity: number; | ||
}; | ||
|
||
const DEFAULTS = { | ||
intensity: 1.0 | ||
}; | ||
|
||
export function inflateAmbientLight(world: HubsWorld, eid: number, params: AmbientLightParams) { | ||
params = Object.assign({}, DEFAULTS, params); | ||
const light = new AmbientLight(); | ||
light.color.set(params.color).convertSRGBToLinear(); | ||
light.intensity = params.intensity; | ||
|
||
addObject3DComponent(world, eid, light); | ||
addComponent(world, LightTag, eid); | ||
addComponent(world, AmbientLightTag, eid); | ||
return eid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters