mirror of
https://github.com/overte-org/overte.git
synced 2025-06-27 03:49:38 +02:00
changed dice to use collisionSoundURL prop
This commit is contained in:
parent
650e8a54af
commit
9c6be26290
1 changed files with 94 additions and 86 deletions
|
@ -21,8 +21,8 @@ var DIE_SIZE = 0.20;
|
||||||
var madeSound = true; // Set false at start of throw to look for collision
|
var madeSound = true; // Set false at start of throw to look for collision
|
||||||
|
|
||||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||||
|
SoundCache.getSound("http://s3.amazonaws.com/hifi-public/sounds/dice/diceCollide.wav");
|
||||||
|
|
||||||
var rollSound = SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/dice/diceRoll.wav");
|
|
||||||
|
|
||||||
var INSUFFICIENT_PERMISSIONS_ERROR_MSG = "You do not have the necessary permissions to create new objects."
|
var INSUFFICIENT_PERMISSIONS_ERROR_MSG = "You do not have the necessary permissions to create new objects."
|
||||||
|
|
||||||
|
@ -37,7 +37,11 @@ var offButton = Overlays.addOverlay("image", {
|
||||||
width: BUTTON_SIZE,
|
width: BUTTON_SIZE,
|
||||||
height: BUTTON_SIZE,
|
height: BUTTON_SIZE,
|
||||||
imageURL: HIFI_PUBLIC_BUCKET + "images/close.png",
|
imageURL: HIFI_PUBLIC_BUCKET + "images/close.png",
|
||||||
color: { red: 255, green: 255, blue: 255},
|
color: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
alpha: 1
|
alpha: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -47,7 +51,11 @@ var deleteButton = Overlays.addOverlay("image", {
|
||||||
width: BUTTON_SIZE,
|
width: BUTTON_SIZE,
|
||||||
height: BUTTON_SIZE,
|
height: BUTTON_SIZE,
|
||||||
imageURL: HIFI_PUBLIC_BUCKET + "images/delete.png",
|
imageURL: HIFI_PUBLIC_BUCKET + "images/delete.png",
|
||||||
color: { red: 255, green: 255, blue: 255},
|
color: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
alpha: 1
|
alpha: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,7 +65,11 @@ var diceButton = Overlays.addOverlay("image", {
|
||||||
width: BUTTON_SIZE,
|
width: BUTTON_SIZE,
|
||||||
height: BUTTON_SIZE,
|
height: BUTTON_SIZE,
|
||||||
imageURL: HIFI_PUBLIC_BUCKET + "images/die.png",
|
imageURL: HIFI_PUBLIC_BUCKET + "images/die.png",
|
||||||
color: { red: 255, green: 255, blue: 255},
|
color: {
|
||||||
|
red: 255,
|
||||||
|
green: 255,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
alpha: 1
|
alpha: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -73,18 +85,26 @@ function shootDice(position, velocity) {
|
||||||
} else {
|
} else {
|
||||||
for (var i = 0; i < NUMBER_OF_DICE; i++) {
|
for (var i = 0; i < NUMBER_OF_DICE; i++) {
|
||||||
dice.push(Entities.addEntity(
|
dice.push(Entities.addEntity(
|
||||||
{ type: "Model",
|
{
|
||||||
|
type: "Model",
|
||||||
modelURL: HIFI_PUBLIC_BUCKET + "models/props/Dice/goldDie.fbx",
|
modelURL: HIFI_PUBLIC_BUCKET + "models/props/Dice/goldDie.fbx",
|
||||||
position: position,
|
position: position,
|
||||||
velocity: velocity,
|
velocity: velocity,
|
||||||
rotation: Quat.fromPitchYawRollDegrees(Math.random() * 360, Math.random() * 360, Math.random() * 360),
|
rotation: Quat.fromPitchYawRollDegrees(Math.random() * 360, Math.random() * 360, Math.random() * 360),
|
||||||
angularVelocity: { x: Math.random() * MAX_ANGULAR_SPEED,
|
angularVelocity: {
|
||||||
|
x: Math.random() * MAX_ANGULAR_SPEED,
|
||||||
y: Math.random() * MAX_ANGULAR_SPEED,
|
y: Math.random() * MAX_ANGULAR_SPEED,
|
||||||
z: Math.random() * MAX_ANGULAR_SPEED },
|
z: Math.random() * MAX_ANGULAR_SPEED
|
||||||
|
},
|
||||||
|
gravity: {
|
||||||
|
x: 0,
|
||||||
|
y: GRAVITY,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
lifetime: LIFETIME,
|
lifetime: LIFETIME,
|
||||||
gravity: { x: 0, y: GRAVITY, z: 0 },
|
|
||||||
shapeType: "box",
|
shapeType: "box",
|
||||||
collisionsWillMove: true
|
collisionsWillMove: true,
|
||||||
|
collisionSoundURL: "http://s3.amazonaws.com/hifi-public/sounds/dice/diceCollide.wav"
|
||||||
}));
|
}));
|
||||||
position = Vec3.sum(position, Vec3.multiply(DIE_SIZE, Vec3.normalize(Quat.getRight(Camera.getOrientation()))));
|
position = Vec3.sum(position, Vec3.multiply(DIE_SIZE, Vec3.normalize(Quat.getRight(Camera.getOrientation()))));
|
||||||
}
|
}
|
||||||
|
@ -97,25 +117,14 @@ function deleteDice() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
|
||||||
if (!madeSound) {
|
|
||||||
// Is it one of our dice?
|
|
||||||
for (var i = 0; i < dice.length; i++) {
|
|
||||||
if (!dice[i].isKnownID) {
|
|
||||||
dice[i] = Entities.identifyEntity(dice[i]);
|
|
||||||
}
|
|
||||||
if ((entity1.id == dice[i].id) || (entity2.id == dice[i].id)) {
|
|
||||||
madeSound = true;
|
|
||||||
Audio.playSound(rollSound, { position: collision.contactPoint, localOnly: true });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function mousePressEvent(event) {
|
function mousePressEvent(event) {
|
||||||
var clickedText = false;
|
var clickedText = false;
|
||||||
var clickedOverlay = Overlays.getOverlayAtPoint({x: event.x, y: event.y});
|
var clickedOverlay = Overlays.getOverlayAtPoint({
|
||||||
|
x: event.x,
|
||||||
|
y: event.y
|
||||||
|
});
|
||||||
if (clickedOverlay == offButton) {
|
if (clickedOverlay == offButton) {
|
||||||
deleteDice();
|
deleteDice();
|
||||||
Script.stop();
|
Script.stop();
|
||||||
|
@ -136,6 +145,5 @@ function scriptEnding() {
|
||||||
Overlays.deleteOverlay(deleteButton);
|
Overlays.deleteOverlay(deleteButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
|
||||||
Controller.mousePressEvent.connect(mousePressEvent);
|
Controller.mousePressEvent.connect(mousePressEvent);
|
||||||
Script.scriptEnding.connect(scriptEnding);
|
Script.scriptEnding.connect(scriptEnding);
|
Loading…
Reference in a new issue