You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+

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 <Badgetext="^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
+

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
+

27
+
28
+
Enjoy the new Devtools and let us know what you think! 🎉
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
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.
0 commit comments