Skip to content

Commit 33aee9c

Browse files
wip documentation
1 parent e573eec commit 33aee9c

File tree

10 files changed

+89
-295
lines changed

10 files changed

+89
-295
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,40 @@
11
<script setup lang="ts">
22
import { TresCanvas } from '@tresjs/core'
3-
import { OrbitControls } from '@tresjs/cientos'
3+
import { Decal, OrbitControls } from '@tresjs/cientos'
4+
import { TresLeches, useControls } from '@tresjs/leches'
5+
import '@tresjs/leches/styles'
6+
import { SRGBColorSpace } from 'three'
7+
8+
useControls({})
9+
10+
const gl = {
11+
clearColor: '#82DBC5',
12+
shadows: true,
13+
alpha: false,
14+
outputColorSpace: SRGBColorSpace,
15+
dpr: [1, 2] as [number, number],
16+
}
17+
18+
useControls({})
419
</script>
520

621
<template>
7-
<TresCanvas clear-color="#82DBC5">
8-
<TresPerspectiveCamera :position="[3, 3, 3]" />
22+
<TresLeches style="position:absolute; left:initial; right:20px; top:10px;" />
23+
24+
<TresCanvas v-bind="gl">
25+
<TresPerspectiveCamera :position="[7.5, 5, 7.5]" />
926
<OrbitControls make-default />
1027

11-
<TresAmbientLight />
12-
<TresDirectionalLight :position="[0, 2, 4]" />
13-
<TresGridHelper />
28+
<TresMesh :scale="3">
29+
<TresMeshStandardMaterial color="white" />
30+
<TresBoxGeometry :args="[1, 1, 1]" />
31+
32+
<Suspense>
33+
<Decal debug :scale="2" :map="['/decal/tres-logo.png', '/decal/vuejs-logo.png']" />
34+
</Suspense>
35+
</TresMesh>
36+
37+
<TresAmbientLight :intensity="2" />
38+
<TresDirectionalLight :intensity="3" :position="[2, 1.5, 2]" />
1439
</TresCanvas>
1540
</template>

docs/guide/abstractions/decal.md

+57-86
Original file line numberDiff line numberDiff line change
@@ -1,152 +1,123 @@
1-
# Decal
1+
# Decal — WIP
22

33
<DocsDemo>
4-
<DecalDemoMaterial />
4+
<DecalDemo />
55
</DocsDemo>
66

77
The `cientos` package provides an abstraction of the [Decal Geometry](https://threejs.org/docs/#examples/en/geometries/DecalGeometry), `<Decal>` is versatile, such as enhancing models with unique details, dynamically altering visual environments, or seamlessly covering seams. This geometry generates a decal mesh that seamlessly integrates into your scene.
88

99
Thanks to its debugging tool 🛠️, it's much easier to position and orientate Decals on objects, models and so on. It also offers a simple way of exporting the data from your `<Decal>` so you can see it permanently on an element.
1010

11+
## Debug Mode
12+
13+
It is crucial to use debug mode to position elements accurately. Without debug mode, you won't be able to see the exact placement and orientation of the decals, making it difficult to achieve the desired results.
14+
15+
If you modify the position of a parent of `Decal(s)` after having already exported their position(s), you will have to re-export the datas of decal(s)
16+
17+
::: warning
18+
Debug mode requires the camera controller [OrbitControls](/guide/controls/orbit-controls.html). It must be present in the scope of `<TresCanvas>`, if not, add it temporarily to add Decal(s).
19+
<br><br>
20+
When you use debug mode on one `<Decal>`, you cannot use it on another `<Decal>`.
21+
22+
```vue
23+
// BAD ❌
24+
<Decal debug :map="texture1" />
25+
26+
<Decal debug :map="texture2" />
27+
28+
// GOOD ✅
29+
<Decal debug :map="texture1" />
30+
31+
<Decal :map="texture2" />
32+
```
33+
:::
34+
1135
::: info
12-
This component is still under development, so please report any problems or suggestions on the [@tresjs/cientos](https://github.com/Tresjs/cientos) repository on GitHub.
36+
Debug mode automatically disables the `enableDamping` and `autoRotate` properties of [OrbitControls](/guide/controls/orbit-controls.html) for a better experience. When you remove debug mode, your settings will be restored.
1337
:::
1438

15-
## Usage
39+
<!-- <DocsDemo>
40+
<DecalDemoDebug />
41+
</DocsDemo>
1642
17-
::: info
18-
In most cases where the `<Decal>` component is used, it is best to use `v-bind` and insert an array object containing data of the `[positions, orientations, sizes, normals]` of a Decal (this data can be recovered using the [debug mode](#debug-mode)).
43+
<<< @/.vitepress/theme/components/DecalDemoDebug.vue{2-6,8-10,12,16,22-26} -->
44+
45+
See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
46+
47+
## Decal Datas
48+
49+
Partie ou on explique la structure d'un objet exporté par le debug mode
50+
51+
JSON object for examples : [Minimal](#minimal), [Various materials](#various-materials), [Mesh prop](#mesh-prop)
52+
:::details decalsDatas
53+
<!-- <<< @/.vitepress/theme/assets/decal/basicDatas.json -->
1954
:::
2055

21-
::: warning
22-
If you modify the position of a parent of `Decal(s)` after having already exported their position(s), you will have to re-export the data with the new positions via [debug mode](#debug-mode).
56+
JSON object for example : [Model](#model)
57+
:::details modelDatas
58+
<!-- <<< @/.vitepress/theme/assets/decal/modelDatas.json -->
2359
:::
2460

61+
## Usage
62+
2563
### Minimal
2664

2765
The minimal version is very easy to set up: you just need to insert a `<Decal>` component with a map props for the Texture and a call to `v-bind`.
2866

2967
*The default material is [MeshBasicMaterial](https://threejs.org/docs/#api/en/materials/MeshBasicMaterial)*.
3068

31-
<DocsDemo>
69+
<!-- <DocsDemo>
3270
<DecalDemoBasic />
3371
</DocsDemo>
3472
35-
<<< @/.vitepress/theme/components/DecalDemoBasic.vue{3-4,6-7,16-17}
73+
<<< @/.vitepress/theme/components/DecalDemoBasic.vue{3-4,6-7,16-17} -->
3674

3775
See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
3876

3977
### Various materials
4078
If the [MeshBasicMaterial](https://threejs.org/docs/#api/en/materials/MeshBasicMaterial) doesn't suit you, you can assign the material you want to the `<Decal>`. You can now make them react to light 💡, simply by choosing the material that allows it, in this case the [MeshPhysicalMaterial](https://threejs.org/docs/#api/en/materials/MeshPhysicalMaterial).
4179

42-
<DocsDemo>
80+
<!-- <DocsDemo>
4381
<DecalDemoMaterial />
4482
</DocsDemo>
4583
46-
<<< @/.vitepress/theme/components/DecalDemoMaterial.vue{3-4,6-7,18-23}
84+
<<< @/.vitepress/theme/components/DecalDemoMaterial.vue{3-4,6-7,18-23} -->
4785

4886
See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
4987

5088
### Mesh Prop
5189
Define the surface to which the decal must attach using the mesh prop.
5290

53-
::: warning
54-
Shapes from [@tresjs/cientos](https://github.com/Tresjs/cientos) repository such as `<Sphere>`, `<Box>`, etc. do not work at the moment. You need to go through the method of using a `<TresMesh />` containing a `<TresGeometry />`. As in the example below ⬇️
55-
:::
56-
57-
<DocsDemo>
91+
<!-- <DocsDemo>
5892
<DecalDemoMeshProp />
5993
</DocsDemo>
6094
61-
<<< @/.vitepress/theme/components/DecalDemoMeshProp.vue{2,4-5,7,9-10,18,22-23}
95+
<<< @/.vitepress/theme/components/DecalDemoMeshProp.vue{2,4-5,7,9-10,18,22-23} -->
6296

6397
See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
6498

6599
### Model
66100
`<Decal>` can be applied to an imported model!
67101

68-
<DocsDemo>
102+
<!-- <DocsDemo>
69103
<DecalDemoModel />
70104
</DocsDemo>
71105
72-
<<< @/.vitepress/theme/components/DecalDemoModel.vue{2-5,7,9-10,12,20-28}
106+
<<< @/.vitepress/theme/components/DecalDemoModel.vue{2-5,7,9-10,12,20-28} -->
73107

74108
See [modelDatas](#decal-datas) part to see the contents of the Decal datas object of the demo.
75109

76-
### Debug Mode
77-
Description
78-
79-
::: warning
80-
Debug mode requires the camera controller [OrbitControls](/guide/controls/orbit-controls.html). It must be present in the scope of `<TresCanvas>`, if not, add it temporarily for your tests.
81-
<br><br>
82-
When you use debug mode on one `<Decal>`, you cannot use it on another `<Decal>`.
83-
84-
```vue
85-
// BAD ❌
86-
<Decal debug :map="texture1" />
87-
88-
<Decal debug :map="texture2" />
89-
90-
// GOOD ✅
91-
<Decal debug :map="texture1" />
92-
93-
<Decal :map="texture2" />
94-
```
95-
:::
96-
97-
::: info
98-
Debug mode automatically disables the `enableDamping` and `autoRotate` properties of [OrbitControls](/guide/controls/orbit-controls.html) for a better experience. When you remove debug mode, your settings will be restored.
99-
:::
100-
101-
Dans notre cas, nous avons repris les examples précédents pour la positions des Decals du logo de Vue.js et Three.js, mais un nouveau `<Decal>` à été ajouté en debug mode avec en texture le logo de Nuxt.js. La ligne bleue lorsque vous survollez votre élement vous permez de savoir ou le `<Decal>` va être projeté, il vous suffit de cliquer et la texture que vous avez renseigné en prop de `<Decal debug>` sera projecté sur l'élement (La sphère dans notre cas).
102-
103-
<DocsDemo>
104-
<DecalDemoDebug />
105-
</DocsDemo>
106-
107-
<<< @/.vitepress/theme/components/DecalDemoDebug.vue{2-6,8-10,12,16,22-26}
108-
109-
See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
110-
111-
### V-For
112-
Description
113-
114-
Demo
115-
116-
Code
117-
### SurfaceSampler Example
118-
Description
119-
120-
Demo
121-
122-
Code
123-
124-
## Decal Datas
125-
126-
Partie ou on explique la structure d'un objet exporté par le debug mode
127-
128-
JSON object for examples : [Minimal](#minimal), [Various materials](#various-materials), [Mesh prop](#mesh-prop)
129-
:::details decalsDatas
130-
<<< @/.vitepress/theme/assets/decal/basicDatas.json
131-
:::
132-
133-
JSON object for example : [Model](#model)
134-
:::details modelDatas
135-
<<< @/.vitepress/theme/assets/decal/modelDatas.json
136-
:::
137-
138110
## Props
139111

140112
| Prop | Description | Default |
141113
| :---------------- | :--------------------------------------------------- | ------------------------- |
142114
| **debug** | `boolean` — Debug mode (Useful for positioning Decal) | `false` |
143115
| **map** | [`Texture`](https://threejs.org/docs/#api/en/textures/Texture) or `null` — The color map. The map should be applied to the `<Decal>` when no material is applied as a child. (See [usages](#usage) for more details) | `null` |
144116
| **mesh** | [`Mesh`](https://threejs.org/docs/#api/en/objects/Mesh) or `null` — Define the surface to which the decal must attach using the mesh prop. (See [Mesh Prop](#mesh-prop) part for more details) | `null` |
145-
| **position** | `number[]` — Position of the decal. Transformed into [`Vector3`](https://threejs.org/docs/#api/en/math/Vector3) | `[-9999,-9999,-9999]` |
146-
| **orientation** | `number[]` — Orientation of the decal. Transformed into [`Euler`](https://threejs.org/docs/#api/en/math/Euler) | `[0,0,0]` |
147-
| **size** | `number[]` — Size of the decal. Transformed into [`Vector3`](https://threejs.org/docs/#api/en/math/Vector3) | `[1,1,1]` |
148-
| **normal** | `number[]` — Normal of the decal. Transformed into [`Vector3`](https://threejs.org/docs/#api/en/math/Vector3) | `[0,0,0]` |
117+
| **data** | `number[]` — Position of the decal. Transformed into [`Vector3`](https://threejs.org/docs/#api/en/math/Vector3) | `[-9999,-9999,-9999]` |
149118
| **polygonOffsetFactor** | `number` — Sets the polygon offset factor | `-10` |
150119
| **depthTest** | `boolean` — Whether to have depth test enabled when rendering this material. | `true` |
151120
| **depthWrite** | `boolean` — Whether rendering this material has any effect on the depth buffer. | `false` |
152121
| **order** | `number` — This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently. <br /> **Sorting is from lowest to highest.** | `Math.round(Math.random() * 100)` |
122+
123+
### Feedbacks
-3.88 KB
Binary file not shown.
-16.2 KB
Binary file not shown.
File renamed without changes.

docs/public/decal/tres-logo.png

2.39 KB
Loading

docs/public/decal/twemoji.png

45 KB
Loading
File renamed without changes.

0 commit comments

Comments
 (0)