Browse Source

feat: add matcap to useTexture

Jaime A Torrealba C 2 years ago
parent
commit
ce374d6c93
2 changed files with 5 additions and 2 deletions
  1. 3 1
      docs/api/composables.md
  2. 2 1
      src/composables/useTexture/index.ts

+ 3 - 1
docs/api/composables.md

@@ -110,11 +110,12 @@ const texture = await useTexture(['path/to/texture.png'])
 - `metalnessMap`: a texture that is used to add a metallic effect to the object's surface
 - `metalnessMap`: a texture that is used to add a metallic effect to the object's surface
 - `aoMap`: a texture that is used to add ambient occlusion (shading in areas where light is blocked by other objects) to the object.
 - `aoMap`: a texture that is used to add ambient occlusion (shading in areas where light is blocked by other objects) to the object.
 - `alphaMap`: a texture that is used to add alpha (the black part render as transparent) to the object. It's necessary to set :trasparent="true" on the material to use this map
 - `alphaMap`: a texture that is used to add alpha (the black part render as transparent) to the object. It's necessary to set :trasparent="true" on the material to use this map
+- `matcap`: this textures encodes the material color and shading.
 
 
 In that case it will return an object with the loaded textures.
 In that case it will return an object with the loaded textures.
 
 
 ```ts
 ```ts
-const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alphaMap } = await useTexture({
+const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alphaMap, matcap } = await useTexture({
   map: 'path/to/albedo.png',
   map: 'path/to/albedo.png',
   displacementMap: 'path/to/height.png',
   displacementMap: 'path/to/height.png',
   normalMap: 'path/to/normal.png',
   normalMap: 'path/to/normal.png',
@@ -122,6 +123,7 @@ const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alph
   metalnessMap: 'path/to/metalness.png',
   metalnessMap: 'path/to/metalness.png',
   aoMap: 'path/to/ambien-occlusion.png',
   aoMap: 'path/to/ambien-occlusion.png',
   alphaMap: 'path/to/alpha.png',
   alphaMap: 'path/to/alpha.png',
+  matcap: 'path/to/matcap.png',
 })
 })
 ```
 ```
 
 

+ 2 - 1
src/composables/useTexture/index.ts

@@ -79,7 +79,7 @@ export async function useTexture(
       return textures[0]
       return textures[0]
     }
     }
   } else {
   } else {
-    const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alphaMap
+    const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alphaMap, matcap
      } = paths as { [key: string]: string }
      } = paths as { [key: string]: string }
     return {
     return {
       map: map ? await loadTexture(map) : null,
       map: map ? await loadTexture(map) : null,
@@ -89,6 +89,7 @@ export async function useTexture(
       metalnessMap: metalnessMap ? await loadTexture(metalnessMap) : null,
       metalnessMap: metalnessMap ? await loadTexture(metalnessMap) : null,
       aoMap: aoMap ? await loadTexture(aoMap) : null,
       aoMap: aoMap ? await loadTexture(aoMap) : null,
       alphaMap: alphaMap ? await loadTexture(alphaMap) : null,
       alphaMap: alphaMap ? await loadTexture(alphaMap) : null,
+      matcap: matcap ? await loadTexture(matcap) : null,
     }
     }
   }
   }
 }
 }