geometry: sample pixels from their centers
This commit is contained in:
parent
60a2e8f19e
commit
ef88325fc8
22
geometry.js
22
geometry.js
@ -1,18 +1,22 @@
|
|||||||
import { memoize } from "./memoize";
|
import { memoize } from "./memoize";
|
||||||
|
|
||||||
function _makeTextureFace(texture) {
|
function _makeTextureFace(texture) {
|
||||||
const textMul = 0.0625;
|
const textureWidth = 16;
|
||||||
const textOff = texture.map(x => x * textMul);
|
const texturesPerAtlas = 16;
|
||||||
|
const textMul = 1 / texturesPerAtlas;
|
||||||
|
const halfPixel = 1 / texturesPerAtlas / textureWidth / 2;
|
||||||
|
const textOff = texture.map(x => x * textMul + halfPixel);
|
||||||
|
const a = textMul / textureWidth * (textureWidth - 1);
|
||||||
const textuv = [
|
const textuv = [
|
||||||
[0.99, 0.99],
|
[1, 1],
|
||||||
[0.01, 0.99],
|
[0, 1],
|
||||||
[0.01, 0.01],
|
[0, 0],
|
||||||
[0.99, 0.99],
|
[1, 1],
|
||||||
[0.01, 0.01],
|
[0, 0],
|
||||||
[0.99, 0.01],
|
[1, 0],
|
||||||
];
|
];
|
||||||
|
|
||||||
const textures = textuv.map(uv => uv.map((x, j) => textMul * x + textOff[j]));
|
const textures = textuv.map(uv => uv.map((x, j) => a * x + textOff[j]));
|
||||||
|
|
||||||
return textures;
|
return textures;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user