-
-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff8c86c
commit 7916b1e
Showing
9 changed files
with
120 additions
and
8 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,67 @@ | ||
# Environment <Badge type="warning" text="^1.7.0" /> | ||
|
||
![Environment](/cientos/environment.png) | ||
|
||
Is a component abstraction that automatically sets up a global cubemap, which affects the default `scene.environment`, and optionally `scene.background`, | ||
|
||
It uses the composable [useEnvironment](/cientos/abstractions/use-environment) under the hood to load the cubemap. | ||
|
||
## Usage | ||
|
||
```html | ||
<Environment | ||
:files="[ | ||
'/px.jpg', | ||
'/nx.jpg', | ||
'/py.jpg', | ||
'/ny.jpg', | ||
'/pz.jpg', | ||
'/nz.jpg' | ||
]" | ||
/> | ||
``` | ||
|
||
You can also pass the `.hdr` file directly: | ||
|
||
```html | ||
<Environment files="/sunset.hdr" /> | ||
``` | ||
|
||
![Environment](/cientos/envmaps.png) | ||
|
||
## Texture reference | ||
|
||
You can access the model reference by pasing a `ref` to the `<Environment />` prop and then using the method `getTexture()` to get the object. | ||
|
||
```vue{4,6,9,14,17} | ||
<script setup lang="ts"> | ||
import { Environment } from '@tresjs/cientos' | ||
let envMap = null | ||
const environmentTexture = shallowRef() | ||
watch(environmentTexture, ({ getTexture }) => { | ||
envMap = getTexture() | ||
}) | ||
</script> | ||
<template> | ||
<Environment ref="environmentTexture" /> | ||
<TresMesh> | ||
<TresSphereGeometry /> | ||
<TresMeshStandardMaterial :env-map="envMap" /> | ||
</TresMesh> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
| Prop | Description | Default | | ||
| :----------- | :------------------------------------------------------------------- | ------------------------------------------------------------------------------ | | ||
| `files` | Array of 6 urls to images, one for each side of the CubeTexture. | `undefined` | | ||
| `path` | Path to the environment map files. | `undefined` | | ||
| `encoding` | Encoding of the environment map. | `sRGBEncoding` for an array of files and `LinearEncoding` for a single texture | | ||
| `background` | If `true`, the environment map will be used as the scene background. | `false` | | ||
| `blur` | Blur factor between 0 and 1. (only works with three 0.146 and up) | 0 | | ||
| `preset` | Preset environment map. | `undefined` | |
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,44 @@ | ||
# UseEnvironment <Badge type="warning" text="^1.7.0" /> | ||
|
||
`useEnvironment` composable that automatically sets up a global cubemap, which affects the default `scene.environment`, and optionally `scene.background`. | ||
|
||
It uses the [CubeTextureLoader](https://threejs.org/docs/#api/en/loaders/CubeTextureLoader) to load the cubemap | ||
|
||
## Usage | ||
|
||
```ts | ||
import { useEnvironment } from '@tresjs/cientos' | ||
|
||
const texture = await useEnvironment({ | ||
files: [ | ||
'/textures/environmentMaps/0/px.jpg', | ||
'/textures/environmentMaps/0/nx.jpg', | ||
'/textures/environmentMaps/0/py.jpg', | ||
'/textures/environmentMaps/0/ny.jpg', | ||
'/textures/environmentMaps/0/pz.jpg', | ||
'/textures/environmentMaps/0/nz.jpg', | ||
], | ||
path: '', | ||
encoding: sRGBEncoding, | ||
}) | ||
``` | ||
|
||
Then you can use the `texture` in your scene: | ||
|
||
```html{3} | ||
<TresMesh> | ||
<TresSphereGeometry /> | ||
<TresMeshStandardMaterial :map="texture" /> | ||
</TresMesh> | ||
``` | ||
|
||
## Options | ||
|
||
| Name | Type | Default | Description | | ||
| :------------- | ---------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------- | | ||
| **files** | `Array` | `undefined` | Array of 6 urls to images, one for each side of the CubeTexture. | | ||
| **path** | `boolean` | `false` | Path to the environment map files. | | ||
| **encoding** | `Encoding` | `sRGBEncoding` for an array of files and `LinearEncoding` for a single texture | Encoding of the environment map. | | ||
| **background** | `boolean` | `false` | If `true` the texture will be used as the scene background. | | ||
| **blur** | `number` | `0` | Blur factor between 0 and 1. (only works with three 0.146 and up) | | ||
| **preset** | `string` | `undefined` | Preset environment map. | |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.