@@ -18,6 +18,7 @@ import {
1818 type BoundingBox ,
1919 SceneLoader
2020} from '@babylonjs/core' ;
21+ import '@babylonjs/loaders/glTF'
2122//@ts -ignore
2223import * as CANNON from 'cannon' ;
2324import type { Size3D } from './types' ;
@@ -46,6 +47,7 @@ export class Game {
4647 private readonly platforms : Mesh [ ] ;
4748 private readonly walls : Mesh [ ] ;
4849 private readonly ball : Mesh ;
50+ private coinModel : Mesh ;
4951 private readonly shadowGenerator : ShadowGenerator ;
5052
5153
@@ -73,14 +75,14 @@ export class Game {
7375 //this.ball.showBoundingBox = true;
7476 //this.walls.forEach(w => w.showBoundingBox = true);
7577
78+ this . loadCoinModel ( ) ;
79+
7680 this . scene . registerBeforeRender ( this . checkSphereBoxCollision . bind ( this ) ) ;
7781
7882 this . engine . runRenderLoop ( ( ) => {
7983 this . updateCameraAndLight ( ) ;
8084 this . scene . render ( ) ;
8185 } ) ;
82-
83- this . loadCoinModel ( ) ;
8486 }
8587
8688 private loadCoinModel ( ) {
@@ -97,6 +99,11 @@ export class Game {
9799 const coin = meshArray [ 0 ] ;
98100 coin . scaling = new Vector3 ( 0.07 , 0.07 , 0.07 ) ;
99101 coin . position = new Vector3 ( 2 , 1 , 0 ) ;
102+
103+ this . coinModel = coin ;
104+
105+ this . shadowGenerator . addShadowCaster ( coin ) ;
106+ coin . receiveShadows = true ;
100107 }
101108 ) ;
102109 }
0 commit comments