Skip to content

Commit

Permalink
Enable GitHub Actions (#108)
Browse files Browse the repository at this point in the history
* Enable GitHub Actions

* Fix lint problems
  • Loading branch information
willeastcott authored Jun 8, 2024
1 parent 44af01c commit b5d14b1
Show file tree
Hide file tree
Showing 18 changed files with 109 additions and 39 deletions.
14 changes: 11 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
"plugin:@typescript-eslint/recommended"
],
"plugins": ["@typescript-eslint", "prettier"]
"plugins": ["@typescript-eslint"],
"rules": {
"no-constant-condition": "off",
"no-empty": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/ban-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
67 changes: 67 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: CI

on:
workflow_dispatch:
push:
branches: [ main ]
paths-ignore: ['README.md', 'LICENSE']
pull_request:
branches: [ main ]
paths-ignore: ['README.md', 'LICENSE']

concurrency:
group: ci-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-latest

timeout-minutes: 10

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install
run: npm ci

- name: Build
run: npm run build

lint:
name: Lint
runs-on: ubuntu-latest

timeout-minutes: 10

strategy:
matrix:
node-version: [18.x]

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install
run: npm ci

- name: Lint
run: npm run lint
2 changes: 1 addition & 1 deletion src/asset-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Asset, AssetRegistry, StandardMaterial, TEXTURETYPE_RGBP } from 'playcanvas';
import { Asset, AssetRegistry, TEXTURETYPE_RGBP } from 'playcanvas';
import { Model } from './model';
import { Splat } from './splat';
import { Env } from './env';
Expand Down
2 changes: 1 addition & 1 deletion src/controllers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MouseController {
};

let closestD = 0;
let closestP = new Vec3();
const closestP = new Vec3();
let closestSplat = null;

for (let i = 0; i < splats.length; ++i) {
Expand Down
7 changes: 3 additions & 4 deletions src/edit-ops.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { GSplatData, Quat, Vec3 } from 'playcanvas';
import { Scene } from './scene';
import { Element } from './element';
import { Splat } from './splat';

enum State {
selected = 1,
hidden = 2,
deleted = 4
};
}

// build a splat index based on a boolean predicate
const buildIndex = (splatData: GSplatData, pred: (i: number) => boolean) => {
Expand Down Expand Up @@ -107,7 +106,7 @@ interface EntityTransform {
position: Vec3;
rotation: Quat;
scale: Vec3;
};
}

interface EntityOp {
splat: Splat;
Expand Down Expand Up @@ -140,7 +139,7 @@ class EntityTransformOp {
destroy() {
this.entityOps = [];
}
};
}

export {
State,
Expand Down
12 changes: 6 additions & 6 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S

const processSelection = (state: Uint8Array, op: string, pred: (i: number) => boolean) => {
for (let i = 0; i < state.length; ++i) {
if (!!(state[i] & (State.deleted | State.hidden))) {
if (state[i] & (State.deleted | State.hidden)) {
state[i] &= ~State.selected;
} else {
const result = pred(i);
Expand Down Expand Up @@ -108,11 +108,11 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
lastExportCursor = editHistory.cursor;
});

events.on('camera.mode', (mode: string) => {
events.on('camera.mode', () => {
scene.forceRender = true;
});

events.on('splatSize', (value: number) => {
events.on('splatSize', () => {
scene.forceRender = true;
});

Expand Down Expand Up @@ -164,7 +164,7 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
selectedSplats().forEach((splat) => {
const splatData = splat.splatData;
const state = splatData.getProp('state') as Uint8Array;
processSelection(state, 'set', (i) => true);
processSelection(state, 'set', () => true);
splat.updateState();
});
});
Expand All @@ -173,7 +173,7 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
selectedSplats().forEach((splat) => {
const splatData = splat.splatData;
const state = splatData.getProp('state') as Uint8Array;
processSelection(state, 'set', (i) => false);
processSelection(state, 'set', () => false);
splat.updateState();
});
});
Expand All @@ -200,7 +200,7 @@ const registerEditorEvents = (events: Events, editHistory: EditHistory, scene: S
let scaleMin;
let scaleMax;
for (let i = 0; i < splatData.numSplats; ++i) {
if (!!(state[i] & State.deleted)) continue;
if (state[i] & State.deleted) continue;
if (first) {
first = false;
scaleMin = Math.min(scale_0[i], scale_1[i], scale_2[i]);
Expand Down
4 changes: 2 additions & 2 deletions src/file-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { Splat } from './splat';
interface RemoteStorageDetails {
method: string;
url: string;
};
}

type ExportType = 'ply' | 'compressed-ply' | 'splat';

interface SceneWriteOptions {
type: ExportType;
filename?: string;
stream?: FileSystemWritableFileStream;
};
}

const filePickerTypes = {
'ply': [{
Expand Down
1 change: 0 additions & 1 deletion src/grid.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
BUFFER_STATIC,
PRIMITIVE_LINES,
SEMANTIC_COLOR,
SEMANTIC_POSITION,
Expand Down
3 changes: 0 additions & 3 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
Asset,
BoundingBox,
Entity,
Mat4,
MeshInstance,
RenderComponent,
Vec3
Expand All @@ -11,8 +10,6 @@ import { Element, ElementType } from './element';
import { Serializer } from './serializer';

const vec = new Vec3();
const mat = new Mat4();
// const bound = new BoundingBox();

// calculate mesh sort distance by node origin (instead of the default bounding box origin)
const calculateSortDistance = (drawCall: any, cameraPosition: Vec3, cameraForward: Vec3) => {
Expand Down
2 changes: 1 addition & 1 deletion src/scene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class Scene {
url: config.model.url,
filename: config.model.filename
}));
};
}

// load env
if (config.env.url) {
Expand Down
6 changes: 3 additions & 3 deletions src/shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface ShortcutOptions {
shift?: boolean;
func?: () => void;
event?: string;
};
}

class Shortcuts {
shortcuts: { keys: string[], options: ShortcutOptions }[] = [];
Expand Down Expand Up @@ -35,8 +35,8 @@ class Shortcuts {

register(keys: string[], options: ShortcutOptions) {
this.shortcuts.push({ keys, options });
};
};
}
}

export {
Shortcuts
Expand Down
8 changes: 4 additions & 4 deletions src/splat-convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { State } from './edit-ops';
interface ConvertEntry {
splatData: GSplatData;
modelMat: Mat4;
};
}

const countTotalSplats = (convertData: ConvertEntry[]) => {
return convertData.reduce((total, entry) => {
Expand Down Expand Up @@ -139,7 +139,7 @@ interface CompressedIndex {
entryIndex: number;
i: number;
globalIndex: number;
};
}

class SingleSplat {
x = 0;
Expand Down Expand Up @@ -180,7 +180,7 @@ class SingleSplat {
this.scale_1 = Math.log(Math.exp(this.scale_1) * scale.y);
this.scale_2 = Math.log(Math.exp(this.scale_2) * scale.z);
}
};
}

const compressedVal = (prop: string, index: CompressedIndex) => {
return index.entry.splatData.getProp(prop)[index.i];
Expand Down Expand Up @@ -501,7 +501,7 @@ const convertPlyCompressed = (convertData: ConvertEntry[]) => {
dataView.setFloat32(chunkOffset + i * 12 * 4 + 44, result.sz.max, true);

// write splat data
let offset = vertexOffset + i * 256 * 4 * 4;
const offset = vertexOffset + i * 256 * 4 * 4;
const chunkSplats = Math.min(numSplats, (i + 1) * 256) - i * 256;
for (let j = 0; j < chunkSplats; ++j) {
dataView.setUint32(offset + j * 4 * 4 + 0, chunk.position[j], true);
Expand Down
4 changes: 2 additions & 2 deletions src/splat-debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ class SplatDebug {
let count = 0;

for (let i = 0; i < splatData.numSplats; ++i) {
if (!!(s[i] & State.deleted)) {
if (s[i] & State.deleted) {
// deleted
vertexData[i * 4 + 3] = -1;
} else if (!!(s[i] & State.hidden)) {
} else if (s[i] & State.hidden) {
// hidden
vertexData[i * 4 + 3] = -1;
} else if (!(s[i] & State.selected)) {
Expand Down
4 changes: 2 additions & 2 deletions src/sw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ self.addEventListener('install', (event) => {
);
});

self.addEventListener('activate', (event) => {
self.addEventListener('activate', () => {
console.log(`activating v${appVersion}`);

// delete the old caches once this one is activated
caches.keys().then((names) => {
for (let name of names) {
for (const name of names) {
if (name !== cacheName) {
caches.delete(name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/picker-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PickerSelection {
deactivate() {
this.root.style.display = 'none';
}
};
}

export { PickerSelection };

6 changes: 3 additions & 3 deletions src/tools/transform-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TransformGizmo } from 'playcanvas';
import { Scene } from '../scene';
import { Splat } from '../splat';
import { Events } from '../events';
import { EditHistory, EditOp } from '../edit-history';
import { EditHistory } from '../edit-history';
import { EntityOp, EntityTransformOp } from '../edit-ops';

// patch gizmo to be more opaque
Expand Down Expand Up @@ -86,7 +86,7 @@ class TransformTool {
}
});

events.on('scene.boundChanged', (editOp: EditOp) => {
events.on('scene.boundChanged', () => {
if (this.splats) {
this.gizmo.attach(this.splats.map((splat) => splat.entity));
}
Expand All @@ -97,7 +97,7 @@ class TransformTool {
scene.forceRender = true;
});

events.on('selection.changed', (selection: Splat) => {
events.on('selection.changed', () => {
this.update();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/editor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Container, InfoBox, Label } from 'pcui';
import { Container, Label } from 'pcui';
import { ControlPanel } from './control-panel';
import { Toolbar } from './toolbar';
import { Events } from '../events';
Expand Down
2 changes: 1 addition & 1 deletion src/ui/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ class Tooltip extends Container {
hide() {
this.hidden = true;
}
};
}

export { Tooltip };

0 comments on commit b5d14b1

Please sign in to comment.