Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.0.1 #7

Merged
merged 35 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2ec5468
build(dep): `@babylonjs` & `@types/node`:
PhilippeMorier Dec 10, 2019
7d237f1
feat(apps/frontend): select initial tool
PhilippeMorier Dec 10, 2019
b9a2b8e
fix(apps/frontend): import hammerjs
PhilippeMorier Dec 10, 2019
05ec1fa
refactor(frontend): scene-viewer into container
PhilippeMorier Dec 10, 2019
b2bd8ad
feat(frontend): dispatch `pointerPick` action
PhilippeMorier Dec 10, 2019
ceee013
feat(frontend): dispatch `add|removeVoxel` action
PhilippeMorier Dec 11, 2019
f9c122b
build(packaging): simplify `prettier:check` command
PhilippeMorier Dec 11, 2019
72c89e0
doc(frontend): add readme with ngrx resources
PhilippeMorier Dec 11, 2019
d6eafd5
feat(frontend): support adding voxel
PhilippeMorier Dec 12, 2019
2e68605
refactor(frontend): don't inject `GridService`
PhilippeMorier Dec 12, 2019
157da40
feat(frontend): effects for when app goes on/offline
PhilippeMorier Dec 12, 2019
4ad0a04
test(frontend): on/offline effects
PhilippeMorier Dec 12, 2019
f7419eb
test(vdb): remove `normals` from test
PhilippeMorier Dec 12, 2019
99fed10
feat(vdb): add `setValueOff` & `isValueOn`
PhilippeMorier Dec 12, 2019
29161bc
test(frontend): set expected position to pass
PhilippeMorier Dec 12, 2019
c015944
fix(frontend): make public for use in template
PhilippeMorier Dec 12, 2019
31ea920
build(dep): `@types/node` & `core-js`
PhilippeMorier Dec 12, 2019
11fa2eb
feat(frontend): enable `removeVoxel`
PhilippeMorier Dec 12, 2019
5a8df98
build(dep): `@babylonjs/*`
PhilippeMorier Dec 12, 2019
38002fb
build(github): keep `develop` after PR merge
PhilippeMorier Dec 12, 2019
2e5f6b3
build(dep): `cypress` to `v3.8.0`
PhilippeMorier Dec 16, 2019
9629429
build(dep): `cypress` to `v3.7.0`
PhilippeMorier Dec 16, 2019
bb5440f
test(vdb): set value with float coordinates:
PhilippeMorier Dec 17, 2019
1362079
build(dep): `cypress` to `v3.7.0`
PhilippeMorier Dec 17, 2019
e8cd3c9
feat(frontend): support adding and removing voxels
PhilippeMorier Dec 18, 2019
97ff0c6
test(ui): remove unused imported components
PhilippeMorier Dec 19, 2019
b041d82
build(CircleCi): use `13.3.0` due failing tests:
PhilippeMorier Dec 19, 2019
a96dfed
fix(frontend): add voxel on positive normal
PhilippeMorier Dec 19, 2019
575e9db
test(frontend): set `setupFilesAfterEnv`
PhilippeMorier Dec 19, 2019
596f386
test(frontend): set `globals`>`tsConfig`
PhilippeMorier Dec 19, 2019
c1ddf83
build(CircleCi): use `13.4.0`
PhilippeMorier Dec 19, 2019
3726648
build(dep): update diverse dependencies:
PhilippeMorier Dec 19, 2019
4d690b9
doc(readme): record macro & git setup
PhilippeMorier Dec 20, 2019
2a3f37a
build(dep): `@angular-devkit/build-angular` & `@angular/cli`
PhilippeMorier Dec 20, 2019
26b866b
Merge branch 'master' into tls-release-0.0.1
PhilippeMorier Dec 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ aliases:
# https://github.com/CircleCI-Public/circleci-dockerfiles/tree/master/node/images
- &use_docker_node
docker:
- image: circleci/node:13.2.0-stretch
- image: circleci/node:13.4.0-stretch

- &use_docker_node_browsers
docker:
- image: circleci/node:13.2.0-stretch-browsers
- image: circleci/node:13.4.0-stretch-browsers

# https://github.com/cypress-io/cypress-docker-images/tree/master/included
- &use_docker_cypress_included
docker:
# 3.8.0 fails with `Error: write EPIPE` when running `benchmark`!?
- image: cypress/included:3.7.0

- &workspace ~/talus
Expand Down
3 changes: 3 additions & 0 deletions .github/delete-merged-branch-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
exclude:
- master
- develop
38 changes: 32 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,18 @@ This project was generated using [Nx](https://nx.dev) with the following command
- https://github.com/nvm-sh/nvm#installation-and-update
2. Install (latest) `node`
- `nvm install node`
- or add a version `nvm install 12.3.1`
- set a version as default `nvm alias default 12.3.1`
- or add a version `nvm install 13.4.0`
- set a version as default `nvm alias default 13.4.0`

### Yarn

#### Manually

1. Install `yarn`
- https://yarnpkg.com/lang/en/docs/install/#debian-stable

#### With brew

1. Install `yarn`
- `brew install yarn`
2. Update
Expand Down Expand Up @@ -94,17 +101,33 @@ Setting up a macro which will fix all the linting issues, optimizes the imports
- Working Dir: `$FileDir$`
- Advanced Options: None, all deactivated

2. Record macro in this order
2. Record macro (Edit > Macros > Start Macro Recording) in this order

- Action: TsLintFileFixAction
- Action: TsLintFileFixAction (with opened \*.ts file)
- Action: OptimizeImports
- Action: ReformatWithPrettierAction
- Action: FileWatcher.runForFiles
- Action: FileWatcher.runForFiles (with opened \*.scss file)
- Action: SaveAll

3. Save macro as e.g. `Fix & Save`

4. Assign Keyboard shortcut `Ctrl` + `S` to macro `Fix & Save`
4. Assign Keyboard shortcut `Ctrl` + `S` to macro `Fix & Save` (search for macro)

### Git

1. Make sure that `git-completion` is working, otherwise run:
`sudo apt-get install git-core bash-completion`

2. Add branch name to shell
- Download & save
[git-prompt.sh](https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh)
- Add in `.bashrc`:
```
# GIT prompt
. ~/Projects/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=1
export PS1='\[\e[1;32m\]\u\[\e[m\]@\[\e[33m\]\h\[\e[m\]:\[\e[34m\]\w\[\e[m\]$(__git_ps1 " (%s)")\$ '
```

## Build

Expand All @@ -126,6 +149,9 @@ Setting up a macro which will fix all the linting issues, optimizes the imports
installed in order to be able to run Cypress locally.
- `yarn e2e <frontend-e2e>`

When updating Cypress version in `package.json` the version in `.circleci/config.yml` needs to be
updated as well.

## Nx

### Update
Expand Down
4 changes: 4 additions & 0 deletions apps/frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,8 @@ module.exports = {
'jest-preset-angular/AngularSnapshotSerializer.js',
'jest-preset-angular/HTMLCommentSerializer.js',
],
// https://github.com/nrwl/nx/issues/1439#issuecomment-561268656
// When using `Run test` directly in WebStorm, change the used config to
// this file i.e. `./frontend/jest.config.js` and not `<rootDir>/jest.config.js`.
setupFilesAfterEnv: ['./src/test-setup.ts'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GridService {
this.accessor.setValueOff(xyz, this.grid.background);
}

computeMesh(): MeshData {
computeMesh(): MeshData | undefined {
return gridToMesh(this.grid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { By } from '@angular/platform-browser';
import { MemoizedSelector, Store } from '@ngrx/store';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { PointerButton, PointerPickInfo } from '@talus/ui';
import { Coord } from '@talus/vdb';
import { Subject } from 'rxjs';
import * as fromApp from '../app.reducer';
import { Tool } from '../tools-panel/tool.model';
Expand Down Expand Up @@ -68,31 +69,114 @@ describe('SceneViewerContainerComponent', () => {
expect(mockStore.dispatch).not.toHaveBeenCalled();
});

it('should dispatch `addVoxel` action', () => {
const action = addVoxel({ position: [1, 1, 1], value: 42 });

stubComponent.pointerPick.next({
pickedPoint: [1, 1, 1],
pointerButton: PointerButton.Main,
normal: [0, 0, 1],
});

expect(mockStore.dispatch).toHaveBeenCalledWith(action);
});

it('should dispatch `removeVoxel` action', () => {
mockSelectedToolIdSelector.setResult(Tool.RemoveVoxel);
mockStore.refreshState();
fixture.detectChanges();

const action = removeVoxel({ position: [1, 1, 1] });

stubComponent.pointerPick.next({
pickedPoint: [1, 1, 1],
pointerButton: PointerButton.Main,
normal: [0, 0, 1],
});

expect(mockStore.dispatch).toHaveBeenCalledWith(action);
});
it.each([
[
[1, 0.2, 0.9],
[1, 0.2, 0.9],
[1, 0, 0],
],
[
[0.99999999, 0.2, 0.9],
[1, 0.2, 0.9],
[1, 0, 0],
],
[
[0.2, 0.99999999, 0.9],
[0.2, 1, 0.9],
[0, 1, 0],
],
[
[0.2, 0.9, 0.0000000001],
[0.2, 0.9, 0],
[0, 0, 1],
],
[
[0, 0, -0.999999],
[0, 0, -1],
[0, 0, 1],
],
[
[0, -2, -0.999999],
[0, -3, -2],
[0, 0, -1],
],
[
[-0, -2, 3],
[-0, -3, 2],
[0, 0, -1],
],
[
[0.5, 1.4, -1],
[0.5, 1.4, -1],
[0, 0, 1],
],
])(
'should dispatch `addVoxel` action for %j',
(pickedPoint: Coord, position: Coord, normal: Coord) => {
const action = addVoxel({ position, value: 42 });

stubComponent.pointerPick.next({
pickedPoint,
pointerButton: PointerButton.Main,
normal,
});

expect(mockStore.dispatch).toHaveBeenCalledWith(action);
},
);

it.each([
[
[1.0000000000001, 0.5, 0.5],
[0, 0.5, 0.5],
[1, 0, 0],
],
[
[0.999999999999, 0.5, 0.5],
[1, 0.5, 0.5],
[-1, 0, 0],
],
[
[1.0000000000001, -0.5, 0.5],
[1, -1.5, 0.5],
[-1, 0, 0],
],
[
[-0.999999999999, -0.5, 0.5],
[-1, -1.5, 0.5],
[-1, 0, 0],
],
[
[-2.0000000000001, -0.5, 0.5],
[-3, -1.5, 0.5],
[1, 0, 0],
],
[
[0.5, 0.999999999999, 0.5],
[0.5, 0, 0.5],
[0, 1, 0],
],
[
[0.5461420538559825, 0.4841910809236776, -2],
[0.5461420538559825, 0.4841910809236776, -2],
[0, 0, -1],
],
])(
'should dispatch `removeVoxel` action for %j',
(pickedPoint: Coord, position: Coord, normal: Coord) => {
mockSelectedToolIdSelector.setResult(Tool.RemoveVoxel);
mockStore.refreshState();
fixture.detectChanges();

const action = removeVoxel({ position });

stubComponent.pointerPick.next({
pickedPoint,
pointerButton: PointerButton.Main,
normal,
});

expect(mockStore.dispatch).toHaveBeenCalledWith(action);
},
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ChangeDetectionStrategy, Component, ViewChild } from '@angular/core';
// import '@babylonjs/core/Rendering/outlineRenderer';
import { select, Store } from '@ngrx/store';
import { PointerButton, PointerPickInfo, SceneViewerComponent } from '@talus/ui';
import { add, Coord } from '@talus/vdb';
import { Coord } from '@talus/vdb';
import { Observable } from 'rxjs';
import * as fromApp from '../app.reducer';
import { Tool } from '../tools-panel/tool.model';
Expand Down Expand Up @@ -44,15 +44,70 @@ export class SceneViewerContainerComponent {

switch (selectedToolId) {
case Tool.AddVoxel:
this.store.dispatch(addVoxel({ position: pickInfo.pickedPoint, value: 42 }));
this.store.dispatch(
addVoxel({ position: this.calcVoxelToAddPosition(pickInfo), value: 42 }),
);
break;
case Tool.RemoveVoxel:
this.store.dispatch(removeVoxel({ position: pickInfo.pickedPoint }));
this.store.dispatch(removeVoxel({ position: this.calcVoxelToRemovePosition(pickInfo) }));
break;
}
}

private calcNewVoxelPosition(pickInfo: PointerPickInfo): Coord {
return add(pickInfo.pickedPoint, pickInfo.normal);
private calcVoxelToAddPosition(pickInfo: PointerPickInfo): Coord {
const pickedIntegerPoint = this.roundDimensionAlongNormal(pickInfo);

// VDB removes fractional-part of the coordinate, i.e. 0.54 -> 0.
// Therefore, positive numbers are getting rounded down (1.9 -> 1) and
// negative numbers are getting rounded up (-0.2 -> 0).
// Hence, the subtraction of 1 is needed.
const newPoint: Coord = [
pickInfo.normal[0] < 0 || (pickInfo.normal[0] === 0 && pickedIntegerPoint[0] < 0)
? pickedIntegerPoint[0] - 1
: pickedIntegerPoint[0],
pickInfo.normal[1] < 0 || (pickInfo.normal[1] === 0 && pickedIntegerPoint[1] < 0)
? pickedIntegerPoint[1] - 1
: pickedIntegerPoint[1],
pickInfo.normal[2] < 0 || (pickInfo.normal[2] === 0 && pickedIntegerPoint[2] < 0)
? pickedIntegerPoint[2] - 1
: pickedIntegerPoint[2],
];

return newPoint;
}

private calcVoxelToRemovePosition(pickInfo: PointerPickInfo): Coord {
const pickedIntegerPoint = this.roundDimensionAlongNormal(pickInfo);

const newPoint: Coord = [
pickInfo.normal[0] > 0 || (pickInfo.normal[0] === 0 && pickedIntegerPoint[0] < 0)
? pickedIntegerPoint[0] - 1
: pickedIntegerPoint[0],
pickInfo.normal[1] > 0 || (pickInfo.normal[1] === 0 && pickedIntegerPoint[1] < 0)
? pickedIntegerPoint[1] - 1
: pickedIntegerPoint[1],
pickInfo.normal[2] > 0 || (pickInfo.normal[2] === 0 && pickedIntegerPoint[2] < 0)
? pickedIntegerPoint[2] - 1
: pickedIntegerPoint[2],
];

return newPoint;
}

/**
* Babylon.js returns sometimes a floating instead of integer number for the dimension of
* the normal vector of the picked point.
* E.g. Click on [1, 0.5, 0.6] on voxel at [0, 0, 0] on its site which has the x-axis as its
* normal vector [1, 0, 0], could result in a picking point of something like [0.99999, 0.5, 0.6].
* Where in fact it should be [1, 0.5, 0.6].
* Since all the voxels are placed on integer positions the dimension of the picked point
* needs to be rounded.
*/
private roundDimensionAlongNormal(pickInfo: PointerPickInfo): Coord {
return [
pickInfo.normal[0] !== 0 ? Math.round(pickInfo.pickedPoint[0]) : pickInfo.pickedPoint[0],
pickInfo.normal[1] !== 0 ? Math.round(pickInfo.pickedPoint[1]) : pickInfo.pickedPoint[1],
pickInfo.normal[2] !== 0 ? Math.round(pickInfo.pickedPoint[2]) : pickInfo.pickedPoint[2],
];
}
}
3 changes: 0 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// const ignoreLibs = ['@babylonjs/core'];

module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
Expand All @@ -11,5 +9,4 @@ module.exports = {
moduleNameMapper: {
'@babylonjs': 'babylonjs',
},
// transformIgnorePatterns: [`/node_modules/(?!(${ignoreLibs.join('|')})/)`],
};
19 changes: 19 additions & 0 deletions libs/ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,23 @@ module.exports = {
'jest-preset-angular/AngularSnapshotSerializer.js',
'jest-preset-angular/HTMLCommentSerializer.js',
],
// https://github.com/nrwl/nx/issues/1439#issuecomment-561268656
// When using `Run test` directly in WebStorm, change the used config to
// this file i.e. `./ui/jest.config.js` and not `<rootDir>/jest.config.js`.
// Otherwise, following error might occur:
// - Cannot find module '@talus/ui'
// - Zone is needed for the async() test helper but could not be found.
setupFilesAfterEnv: ['./src/test-setup.ts'],

// https://github.com/thymikee/jest-preset-angular/issues/293#issuecomment-513544717
// When using `Run test` directly in WebStorm, the scss couldn't be loaded.
// - Error: connect ECONNREFUSED 127.0.0.1:80
// - Error: Uncaught (in promise): Failed to load *.component.scss
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
// stringifyContentPathRegex: '\\.html$',
// astTransformers: [require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')],
},
},
};
Loading