|
1 |
| -# Decal |
| 1 | +# Decal — WIP |
2 | 2 |
|
3 | 3 | <DocsDemo>
|
4 |
| - <DecalDemoMaterial /> |
| 4 | + <DecalDemo /> |
5 | 5 | </DocsDemo>
|
6 | 6 |
|
7 | 7 | 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.
|
8 | 8 |
|
9 | 9 | 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.
|
10 | 10 |
|
| 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 | + |
11 | 35 | ::: 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. |
13 | 37 | :::
|
14 | 38 |
|
15 |
| -## Usage |
| 39 | +<!-- <DocsDemo> |
| 40 | + <DecalDemoDebug /> |
| 41 | +</DocsDemo> |
16 | 42 |
|
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 --> |
19 | 54 | :::
|
20 | 55 |
|
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 --> |
23 | 59 | :::
|
24 | 60 |
|
| 61 | +## Usage |
| 62 | + |
25 | 63 | ### Minimal
|
26 | 64 |
|
27 | 65 | 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`.
|
28 | 66 |
|
29 | 67 | *The default material is [MeshBasicMaterial](https://threejs.org/docs/#api/en/materials/MeshBasicMaterial)*.
|
30 | 68 |
|
31 |
| -<DocsDemo> |
| 69 | +<!-- <DocsDemo> |
32 | 70 | <DecalDemoBasic />
|
33 | 71 | </DocsDemo>
|
34 | 72 |
|
35 |
| -<<< @/.vitepress/theme/components/DecalDemoBasic.vue{3-4,6-7,16-17} |
| 73 | +<<< @/.vitepress/theme/components/DecalDemoBasic.vue{3-4,6-7,16-17} --> |
36 | 74 |
|
37 | 75 | See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
|
38 | 76 |
|
39 | 77 | ### Various materials
|
40 | 78 | 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).
|
41 | 79 |
|
42 |
| -<DocsDemo> |
| 80 | +<!-- <DocsDemo> |
43 | 81 | <DecalDemoMaterial />
|
44 | 82 | </DocsDemo>
|
45 | 83 |
|
46 |
| -<<< @/.vitepress/theme/components/DecalDemoMaterial.vue{3-4,6-7,18-23} |
| 84 | +<<< @/.vitepress/theme/components/DecalDemoMaterial.vue{3-4,6-7,18-23} --> |
47 | 85 |
|
48 | 86 | See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
|
49 | 87 |
|
50 | 88 | ### Mesh Prop
|
51 | 89 | Define the surface to which the decal must attach using the mesh prop.
|
52 | 90 |
|
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> |
58 | 92 | <DecalDemoMeshProp />
|
59 | 93 | </DocsDemo>
|
60 | 94 |
|
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} --> |
62 | 96 |
|
63 | 97 | See [decalsDatas](#decal-datas) part to see the contents of the Decal's datas object of the demo.
|
64 | 98 |
|
65 | 99 | ### Model
|
66 | 100 | `<Decal>` can be applied to an imported model!
|
67 | 101 |
|
68 |
| -<DocsDemo> |
| 102 | +<!-- <DocsDemo> |
69 | 103 | <DecalDemoModel />
|
70 | 104 | </DocsDemo>
|
71 | 105 |
|
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} --> |
73 | 107 |
|
74 | 108 | See [modelDatas](#decal-datas) part to see the contents of the Decal datas object of the demo.
|
75 | 109 |
|
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 |
| - |
138 | 110 | ## Props
|
139 | 111 |
|
140 | 112 | | Prop | Description | Default |
|
141 | 113 | | :---------------- | :--------------------------------------------------- | ------------------------- |
|
142 | 114 | | **debug** | `boolean` — Debug mode (Useful for positioning Decal) | `false` |
|
143 | 115 | | **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` |
|
144 | 116 | | **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]` | |
149 | 118 | | **polygonOffsetFactor** | `number` — Sets the polygon offset factor | `-10` |
|
150 | 119 | | **depthTest** | `boolean` — Whether to have depth test enabled when rendering this material. | `true` |
|
151 | 120 | | **depthWrite** | `boolean` — Whether rendering this material has any effect on the depth buffer. | `false` |
|
152 | 121 | | **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 |
0 commit comments