Skip to content

Commit 6203ee8

Browse files
kevinrev26racsoraul
authored andcommitted
Solutions #1
1 parent eb6beae commit 6203ee8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Monster3DProfile extends Component {
2929
async componentDidMount() {
3030

3131
const { background, typeId, isDead, ambientIntensity, ambientColor, directIntensity, directColor, zoom } = this.props
32+
this.lastId = typeId;
3233

3334
const mon = monsterType(typeId, isDead ? isDead : false)
3435

@@ -356,18 +357,20 @@ class Monster3DProfile extends Component {
356357
this.controls.autoRotate = autoRotate
357358
this.controls.autoRotateSpeed = autoRotateSpeed
358359

359-
//this.dettachMonster();
360-
361-
/*try {
362-
console.log(monster3D(mon.model))
363-
await gltfLoader(monster3D(mon.model), this.loadMonster);
364-
} catch (error) {
365-
console.log(error)
366-
}*///
360+
if( this.lastId !== typeId ){
361+
this.dettachMonster();
362+
try {
363+
console.log(monster3D(mon.model))
364+
await gltfLoader(monster3D(mon.model), this.loadMonster);
365+
} catch (error) {
366+
console.log(error)
367+
}
368+
this.lastId = typeId
369+
}
367370

368371
// darken or light the monster according to current 'action'
369372
this.monsterLightColor(action)
370-
373+
//
371374
}
372375

373376
// plays the requested animation by the 'action' prop

0 commit comments

Comments
 (0)