Skip to content

Commit

Permalink
tsconfig.json: fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sguimmara committed Sep 10, 2023
1 parent 54d0c87 commit 53aa152
Show file tree
Hide file tree
Showing 41 changed files with 88 additions and 124 deletions.
9 changes: 7 additions & 2 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
/* eslint-env node */
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended-type-checked'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: ['tsconfig.json', 'tests/tsconfig.json', 'examples/tsconfig.json'] ,
},
plugins: ['@typescript-eslint'],
root: true,
ignorePatterns: ['pages', 'dist', 'docs'],
ignorePatterns: ['pages', 'dist', 'docs', 'vite.config.ts', '.eslintrc.cjs'],
rules: {
quotes: [2, 'single', { 'avoidEscape': true }]
}
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/active-inactive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ async function main() {
});
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/alpha-blending/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ async function main() {
});
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/bounds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/clear-color/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ async function main() {
})
}

main();
main().catch(e => console.error(e));
4 changes: 3 additions & 1 deletion examples/basic/dynamic-geometry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ async function main() {

const camera = new Camera('perspective');
camera.transform.setPosition(0, 0, 300);
camera.nearPlane = 1;
camera.farPlane = 600;

const helper = new BoundsHelper({ source: solidMesh });

Expand Down Expand Up @@ -75,4 +77,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/frustum-culling/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/full-screen-quad/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/mode-lines/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/mode-points/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ async function main() {
});
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/scene-graph/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ async function main() {
}
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/solid+lines/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ async function main() {
}).on('change', (ev) => wireframe.withLineOffset(ev.value));
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/transparent-texture/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ async function main() {
requestAnimationFrame(renderLoop);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/basic/vertex-colors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/effects/colorimetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ async function main() {
});
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/effects/flip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ async function main() {
});
}

main();
main().catch(e => console.error(e));
3 changes: 3 additions & 0 deletions examples/formats/gltf-helmet/gltf.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import { MeshObject, Node, Scene } from 'hammerhead.gl/scene';
import { parse } from '@loaders.gl/core';
import * as gltf from '@loaders.gl/gltf';
Expand Down
5 changes: 2 additions & 3 deletions examples/formats/gltf-helmet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Camera, Node } from 'hammerhead.gl/scene';
import GLTFLoader from './gltf';
import { frameBounds } from '../../lib';
import Inspector from '../../Inspector';
import { Renderer } from 'hammerhead.gl/renderer';
import { BoundsHelper } from 'hammerhead.gl/helpers';

const canvas = document.getElementById('canvas') as HTMLCanvasElement;
Expand All @@ -15,7 +14,7 @@ async function main() {
const loader = new GLTFLoader();
const gltf = await loader.loadGltfScene(uri, baseUri);
const context = await Context.create(canvas);
const renderer = context.renderer as Renderer;
const renderer = context.renderer;

const scene = gltf[0];

Expand Down Expand Up @@ -51,4 +50,4 @@ async function main() {
new Inspector(context);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/geometries/cube/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/geometries/quad/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 1 addition & 1 deletion examples/geometries/tetrahedron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ async function main() {
context.on('resized', render);
}

main();
main().catch(e => console.error(e));
2 changes: 2 additions & 0 deletions examples/lib.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { parse } from '@loaders.gl/core';
import * as ply from '@loaders.gl/ply';

Expand Down
30 changes: 10 additions & 20 deletions examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
{
"compilerOptions": {
"lib": ["ES2022", "DOM"],
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "node",
"noEmit": true,
"esModuleInterop": true,
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"baseUrl": "../src",
"paths": {
"hammerhead.gl/*": ["./*"],
},
"typeRoots": [ "../node_modules/@webgpu/types", "../node_modules/@types"]
},
"include": ["**/*"],
}
{
"extends": "../tsconfig.common.json",
"compilerOptions": {
"paths": {
"hammerhead.gl/*": ["../dist/*"],
"@/*": ["../dist/*"],
},
},
"include": ["**/*"],
}
37 changes: 1 addition & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"type": "module",
"description": "A 3D renderer written in TypeScript and WebGPU.",
"main": "index.js",
"imports": {
"@/*": "./*"
},
"scripts": {
"precommit": "npm run lint && npm test",
"test": "vitest run",
Expand Down Expand Up @@ -55,9 +58,6 @@
"vitest-mock-extended": "^1.1.3"
},
"dependencies": {
"@popperjs/core": "^2.11.8",
"bootstrap": "^5.3.1",
"bootstrap-icons": "^1.10.5",
"chroma-js": "^2.4.2",
"wgpu-matrix": "^2.4.0"
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/Transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export default class Transform implements Version, Sized, Visitable {
if (typeof x === 'number') {
quat.set(x, y, z, w, this.quaternion);
} else {
const q = x as Quat;
quat.set(q[0], q[1], q[2], q[3], this.quaternion);
quat.set(x[0], x[1], x[2], x[3], this.quaternion);
}
this.incrementVersion();
this.localMatrixNeedsUpdate = true;
Expand Down
2 changes: 1 addition & 1 deletion src/interaction/controls/OrbitControls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default class OrbitControls extends Controls {
super(camera);
this._interactiveElement = interactiveElement;

this._interactiveElement.addEventListener('pointermove', this.onPointerMove);
this._interactiveElement.addEventListener('pointermove', ev => this.onPointerMove(ev));
this._interactiveElement.addEventListener('wheel', ev => this.onZoom(ev));
}

Expand Down
7 changes: 4 additions & 3 deletions src/materials/Material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
Mat4Uniform,
Uniform,
BufferUniform,
ObjectUniform,
} from './uniforms';
import UniformType from './UniformType';
import GlobalValues from '@/renderer/GlobalValues';
Expand Down Expand Up @@ -104,7 +105,7 @@ export class Blending {
}
}

function allocateUniform(type: UniformType) {
function allocateUniform(type: UniformType): UntypedUniform {
switch (type) {
case UniformType.Texture2D:
return new TextureUniform();
Expand All @@ -121,12 +122,12 @@ function allocateUniform(type: UniformType) {
case UniformType.Mat4:
return new Mat4Uniform();
case UniformType.GlobalValues:
return new GlobalValues();
return new ObjectUniform(new GlobalValues());
}
}

function allocateUniforms(layout: UniformInfo[]): UntypedUniform[] {
const uniforms = Array(layout.length);
const uniforms: UntypedUniform[] = Array<UntypedUniform>(layout.length);
for (let i = 0; i < layout.length; i++) {
const info = layout[i];
uniforms[info.binding] = allocateUniform(info.type);
Expand Down
2 changes: 1 addition & 1 deletion src/materials/ShaderPreprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function toUniformType(type: UniformType): string {
case UniformType.F32Array:
return 'array<f32>';
default:
throw new ShaderError(`unimplemented uniform type: ${type}`);
throw new ShaderError('unimplemented uniform type');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/BufferStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class BufferStore implements Service, Stats {
getIndexBuffer(mesh: Mesh): GPUBuffer {
let storage = this.geometryStorages.get(mesh.id);
if (!storage) {
mesh.on('destroyed', evt => this.onGeometryDestroyed(evt.source as Mesh));
mesh.on('destroyed', evt => this.onGeometryDestroyed(evt.source));
storage = new GeometryStorage(mesh);
this.geometryStorages.set(mesh.id, storage);
} else if (storage.indexBuffer) {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/PipelineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ class PipelineManager implements Service {
this.perMaterialMap.set(material.id, perMaterial);

material.on('destroyed', (evt) =>
this.onMaterialDestroyed(evt.source as Material)
this.onMaterialDestroyed(evt.source)
);
} else {
this.updatePipeline(perMaterial, mesh);
Expand Down
1 change: 1 addition & 0 deletions tests/core/Container.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Container, Service } from '@/core';
import { describe, expect, it, beforeEach } from 'vitest';
import { mock } from 'vitest-mock-extended';
Expand Down
1 change: 1 addition & 0 deletions tests/materials/uniforms/Mat4Uniform.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Visitor } from '@/core';
import { Mat4Uniform } from '@/materials/uniforms';
import { describe, expect, it } from 'vitest';
Expand Down
1 change: 1 addition & 0 deletions tests/materials/uniforms/ObjectUniform.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Sized, Version, Visitable, Visitor } from '@/core';
import { ObjectUniform } from '@/materials/uniforms';
import { describe, expect, it } from 'vitest';
Expand Down
1 change: 1 addition & 0 deletions tests/materials/uniforms/ScalarUniform.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Visitor } from '@/core';
import { ScalarUniform } from '@/materials/uniforms';
import { describe, expect, it } from 'vitest';
Expand Down
1 change: 1 addition & 0 deletions tests/materials/uniforms/Vec2Uniform.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Visitor } from '@/core';
import { Vec2Uniform } from '@/materials/uniforms';
import { describe, expect, it } from 'vitest';
Expand Down
1 change: 1 addition & 0 deletions tests/materials/uniforms/Vec3Uniform.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Visitor } from '@/core';
import { Vec3Uniform } from '@/materials/uniforms';
import { describe, expect, it } from 'vitest';
Expand Down
1 change: 1 addition & 0 deletions tests/materials/uniforms/Vec4Uniform.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/unbound-method */
import { Visitor } from '@/core';
import { Vec4Uniform } from '@/materials/uniforms';
import chroma from 'chroma-js';
Expand Down
Loading

0 comments on commit 53aa152

Please sign in to comment.