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

docs: add tresjs (vue) to docs #46

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,29 @@ function Cube() {
}
```

</details>
<details>
<summary>Show Vue (Tresjs) example</summary>
FarazzShaikh marked this conversation as resolved.
Show resolved Hide resolved

```vue
<script setup>
import { CustomShaderMaterial } from '@tresjs/cientos'

</script>
<template>
<TresMesh>
<TresTorusKnotGeometry :args="[1, 0.3, 512, 32]" />
<CustomShaderMaterial
:baseMaterial="THREE.MeshPhysicalMaterial"
:vertexShader="yourGLSLVertex"
:fragmentShader="yourGLSLFragment"
:uniforms="yourUniforms"
silent
/>
</TresMesh>
</template>
```

</details>

## Installation
Expand Down Expand Up @@ -222,6 +245,43 @@ function Cube() {

</details>

<details >
<summary>Show Vue (Tresjs) example</summary>

```vue
<script setup>
import {ref } from 'vue'
import { CustomShaderMaterial } from '@tresjs/cientos'

const materialBase = ref()
</script>

<template>
<TresMesh>
<TresTorusKnotGeometry :args="[1, 0.3, 512, 32]" />
<CustomShaderMaterial
ref="materialBase"
:baseMaterial="THREE.MeshPhysicalMaterial"
:vertexShader="yourGLSLVertex"
:fragmentShader="yourGLSLFragment"
:uniforms="yourUniforms"
silent
/>
</TresMesh>

<TresMesh v-if="materialBase">
<TresSphereGeometry :args="[0.5, 16, 16]" />
<CustomShaderMaterial
:base-material="new CustomShaderMaterialImpl({
baseMaterial: materialBase.value,
})"
/>
</TresMesh>
</template>
```

</details
FarazzShaikh marked this conversation as resolved.
Show resolved Hide resolved

### Gotchas

- When extending already extended material, variables, uniforms, attributes, varyings and functions are **NOT** scoped to the material they are defined in. Thus, you **WILL** get redefinition errors if you do not manually scope these identifiers.
Expand Down