-
-
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.
- Loading branch information
1 parent
b5f3872
commit c1da082
Showing
13 changed files
with
114 additions
and
18 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,29 @@ | ||
<script setup lang="ts"> | ||
import { useTres } from '@tresjs/core' | ||
const styles = { | ||
width: '100%', | ||
height: '550px', | ||
border: '1px solid #e2e2e2', | ||
borderRadius: '8px', | ||
overflow: 'hidden', | ||
} | ||
const { state } = useTres() | ||
</script> | ||
<template> | ||
<ClientOnly> | ||
<TresCanvas shadows clear-color="#fff" :style="styles"> | ||
<TresPerspectiveCamera :position="[0, 2, 4]" /> | ||
<TresScene> | ||
<TresOrbitControls v-if="state.renderer" :args="[state.camera, state.renderer?.domElement]" /> | ||
|
||
<TresDirectionalLight :position="[0, 2, 4]" :intensity="2" cast-shadow /> | ||
<TresMesh :rotation="[-Math.PI / 4, -Math.PI / 4, Math.PI / 4]"> | ||
<TresTorusGeometry :args="[1, 0.5, 16, 32]" /> | ||
<TresMeshToonMaterial color="#FBB03B" /> | ||
</TresMesh> | ||
</TresScene> | ||
</TresCanvas> | ||
</ClientOnly> | ||
</template> |
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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
import Tres from '@tresjs/core' | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' | ||
// .vitepress/theme/index.ts | ||
import DefaultTheme from 'vitepress/theme' | ||
import './config.css' | ||
import FirstScene from './components/FirstScene.vue' | ||
import FirstSceneLightToon from './components/FirstSceneLightToon.vue' | ||
|
||
import ExtendExample from './components/ExtendExample.vue' | ||
export default { | ||
...DefaultTheme, | ||
enhanceApp(ctx) { | ||
ctx.app.component('FirstScene', FirstScene) | ||
ctx.app.component('FirstSceneLightToon', FirstSceneLightToon) | ||
ctx.app.use(Tres) | ||
ctx.app.component('ExtendExample', ExtendExample) | ||
ctx.app.use(Tres, { | ||
extends: { | ||
OrbitControls, | ||
}, | ||
}) | ||
}, | ||
} |
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,30 @@ | ||
# Extend 🔌 | ||
|
||
Tres offers bare bones functionality, but it's easy to add third-party elements and extend them into its internal catalogue. | ||
|
||
## Adding a third-party element | ||
|
||
Most of 3D experience uses `OrbitControls` which is not part of the core library. To add it, you need to import it and add it to the `extends` option when installing the plugin: | ||
|
||
```js | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' | ||
|
||
app.use(plugin, { | ||
extends: { | ||
OrbitControls, | ||
}, | ||
}) | ||
``` | ||
|
||
This will automatically add a `<TresOrbitControls>` to the catalogue, so you can use it in your templates: | ||
|
||
```vue | ||
<template> | ||
<TresCanvas shadows alpha> | ||
<TresPerspectiveCamera :position="[5, 5, 5]" /> | ||
<TresScene> | ||
<TresOrbitControls v-if="state.renderer" :args="[state.camera, state.renderer?.domElement]" /> | ||
</TresScene> | ||
</TresCanvas> | ||
</template> | ||
``` |
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { defineSetupVue3 } from '@histoire/plugin-vue' | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' | ||
|
||
import Tres from './src' | ||
|
||
export const setupVue3 = defineSetupVue3(({ app }) => { | ||
app.use(Tres, { | ||
prefix: 'Tres', | ||
extends: { | ||
OrbitControls, | ||
}, | ||
}) | ||
}) |
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
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
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 |
---|---|---|
@@ -1,9 +1,14 @@ | ||
import { createApp } from 'vue' | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' | ||
import App from './App.vue' | ||
import plugin from '.' | ||
import './style.css' | ||
|
||
export const app = createApp(App) | ||
|
||
app.use(plugin) | ||
app.use(plugin, { | ||
extends: { | ||
OrbitControls, | ||
}, | ||
}) | ||
app.mount('#app') |