Skip to content

Commit

Permalink
Merge branch 'main' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarosabu committed Apr 23, 2024
2 parents b536ab1 + b71573d commit 5f20467
Show file tree
Hide file tree
Showing 20 changed files with 478 additions and 202 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Thanks from the heart 💚 for taking the time to help out. This guide will help

## Setup

All the packages in the ecosystem use [pnpm workspaces](https://pnpm.io/workspaces). PnPM is a package manager that is faster than npm and yarn. It also uses symlinks to avoid code duplication.
All the packages in the ecosystem use [pnpm workspaces](https://pnpm.io/workspaces). Pnpm is a package manager that is faster than npm and yarn. It also uses symlinks to avoid code duplication.

The `workspace` has the following structure:

Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
export const deConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
themeConfig: {
editLink: {
pattern: 'https://github.com/tresjs/tres/edit/main/packages/docs/:path',
pattern: 'https://github.com/tresjs/tres/edit/main/docs/:path',
text: 'Änderungen an dieser Seite vorschlagen',
},
sidebar: [
Expand Down Expand Up @@ -77,6 +77,7 @@ export const deConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'v-light-helper', link: '/de/directives/v-light-helper' },
{ text: 'v-always-look-at', link: '/de/directives/v-always-look-at' },
{ text: 'v-distance-to', link: '/de/directives/v-distance-to' },
{ text: 'v-rotate', link: '/directives/v-rotate' },
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
themeConfig: {
editLink: {
pattern: 'https://github.com/tresjs/tres/edit/main/packages/docs/:path',
pattern: 'https://github.com/tresjs/tres/edit/main/docs/:path',
text: 'Suggest changes to this page',
},
sidebar: [
Expand Down Expand Up @@ -78,6 +78,7 @@ export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'v-light-helper', link: '/directives/v-light-helper' },
{ text: 'v-always-look-at', link: '/directives/v-always-look-at' },
{ text: 'v-distance-to', link: '/directives/v-distance-to' },
{ text: 'v-rotate', link: '/directives/v-rotate' },
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
export const esConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
themeConfig: {
editLink: {
pattern: 'https://github.com/tresjs/tres/edit/main/packages/docs/:path',
pattern: 'https://github.com/tresjs/tres/edit/main/docs/:path',
text: 'Sugerir cambios a esta página',
},
sidebar: [
Expand Down Expand Up @@ -78,6 +78,7 @@ export const esConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'v-light-helper', link: '/es/directives/v-light-helper' },
{ text: 'v-always-look-at', link: '/es/directives/v-always-look-at' },
{ text: 'v-distance-to', link: '/es/directives/v-distance-to' },
{ text: 'v-rotate', link: '/directives/v-rotate' },
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
export const frConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
themeConfig: {
editLink: {
pattern: 'https://github.com/tresjs/tres/edit/main/packages/docs/:path',
pattern: 'https://github.com/tresjs/tres/edit/main/docs/:path',
text: 'Suggérer un changement à cette page.',
},
sidebar: [
Expand Down Expand Up @@ -79,6 +79,7 @@ export const frConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'v-light-helper', link: '/fr/directives/v-light-helper' },
{ text: 'v-always-look-at', link: '/fr/directives/v-always-look-at' },
{ text: 'v-distance-to', link: '/fr/directives/v-distance-to' },
{ text: 'v-rotate', link: '/directives/v-rotate' },
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/nl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
export const nlConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
themeConfig: {
editLink: {
pattern: 'https://github.com/tresjs/tres/edit/main/packages/docs/:path',
pattern: 'https://github.com/tresjs/tres/edit/main/docs/:path',
text: 'Stel wijzigingen op deze pagina voor',
},
sidebar: [
Expand Down Expand Up @@ -78,6 +78,7 @@ export const nlConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'v-light-helper', link: '/nl/directives/v-light-helper' },
{ text: 'v-always-look-at', link: '/nl/directives/v-always-look-at' },
{ text: 'v-distance-to', link: '/nl/directives/v-distance-to' },
{ text: 'v-rotate', link: '/directives/v-rotate' },
],
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DefaultTheme, LocaleSpecificConfig } from 'vitepress'
export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
themeConfig: {
editLink: {
pattern: 'https://github.com/tresjs/tres/edit/main/packages/docs/:path',
pattern: 'https://github.com/tresjs/tres/edit/main/docs/:path',
text: '对本页内容给出建议',
},
sidebar: [
Expand Down Expand Up @@ -77,6 +77,7 @@ export const zhConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
{ text: 'v-light-helper', link: '/zh/directives/v-light-helper' },
{ text: 'v-always-look-at', link: '/zh/directives/v-always-look-at' },
{ text: 'v-distance-to', link: '/zh/directives/v-distance-to' },
{ text: 'v-rotate', link: '/directives/v-rotate' },
],
},
{
Expand Down
97 changes: 91 additions & 6 deletions docs/.vitepress/theme/components/HomeSponsors.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<script setup lang="ts">
import { VPHomeSponsors } from 'vitepress/theme'
import { useSponsor } from '../composables/sponsor'
const { data } = useSponsor()
/* const { data } = useSponsor() */
</script>

<template>
<VPHomeSponsors
v-if="data"
message="TresJS is free and open source, made possible by wonderful sponsors."
:data="data"
:data="[]"
/>
<div class="action">
<a
Expand All @@ -18,9 +16,94 @@ const { data } = useSponsor()
target="_blank"
rel="noreferrer"
>
Become a sponsor <i class="i-carbon-heart"></i>
Become a sponsor
</a>
</div>
<div class="action">
<p class="message">Consider supporting our friends</p>
</div>
<ul class="action flex flex-wrap w-full sm:w-2/3 md:1/3 mx-auto">
<li>
<a
class="sponsor"
href="https://github.com/sponsors/vitejs"
target="_blank"
rel="noreferrer"
>
Vite <i class="i-logos-vitejs ml-2"></i>
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/patak-dev"
target="_blank"
rel="noreferrer"
>
Patak <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/583075?v=4" alt="" />
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/antfu"
target="_blank"
rel="noreferrer"
>
Anthony Fu <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/11247099?v=4" alt="" />
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/posva"
target="_blank"
rel="noreferrer"
>
posva <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/664177?v=4" alt="" />
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/johnsoncodehk"
target="_blank"
rel="noreferrer"
>
Johnson Chu <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/16279759?v=4" alt="" />
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/CodyJasonBennett"
target="_blank"
rel="noreferrer"
>
Cody Bennet <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/23324155?v=4" alt="" />
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/nuxt"
target="_blank"
rel="noreferrer"
>
Daniel Roe <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/23360933?s=160&v=4" alt="" />
</a>
</li>
<li>
<a
class="sponsor"
href="https://github.com/sponsors/danielroe"
target="_blank"
rel="noreferrer"
>
Nuxt <img class="w-5 h-5 rounded ml-2" src="https://avatars.githubusercontent.com/u/28706372?v=4" alt="" />
</a>
</li>
</ul>
</template>

<style scoped>
Expand All @@ -33,7 +116,9 @@ const { data } = useSponsor()
.sponsor {
/* .VPButton */
display: inline-block;
display: flex;
align-items: center;
justify-content: space-between;
border: 1px solid transparent;
text-align: center;
font-weight: 600;
Expand Down
4 changes: 4 additions & 0 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,7 @@
color: var(--vp-button-alt-text);
background-color: var(--vp-button-alt-bg);
}

.VPHomeSponsors {
margin-bottom: 0px !important;
}
8 changes: 4 additions & 4 deletions docs/directives/v-always-look-at.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ With the new directive v-always-look-at provided by **TresJS**, you can add easi

```vue{3,9}
<script setup lang="ts">
import { TresCanvas } from '@tresjs/core'
import { Box, vAlwaysLookAt } from '@tresjs/cientos'
import { TresCanvas, vAlwaysLookAt } from '@tresjs/core'
import { Box } from '@tresjs/cientos'
</script>
<template>
<TresCanvas >
Expand All @@ -33,8 +33,8 @@ Another advantage is that you can look at an instance in movement, for example w
```vue{4,6,20,23}
<script setup lang="ts">
import { shallowRef } from 'vue'
import { TresCanvas, useRenderLoop } from '@tresjs/core'
import { Box, vAlwaysLookAt } from '@tresjs/cientos'
import { TresCanvas, useRenderLoop, vAlwaysLookAt } from '@tresjs/core'
import { Box } from '@tresjs/cientos'
const sphereRef = shallowRef()
Expand Down
3 changes: 2 additions & 1 deletion docs/directives/v-distance-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ In addition, an arrow will be created to indicate which objects you're measuring

```vue{2,8,13}
<script setup lang="ts">
import { OrbitControls, Sphere, vLog } from '@tresjs/cientos'
import { vDistanceTo } from '@tresjs/core'
import { OrbitControls, Sphere } from '@tresjs/cientos'
</script>
<template>
<TresCanvas v-bind="gl">
Expand Down
3 changes: 2 additions & 1 deletion docs/directives/v-light-helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ The following lights are supported:

```vue{2,8,11,14,17}
<script setup lang="ts">
import { OrbitControls, Sphere, vLightHelper } from '@tresjs/cientos'
import { vLightHelper } from '@tresjs/core'
import { OrbitControls, Sphere, } from '@tresjs/cientos'
</script>
<template>
<TresCanvas >
Expand Down
3 changes: 2 additions & 1 deletion docs/directives/v-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ With the new directive v-log provided by **TresJS**, you can do this by just add

```vue{2,10,12}
<script setup lang="ts">
import { OrbitControls, Sphere, vLog } from '@tresjs/cientos'
import { vLog } from '@tresjs/core'
import { OrbitControls, Sphere } from '@tresjs/cientos'
</script>
<template>
<TresCanvas >
Expand Down
80 changes: 80 additions & 0 deletions docs/directives/v-rotate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# v-rotate

## Problem

When you want to simply add rotation to your mesh, you have to use the template reference, [useRenderLoop](/api/composables#userenderloop) and then assign the axis and the speed, but before check if you mesh is already available:

```vue
<script setup lang="ts">
import { shallowRef, watch } from 'vue'
import { useRenderLoop } from '@tresjs/core'
const boxRef = shallowRef()
const { onLoop } = useRenderLoop()
onLoop(({ elapsed }) => {
if (boxRef.value) {
boxRef.value.rotation.x = elapsed
}
})
</script>
<template>
<TresCanvas>
<TresPerspectiveCamera :position="[0, 2, 5]" />
<TresMesh
ref="boxRef"
:scale="0.5"
>
<TresBoxGeometry />
<TresMesh>
<OrbitControls />
</TresMesh>
</TresMesh>
</TresCanvas>
</template>
```

And is A LOT of code just for a simple rotation right? Normally we need something fast to see if something is working

## Usage

With the new directive v-rotate provided by **TresJS**, you can do this by just adding `v-rotate` to the instance.

```vue{2,8}
<script setup lang="ts">
import { vRotate } from '@tresjs/core'
</script>
<template>
<TresCanvas >
<TresPerspectiveCamera :position="[0, 2, 5]" />
<TresMesh
v-rotate // 😍
>
<TresBoxGeometry />
</TresMesh>
</TresCanvas>
</template>
```
By default `v-rotate` uses [Quaternions](https://threejs.org/docs/index.html?q=quater#api/en/math/Quaternion) so you don't have to worry by [Gimbal Lock](https://en.wikipedia.org/wiki/Gimbal_lock), or check if you mesh is available in the first frames.

## Modifiers

You can control the axis and the rotation speed by adding modifiers

```vue{2,8}
<script setup lang="ts">
import { vRotate } from '@tresjs/core'
</script>
<template>
<TresCanvas >
<TresPerspectiveCamera :position="[0, 2, 5]" />
<TresMesh
v-rotate:x.y="0.1" // the axis will be x and y with a speed of 0.1
>
<TresBoxGeometry />
</TresMesh>
</TresCanvas>
</template>
```
4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"@tresjs/core": "workspace:^"
},
"devDependencies": {
"unocss": "^0.58.3",
"@iconify-json/logos": "^1.1.42",
"@iconify-json/mdi": "^1.1.66",
"unocss": "^0.58.0",
"vite-svg-loader": "^5.1.0"
}
}
Loading

0 comments on commit 5f20467

Please sign in to comment.