Hi All,
I’m just in the middle of implementing terrain quantisation for my Cesium port, and have come across this use of a scratch Cartesian3 in the vertex generation worker.
for (var i = 0; i < quantizedVertexCount; ++i) {
var u = uBuffer[i] / maxShort;
var v = vBuffer[i] / maxShort;
var height = CesiumMath.lerp(minimumHeight, maximumHeight, heightBuffer[i] / maxShort);
cartographicScratch.longitude = CesiumMath.lerp(west, east, u);
cartographicScratch.latitude = CesiumMath.lerp(south, north, v);
cartographicScratch.height = height;
var position = ellipsoid.cartographicToCartesian(cartographicScratch);
uvs[i] = new Cartesian2(u, v);
heights[i] = height;
positions[i] = position;
Matrix4.multiplyByPoint(toENU, position, cartesian3Scratch);
Cartesian3.minimumByComponent(cartesian3Scratch, minimum, minimum);
Cartesian3.maximumByComponent(cartesian3Scratch, maximum, maximum);
}
…
var bufferIndex = 0;
for (var j = 0; j < quantizedVertexCount; ++j) {
if (hasVertexNormals) {
var n = j * 2.0;
toPack.x = octEncodedNormals[n];
toPack.y = octEncodedNormals[n + 1];
if (exaggeration !== 1.0) {
var normal = AttributeCompression.octDecode(toPack.x, toPack.y, scratchNormal);
var fromENUNormal = Transforms.eastNorthUpToFixedFrame(cartesian3Scratch, ellipsoid, scratchFromENU);
…
}
}
}
``
It seems to be reset for each vertex but then used to generate normals for the next step even though it seemingly just ends up as the last vertex position in the array.
Is there some significance to this I’m missing?
Thanks,
Ryan