Skip to content

Commit b30cb10

Browse files
committed
chore(repo): adjust to new APIs
1 parent 5e4b6f6 commit b30cb10

File tree

149 files changed

+718
-681
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+718
-681
lines changed

apps/examples/src/app/cannon/basic/scene.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { Triplet } from '@pmndrs/cannon-worker-api';
1313
import { NgtArgs } from 'angular-three';
1414
import { NgtcPhysics } from 'angular-three-cannon';
15-
import { injectBox, injectPlane } from 'angular-three-cannon/body';
15+
import { box, plane } from 'angular-three-cannon/body';
1616
import { NgtcDebug } from 'angular-three-cannon/debug';
1717
import { Mesh } from 'three';
1818
import { State } from './state';
@@ -35,7 +35,7 @@ export class Plane {
3535
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
3636

3737
constructor() {
38-
injectPlane(() => ({ mass: 0, position: this.position(), args: this.args }), this.mesh);
38+
plane(() => ({ mass: 0, position: this.position(), args: this.args }), this.mesh);
3939
}
4040
}
4141

@@ -57,7 +57,7 @@ export class Box {
5757
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
5858

5959
constructor() {
60-
injectBox(() => ({ mass: 10000, position: this.position(), args: this.args }), this.mesh);
60+
box(() => ({ mass: 10000, position: this.position(), args: this.args }), this.mesh);
6161
}
6262
}
6363

apps/examples/src/app/cannon/chain/scene.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import {
1616
} from '@angular/core';
1717
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
1818
import { CylinderArgs, Triplet } from '@pmndrs/cannon-worker-api';
19-
import { NgtArgs, injectBeforeRender, injectStore } from 'angular-three';
19+
import { NgtArgs, beforeRender, injectStore } from 'angular-three';
2020
import { NgtcPhysics } from 'angular-three-cannon';
21-
import { injectBox, injectCylinder, injectSphere } from 'angular-three-cannon/body';
22-
import { injectConeTwist } from 'angular-three-cannon/constraint';
21+
import { box, cylinder, sphere } from 'angular-three-cannon/body';
22+
import { coneTwist } from 'angular-three-cannon/constraint';
2323
import { Color, ColorRepresentation, Mesh, Object3D } from 'three';
2424

2525
interface Handle {
@@ -63,15 +63,12 @@ export class ChainLink {
6363
protected mesh = viewChild.required<ElementRef<Mesh>>('mesh');
6464

6565
constructor() {
66-
injectCylinder(
67-
() => ({ mass: 1, args: this.args(), linearDamping: 0.8, position: this.position() }),
68-
this.mesh,
69-
);
66+
cylinder(() => ({ mass: 1, args: this.args(), linearDamping: 0.8, position: this.position() }), this.mesh);
7067

7168
const injector = inject(Injector);
7269
// NOTE: we want to run this in afterNextRender because we want the input to resolve
7370
afterNextRender(() => {
74-
injectConeTwist(this.parent.ref, this.mesh, {
71+
coneTwist(this.parent.ref, this.mesh, {
7572
injector,
7673
options: {
7774
angle: Math.PI / 8,
@@ -143,9 +140,9 @@ export class PointerHandle {
143140
protected mesh = viewChild.required<ElementRef<Mesh>>('mesh');
144141

145142
constructor() {
146-
const boxApi = injectBox(() => ({ args: this.args, position: this.position, type: 'Kinematic' }), this.mesh);
143+
const boxApi = box(() => ({ args: this.args, position: this.position, type: 'Kinematic' }), this.mesh);
147144

148-
injectBeforeRender(({ pointer: { x, y }, viewport: { width, height } }) => {
145+
beforeRender(({ pointer: { x, y }, viewport: { width, height } }) => {
149146
boxApi()?.position.set((x * width) / 2, (y * height) / 2, 0);
150147
});
151148
}
@@ -173,7 +170,7 @@ export class StaticHandle {
173170
protected mesh = viewChild.required<ElementRef<Mesh>>('mesh');
174171

175172
constructor() {
176-
injectSphere(() => ({ args: [1.5], position: this.position(), type: 'Static' }), this.mesh);
173+
sphere(() => ({ args: [1.5], position: this.position(), type: 'Static' }), this.mesh);
177174
}
178175
}
179176

apps/examples/src/app/cannon/compound/scene.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
import { Triplet } from '@pmndrs/cannon-worker-api';
1515
import { NgtArgs } from 'angular-three';
1616
import { NgtcPhysics } from 'angular-three-cannon';
17-
import { injectCompound, injectPlane } from 'angular-three-cannon/body';
17+
import { compound, plane } from 'angular-three-cannon/body';
1818
import { NgtcDebug } from 'angular-three-cannon/debug';
1919
import { Group } from 'three';
2020

@@ -41,7 +41,7 @@ export class Plane {
4141
private group = viewChild.required<ElementRef<Group>>('group');
4242

4343
constructor() {
44-
injectPlane(() => ({ type: 'Static', rotation: this.rotation() }), this.group);
44+
plane(() => ({ type: 'Static', rotation: this.rotation() }), this.group);
4545
}
4646
}
4747

@@ -78,7 +78,7 @@ export class CompoundBody {
7878
private group = viewChild.required<ElementRef<Group>>('group');
7979

8080
constructor() {
81-
const compoundApi = injectCompound(
81+
const compoundApi = compound(
8282
() => ({
8383
isTrigger: this.isTrigger(),
8484
mass: this.mass(),

apps/examples/src/app/cannon/convexpolyhedron/scene.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
import { Triplet } from '@pmndrs/cannon-worker-api';
1313
import { NgtArgs } from 'angular-three';
1414
import { NgtcPhysics } from 'angular-three-cannon';
15-
import { injectConvexPolyhedron } from 'angular-three-cannon/body';
15+
import { convexPolyhedron } from 'angular-three-cannon/body';
1616
import { NgtcDebug } from 'angular-three-cannon/debug';
17-
import { injectGLTF } from 'angular-three-soba/loaders';
17+
import { gltfResource } from 'angular-three-soba/loaders';
1818
import { BoxGeometry, BufferGeometry, ConeGeometry, Mesh } from 'three';
1919
import { GLTF, Geometry } from 'three-stdlib';
2020
import { UiPlane } from '../ui/plane';
@@ -57,7 +57,7 @@ export class Cone {
5757
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
5858

5959
constructor() {
60-
injectConvexPolyhedron(
60+
convexPolyhedron(
6161
() => ({
6262
args: this.args(),
6363
mass: 100,
@@ -98,7 +98,7 @@ export class Cube {
9898
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
9999

100100
constructor() {
101-
injectConvexPolyhedron(
101+
convexPolyhedron(
102102
() => ({
103103
args: this.args(),
104104
mass: 100,
@@ -137,9 +137,9 @@ type DiamondGLTF = GLTF & {
137137
export class Diamond {
138138
protected positionRotationInputs = inject(PositionRotationInput, { host: true });
139139

140-
private gltf = injectGLTF<DiamondGLTF>(() => './diamond.glb');
140+
private gltf = gltfResource<DiamondGLTF>(() => './diamond.glb');
141141
protected geometry = computed(() => {
142-
const gltf = this.gltf();
142+
const gltf = this.gltf.value();
143143
if (!gltf) return null;
144144
return gltf.nodes.Cylinder.geometry;
145145
});
@@ -152,7 +152,7 @@ export class Diamond {
152152
private mesh = viewChild<ElementRef<Mesh>>('mesh');
153153

154154
constructor() {
155-
injectConvexPolyhedron(
155+
convexPolyhedron(
156156
() => ({
157157
args: this.args(),
158158
mass: 100,

apps/examples/src/app/cannon/cube-heap/scene.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import {
1111
viewChild,
1212
} from '@angular/core';
1313
import { Triplet } from '@pmndrs/cannon-worker-api';
14-
import { NgtArgs, injectBeforeRender } from 'angular-three';
14+
import { NgtArgs, beforeRender } from 'angular-three';
1515
import { NgtcPhysics } from 'angular-three-cannon';
16-
import { NgtcBodyPublicApi, injectBox, injectPlane, injectSphere } from 'angular-three-cannon/body';
16+
import { NgtcBodyPublicApi, box, plane, sphere } from 'angular-three-cannon/body';
1717
import { Color, InstancedMesh, Mesh } from 'three';
1818
import niceColors from '../../colors';
1919
import { shape } from './state';
@@ -36,7 +36,7 @@ export class Plane {
3636
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
3737

3838
constructor() {
39-
injectPlane(() => ({ rotation: this.rotation() }), this.mesh);
39+
plane(() => ({ rotation: this.rotation() }), this.mesh);
4040
}
4141
}
4242

@@ -49,7 +49,7 @@ export abstract class InstancesInput {
4949
abstract bodyApi: Signal<NgtcBodyPublicApi | null>;
5050

5151
constructor() {
52-
injectBeforeRender(() => {
52+
beforeRender(() => {
5353
this.bodyApi()
5454
?.at(Math.floor(Math.random() * this.count()))
5555
.position.set(0, Math.random() * 2, 0);
@@ -75,7 +75,7 @@ export class Boxes extends InstancesInput {
7575
protected args = computed<Triplet>(() => [this.size(), this.size(), this.size()]);
7676
private mesh = viewChild<ElementRef<InstancedMesh>>('mesh');
7777

78-
bodyApi = injectBox(
78+
bodyApi = box(
7979
() => ({ args: this.args(), mass: 1, position: [Math.random() - 0.5, Math.random() * 2, Math.random() - 0.5] }),
8080
this.mesh,
8181
);
@@ -99,7 +99,7 @@ export class Spheres extends InstancesInput {
9999
protected args = computed<Triplet>(() => [this.size(), this.size(), this.size()]);
100100
private mesh = viewChild<ElementRef<InstancedMesh>>('mesh');
101101

102-
bodyApi = injectSphere(
102+
bodyApi = sphere(
103103
() => ({
104104
args: [this.size()],
105105
mass: 1,

apps/examples/src/app/cannon/kinematic-cube/scene.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import {
88
viewChild,
99
} from '@angular/core';
1010
import { Triplet } from '@pmndrs/cannon-worker-api';
11-
import { NgtArgs, injectBeforeRender } from 'angular-three';
11+
import { NgtArgs, beforeRender } from 'angular-three';
1212
import { NgtcPhysics } from 'angular-three-cannon';
13-
import { injectBox, injectPlane, injectSphere } from 'angular-three-cannon/body';
13+
import { box, plane, sphere } from 'angular-three-cannon/body';
1414
import { Color, InstancedMesh, Mesh } from 'three';
1515
import niceColors from '../../colors';
1616

@@ -34,7 +34,7 @@ export class Plane {
3434
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
3535

3636
constructor() {
37-
injectPlane(() => ({ position: this.position(), rotation: this.rotation() }), this.mesh);
37+
plane(() => ({ position: this.position(), rotation: this.rotation() }), this.mesh);
3838
}
3939
}
4040

@@ -56,9 +56,9 @@ export class Box {
5656
private mesh = viewChild.required<ElementRef<Mesh>>('mesh');
5757

5858
constructor() {
59-
const boxApi = injectBox(() => ({ args: this.args, mass: 1, type: 'Kinematic' }), this.mesh);
59+
const boxApi = box(() => ({ args: this.args, mass: 1, type: 'Kinematic' }), this.mesh);
6060

61-
injectBeforeRender(({ clock }) => {
61+
beforeRender(({ clock }) => {
6262
const api = boxApi();
6363
if (!api) return;
6464
const t = clock.elapsedTime;
@@ -100,7 +100,7 @@ export class InstancedSpheres {
100100
});
101101

102102
constructor() {
103-
injectSphere(
103+
sphere(
104104
(index) => ({
105105
args: [1],
106106
mass: 1,

0 commit comments

Comments
 (0)