Skip to content

Commit aea07c6

Browse files
committed
docs: more on aviator
1 parent 1127e36 commit aea07c6

File tree

8 files changed

+28
-24
lines changed

8 files changed

+28
-24
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"useTabs": true,
44
"tabWidth": 4,
55
"printWidth": 120,
6-
"plugins": ["prettier-plugin-organize-imports"]
6+
"plugins": ["prettier-plugin-organize-imports"],
7+
"htmlWhitespaceSensitivity": "ignore"
78
}
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,14 @@
11
<ngt-canvas [sceneGraph]="scene" [camera]="{ fov: 50, near: 0.1, far: 10000 }" [shadows]="true" />
2-
<span style="position: absolute; top: 0; right: 1rem; font-size: xxx-large; color: #ffd700">{{ game.coins }}</span>
2+
<span
3+
style="
4+
position: absolute;
5+
top: 1rem;
6+
right: 1rem;
7+
font-size: x-large;
8+
font-family: 'Exo 2';
9+
font-weight: bold;
10+
color: #ffd700;
11+
"
12+
>
13+
Coins: {{ game.coins }}
14+
</span>

apps/sandbox/src/app/aviator/canvas.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ import { WorldService } from './services/world.service';
1313
})
1414
export class AviatorCanvas {
1515
scene = AviatorScene;
16-
1716
game = inject(GameService);
1817
}

apps/sandbox/src/app/aviator/components/airplane/propeller/propeller.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[geometry]="bladeGeometryRef.nativeElement"
2020
/>
2121

22-
<!-- blade 1 -->
22+
<!-- blade 2 -->
2323
<ngt-mesh
2424
[position]="[8, 0, 0]"
2525
[rotation]="[Math.PI / 2, 0, 0]"

apps/sandbox/src/app/aviator/components/sky/cloud/cloud.component.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<ngt-object3D (afterAttach)="afterAttach.emit($event.node)" (beforeRender)="onCloudBeforeRender($event)">
2-
<ngt-box-geometry *args="[20, 20, 20]" [ref]="cloudGeometryRef" />
3-
<ngt-mesh-phong-material [color]="Colors.white" />
2+
<ngt-box-geometry *args="[20, 20, 20]" [ref]="cloudGeometryRef" attach="none" />
3+
<ngt-mesh-phong-material #material [color]="Colors.white" attach="none" />
44

55
<ngt-mesh
66
*ngFor="let i; repeat: count"
77
[geometry]="cloudGeometryRef.nativeElement"
8+
[material]="material"
89
[castShadow]="true"
910
[receiveShadow]="true"
1011
(afterAttach)="onAfterMeshAttach($event, i)"

apps/sandbox/src/app/aviator/services/game.service.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { ChangeDetectorRef, Injectable, inject } from '@angular/core';
1+
import { Injectable, NgZone, inject } from '@angular/core';
22
import { WorldService } from './world.service';
33

44
@Injectable()
55
export class GameService {
6-
private cdr = inject(ChangeDetectorRef);
7-
world = inject(WorldService);
6+
private zone = inject(NgZone);
7+
private world = inject(WorldService);
88

99
status = 'playing';
1010

@@ -50,8 +50,9 @@ export class GameService {
5050
};
5151

5252
addCoin() {
53-
this.coins += 1;
54-
this.statistics.coinsCollected += 1;
55-
this.cdr.detectChanges();
53+
this.zone.run(() => {
54+
this.coins += 1;
55+
this.statistics.coinsCollected += 1;
56+
});
5657
}
5758
}

apps/sandbox/src/app/aviator/utils/collectibles.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,11 @@ export class Coin extends THREE.Mesh implements Collectible {
4747
if (collide(this.refs.airplane, this, this.world.coinDistanceTolerance)) {
4848
spawnParticles(this.position.clone(), 5, COLOR_COINS, 0.8, this.scene);
4949
this.game.addCoin();
50+
// audioManager.play('coin', { volume: 0.5 });
5051
this.collectibles.remove(this);
5152
} else if (this.angle > Math.PI) {
5253
this.collectibles.remove(this);
5354
}
5455
}
55-
56-
// collision?
57-
// if (collide(airplane.mesh, this.mesh, this.world.coinDistanceTolerance)) {
58-
// spawnParticles(this.mesh.position.clone(), 5, COLOR_COINS, 0.8);
59-
// addCoin();
60-
// audioManager.play('coin', { volume: 0.5 });
61-
// sceneManager.remove(this);
62-
// }
63-
// // passed-by?
64-
// else if (this.angle > Math.PI) {
65-
// sceneManager.remove(this);
66-
// }
6756
}
6857
}

apps/sandbox/src/styles.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* You can add global styles to this file, and also import other style files */
2+
@import url('https://fonts.googleapis.com/css2?family=Exo+2:wght@300;700&display=swap');
23

34
* {
45
box-sizing: border-box;

0 commit comments

Comments
 (0)