Hi,
I wrote all my class like this example, everything works good.
import * as THREE from "https://threejs.org/build/three.module.js";
class Enemy {
constructor(sce) {
this.mesh = new THREE.Object3D();
let geometry = new THREE.BoxGeometry(50, 50, 50);
let mat = new THREE.MeshPhongMaterial({
color: params.color_enemy,
});
let enemy = new THREE.Mesh(geometry, mat);
this.mesh.add(enemy)
sce.add(this.mesh)
}
}
}
export default Enemy;
My problem is that i use ‘this.mesh’ to access my entity, so when i would like modify the position
i must do this :
let enemy = new Enemy(scene)
enemy.mesh.position.set((0,1,2)
What i would like to do is to access directly my entity like this :
enemy.position.set((0,1,2)
For that i must refer “this” to the object itself in my class but i don’t know how…
Could you show me the good syntax ?
Thanks.