mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into controllers
This commit is contained in:
commit
90afb444d2
10 changed files with 74 additions and 59 deletions
|
@ -101,10 +101,10 @@ var STATE_DISTANCE_HOLDING = 2;
|
|||
var STATE_CONTINUE_DISTANCE_HOLDING = 3;
|
||||
var STATE_NEAR_GRABBING = 4;
|
||||
var STATE_CONTINUE_NEAR_GRABBING = 5;
|
||||
var STATE_NEAR_GRABBING_NON_COLLIDING = 6;
|
||||
var STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING = 7;
|
||||
var STATE_FAR_GRABBING_NON_COLLIDING = 8;
|
||||
var STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING = 9;
|
||||
var STATE_NEAR_TRIGGER = 6;
|
||||
var STATE_CONTINUE_NEAR_TRIGGER = 7;
|
||||
var STATE_FAR_TRIGGER = 8;
|
||||
var STATE_CONTINUE_FAR_TRIGGER = 9;
|
||||
var STATE_RELEASE = 10;
|
||||
|
||||
|
||||
|
@ -122,14 +122,14 @@ function stateToName(state) {
|
|||
return "near_grabbing";
|
||||
case STATE_CONTINUE_NEAR_GRABBING:
|
||||
return "continue_near_grabbing";
|
||||
case STATE_NEAR_GRABBING_NON_COLLIDING:
|
||||
return "near_grabbing_non_colliding";
|
||||
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
|
||||
return "continue_near_grabbing_non_colliding";
|
||||
case STATE_FAR_GRABBING_NON_COLLIDING:
|
||||
return "far_grabbing_non_colliding";
|
||||
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
|
||||
return "continue_far_grabbing_non_colliding";
|
||||
case STATE_NEAR_TRIGGER:
|
||||
return "near_trigger";
|
||||
case STATE_CONTINUE_NEAR_TRIGGER:
|
||||
return "continue_near_trigger";
|
||||
case STATE_FAR_TRIGGER:
|
||||
return "far_trigger";
|
||||
case STATE_CONTINUE_FAR_TRIGGER:
|
||||
return "continue_far_trigger";
|
||||
case STATE_RELEASE:
|
||||
return "release";
|
||||
}
|
||||
|
@ -212,17 +212,17 @@ function MyController(hand) {
|
|||
case STATE_CONTINUE_NEAR_GRABBING:
|
||||
this.continueNearGrabbing();
|
||||
break;
|
||||
case STATE_NEAR_GRABBING_NON_COLLIDING:
|
||||
this.nearGrabbingNonColliding();
|
||||
case STATE_NEAR_TRIGGER:
|
||||
this.nearTrigger();
|
||||
break;
|
||||
case STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING:
|
||||
this.continueNearGrabbingNonColliding();
|
||||
case STATE_CONTINUE_NEAR_TRIGGER:
|
||||
this.continueNearTrigger();
|
||||
break;
|
||||
case STATE_FAR_GRABBING_NON_COLLIDING:
|
||||
this.farGrabbingNonColliding();
|
||||
case STATE_FAR_TRIGGER:
|
||||
this.farTrigger();
|
||||
break;
|
||||
case STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING:
|
||||
this.continueFarGrabbingNonColliding();
|
||||
case STATE_CONTINUE_FAR_TRIGGER:
|
||||
this.continueFarTrigger();
|
||||
break;
|
||||
case STATE_RELEASE:
|
||||
this.release();
|
||||
|
@ -394,7 +394,7 @@ function MyController(hand) {
|
|||
// the hand is very close to the intersected object. go into close-grabbing mode.
|
||||
if (grabbableData.wantsTrigger) {
|
||||
this.grabbedEntity = intersection.entityID;
|
||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
||||
this.setState(STATE_NEAR_TRIGGER);
|
||||
return;
|
||||
} else if (!intersection.properties.locked) {
|
||||
this.grabbedEntity = intersection.entityID;
|
||||
|
@ -411,7 +411,7 @@ function MyController(hand) {
|
|||
return;
|
||||
} else if (grabbableData.wantsTrigger) {
|
||||
this.grabbedEntity = intersection.entityID;
|
||||
this.setState(STATE_FAR_GRABBING_NON_COLLIDING);
|
||||
this.setState(STATE_FAR_TRIGGER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ function MyController(hand) {
|
|||
return;
|
||||
}
|
||||
if (grabbableData.wantsTrigger) {
|
||||
this.setState(STATE_NEAR_GRABBING_NON_COLLIDING);
|
||||
this.setState(STATE_NEAR_TRIGGER);
|
||||
return;
|
||||
} else if (!props.locked) {
|
||||
this.setState(STATE_NEAR_GRABBING);
|
||||
|
@ -538,6 +538,7 @@ function MyController(hand) {
|
|||
this.continueDistanceHolding = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -631,6 +632,7 @@ function MyController(hand) {
|
|||
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -698,6 +700,7 @@ function MyController(hand) {
|
|||
this.continueNearGrabbing = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -733,9 +736,10 @@ function MyController(hand) {
|
|||
}
|
||||
};
|
||||
|
||||
this.nearGrabbingNonColliding = function() {
|
||||
this.nearTrigger = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||
return;
|
||||
}
|
||||
if (this.hand === RIGHT_HAND) {
|
||||
|
@ -743,13 +747,14 @@ function MyController(hand) {
|
|||
} else {
|
||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||
}
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startNearGrabNonColliding");
|
||||
this.setState(STATE_CONTINUE_NEAR_GRABBING_NON_COLLIDING);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startNearTrigger");
|
||||
this.setState(STATE_CONTINUE_NEAR_TRIGGER);
|
||||
};
|
||||
|
||||
this.farGrabbingNonColliding = function() {
|
||||
this.farTrigger = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -758,22 +763,24 @@ function MyController(hand) {
|
|||
} else {
|
||||
Entities.callEntityMethod(this.grabbedEntity, "setLeftHand");
|
||||
}
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startFarGrabNonColliding");
|
||||
this.setState(STATE_CONTINUE_FAR_GRABBING_NON_COLLIDING);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "startFarTrigger");
|
||||
this.setState(STATE_CONTINUE_FAR_TRIGGER);
|
||||
};
|
||||
|
||||
this.continueNearGrabbingNonColliding = function() {
|
||||
this.continueNearTrigger = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||
return;
|
||||
}
|
||||
|
||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearGrabbingNonColliding");
|
||||
Entities.callEntityMethod(this.grabbedEntity, "continueNearTrigger");
|
||||
};
|
||||
|
||||
this.continueFarGrabbingNonColliding = function() {
|
||||
this.continueFarTrigger = function() {
|
||||
if (this.triggerSmoothedReleased()) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "stopNearTrigger");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -789,12 +796,13 @@ function MyController(hand) {
|
|||
this.lastPickTime = now;
|
||||
if (intersection.entityID != this.grabbedEntity) {
|
||||
this.setState(STATE_RELEASE);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "stopFarTrigger");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.lineOn(pickRay.origin, Vec3.multiply(pickRay.direction, LINE_LENGTH), NO_INTERSECT_COLOR);
|
||||
Entities.callEntityMethod(this.grabbedEntity, "continueFarGrabbingNonColliding");
|
||||
Entities.callEntityMethod(this.grabbedEntity, "continueFarTrigger");
|
||||
};
|
||||
|
||||
_this.allTouchedIDs = {};
|
||||
|
@ -876,7 +884,6 @@ function MyController(hand) {
|
|||
if (this.actionID !== null) {
|
||||
Entities.deleteAction(this.grabbedEntity, this.actionID);
|
||||
}
|
||||
Entities.callEntityMethod(this.grabbedEntity, "releaseGrab");
|
||||
}
|
||||
|
||||
this.deactivateEntity(this.grabbedEntity);
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
ColorSelector.prototype = {
|
||||
|
||||
startFarGrabNonColliding: function() {
|
||||
startFarTrigger: function() {
|
||||
this.selectColor();
|
||||
},
|
||||
|
||||
|
@ -46,4 +46,4 @@
|
|||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new ColorSelector();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
BoardEraser.prototype = {
|
||||
|
||||
startFarGrabNonColliding: function() {
|
||||
startFarTrigger: function() {
|
||||
this.eraseBoard();
|
||||
},
|
||||
|
||||
|
@ -42,4 +42,4 @@
|
|||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new BoardEraser();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
this.hand = LEFT_HAND;
|
||||
},
|
||||
|
||||
startFarGrabNonColliding: function() {
|
||||
startFarTrigger: function() {
|
||||
if (this.painting) {
|
||||
return;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@
|
|||
});
|
||||
},
|
||||
|
||||
continueFarGrabbingNonColliding: function() {
|
||||
continueFarTrigger: function() {
|
||||
var handPosition = this.getHandPosition();
|
||||
var pickRay = {
|
||||
origin: handPosition,
|
||||
|
@ -183,7 +183,7 @@
|
|||
|
||||
},
|
||||
|
||||
releaseGrab: function() {
|
||||
stopFarTrigger: function() {
|
||||
if(this.hand !== this.whichHand) {
|
||||
return;
|
||||
}
|
||||
|
@ -249,4 +249,4 @@
|
|||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new Whiteboard();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -74,6 +74,9 @@ var drawingSurface = Entities.addEntity({
|
|||
userData: JSON.stringify({
|
||||
color: {
|
||||
currentColor: colors[0]
|
||||
},
|
||||
"grabbableKey": {
|
||||
wantsTrigger:true
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -211,4 +214,4 @@ function cleanup() {
|
|||
|
||||
|
||||
// Uncomment this line to delete whiteboard and all associated entity on script close
|
||||
// Script.scriptEnding.connect(cleanup);
|
||||
// Script.scriptEnding.connect(cleanup);
|
||||
|
|
|
@ -15,35 +15,35 @@
|
|||
|
||||
/*global LightSwitch */
|
||||
|
||||
(function () {
|
||||
(function() {
|
||||
var _this;
|
||||
var utilitiesScript = Script.resolvePath("../../libraries/utils.js");
|
||||
Script.include(utilitiesScript);
|
||||
LightSwitch = function () {
|
||||
LightSwitch = function() {
|
||||
_this = this;
|
||||
this.switchSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/sounds/Switches%20and%20sliders/lamp_switch_2.wav");
|
||||
};
|
||||
|
||||
LightSwitch.prototype = {
|
||||
|
||||
clickReleaseOnEntity: function (entityID, mouseEvent) {
|
||||
clickReleaseOnEntity: function(entityID, mouseEvent) {
|
||||
if (!mouseEvent.isLeftButton) {
|
||||
return;
|
||||
}
|
||||
this.toggleLights();
|
||||
},
|
||||
|
||||
startNearGrabNonColliding: function () {
|
||||
startNearTrigger: function() {
|
||||
this.toggleLights();
|
||||
},
|
||||
|
||||
toggleLights: function () {
|
||||
toggleLights: function() {
|
||||
var lightData = getEntityCustomData(this.resetKey, this.entityID, {});
|
||||
var on = !lightData.on;
|
||||
var lightType = lightData.type;
|
||||
|
||||
var lights = Entities.findEntities(this.position, 20);
|
||||
lights.forEach(function (light) {
|
||||
lights.forEach(function(light) {
|
||||
var type = getEntityCustomData(_this.resetKey, light, {}).type;
|
||||
if (type === lightType && JSON.stringify(light) !== JSON.stringify(_this.entityID)) {
|
||||
Entities.editEntity(light, {
|
||||
|
@ -63,9 +63,13 @@
|
|||
type: lightType,
|
||||
resetMe: true
|
||||
});
|
||||
|
||||
setEntityCustomData('grabbableKey', this.entityID, {
|
||||
wantsTrigger: true
|
||||
});
|
||||
},
|
||||
|
||||
flipSwitch: function () {
|
||||
flipSwitch: function() {
|
||||
var rotation = Entities.getEntityProperties(this.entityID, "rotation").rotation;
|
||||
var axis = {
|
||||
x: 0,
|
||||
|
@ -79,7 +83,7 @@
|
|||
rotation: rotation
|
||||
});
|
||||
},
|
||||
preload: function (entityID) {
|
||||
preload: function(entityID) {
|
||||
this.entityID = entityID;
|
||||
this.resetKey = "resetMe";
|
||||
//The light switch is static, so just cache its position once
|
||||
|
|
|
@ -17,7 +17,7 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
|||
|
||||
Resetter.prototype = {
|
||||
|
||||
startNearGrabNonColliding: function() {
|
||||
startNearTrigger: function() {
|
||||
this.resetObjects();
|
||||
},
|
||||
|
||||
|
@ -108,4 +108,4 @@ var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/";
|
|||
};
|
||||
|
||||
return new Resetter();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
},
|
||||
|
||||
startNearGrabNonColliding: function() {
|
||||
startNearTrigger: function() {
|
||||
this.triggerReset();
|
||||
},
|
||||
|
||||
|
@ -1259,4 +1259,4 @@
|
|||
};
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new ResetSwitch();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -247,7 +247,8 @@ MasterReset = function() {
|
|||
resetMe: true
|
||||
},
|
||||
grabbableKey: {
|
||||
grabbable: false
|
||||
grabbable: false,
|
||||
wantsTrigger:true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -1237,4 +1238,4 @@ MasterReset = function() {
|
|||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
Resetter.prototype = {
|
||||
|
||||
startNearGrabNonColliding: function() {
|
||||
startNearTrigger: function() {
|
||||
this.resetObjects();
|
||||
},
|
||||
|
||||
|
@ -125,4 +125,4 @@
|
|||
};
|
||||
|
||||
return new Resetter();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue