}
placeGoal();
functionRamp(x, y) {
this.mesh =newPhysijs.ConvexMesh(
newTHREE.CylinderGeometry(5, height * 0.05, height * 0.25),
Physijs.createMaterial(
newTHREE.MeshBasicMaterial({color:0x0000cc}), 0.2, 1.0
),
0
);
this.move(x, y);
this.rotate(2*Math.PI*Math.random());
this.listenForEvents();
}
Ramp.prototype.move =function(x, y) {
this.mesh.position.x = this.mesh.position.x + x;
this.mesh.position.y = this.mesh.position.y + y;
this.mesh.__dirtyRotation = true;
this.mesh.__dirtyPosition = true;
};
Ramp.prototype.rotate =function(angle) {
this.mesh.rotation.z = this.mesh.rotation.z + angle;
this.mesh.__dirtyRotation = true;
this.mesh.__dirtyPosition = true;
};
Ramp.prototype.listenForEvents = function() {
varme = this,
mesh = this.mesh;
mesh.addEventListener('drag',function(event) {
me.move(event.x_diff, event.y_diff);
});
document.addEventListener('keydown',function(event) {
if(!mesh.isActive)return;
if(event.keyCode != 83)return;// S
me.rotate(0.1);
});
};
varramp1 =newRamp(-width/4, height/4);
scene.add(ramp1.mesh);
varramp2 =newRamp(width/4, -height/4);
scene.add(ramp2.mesh);
Appendix 1. Project Code • 262
Prepared exclusively for Michael Powell report erratum • discuss