make player model changable

This commit is contained in:
Marius Unsel 2026-02-24 01:26:17 +01:00
parent efd4369f41
commit 7b0dbddc45
2 changed files with 5 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import * as THREE from 'three';
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
import { AppState } from '../store';
import { connect } from 'react-redux';
import { PLAYER_MODEL_FILENAME } from '../game/player';
interface TalkyFaceProps {
@ -58,7 +59,7 @@ class TalkyFace extends Component<TalkyFaceProps> {
// ROBOT MODEL
this.clock = new THREE.Clock()
let loader = new GLTFLoader();
loader.load('assets/models/RobotExpressive.glb', (gltf) => {
loader.load(PLAYER_MODEL_FILENAME, (gltf) => {
this.model = gltf.scene;
this.animations = gltf.animations;
this.mixer = new THREE.AnimationMixer(this.model)

View File

@ -13,7 +13,8 @@ import { wonLevel } from '../store/executionState/actions';
// model control from https://github.com/mrdoob/three.js/blob/master/examples/webgl_animation_skinning_morph.html
// var states = ['Idle', 'Walking', 'Running', 'Dance', 'Death', 'Sitting', 'Standing'];
// var emotes = ['Jump', 'Yes', 'No', 'Wave', 'Punch', 'ThumbsUp'];
export const PLAYER_MODEL_FILENAME = '/assets/models/RobotExpressive.glb'
//export const PLAYER_MODEL_FILENAME = '/assets/models/robot.glb'
export class Player {
scene: THREE.Scene;
model: THREE.Object3D;
@ -32,7 +33,7 @@ export class Player {
this.level = level;
this.clock = new THREE.Clock()
let loader = new GLTFLoader();
loader.load('assets/models/RobotExpressive.glb', (gltf) => {
loader.load(PLAYER_MODEL_FILENAME, (gltf) => {
this.model = gltf.scene;
this.animations = gltf.animations;
this.mixer = new THREE.AnimationMixer(this.model)