diff --git a/src/client/game.ts b/src/client/game.ts index 8124db5..a901a90 100644 --- a/src/client/game.ts +++ b/src/client/game.ts @@ -11,7 +11,7 @@ import { PonyEyes } from './object/other/eyes'; import { VideoPlayer } from './object/other/video-player'; import { Player } from './object/player'; import { PlayerEntity } from './object/player-entity'; -import modelLoaderInstance from './object/pony-loader'; +import { PonyModel } from './object/pony-loader'; import { ClientWorld } from './object/world/ClientWorld'; import { ClientWorldLoader } from './object/world/ClientWorldLoader'; import { ClientWorldManifest } from './object/world/ClientWorldManifest'; @@ -40,7 +40,7 @@ export class Game { const cube = await CubeMap.load('/assets/skybox/default'); - await modelLoaderInstance.loadPonyModel(); + await PonyModel.getInstance().loadPonyModel(); await PonyEyes.getInstance().initialize(); await this.world.initialize(); diff --git a/src/client/object/chat.ts b/src/client/object/chat.ts index 8c4213c..18b5dad 100644 --- a/src/client/object/chat.ts +++ b/src/client/object/chat.ts @@ -4,7 +4,7 @@ import seedrandom from 'seedrandom'; const nameColorPallete = { H: [1, 360], S: [0, 100], - L: [50, 100], + L: [50, 80], }; export class Chat { diff --git a/src/client/object/pony-loader.ts b/src/client/object/pony-loader.ts index b2d166f..f3c0a64 100644 --- a/src/client/object/pony-loader.ts +++ b/src/client/object/pony-loader.ts @@ -9,7 +9,9 @@ const dracoLoader = new DRACOLoader(); dracoLoader.setDecoderPath('/examples/js/libs/draco/'); loader.setDRACOLoader(dracoLoader); -class PonyModel { +let instance: PonyModel; + +export class PonyModel { public ponyModel!: THREE.Group; public animations!: THREE.AnimationClip[]; @@ -46,7 +48,11 @@ class PonyModel { ); }); } -} -const modelLoaderInstance = new PonyModel(); -export default modelLoaderInstance; + public static getInstance(): PonyModel { + if (!instance) { + instance = new PonyModel(); + } + return instance; + } +} diff --git a/src/client/object/pony.ts b/src/client/object/pony.ts index 74d3f5d..22ad287 100644 --- a/src/client/object/pony.ts +++ b/src/client/object/pony.ts @@ -1,5 +1,4 @@ import * as SkeletonUtils from 'three/examples/jsm/utils/SkeletonUtils'; -import modelLoaderInstance from './pony-loader'; import { CharacterPacket, FullStatePacket } from '../../common/types/packet'; import { NameTag } from './nametag'; import { CanvasUtils } from './canvas-utils'; @@ -15,6 +14,7 @@ import { } from 'three'; import { ClientWorld } from './world/ClientWorld'; import { PonyEyes } from './other/eyes'; +import { PonyModel } from './pony-loader'; const nameTagBuilder = new CanvasUtils({ fill: false, @@ -39,7 +39,8 @@ export class PonyEntity { public heightSource?: ClientWorld; initialize() { - this.model = (SkeletonUtils as any).clone(modelLoaderInstance.ponyModel); + const loader = PonyModel.getInstance(); + this.model = (SkeletonUtils as any).clone(loader.ponyModel); this.material = ( (this.model.children[0].children[1] as Mesh) .material as MeshStandardMaterial @@ -48,8 +49,8 @@ export class PonyEntity { (this.model.children[0].children[2] as Mesh).material = PonyEyes.getInstance().getShader(); this.mixer = new AnimationMixer(this.model); - this.idleAction = this.mixer.clipAction(modelLoaderInstance.animations[0]); - this.walkAction = this.mixer.clipAction(modelLoaderInstance.animations[2]); + this.idleAction = this.mixer.clipAction(loader.animations[0]); + this.walkAction = this.mixer.clipAction(loader.animations[2]); this.idleAction.play(); this.container = new Object3D(); this.container.add(this.model);