Skip to content

Commit

Permalink
docs: update status of useTres composable
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Feb 15, 2023
1 parent 6481cec commit 2064344
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions docs/api/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,32 +170,13 @@ Then you can use the new component in your template. Notice that the new compone
</template>
```

# useTres <Badge type="warning" text="experimental" />
# useTres <Badge type="warning" text="^1.7.0" />

This composable aims to provide access to the state model which contains the default renderer, camera, scene, and other useful properties. It is still experimental and it is not recommended to use it in production because is highly like subject to change.
This composable aims to provide access to the state model which contains the default renderer, camera, scene, and other useful properties.

```ts
const { state } = useTres()

console.log(state.camera) // THREE.PerspectiveCamera
console.log(state.renderer) // THREE.WebGLRenderer
```

Until this composable is stable, it is recommended to use the `provide/inject` API to acces the elements you need. These are the available keys:

- `camera`: it returns the current active camera
- `renderer`: it returns the current active renderer
- `local-scene`: it returns the current active scene
- `catalogue`: it returns the current catalogue of components
- `extend` : it returns the `extend` function from the `useCatalogue` composable. Specially needed if you are a plugin author.
- `aspect-ratio`: it returns the current aspect ratio of the canvas

```ts
import { provide, inject } from 'vue'

const camera = inject<Ref<Camera>>('camera')
const renderer = inject<Ref<WebGLRenderer>>('renderer')

console.log(camera.value) // THREE.PerspectiveCamera
console.log(renderer.value) // THREE.WebGLRenderer
```

0 comments on commit 2064344

Please sign in to comment.