Skip to content

Commit 898a8b1

Browse files
committed
Merge branch 'main' into v4
2 parents 08717ef + 91e047a commit 898a8b1

31 files changed

+1588
-1110
lines changed

CHANGELOG.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
## [3.7.0](https://github.com/Tresjs/tres/compare/3.6.1...3.7.0) (2024-01-29)
12

2-
3-
## [4.0.0-next.0](https://github.com/Tresjs/tres/compare/3.6.0...4.0.0-next.0) (2023-12-22)
3+
### Features
4+
5+
* 474 vue chrome devtools plugin ([#526](https://github.com/Tresjs/tres/issues/526)) ([0185bfa](https://github.com/Tresjs/tres/commit/0185bfa6f04faff5eabbc526616713ef7747ebeb))
6+
* 524 feat add directives to core ([#525](https://github.com/Tresjs/tres/issues/525)) ([5268e9f](https://github.com/Tresjs/tres/commit/5268e9f13bf65c61d5ddfe7153b71b335449b81d))
47

58

6-
### Features
9+
### Bug Fixes
710

8-
* 474 vue chrome devtools plugin ([#479](https://github.com/Tresjs/tres/issues/479)) ([224ab06](https://github.com/Tresjs/tres/commit/224ab06a4404e2ae5a0cbd2f43041961862b09fd))
9-
11+
* **docs:** change image path to silence warning ([#519](https://github.com/Tresjs/tres/issues/519)) ([280d248](https://github.com/Tresjs/tres/commit/280d2482760bde1032e24c4a9e96af4beea954ed))
1012

1113
## [3.6.1](https://github.com/Tresjs/tres/compare/3.6.0...3.6.1) (2024-01-16)
1214

docs/.vitepress/config.ts

+29-9
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,48 @@ export default defineConfig({
6464
},
6565
],
6666
},
67+
68+
{
69+
text: 'Advanced',
70+
71+
items: [
72+
{ text: 'Extending', link: '/advanced/extending' },
73+
{ text: 'primitive', link: '/advanced/primitive' },
74+
{ text: 'Performance', link: '/advanced/performance' },
75+
{
76+
text: 'Caveats',
77+
link: '/advanced/caveats',
78+
},
79+
],
80+
},
81+
{
82+
text: 'Debug',
83+
items: [
84+
{ text: 'Devtools', link: '/debug/devtools' },
85+
],
86+
},
6787
{
6888
text: 'Examples',
89+
collapsed: true,
6990
items: [
7091
{ text: 'Orbit Controls', link: '/examples/orbit-controls' },
7192
{ text: 'Basic Animations', link: '/examples/basic-animations' },
7293
{ text: 'Groups', link: '/examples/groups' },
7394
{ text: 'Load Textures', link: '/examples/load-textures' },
7495
{ text: 'Load Models', link: '/examples/load-models' },
7596
{ text: 'Load Text', link: '/examples/text-3d' },
97+
{ text: 'Lights & Shadows', link: '/examples/lights-shadows' },
98+
{ text: 'Shaders', link: '/examples/shaders' },
7699
],
77100
},
78101
{
79-
text: 'Advanced',
80-
102+
text: 'Directives',
103+
collapsed: true,
81104
items: [
82-
{ text: 'Extending', link: '/advanced/extending' },
83-
{ text: 'primitive', link: '/advanced/primitive' },
84-
{ text: 'Performance', link: '/advanced/performance' },
85-
{
86-
text: 'Caveats',
87-
link: '/advanced/caveats',
88-
},
105+
{ text: 'v-log', link: '/directives/v-log' },
106+
{ text: 'v-light-helper', link: '/directives/v-light-helper' },
107+
{ text: 'v-always-look-at', link: '/directives/v-always-look-at' },
108+
{ text: 'v-distance-to', link: '/directives/v-distance-to' },
89109
],
90110
},
91111
{

docs/debug/devtools.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Devtools
2+
3+
4+
5+
One of the most difficult things a developer faces when creating 3D experiences on the browser is debugging. The browser `canvas` is a black box, and it's hard to know what's going on inside. The imperative nature of [ThreeJS](https://threejs.org/) makes it incredibly difficult to debug, having to depend on `console.log` to see what's going on, or third party to fine-tune and inspect the scene.
6+
7+
Don't make me get started with checking the performance of your scene. 😱
8+
9+
![developer debugging 3D](/debug-3D.png)
10+
11+
One of our goals with TresJS is to offer **the best DX (Developer Experience)** when dealing with 3D scenes on the browser. Thanks to the declarative nature of the ecosystem plus the variety of solutions the Vue ecosystem offers such as the Vue Devtools, Nuxt and Vite, we can offer a better tooling for devs to debug their scenes.
12+
13+
## Introducing the Devtools
14+
15+
From <Badge text="^3.7.0" /> we are introducing the TresJS Devtools, a customized inspector tab for the [Official Vue Chrome Devtools](https://devtools.vuejs.org/guide/installation.html) that allows you to inspect your TresJS scenes and components.
16+
17+
![TresJS Devtools](/vue-chrome-devtools.png)
18+
19+
### Features
20+
21+
- **Scene Inspector**: Inspect the current scene and its components using a tree view similar to the Vue Devtools component inspector.
22+
- **Memory Allocation**: See how much memory is being by the components.
23+
- **Object Inspector**: Inspect the properties of the selected object in the scene, including its children.
24+
- **Editable Properties**: And yes, you can edit the properties of the selected object and see the changes in real-time.
25+
26+
![](/devtools-scene-inspector.png)
27+
28+
Enjoy the new Devtools and let us know what you think! 🎉

docs/directives/v-always-look-at.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# v-always-look-at 👀
2+
3+
With the new directive v-always-look-at provided by **TresJS**, you can add easily command an [Object3D](https://threejs.org/docs/index.html?q=object#api/en/core/Object3D) to always look at a specific position, this could be passed as a Vector3 or an Array.
4+
5+
## Usage
6+
7+
```vue{3,9}
8+
<script setup lang="ts">
9+
import { TresCanvas } from '@tresjs/core'
10+
import { Box, vAlwaysLookAt } from '@tresjs/cientos'
11+
</script>
12+
<template>
13+
<TresCanvas >
14+
<TresPerspectiveCamera :position="[0, 2, 5]" />
15+
<Box
16+
v-always-look-at="new Vector3(0, 0, 0)"
17+
/>
18+
</TresCanvas>
19+
</template>
20+
```
21+
No matter where the Box move will always look-at the position [0,0,0]
22+
23+
### Why not use the in built method look-at?
24+
25+
You could ask, this is fine but I can use the `:look-at` method directly in the component, why should I need this?
26+
27+
The answers is that with the method `:look-at` you will indicated to look at that position just once, when the instance is mounted, then if the object changes this will not get updated
28+
29+
### You can look at other instance too!
30+
31+
Another advantage is that you can look at an instance in movement, for example with the camera, like so:
32+
33+
```vue{4,6,20,23}
34+
<script setup lang="ts">
35+
import { shallowRef } from 'vue'
36+
import { TresCanvas, useRenderLoop } from '@tresjs/core'
37+
import { Box, vAlwaysLookAt } from '@tresjs/cientos'
38+
39+
const sphereRef = shallowRef()
40+
41+
const { onLoop } = useRenderLoop()
42+
43+
// here we update the position of the sphere and the camera will always follow the object
44+
onLoop(({ elapsed }) => {
45+
if (sphereRef.value) {
46+
sphereRef.value.value.position.y = Math.sin(elapsed) * 1.5
47+
}
48+
})
49+
</script>
50+
<template>
51+
<TresCanvas >
52+
<TresPerspectiveCamera :position="[0, 2, 5]"
53+
v-always-look-at="sphereRef"
54+
/>
55+
<Sphere
56+
ref="sphereRef"
57+
:scale="0.5"
58+
/>
59+
</TresCanvas>
60+
</template>
61+
```

docs/directives/v-distance-to.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# v-distance-to
2+
3+
Have you tried to calculate the distance between two Object3Ds?
4+
5+
With the new directive `v-distance-to` it's easier than ever, you should only indicate the target object to perform the measure and the result will appear in your console.
6+
7+
In addition, an arrow will be created to indicate which objects you're measuring.
8+
9+
```vue{2,8,13}
10+
<script setup lang="ts">
11+
import { OrbitControls, Sphere, vLog } from '@tresjs/cientos'
12+
</script>
13+
<template>
14+
<TresCanvas v-bind="gl">
15+
<TresPerspectiveCamera :position="[0, 2, 5]" />
16+
<Sphere
17+
ref="sphere1Ref"
18+
:position="[-2, slider, 0]"
19+
:scale="0.5"
20+
/>
21+
<Sphere
22+
v-distance-to="sphere1Ref"
23+
:position="[2, 0, 0]"
24+
:scale="0.5"
25+
/>
26+
<TresGridHelper :args="[10, 10]" />
27+
<OrbitControls />
28+
</TresCanvas>
29+
</template>
30+
```
31+
32+
The use of `v-distance-to` is reactive, so it works perfectly with @tres/leches 🍰.
33+
34+
::: warning
35+
`v-distance-to` will not measure an object in movement within the renderLoop.
36+
:::

docs/directives/v-light-helper.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# v-light-helper 🔆
2+
3+
With the new directive v-light-helper provided by **TresJS**, you can add fast the respective helper to your lights with just one line of code 😍.
4+
5+
The following lights are supported:
6+
- DirectionalLight
7+
- PointLight
8+
- SpotLight
9+
- HemisphereLight
10+
11+
## Usage
12+
13+
```vue{2,8,11,14,17}
14+
<script setup lang="ts">
15+
import { OrbitControls, Sphere, vLightHelper } from '@tresjs/cientos'
16+
</script>
17+
<template>
18+
<TresCanvas >
19+
<TresPerspectiveCamera :position="[0, 2, 5]" />
20+
<TresDirectionalLight
21+
v-light-helper
22+
/>
23+
<TresPointLight
24+
v-light-helper
25+
/>
26+
<TresSpotLight
27+
v-light-helper
28+
/>
29+
<TresHemisphereLight
30+
v-light-helper
31+
/>
32+
</TresCanvas>
33+
</template>
34+
```

docs/directives/v-log.md

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# v-log
2+
3+
### Problem
4+
5+
When you have to log your instance you have to use the template reference and then log them:
6+
7+
```vue
8+
<script setup lang="ts">
9+
import { shallowRef, watch } from 'vue'
10+
11+
const sphereRef = shallowRef()
12+
13+
watch(sphereRef, (value) => {
14+
console.log(value) // Really for a log?!!! 😫
15+
})
16+
</script>
17+
18+
<template>
19+
<TresCanvas>
20+
<TresPerspectiveCamera :position="[0, 2, 5]" />
21+
<Sphere
22+
ref="sphereRef"
23+
:scale="0.5"
24+
/>
25+
<OrbitControls />
26+
</TresCanvas>
27+
</template>
28+
```
29+
30+
And is A LOT of code just for a simple log right?
31+
32+
## Usage
33+
34+
With the new directive v-log provided by **TresJS**, you can do this by just adding `v-log` to the instance.
35+
36+
```vue{2,10,12}
37+
<script setup lang="ts">
38+
import { OrbitControls, Sphere, vLog } from '@tresjs/cientos'
39+
</script>
40+
<template>
41+
<TresCanvas >
42+
<TresPerspectiveCamera :position="[0, 2, 5]" />
43+
<Sphere
44+
ref="sphereRef"
45+
:scale="0.5"
46+
v-log:material <!-- will print just the material 🎉 -->
47+
/>
48+
<OrbitControls v-log />
49+
</TresCanvas>
50+
</template>
51+
```
52+
53+
Note that you can pass a modifier with the name of a property, for example `v-log:material`, and will log directly the `material` property 😍

0 commit comments

Comments
 (0)