change var to let/const now it's a real thing

This commit is contained in:
Daniel Leone 2022-02-04 10:35:54 +08:00
parent ea5bfcf727
commit 98786878e7
7 changed files with 25 additions and 21 deletions

View File

@ -291,10 +291,10 @@ HeightmapTerrainData.prototype.createMesh = function (options) {
const vertexCountWithoutSkirts = result.gridWidth * result.gridHeight;
var encoding = TerrainEncoding.clone(result.encoding);
var vertices = new Float32Array(result.vertices);
const encoding = TerrainEncoding.clone(result.encoding);
const vertices = new Float32Array(result.vertices);
var octreeTrianglePicker = null;
let octreeTrianglePicker = null;
if (encoding.exaggeration === 1 && result.octree) {
// ahhh, sorry, the octree data structure is built off non-exaggerated triangles
octreeTrianglePicker = new OctreeTrianglePicking(

View File

@ -554,7 +554,7 @@ HeightmapTessellator.computeVertices = function (options) {
console.timeEnd("creating oriented bounding box");
console.time("making packed triangles");
var packedTriangles = createPackedTriangles(
const packedTriangles = createPackedTriangles(
positions,
inverseTransform,
width,

View File

@ -1018,7 +1018,7 @@ Matrix3.multiplyByScale = function (matrix, scale, result) {
return result;
};
var uniformScaleScratch = new Cartesian3();
const uniformScaleScratch = new Cartesian3();
Matrix3.multiplyByUniformScale = function (matrix, scale, result) {
//>>includeStart('debug', pragmas.debug);

View File

@ -372,7 +372,7 @@ QuantizedMeshTerrainData.prototype.createMesh = function (options) {
const stride = result.vertexStride;
const terrainEncoding = TerrainEncoding.clone(result.encoding);
var trianglePicking = new OctreeTrianglePicking(
const trianglePicking = new OctreeTrianglePicking(
result.packedOctree,
createTriangleVerticesCallback(
vertices,

View File

@ -50,7 +50,7 @@ Ray.clone = function (ray, result) {
return result;
};
var scratchCartesian = new Cartesian3();
const scratchCartesian = new Cartesian3();
/**
* Computes the point along the ray given by r(t) = o + t*d,
@ -76,7 +76,11 @@ Ray.getPoint = function (ray, t, result) {
result = new Cartesian3();
}
var offset = Cartesian3.multiplyByScalar(ray.direction, t, scratchCartesian);
const offset = Cartesian3.multiplyByScalar(
ray.direction,
t,
scratchCartesian
);
return Cartesian3.add(ray.origin, offset, result);
};
export default Ray;

View File

@ -191,17 +191,17 @@ TerrainMesh.prototype.pickRay = function (
frameState,
projection
) {
var trace = window.showPickDetails;
const trace = window.showPickDetails;
var traceDetails;
let traceDetails;
if (trace) {
traceDetails = {};
}
var newPickValue, oldPickValue;
let newPickValue, oldPickValue;
var hasOctree = !!this._octreeTrianglePicking;
var canUseOctree =
const hasOctree = !!this._octreeTrianglePicking;
const canUseOctree =
frameState /* not always passed in */ &&
frameState.mode === SceneMode.SCENE3D /* 3d mode only*/ &&
frameState.terrainExaggeration ===
@ -233,13 +233,13 @@ TerrainMesh.prototype.pickRay = function (
!isCartesianAlmostEqual(newPickValue, oldPickValue)
) {
console.error("pick values are different", newPickValue, oldPickValue);
var newPickAgain = this._octreeTrianglePicking.rayIntersect(
const newPickAgain = this._octreeTrianglePicking.rayIntersect(
ray,
cullBackFaces,
null,
traceDetails
);
var oldPickAgain = this._defaultPickStrategy.rayIntersect(
const oldPickAgain = this._defaultPickStrategy.rayIntersect(
ray,
cullBackFaces,
frameState.mode,

View File

@ -26,12 +26,12 @@ const cartographicScratch = new Cartographic();
const toPack = new Cartesian2();
function createPackedTrianglesFromIndices(indices, positions, invTrans) {
var v0 = new Cartesian3();
var v1 = new Cartesian3();
var v2 = new Cartesian3();
var triangleCount = indices.length / 3;
var i;
var triangles = []; // new Float32Array(triangleCount * 6);
const v0 = new Cartesian3();
const v1 = new Cartesian3();
const v2 = new Cartesian3();
const triangleCount = indices.length / 3;
let i;
const triangles = []; // new Float32Array(triangleCount * 6);
for (i = 0; i < triangleCount; i++) {
Matrix4.multiplyByPoint(invTrans, positions[indices[i * 3]], v0);