Skip to content

Commit

Permalink
feat: add matcap to useTexture
Browse files Browse the repository at this point in the history
  • Loading branch information
JaimeTorrealba committed Mar 29, 2023
1 parent 7cb26e2 commit ce374d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/api/composables.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,20 @@ const texture = await useTexture(['path/to/texture.png'])
- `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.
- `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.

```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',
displacementMap: 'path/to/height.png',
normalMap: 'path/to/normal.png',
roughnessMap: 'path/to/roughness.png',
metalnessMap: 'path/to/metalness.png',
aoMap: 'path/to/ambien-occlusion.png',
alphaMap: 'path/to/alpha.png',
matcap: 'path/to/matcap.png',
})
```

Expand Down
3 changes: 2 additions & 1 deletion src/composables/useTexture/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function useTexture(
return textures[0]
}
} else {
const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alphaMap
const { map, displacementMap, normalMap, roughnessMap, metalnessMap, aoMap, alphaMap, matcap
} = paths as { [key: string]: string }
return {
map: map ? await loadTexture(map) : null,
Expand All @@ -89,6 +89,7 @@ export async function useTexture(
metalnessMap: metalnessMap ? await loadTexture(metalnessMap) : null,
aoMap: aoMap ? await loadTexture(aoMap) : null,
alphaMap: alphaMap ? await loadTexture(alphaMap) : null,
matcap: matcap ? await loadTexture(matcap) : null,
}
}
}

0 comments on commit ce374d6

Please sign in to comment.