-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: added primitive * docs: fix grammar * docs: fix grammar * docs: fix grammar abstraction * docs: fix grammar
- Loading branch information
1 parent
58fdbb5
commit a4c8785
Showing
3 changed files
with
60 additions
and
7 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,47 @@ | ||
# Primitives | ||
|
||
The `<primitive />` component is a versatile low-level component in TresJS that allows you to directly use any Three.js object within your Vue application without an abstraction. It acts as a bridge between Vue's reactivity system and Three.js's scene graph. | ||
|
||
## Usage | ||
|
||
```html | ||
<script setup lang="ts"> | ||
// Import necessary Three.js classes | ||
import { Mesh, BoxGeometry, MeshBasicMaterial } from 'three'; | ||
// Create a box geometry and a basic material | ||
const geometry = new BoxGeometry(1, 1, 1); | ||
const material = new MeshBasicMaterial({ color: 0x00ff00 }); | ||
// Create a mesh with the geometry and material | ||
const meshWithMaterial = new Mesh(geometry, material); | ||
</script> | ||
|
||
<template> | ||
<TresCanvas> | ||
<primitive :object="meshWithMaterial" /> | ||
</TresCanvas> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
`object`: This prop expects a Three.js Object3D or any of its derived classes. It is the primary object that the `<primitive />` component will render. In the updated example, a `Mesh` object with an associated `Material` is passed to this prop. | ||
|
||
## Usage with Models | ||
|
||
The `<primitive />` component is especially useful for rendering complex objects like models loaded from external sources. The following example shows how to load a model from a GLTF file and render it using the `<primitive />` component. | ||
|
||
```html | ||
<script lang="ts" setup> | ||
import { useGLTF } from '@tresjs/cientos' | ||
const { nodes } = await useGLTF('/models/AkuAku.gltf') | ||
</script> | ||
|
||
<TresCanvas> | ||
<Suspense> | ||
<primitive :object="nodes.AkuAku" /> | ||
</Suspense> | ||
</TresCanvas> | ||
``` |
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