Frank_Vr
Frank_Vr

Reputation: 659

object orientated javascript

I've got this object player1 and i can't get the scene.add(Obj); line to work as it comes up with an error saying Obj does not exist:

function Player(x, y, z) {
 this.Speed = 0;
 this.AngleAcc = 0;
 this.Angle = 0;
 this.X=x;
 this.Y=y;
 this.Z=z;
 this.MaxSpeed = 100;

 var PlayerMateririal = new THREE.MeshLambertMaterial({ color: 0x00ff80, overdraw: 0.5 });
 this.Obj = new THREE.Mesh(new THREE.BoxGeometry(50, 90, 60), PlayerMateririal);
 scene.add(Obj);
 Obj.position.set(x, y, z);
}

thanks i'm using Three.js and want to set the Obj position in other locations hence why i'm setting it up as a property.

Upvotes: 0

Views: 55

Answers (1)

Iram
Iram

Reputation: 276

Use this keyword

scene.add(this.Obj);

Upvotes: 1

Related Questions