Skip to content

Commit

Permalink
Reflect the review comments
Browse files Browse the repository at this point in the history
* Rename AmbientLight to AmbientLightTag
* Add default parameters for AmbientLight inflator
  • Loading branch information
takahirox committed Feb 2, 2023
1 parent b95179c commit 8983e58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/bit-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const AEntity = defineComponent();
export const Object3DTag = defineComponent();
export const GLTFModel = defineComponent();
export const LightTag = defineComponent();
export const AmbientLight = defineComponent();
export const AmbientLightTag = defineComponent();
export const DirectionalLight = defineComponent();
export const CursorRaycastable = defineComponent();
export const RemoteHoverTarget = defineComponent();
Expand Down
13 changes: 9 additions & 4 deletions src/inflators/ambient-light.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
import { addComponent } from "bitecs";
import { addObject3DComponent } from "../utils/jsx-entity";
import { AmbientLight, LightTag } from "../bit-components";
import { AmbientLight as AL } from "three";
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) {
const light = new AL();
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, AmbientLight, eid);
addComponent(world, AmbientLightTag, eid);
return eid;
}

0 comments on commit 8983e58

Please sign in to comment.