# Modernizing old borrowed code

**URL:** <https://discourse.threejs.org/t/modernizing-old-borrowed-code/30277>\
**Category:** Questions\
**Tags:** geometry, textures\
**Created:** [September 27, 2021, 3:27am UTC](https://discourse.threejs.org/t/modernizing-old-borrowed-code/30277 "2021-09-27T03:27:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjaminhill](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/benjaminhill/32/21217_2.png) [@benjaminhill](https://discourse.threejs.org/u/benjaminhill)\
**Post date:** [September 27, 2021, 3:27am UTC](https://discourse.threejs.org/t/modernizing-old-borrowed-code/30277/1 "2021-09-27T03:27:05Z")

</div>

I have old code. I have a sphere map. It works! But I don’t know how, so I’m not sure how to make it work with the latest three.js.

Example: [https://eyeseeyouween.appspot.com/](https://eyeseeyouween.appspot.com/)

It uses this code chunk:

```javascript
// modify UVs to accommodate MatCap texture (I don't know what this means)
const faceVertexUvs = geometry.faceVertexUvs[0];
for (let i = 0; i < faceVertexUvs.length; i++) {
    for (let j = 0; j < 3; j++) {
        faceVertexUvs[i][j].x = geometry.faces[i].vertexNormals[j].x * 0.5 + 0.5;
        faceVertexUvs[i][j].y = geometry.faces[i].vertexNormals[j].y * 0.5 + 0.5;
    }
}   

```

But… what is that? Do I need to know how it works, or is there some drop-in replacement that will be compatible with modern three.js?

This question seems related, but I wasn’t entirely clear on the solve:

> [@faceVertexUvs for BufferGeometry](https://discourse.threejs.org/t/facevertexuvs-for-buffergeometry/23040):
>
> Hi there, Due to the phaseout of the Geometry, I have a question for the BoxBufferGeometry: In my application, I change the faceVertexUvs Box like so (to fit a custom texture) geometry.faceVertexUvs[0][0] = [new Vector2(texture\_data.side2[1].x, texture\_data.side2[0].y), new Vector2(texture\_data.side2[0].x, texture\_data.side2[0].y), new Vector2(texture\_data.side2[1].x, texture\_data.side2[1].y), ]; … for each side. While doing this I understand what I am doing, however doing thi…
