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

feat(environment): enhance environment and background props #590

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

alvarosabu
Copy link
Member

  • Added new properties for background and environment intensity, as well as their rotations, to improve scene customization.
  • Updated useEnvironment and related components to support the new properties, ensuring better control over lighting and background effects.
  • Refactored EnvironmentDemo to utilize the new properties, enhancing the demo's interactivity and visual fidelity.
  • Improved type definitions in EnvironmentOptions to include the new parameters for better TypeScript support.

- Added new properties for background and environment intensity, as well as their rotations, to improve scene customization.
- Updated `useEnvironment` and related components to support the new properties, ensuring better control over lighting and background effects.
- Refactored `EnvironmentDemo` to utilize the new properties, enhancing the demo's interactivity and visual fidelity.
- Improved type definitions in `EnvironmentOptions` to include the new parameters for better TypeScript support.
@alvarosabu alvarosabu self-assigned this Jan 24, 2025
Copy link

netlify bot commented Jan 24, 2025

Deploy Preview for cientos-tresjs ready!

Name Link
🔨 Latest commit 2310c9b
🔍 Latest deploy log https://app.netlify.com/sites/cientos-tresjs/deploys/6793656ed3fd6d0008bb9f0b
😎 Deploy Preview https://deploy-preview-590--cientos-tresjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@alvarosabu alvarosabu added the feature New feature or request label Jan 24, 2025
Copy link

pkg-pr-new bot commented Jan 24, 2025

Open in Stackblitz

npm i https://pkg.pr.new/@tresjs/cientos@590

commit: 2310c9b

Copy link
Contributor

@andretchen0 andretchen0 left a comment

Choose a reason for hiding this comment

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

The new props look handy!

Some changes below.

})

watch(() => environmentRotation?.value, (value) => {
if (scene.value && value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

value can be a number. 0 is a valid value, but will cause this predicate to be false.

scene.value.environmentRotation = new Euler(value, value, value)
}
else if (value instanceof Vector3) {
scene.value.environmentRotation = new Euler(value.x, value.y, value.z)
Copy link
Contributor

Choose a reason for hiding this comment

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

(non-blocking)

This branch could be removed. The next predicate will match Vector3 and set the value accordingly.

scene.value.backgroundRotation = new Euler(value, value, value)
}
else if (value instanceof Vector3) {
scene.value.backgroundRotation = new Euler(value.x, value.y, value.z)
Copy link
Contributor

Choose a reason for hiding this comment

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

(non-blocking)

This branch could be removed. The next predicate will match Vector3 and set the value accordingly.

})

watch(() => backgroundRotation?.value, (value) => {
if (scene.value && value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

value can be a number. 0 is a valid value, but will cause this predicate to be false.

@@ -105,6 +115,67 @@ export async function useEnvironment(
immediate: true,
})

watch(() => backgroundIntensity?.value, (value) => {
if (scene.value && value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

0 will make this predicate false.

immediate: true,
})

watch(() => environmentIntensity?.value, (value) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

0 will make this predicate false.

backgroundIntensity = ref(1),
environmentIntensity = ref(1),
backgroundRotation = ref([0, 0, 0]),
environmentRotation = ref([0, 0, 0]),
Copy link
Contributor

@andretchen0 andretchen0 Jan 25, 2025

Choose a reason for hiding this comment

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

In the playground, changing environmentRotation doesn't seem to have an effect.

I was expecting that changing environmentRotation would rotate the material map similar to this THREE demo, when backgroundRotationX and syncMaterial are checked (though not in sync with the background rotation).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants