---
agentTools:
  projectIndex: https://whsjs.readme.io/llms.txt
---

# TextureModule

A TextureModule can be applied to any Mesh or Model.

Creating an instance.  url takes a path, or a data object.

[block:code]
{
  "codes": [
    {
      "code": "var woodTexture = new WHS.mesh.TextureModule({\n    url: `${process.assetsPath}/textures/wood.jpg`\n});",
      "language": "javascript"
    }
  ]
}
[/block]

Example of wood texture applied to a Box.

[block:code]
{
  "codes": [
    {
      "code": "const box = new WHS.Box({\n  geometry: {\n    width: 2, \n    height: 2,\n    depth: 2\n  },\n  modules: [\n      new WHS.mesh.TextureModule({\n        url: `${process.assetsPath}/textures/wood.jpg`,\n        repeat: new THREE.Vector2(1, 1) // optional\n      })\n  ],\n  material: new THREE.MeshBasicMaterial({\n    color: 0xffffff\n  }),\n  position: [50, 60, 70]\n});\n\nbox.addTo(world);",
      "language": "javascript"
    }
  ]
}
[/block]