mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Merge pull request #4914 from sethalves/airhockey-hull
airhockey -- various adjustments
This commit is contained in:
commit
85fac8394a
2 changed files with 56 additions and 35 deletions
|
@ -75,11 +75,13 @@ var paddle1Pos, paddle2Pos;
|
|||
var names = ["air-hockey-table-23j4h1jh82jsjfw91jf232n2k", // keep this synchronized with what's in grabHockey.js
|
||||
"air-hockey-paddle-23j4h1jh82jsjfw91jf232n2k",
|
||||
"air-hockey-puck-23j4h1jh82jsjfw91jf232n2k",
|
||||
"air-hockey-light-23j4h1jh82jsjfw91jf232n2k"];
|
||||
"air-hockey-light-23j4h1jh82jsjfw91jf232n2k",
|
||||
"air-hockey-floor-23j4h1jh82jsjfw91jf232n2k"];
|
||||
var table_name_index = 0;
|
||||
var paddle_name_index = 1;
|
||||
var puck_name_index = 2;
|
||||
var light_name_index = 3;
|
||||
var floor_name_index = 4;
|
||||
|
||||
|
||||
var deleteButton = Overlays.addOverlay("image", {
|
||||
|
@ -289,8 +291,40 @@ function mousePressEvent(event) {
|
|||
}
|
||||
|
||||
function spawnAllTheThings() {
|
||||
center = Vec3.sum(MyAvatar.position, Vec3.multiply((FIELD_WIDTH + FIELD_LENGTH) * 0.60, Quat.getFront(Camera.getOrientation())));
|
||||
table = Entities.addEntity({
|
||||
center = Vec3.sum(MyAvatar.position,
|
||||
Vec3.multiply((FIELD_WIDTH + FIELD_LENGTH) * 0.60, Quat.getFront(Camera.getOrientation())));
|
||||
|
||||
Entities.addEntity({
|
||||
name: names[floor_name_index],
|
||||
type: "Box",
|
||||
position: Vec3.subtract(center, {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
}),
|
||||
dimensions: {
|
||||
x: FIELD_WIDTH,
|
||||
y: FLOOR_THICKNESS,
|
||||
z: FIELD_LENGTH
|
||||
},
|
||||
color: {
|
||||
red: 128,
|
||||
green: 128,
|
||||
blue: 128
|
||||
},
|
||||
gravity: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
ignoreCollisions: false,
|
||||
locked: true,
|
||||
friction: floorFriction,
|
||||
visible: debugVisible,
|
||||
lifetime: LIFETIME
|
||||
});
|
||||
|
||||
Entities.addEntity({
|
||||
name: names[table_name_index],
|
||||
type: "Model",
|
||||
modelURL: polyTable,
|
||||
|
@ -301,7 +335,7 @@ function spawnAllTheThings() {
|
|||
z: 1.31
|
||||
}, MODEL_SCALE),
|
||||
position: Vec3.sum(center, MODEL_OFFSET),
|
||||
friction: floorFriction,
|
||||
restitution: edgeRestitution,
|
||||
ignoreCollisions: false,
|
||||
visible: true,
|
||||
locked: true,
|
||||
|
|
|
@ -11,29 +11,17 @@
|
|||
//
|
||||
|
||||
// these are hand-measured bounds of the AirHockey table
|
||||
var fieldHalfExtent = {
|
||||
var fieldMaxOffset = {
|
||||
x: 0.475,
|
||||
y: 0.315,
|
||||
z: 0.830
|
||||
z: 0.82
|
||||
};
|
||||
//var fieldMinOffset = {
|
||||
// x: -0.475,
|
||||
// y: 0.315,
|
||||
// z: -0.830
|
||||
//};
|
||||
var halfCornerBoxWidth = 0.85;
|
||||
|
||||
//// parameters for storing the table playing field
|
||||
//var fieldMax = {
|
||||
// x: 0,
|
||||
// y: 0,
|
||||
// z: 0
|
||||
//};
|
||||
//var fieldMin = {
|
||||
// x: 0,
|
||||
// y: 0,
|
||||
// z: 0
|
||||
//};
|
||||
var fieldMinOffset = {
|
||||
x: -0.460, // yes, smaller than max
|
||||
y: 0.315,
|
||||
z: -0.830
|
||||
};
|
||||
var halfCornerBoxWidth = 0.84;
|
||||
|
||||
var tablePosition = {
|
||||
x: 0,
|
||||
|
@ -152,10 +140,9 @@ function mousePressEvent(event) {
|
|||
var props = Entities.getEntityProperties(table);
|
||||
// keep this name synchronized with what's in airHockey.js
|
||||
if (props.name === "air-hockey-table-23j4h1jh82jsjfw91jf232n2k") {
|
||||
// need to remember the table's position so we can clamp the targetPositon
|
||||
// to remain on the playing field
|
||||
tablePosition = props.position;
|
||||
// when we know the table's position we can compute the X-Z bounds of its field
|
||||
//fieldMax = Vec3.sum(tablePosition, fieldMaxOffset);
|
||||
//fieldMin = Vec3.sum(tablePosition, fieldMinOffset);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -250,15 +237,15 @@ function mouseMoveEvent(event) {
|
|||
mousePosition = Vec3.subtract(mousePosition, tablePosition);
|
||||
|
||||
// clamp local mousePosition to table field
|
||||
if (mousePosition.x > fieldHalfExtent.x) {
|
||||
mousePosition.x = fieldHalfExtent.x;
|
||||
} else if (mousePosition.x < - fieldHalfExtent.x) {
|
||||
mousePosition.x = - fieldHalfExtent.x;
|
||||
if (mousePosition.x > fieldMaxOffset.x) {
|
||||
mousePosition.x = fieldMaxOffset.x;
|
||||
} else if (mousePosition.x < fieldMinOffset.x) {
|
||||
mousePosition.x = fieldMinOffset.x;
|
||||
}
|
||||
if (mousePosition.z > fieldHalfExtent.z) {
|
||||
mousePosition.z = fieldHalfExtent.z;
|
||||
} else if (mousePosition.z < - fieldHalfExtent.z) {
|
||||
mousePosition.z = - fieldHalfExtent.z;
|
||||
if (mousePosition.z > fieldMaxOffset.z) {
|
||||
mousePosition.z = fieldMaxOffset.z;
|
||||
} else if (mousePosition.z < fieldMinOffset.z) {
|
||||
mousePosition.z = fieldMinOffset.z;
|
||||
}
|
||||
|
||||
// clamp to rotated square (for cut corners)
|
||||
|
|
Loading…
Reference in a new issue