Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable environment variables #139

Merged
merged 7 commits into from
Jun 5, 2024

Conversation

sachamorgese
Copy link
Contributor

What kind of change does your PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Refactor
  • Tests
  • Other, please describe:

constructor(
scene: Scene,
camera: PerspectiveCamera,
spawnSun: boolean = false,
Copy link
Contributor

@TheCodeTherapy TheCodeTherapy May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd eliminate the default value for the spawnSun argument (explicit is always better) otherwise, we'll need to make it the last constructor argument (wouldn't hurt much as we're changing the constructor signature anyway, but as we may want to instantiate the composer with just an empty {} (or just omit completely and have it to be undefined) to be an untouched environmentConfiguration I think it would be good to have it as a last private optional argument).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, completely missed that, you're right. I think it makes sense to remove the default argument

@@ -91,11 +91,17 @@ export class Composer {
private readonly gaussGrainPass: ShaderPass;

private ambientLight: AmbientLight | null = null;
private environmentConfiguration: EnvironmentConfiguration;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can exclude this and receive+declare as a private optional property in the constructor arguments.

camera: PerspectiveCamera,
spawnSun: boolean = false,
environmentConfiguration: EnvironmentConfiguration,
) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the 2 comments above make sense, then we can alter the constructor signature to:

constructor(
    scene: Scene,
    camera: PerspectiveCamera,
    spawnSun: boolean,
    private environmentConfiguration?: EnvironmentConfiguration | undefined,
  )

if (environmentConfiguration.postProcessing?.bloomIntensity) {
extrasValues.bloom = environmentConfiguration.postProcessing.bloomIntensity;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (this.environmentConfiguration?.postProcessing?.bloomIntensity) {
  extrasValues.bloom = this.environmentConfiguration.postProcessing.bloomIntensity;
}

@@ -52,13 +52,32 @@ type MMLDocumentConfiguration = {
};
};

export type EnvironmentConfiguration = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this to the core library (in the composer.ts file) minus the enableTweakPane field so that the core doesn't depend on this high level library.


public sun: Sun | null = null;
public spawnSun: boolean;

constructor(scene: Scene, camera: PerspectiveCamera, spawnSun: boolean = false) {
constructor(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make this constructor take an object to disambiguate what the boolean arg is for

bloomIntensity?: number;
},
}

export type Networked3dWebExperienceClientConfig = {
sessionToken: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make enableTweakPane part of this config

@sachamorgese sachamorgese force-pushed the feature/add-configurable-env-variabels branch from 567ac8a to b02254d Compare June 3, 2024 10:24
@sachamorgese sachamorgese marked this pull request as ready for review June 3, 2024 10:27
@sachamorgese sachamorgese changed the title WIP: Add configurable environment variables Add configurable environment variables Jun 3, 2024
@MarcusLongmuir MarcusLongmuir merged commit 8634a66 into main Jun 5, 2024
5 checks passed
@MarcusLongmuir MarcusLongmuir deleted the feature/add-configurable-env-variabels branch June 5, 2024 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants