name color test

This commit is contained in:
Evert Prants 2022-04-11 22:57:54 +03:00
parent 686f1c9123
commit e33924329c
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
4 changed files with 18 additions and 11 deletions

View File

@ -11,7 +11,7 @@ import { PonyEyes } from './object/other/eyes';
import { VideoPlayer } from './object/other/video-player'; import { VideoPlayer } from './object/other/video-player';
import { Player } from './object/player'; import { Player } from './object/player';
import { PlayerEntity } from './object/player-entity'; 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 { ClientWorld } from './object/world/ClientWorld';
import { ClientWorldLoader } from './object/world/ClientWorldLoader'; import { ClientWorldLoader } from './object/world/ClientWorldLoader';
import { ClientWorldManifest } from './object/world/ClientWorldManifest'; import { ClientWorldManifest } from './object/world/ClientWorldManifest';
@ -40,7 +40,7 @@ export class Game {
const cube = await CubeMap.load('/assets/skybox/default'); const cube = await CubeMap.load('/assets/skybox/default');
await modelLoaderInstance.loadPonyModel(); await PonyModel.getInstance().loadPonyModel();
await PonyEyes.getInstance().initialize(); await PonyEyes.getInstance().initialize();
await this.world.initialize(); await this.world.initialize();

View File

@ -4,7 +4,7 @@ import seedrandom from 'seedrandom';
const nameColorPallete = { const nameColorPallete = {
H: [1, 360], H: [1, 360],
S: [0, 100], S: [0, 100],
L: [50, 100], L: [50, 80],
}; };
export class Chat { export class Chat {

View File

@ -9,7 +9,9 @@ const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderPath('/examples/js/libs/draco/'); dracoLoader.setDecoderPath('/examples/js/libs/draco/');
loader.setDRACOLoader(dracoLoader); loader.setDRACOLoader(dracoLoader);
class PonyModel { let instance: PonyModel;
export class PonyModel {
public ponyModel!: THREE.Group; public ponyModel!: THREE.Group;
public animations!: THREE.AnimationClip[]; public animations!: THREE.AnimationClip[];
@ -46,7 +48,11 @@ class PonyModel {
); );
}); });
} }
}
const modelLoaderInstance = new PonyModel(); public static getInstance(): PonyModel {
export default modelLoaderInstance; if (!instance) {
instance = new PonyModel();
}
return instance;
}
}

View File

@ -1,5 +1,4 @@
import * as SkeletonUtils from 'three/examples/jsm/utils/SkeletonUtils'; import * as SkeletonUtils from 'three/examples/jsm/utils/SkeletonUtils';
import modelLoaderInstance from './pony-loader';
import { CharacterPacket, FullStatePacket } from '../../common/types/packet'; import { CharacterPacket, FullStatePacket } from '../../common/types/packet';
import { NameTag } from './nametag'; import { NameTag } from './nametag';
import { CanvasUtils } from './canvas-utils'; import { CanvasUtils } from './canvas-utils';
@ -15,6 +14,7 @@ import {
} from 'three'; } from 'three';
import { ClientWorld } from './world/ClientWorld'; import { ClientWorld } from './world/ClientWorld';
import { PonyEyes } from './other/eyes'; import { PonyEyes } from './other/eyes';
import { PonyModel } from './pony-loader';
const nameTagBuilder = new CanvasUtils({ const nameTagBuilder = new CanvasUtils({
fill: false, fill: false,
@ -39,7 +39,8 @@ export class PonyEntity {
public heightSource?: ClientWorld; public heightSource?: ClientWorld;
initialize() { initialize() {
this.model = (SkeletonUtils as any).clone(modelLoaderInstance.ponyModel); const loader = PonyModel.getInstance();
this.model = (SkeletonUtils as any).clone(loader.ponyModel);
this.material = ( this.material = (
(this.model.children[0].children[1] as Mesh) (this.model.children[0].children[1] as Mesh)
.material as MeshStandardMaterial .material as MeshStandardMaterial
@ -48,8 +49,8 @@ export class PonyEntity {
(this.model.children[0].children[2] as Mesh).material = (this.model.children[0].children[2] as Mesh).material =
PonyEyes.getInstance().getShader(); PonyEyes.getInstance().getShader();
this.mixer = new AnimationMixer(this.model); this.mixer = new AnimationMixer(this.model);
this.idleAction = this.mixer.clipAction(modelLoaderInstance.animations[0]); this.idleAction = this.mixer.clipAction(loader.animations[0]);
this.walkAction = this.mixer.clipAction(modelLoaderInstance.animations[2]); this.walkAction = this.mixer.clipAction(loader.animations[2]);
this.idleAction.play(); this.idleAction.play();
this.container = new Object3D(); this.container = new Object3D();
this.container.add(this.model); this.container.add(this.model);