mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +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
|
var names = ["air-hockey-table-23j4h1jh82jsjfw91jf232n2k", // keep this synchronized with what's in grabHockey.js
|
||||||
"air-hockey-paddle-23j4h1jh82jsjfw91jf232n2k",
|
"air-hockey-paddle-23j4h1jh82jsjfw91jf232n2k",
|
||||||
"air-hockey-puck-23j4h1jh82jsjfw91jf232n2k",
|
"air-hockey-puck-23j4h1jh82jsjfw91jf232n2k",
|
||||||
"air-hockey-light-23j4h1jh82jsjfw91jf232n2k"];
|
"air-hockey-light-23j4h1jh82jsjfw91jf232n2k",
|
||||||
|
"air-hockey-floor-23j4h1jh82jsjfw91jf232n2k"];
|
||||||
var table_name_index = 0;
|
var table_name_index = 0;
|
||||||
var paddle_name_index = 1;
|
var paddle_name_index = 1;
|
||||||
var puck_name_index = 2;
|
var puck_name_index = 2;
|
||||||
var light_name_index = 3;
|
var light_name_index = 3;
|
||||||
|
var floor_name_index = 4;
|
||||||
|
|
||||||
|
|
||||||
var deleteButton = Overlays.addOverlay("image", {
|
var deleteButton = Overlays.addOverlay("image", {
|
||||||
|
@ -289,8 +291,40 @@ function mousePressEvent(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function spawnAllTheThings() {
|
function spawnAllTheThings() {
|
||||||
center = Vec3.sum(MyAvatar.position, Vec3.multiply((FIELD_WIDTH + FIELD_LENGTH) * 0.60, Quat.getFront(Camera.getOrientation())));
|
center = Vec3.sum(MyAvatar.position,
|
||||||
table = Entities.addEntity({
|
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],
|
name: names[table_name_index],
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: polyTable,
|
modelURL: polyTable,
|
||||||
|
@ -301,7 +335,7 @@ function spawnAllTheThings() {
|
||||||
z: 1.31
|
z: 1.31
|
||||||
}, MODEL_SCALE),
|
}, MODEL_SCALE),
|
||||||
position: Vec3.sum(center, MODEL_OFFSET),
|
position: Vec3.sum(center, MODEL_OFFSET),
|
||||||
friction: floorFriction,
|
restitution: edgeRestitution,
|
||||||
ignoreCollisions: false,
|
ignoreCollisions: false,
|
||||||
visible: true,
|
visible: true,
|
||||||
locked: true,
|
locked: true,
|
||||||
|
|
|
@ -11,29 +11,17 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
// these are hand-measured bounds of the AirHockey table
|
// these are hand-measured bounds of the AirHockey table
|
||||||
var fieldHalfExtent = {
|
var fieldMaxOffset = {
|
||||||
x: 0.475,
|
x: 0.475,
|
||||||
y: 0.315,
|
y: 0.315,
|
||||||
z: 0.830
|
z: 0.82
|
||||||
};
|
};
|
||||||
//var fieldMinOffset = {
|
var fieldMinOffset = {
|
||||||
// x: -0.475,
|
x: -0.460, // yes, smaller than max
|
||||||
// y: 0.315,
|
y: 0.315,
|
||||||
// z: -0.830
|
z: -0.830
|
||||||
//};
|
};
|
||||||
var halfCornerBoxWidth = 0.85;
|
var halfCornerBoxWidth = 0.84;
|
||||||
|
|
||||||
//// parameters for storing the table playing field
|
|
||||||
//var fieldMax = {
|
|
||||||
// x: 0,
|
|
||||||
// y: 0,
|
|
||||||
// z: 0
|
|
||||||
//};
|
|
||||||
//var fieldMin = {
|
|
||||||
// x: 0,
|
|
||||||
// y: 0,
|
|
||||||
// z: 0
|
|
||||||
//};
|
|
||||||
|
|
||||||
var tablePosition = {
|
var tablePosition = {
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -152,10 +140,9 @@ function mousePressEvent(event) {
|
||||||
var props = Entities.getEntityProperties(table);
|
var props = Entities.getEntityProperties(table);
|
||||||
// keep this name synchronized with what's in airHockey.js
|
// keep this name synchronized with what's in airHockey.js
|
||||||
if (props.name === "air-hockey-table-23j4h1jh82jsjfw91jf232n2k") {
|
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;
|
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);
|
mousePosition = Vec3.subtract(mousePosition, tablePosition);
|
||||||
|
|
||||||
// clamp local mousePosition to table field
|
// clamp local mousePosition to table field
|
||||||
if (mousePosition.x > fieldHalfExtent.x) {
|
if (mousePosition.x > fieldMaxOffset.x) {
|
||||||
mousePosition.x = fieldHalfExtent.x;
|
mousePosition.x = fieldMaxOffset.x;
|
||||||
} else if (mousePosition.x < - fieldHalfExtent.x) {
|
} else if (mousePosition.x < fieldMinOffset.x) {
|
||||||
mousePosition.x = - fieldHalfExtent.x;
|
mousePosition.x = fieldMinOffset.x;
|
||||||
}
|
}
|
||||||
if (mousePosition.z > fieldHalfExtent.z) {
|
if (mousePosition.z > fieldMaxOffset.z) {
|
||||||
mousePosition.z = fieldHalfExtent.z;
|
mousePosition.z = fieldMaxOffset.z;
|
||||||
} else if (mousePosition.z < - fieldHalfExtent.z) {
|
} else if (mousePosition.z < fieldMinOffset.z) {
|
||||||
mousePosition.z = - fieldHalfExtent.z;
|
mousePosition.z = fieldMinOffset.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clamp to rotated square (for cut corners)
|
// clamp to rotated square (for cut corners)
|
||||||
|
|
Loading…
Reference in a new issue