apply 3D wood prism...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ensureMeshUvws(geometry) { | |
// If mesh has no uvws, generate them by copying the vertex position vectors | |
// (x,y,z) => (u,v,w). We apply no transform. All geometry loaded by lmvtk uses | |
// this interleaved vertex buffer approach. We have to get the vertex position | |
// vectors out of the interleaved vertex buffer. | |
if (!geometry.getAttribute('uvw')) { | |
let vbb = ggeom.vb; // should always be 3 | |
let vo = geometry.getAttribute('position').itemOffset; // should always be 0 | |
let vz = geometry.getAttribute('position').itemSize; // should always be 3 | |
let vs = geometry.vbstride; | |
let vb = geometry.vb; | |
let vn = vb.length / vs; | |
let wb = new Float32Array(vn * vz); | |
for (let vi = 0; vi < vn; vi++) { | |
wb[vz * vi + 0] = vb[vs * vi + vo + 1]; | |
wb[vz * vi + 1] = vb[vs * vi + vo + 2]; | |
wb[vz * vi + 2] = vb[vs * vi + vo + 0]; | |
} | |
geometry.addAttribute('uvw', new THREE.BufferAttribute(wb, vz)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment