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

libs/core/package.json

Lines changed: 4 additions & 2 deletions
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"

libs/core/src/lib/portal.ts

Lines changed: 1 addition & 0 deletions
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;

libs/core/src/lib/utils/signal-store.ts

Lines changed: 5 additions & 1 deletion
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
}

libs/plugin/generators.json

Lines changed: 10 additions & 0 deletions
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
}

libs/plugin/package.json

Lines changed: 4 additions & 2 deletions
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": {
Lines changed: 4 additions & 0 deletions
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);
Lines changed: 21 additions & 0 deletions
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+
});
Lines changed: 28 additions & 0 deletions
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+
}
Lines changed: 6 additions & 0 deletions
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+
}

libs/plugin/src/generators/versions.ts

Lines changed: 2 additions & 0 deletions
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';

0 commit comments

Comments
 (0)