mirror of
https://github.com/lubosz/overte.git
synced 2025-04-26 06:55:39 +02:00
merge fix
This commit is contained in:
commit
6d3a9f7bc0
2 changed files with 51 additions and 7 deletions
examples
|
@ -1,4 +1,17 @@
|
|||
// Pool Table
|
||||
// Billiards.js
|
||||
//
|
||||
// Created by Philip Rosedale on January 21, 2015
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Creates a pool table in front of you. Hold and release space ball to shoot a ball.
|
||||
// Cue ball will return if falls off table. Delete and reset to restart.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
|
||||
var tableParts = [];
|
||||
var balls = [];
|
||||
var cueBall;
|
||||
|
@ -19,6 +32,10 @@ var cuePosition;
|
|||
|
||||
var startStroke = 0;
|
||||
|
||||
// Sounds to use
|
||||
hitSounds = [];
|
||||
hitSounds.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "Collisions-ballhitsandcatches/billiards/collision1.wav"));
|
||||
|
||||
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
||||
var screenSize = Controller.getViewportDimensions();
|
||||
var reticle = Overlays.addOverlay("image", {
|
||||
|
@ -122,6 +139,9 @@ function makeBalls(pos) {
|
|||
}
|
||||
ballPosition.x += (BALL_GAP + Math.sqrt(3.0) / 2.0 * BALL_SIZE) * SCALE;
|
||||
}
|
||||
print(balls.length + " Object balls made.");
|
||||
print(isObjectBall(balls[1].id));
|
||||
|
||||
// Cue Ball
|
||||
cuePosition = { x: pos.x - (LENGTH / 4.0) * SCALE, y: pos.y + HEIGHT / 2.0 + DROP_HEIGHT, z: pos.z };
|
||||
cueBall = Entities.addEntity(
|
||||
|
@ -138,6 +158,14 @@ function makeBalls(pos) {
|
|||
|
||||
}
|
||||
|
||||
function isObjectBall(id) {
|
||||
for (var i; i < balls.length; i++) {
|
||||
if (balls[i].id == id)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function shootCue(velocity) {
|
||||
var DISTANCE_FROM_CAMERA = BALL_SIZE * 5.0 * SCALE;
|
||||
var camera = Camera.getPosition();
|
||||
|
@ -213,12 +241,27 @@ function update(deltaTime) {
|
|||
|
||||
}
|
||||
|
||||
function entityCollisionWithEntity(entity1, entity2, collision) {
|
||||
/*
|
||||
if ((entity1.id == cueBall.id) || (entity2.id == cueBall.id)) {
|
||||
print("Cue ball collision!");
|
||||
//audioOptions.position = Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation()));
|
||||
//Audio.playSound(hitSounds[0], { position: Vec3.sum(Camera.getPosition(), Quat.getFront(Camera.getOrientation())) });
|
||||
}
|
||||
|
||||
else if (isObjectBall(entity1.id) || isObjectBall(entity2.id)) {
|
||||
print("Object ball collision");
|
||||
} */
|
||||
}
|
||||
|
||||
tableCenter = Vec3.sum(MyAvatar.position, Vec3.multiply(4.0, Quat.getFront(Camera.getOrientation())));
|
||||
|
||||
makeTable(tableCenter);
|
||||
makeBalls(tableCenter);
|
||||
|
||||
Entities.entityCollisionWithEntity.connect(entityCollisionWithEntity);
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
Controller.keyPressEvent.connect(keyPressEvent);
|
||||
Controller.keyReleaseEvent.connect(keyReleaseEvent);
|
||||
Script.update.connect(update);
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ function controller(wichSide) {
|
|||
this.rotationAtGrab;
|
||||
this.gravityAtGrab;
|
||||
this.modelPositionAtGrab;
|
||||
this.rotationAtGrab;
|
||||
this.modelRotationAtGrab;
|
||||
this.jointsIntersectingFromStart = [];
|
||||
|
||||
this.laser = Overlays.addOverlay("line3d", {
|
||||
|
@ -167,10 +167,10 @@ function controller(wichSide) {
|
|||
this.positionAtGrab = this.palmPosition;
|
||||
this.rotationAtGrab = this.rotation;
|
||||
this.modelPositionAtGrab = properties.position;
|
||||
this.rotationAtGrab = properties.rotation;
|
||||
this.modelRotationAtGrab = properties.rotation;
|
||||
this.gravityAtGrab = properties.gravity;
|
||||
|
||||
Entities.editEntity(entityID, { gravity: { x: 0, y: 0, z: 0 }, velocity: { x: 0, y: 0, z: 0 } });
|
||||
|
||||
|
||||
this.jointsIntersectingFromStart = [];
|
||||
for (var i = 0; i < jointList.length; i++) {
|
||||
|
@ -390,8 +390,9 @@ function controller(wichSide) {
|
|||
|
||||
newRotation = Quat.multiply(this.rotation,
|
||||
Quat.inverse(this.rotationAtGrab));
|
||||
newRotation = Quat.multiply(newRotation, newRotation);
|
||||
newRotation = Quat.multiply(newRotation,
|
||||
this.rotationAtGrab);
|
||||
this.modelRotationAtGrab);
|
||||
break;
|
||||
}
|
||||
Entities.editEntity(this.entityID, {
|
||||
|
@ -604,11 +605,11 @@ function moveEntities() {
|
|||
leftController.positionAtGrab = leftController.palmPosition;
|
||||
leftController.rotationAtGrab = leftController.rotation;
|
||||
leftController.modelPositionAtGrab = leftController.oldModelPosition;
|
||||
leftController.rotationAtGrab = rotation;
|
||||
leftController.modelRotationAtGrab = rotation;
|
||||
rightController.positionAtGrab = rightController.palmPosition;
|
||||
rightController.rotationAtGrab = rightController.rotation;
|
||||
rightController.modelPositionAtGrab = rightController.oldModelPosition;
|
||||
rightController.rotationAtGrab = rotation;
|
||||
rightController.modelRotationAtGrab = rotation;
|
||||
break;
|
||||
}
|
||||
Entities.editEntity(leftController.entityID, {
|
||||
|
|
Loading…
Reference in a new issue