Skip to content

Commit ff76de7

Browse files
committed
feat(rapier): add rapier
wip rapier
1 parent be14df8 commit ff76de7

37 files changed

+1563
-15
lines changed

Diff for: libs/core/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@
4040
"packageGroup": [
4141
"angular-three-soba",
4242
"angular-three-postprocessing",
43-
"angular-three-cannon"
43+
"angular-three-cannon",
44+
"angular-three-rapier"
4445
]
4546
},
4647
"ng-update": {
4748
"migrations": "./plugin/migrations.json",
4849
"packageGroup": [
4950
"angular-three-soba",
5051
"angular-three-postprocessing",
51-
"angular-three-cannon"
52+
"angular-three-cannon",
53+
"angular-three-rapier"
5254
]
5355
},
5456
"web-types": "./web-types.json"

Diff for: libs/core/src/lib/portal.ts

+1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ export class NgtPortal implements OnInit {
214214
requestAnimationFrame(() => {
215215
this.portalStore.set((injectState) => this.inject(this.parentStore.get(), injectState));
216216
});
217+
217218
this.portalContentView = this.portalContentAnchor.createEmbeddedView(this.portalContentTemplate);
218219
safeDetectChanges(this.portalContentView);
219220
this.portalContentRendered = true;

Diff for: libs/core/src/lib/utils/signal-store.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ export function signalStore<State extends object>(
146146

147147
const computedCache = new Map();
148148

149+
if (!options) {
150+
options = { equal: Object.is };
151+
}
152+
149153
if (typeof initialState === 'function') {
150154
source = signal({} as State, options);
151155
state = source.asReadonly();
@@ -180,5 +184,5 @@ function parseStoreOptions(keysAndOptions: any[]): [string[], CreateComputedOpti
180184
return [keysAndOptions.slice(0, -1), keysAndOptions.at(-1)];
181185
}
182186

183-
return [keysAndOptions];
187+
return [keysAndOptions, { equal: Object.is }];
184188
}

Diff for: libs/plugin/generators.json

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"factory": "./src/generators/init-cannon/generator",
2323
"schema": "./src/generators/init-cannon/schema.json",
2424
"description": "Init Angular Three cannon with proper packages "
25+
},
26+
"rapier": {
27+
"factory": "./src/generators/init-rapier/generator",
28+
"schema": "./src/generators/init-rapier/schema.json",
29+
"description": "Init Angular Three rapier with proper packages "
2530
}
2631
},
2732
"schematics": {
@@ -44,6 +49,11 @@
4449
"factory": "./src/generators/init-cannon/compat",
4550
"schema": "./src/generators/init-cannon/schema.json",
4651
"description": "Init Angular Three cannon with proper packages "
52+
},
53+
"rapier": {
54+
"factory": "./src/generators/init-rapier/compat",
55+
"schema": "./src/generators/init-rapier/schema.json",
56+
"description": "Init Angular Three rapier with proper packages "
4757
}
4858
}
4959
}

Diff for: libs/plugin/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66
"packageGroup": [
77
"angular-three-soba",
88
"angular-three-postprocessing",
9-
"angular-three-cannon"
9+
"angular-three-cannon",
10+
"angular-three-rapier"
1011
]
1112
},
1213
"ng-update": {
1314
"migrations": "./migrations.json",
1415
"packageGroup": [
1516
"angular-three-soba",
1617
"angular-three-postprocessing",
17-
"angular-three-cannon"
18+
"angular-three-cannon",
19+
"angular-three-rapier"
1820
]
1921
},
2022
"dependencies": {

Diff for: libs/plugin/src/generators/init-rapier/compat.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { convertNxGenerator } from '@nx/devkit';
2+
import init from './generator';
3+
4+
export default convertNxGenerator(init);
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { readJson, Tree } from '@nx/devkit';
2+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3+
import { ANGULAR_THREE_VERSION, RAPIER_COMPAT_VERSION } from '../versions';
4+
import init from './generator';
5+
6+
describe('init generator', () => {
7+
let appTree: Tree;
8+
9+
beforeEach(() => {
10+
appTree = createTreeWithEmptyWorkspace();
11+
});
12+
13+
it('should add three dependencies', async () => {
14+
await init(appTree);
15+
16+
const packageJson = readJson(appTree, 'package.json');
17+
18+
expect(packageJson.dependencies['angular-three-rapier']).toEqual(ANGULAR_THREE_VERSION);
19+
expect(packageJson.dependencies['@dimforge/rapier3d-compat']).toEqual(RAPIER_COMPAT_VERSION);
20+
});
21+
});

Diff for: libs/plugin/src/generators/init-rapier/generator.ts

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { addDependenciesToPackageJson, installPackagesTask, logger, readJson, type Tree } from '@nx/devkit';
2+
import { ANGULAR_THREE_VERSION, NGXTENSION_VERSION, RAPIER_COMPAT_VERSION } from '../versions';
3+
4+
export default async function (tree: Tree) {
5+
logger.log('Initializing Angular Three Rapier...');
6+
7+
const packageJson = readJson(tree, 'package.json');
8+
9+
const version =
10+
packageJson['dependencies']?.['angular-three'] ||
11+
packageJson['devDependencies']?.['angular-three'] ||
12+
ANGULAR_THREE_VERSION;
13+
14+
addDependenciesToPackageJson(
15+
tree,
16+
{
17+
'angular-three-rapier': version,
18+
'angular-three-soba': version,
19+
'@dimforge/rapier3d-compat': RAPIER_COMPAT_VERSION,
20+
ngxtension: NGXTENSION_VERSION,
21+
},
22+
{},
23+
);
24+
25+
return () => {
26+
installPackagesTask(tree);
27+
};
28+
}

Diff for: libs/plugin/src/generators/init-rapier/schema.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"cli": "nx",
4+
"$id": "Init",
5+
"title": "Init Angular Three Cannon"
6+
}

Diff for: libs/plugin/src/generators/versions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@ export const CANNON_WORKER_API_VERSION = '^2.0.0';
1414
export const CANNON_ES_VERSION = '^0.20.0';
1515
export const CANNON_ES_DEBUGGER_VERSION = '^1.0.0';
1616

17+
export const RAPIER_COMPAT_VERSION = '0.11.2';
18+
1719
export const NGXTENSION_VERSION = '^0.3.0';

Diff for: libs/plugin/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export { default as initCannonGenerator } from './generators/init-cannon/generator';
12
export { default as initPostprocessingGenerator } from './generators/init-postprocessing/generator';
3+
export { default as initRapierGenerator } from './generators/init-rapier/generator';
24
export { default as initSobaGenerator } from './generators/init-soba/generator';
35
export { default as initGenerator } from './generators/init/generator';

Diff for: libs/rapier/.eslintrc.json

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts"],
7+
"extends": ["plugin:@nx/angular", "plugin:@angular-eslint/template/process-inline-templates"],
8+
"rules": {
9+
"@angular-eslint/directive-selector": [
10+
"error",
11+
{
12+
"type": "attribute",
13+
"prefix": "platform",
14+
"style": "camelCase"
15+
}
16+
],
17+
"@angular-eslint/component-selector": [
18+
"error",
19+
{
20+
"type": "element",
21+
"prefix": "platform",
22+
"style": "kebab-case"
23+
}
24+
]
25+
}
26+
},
27+
{
28+
"files": ["*.html"],
29+
"extends": ["plugin:@nx/angular-template"],
30+
"rules": {}
31+
},
32+
{
33+
"files": ["*.json"],
34+
"parser": "jsonc-eslint-parser",
35+
"rules": {
36+
"@nx/dependency-checks": "error"
37+
}
38+
}
39+
]
40+
}

Diff for: libs/rapier/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# rapier
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
## Running unit tests
6+
7+
Run `nx test rapier` to execute the unit tests.

Diff for: libs/rapier/jest.config.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'rapier',
4+
preset: '../../jest.preset.js',
5+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6+
coverageDirectory: '../../coverage/libs/rapier',
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
],
22+
};

Diff for: libs/rapier/ng-package.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../dist/libs/rapier",
4+
"lib": {
5+
"entryFile": "src/index.ts"
6+
}
7+
}

Diff for: libs/rapier/package.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "angular-three-rapier",
3+
"version": "0.0.0-replace",
4+
"publishConfig": {
5+
"access": "public"
6+
},
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/angular-threejs/angular-three/tree/main/libs/rapier"
10+
},
11+
"author": {
12+
"name": "Chau Tran",
13+
"email": "nartc7789@gmail.com",
14+
"url": "https://nartc.me"
15+
},
16+
"description": "Cannon.js physics integration with Angular Three",
17+
"keywords": [
18+
"angular",
19+
"threejs",
20+
"renderer",
21+
"rapier",
22+
"physics"
23+
],
24+
"license": "MIT",
25+
"peerDependencies": {
26+
"@angular/common": " ^16.0.0",
27+
"@angular/core": " ^16.0.0",
28+
"@dimforge/rapier3d-compat": "0.11.2",
29+
"angular-three": "^2.0.0",
30+
"angular-three-soba": "^2.0.0",
31+
"ngxtension": "^0.1.0",
32+
"three": ">=0.148.0"
33+
},
34+
"dependencies": {
35+
"tslib": "^2.3.0"
36+
},
37+
"sideEffects": false
38+
}

Diff for: libs/rapier/project.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "rapier",
3+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/rapier/src",
5+
"prefix": "platform",
6+
"tags": [],
7+
"projectType": "library",
8+
"targets": {
9+
"build": {
10+
"executor": "@nx/angular:package",
11+
"outputs": ["{workspaceRoot}/dist/{projectRoot}"],
12+
"options": {
13+
"project": "libs/rapier/ng-package.json"
14+
},
15+
"configurations": {
16+
"production": {
17+
"tsConfig": "libs/rapier/tsconfig.lib.prod.json"
18+
},
19+
"development": {
20+
"tsConfig": "libs/rapier/tsconfig.lib.json"
21+
}
22+
},
23+
"defaultConfiguration": "production"
24+
},
25+
"test": {
26+
"executor": "@nx/jest:jest",
27+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
28+
"options": {
29+
"jestConfig": "libs/rapier/jest.config.ts",
30+
"passWithNoTests": true
31+
},
32+
"configurations": {
33+
"ci": {
34+
"ci": true,
35+
"codeCoverage": true
36+
}
37+
}
38+
},
39+
"lint": {
40+
"executor": "@nx/linter:eslint",
41+
"outputs": ["{options.outputFile}"],
42+
"options": {
43+
"lintFilePatterns": ["libs/rapier/**/*.ts", "libs/rapier/**/*.html", "libs/rapier/package.json"]
44+
}
45+
}
46+
}
47+
}

Diff for: libs/rapier/src/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './lib/instanced-rigid-bodies';
2+
export * from './lib/physics';
3+
export * from './lib/rigid-body';
4+
export * from './lib/types';

0 commit comments

Comments
 (0)