mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-06-01 06:50:50 +02:00
take care of naughty intervals
This commit is contained in:
parent
4a9f6e677c
commit
5c83db3b28
1 changed files with 51 additions and 22 deletions
|
@ -12,9 +12,14 @@ var inTeleportMode = false;
|
||||||
|
|
||||||
var currentFadeSphereOpacity = 1;
|
var currentFadeSphereOpacity = 1;
|
||||||
var fadeSphereInterval = null;
|
var fadeSphereInterval = null;
|
||||||
|
var fadeSphereUpdateInterval = null;
|
||||||
//milliseconds between fading one-tenth -- so this is a half second fade total
|
//milliseconds between fading one-tenth -- so this is a half second fade total
|
||||||
var FADE_IN_INTERVAL = 50;
|
var USE_FADE_MODE = true;
|
||||||
var FADE_OUT_INTERVAL = 50;
|
var USE_FADE_IN = false;
|
||||||
|
var USE_FADE_OUT = true;
|
||||||
|
var FADE_IN_INTERVAL = 25;
|
||||||
|
var FADE_OUT_INTERVAL = 25;
|
||||||
|
|
||||||
|
|
||||||
// instant
|
// instant
|
||||||
var NUMBER_OF_STEPS = 0;
|
var NUMBER_OF_STEPS = 0;
|
||||||
|
@ -24,7 +29,7 @@ var SMOOTH_ARRIVAL_SPACING = 0;
|
||||||
// var SMOOTH_ARRIVAL_SPACING = 150;
|
// var SMOOTH_ARRIVAL_SPACING = 150;
|
||||||
// var NUMBER_OF_STEPS = 2;
|
// var NUMBER_OF_STEPS = 2;
|
||||||
|
|
||||||
//medium-slow
|
// medium-slow
|
||||||
// var SMOOTH_ARRIVAL_SPACING = 100;
|
// var SMOOTH_ARRIVAL_SPACING = 100;
|
||||||
// var NUMBER_OF_STEPS = 4;
|
// var NUMBER_OF_STEPS = 4;
|
||||||
|
|
||||||
|
@ -32,10 +37,13 @@ var SMOOTH_ARRIVAL_SPACING = 0;
|
||||||
// var SMOOTH_ARRIVAL_SPACING = 33;
|
// var SMOOTH_ARRIVAL_SPACING = 33;
|
||||||
// var NUMBER_OF_STEPS = 6;
|
// var NUMBER_OF_STEPS = 6;
|
||||||
|
|
||||||
// //fast
|
//fast
|
||||||
// var SMOOTH_ARRIVAL_SPACING = 10;
|
// var SMOOTH_ARRIVAL_SPACING = 10;
|
||||||
// var NUMBER_OF_STEPS = 20;
|
// var NUMBER_OF_STEPS = 20;
|
||||||
|
|
||||||
|
|
||||||
|
// var NUMBER_OF_STEPS=9;
|
||||||
|
// var SMOOTH_ARRIVAL_SPACING=25;
|
||||||
var USE_THUMB_AND_TRIGGER_MODE = false;
|
var USE_THUMB_AND_TRIGGER_MODE = false;
|
||||||
|
|
||||||
var TARGET_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/teleporter/target.fbx';
|
var TARGET_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/teleporter/target.fbx';
|
||||||
|
@ -82,6 +90,7 @@ function Teleporter() {
|
||||||
this.targetOverlay = null;
|
this.targetOverlay = null;
|
||||||
this.updateConnected = null;
|
this.updateConnected = null;
|
||||||
this.smoothArrivalInterval = null;
|
this.smoothArrivalInterval = null;
|
||||||
|
this.fadeSphere = null;
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
this.createMappings();
|
this.createMappings();
|
||||||
|
@ -138,10 +147,11 @@ function Teleporter() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.createFadeSphere = function(avatarHead) {
|
this.createFadeSphere = function(avatarHead) {
|
||||||
var sphereProps = {
|
var sphereProps = {
|
||||||
position: avatarHead,
|
position: avatarHead,
|
||||||
size: 0.25,
|
size: -1,
|
||||||
color: {
|
color: {
|
||||||
red: 0,
|
red: 0,
|
||||||
green: 0,
|
green: 0,
|
||||||
|
@ -151,30 +161,40 @@ function Teleporter() {
|
||||||
solid: true,
|
solid: true,
|
||||||
visible: true,
|
visible: true,
|
||||||
ignoreRayIntersection: true,
|
ignoreRayIntersection: true,
|
||||||
drawInFront: true
|
drawInFront: false
|
||||||
};
|
};
|
||||||
|
|
||||||
currentFadeSphereOpacity = 1;
|
currentFadeSphereOpacity = 10;
|
||||||
|
|
||||||
_this.fadeSphere = Overlays.addOverlay("sphere", sphereProps);
|
|
||||||
|
|
||||||
|
_this.fadeSphere = Overlays.addOverlay("cube", sphereProps);
|
||||||
|
Script.clearInterval(fadeSphereInterval)
|
||||||
Script.update.connect(_this.updateFadeSphere);
|
Script.update.connect(_this.updateFadeSphere);
|
||||||
|
if (USE_FADE_OUT === true) {
|
||||||
|
this.fadeSphereOut();
|
||||||
|
}
|
||||||
|
if (USE_FADE_IN === true) {
|
||||||
|
this.fadeSphereIn();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fadeSphereOut = function() {
|
this.fadeSphereOut = function() {
|
||||||
|
|
||||||
fadeSphereInterval = Script.setInterval(function() {
|
fadeSphereInterval = Script.setInterval(function() {
|
||||||
if (currentFadeSphereOpacity === 0) {
|
if (currentFadeSphereOpacity <= 0) {
|
||||||
Script.clearInterval(fadeSphereInterval);
|
Script.clearInterval(fadeSphereInterval);
|
||||||
_this.deleteFadeSphere();
|
_this.deleteFadeSphere();
|
||||||
fadeSphereInterval = null;
|
fadeSphereInterval = null;
|
||||||
|
print('sphere done fading out');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentFadeSphereOpacity > 0) {
|
if (currentFadeSphereOpacity > 0) {
|
||||||
currentFadeSphereOpacity -= 0.1;
|
currentFadeSphereOpacity = currentFadeSphereOpacity - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print('setting sphere alpha to: ' + currentFadeSphereOpacity)
|
||||||
Overlays.editOverlay(_this.fadeSphere, {
|
Overlays.editOverlay(_this.fadeSphere, {
|
||||||
alpha: currentFadeSphereOpacity
|
alpha: currentFadeSphereOpacity / 10
|
||||||
})
|
})
|
||||||
|
|
||||||
}, FADE_OUT_INTERVAL);
|
}, FADE_OUT_INTERVAL);
|
||||||
|
@ -182,17 +202,18 @@ function Teleporter() {
|
||||||
|
|
||||||
this.fadeSphereIn = function() {
|
this.fadeSphereIn = function() {
|
||||||
fadeSphereInterval = Script.setInterval(function() {
|
fadeSphereInterval = Script.setInterval(function() {
|
||||||
if (currentFadeSphereOpacity === 1) {
|
if (currentFadeSphereOpacity >= 1) {
|
||||||
Script.clearInterval(fadeSphereInterval);
|
Script.clearInterval(fadeSphereInterval);
|
||||||
_this.deleteFadeSphere();
|
_this.deleteFadeSphere();
|
||||||
fadeSphereInterval = null;
|
fadeSphereInterval = null;
|
||||||
|
print('sphere done fading in')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentFadeSphereOpacity < 1) {
|
if (currentFadeSphereOpacity < 1) {
|
||||||
currentFadeSphereOpacity += 0.1;
|
currentFadeSphereOpacity = currentFadeSphereOpacity - 1;
|
||||||
}
|
}
|
||||||
Overlays.editOverlay(_this.fadeSphere, {
|
Overlays.editOverlay(_this.fadeSphere, {
|
||||||
alpha: currentFadeSphereOpacity
|
alpha: currentFadeSphereOpacity / 10
|
||||||
})
|
})
|
||||||
|
|
||||||
}, FADE_IN_INTERVAL);
|
}, FADE_IN_INTERVAL);
|
||||||
|
@ -206,8 +227,13 @@ function Teleporter() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deleteFadeSphere = function() {
|
this.deleteFadeSphere = function() {
|
||||||
Script.update.disconnect(_this.updateFadeSphere);
|
if (_this.fadeSphere !== null) {
|
||||||
Overlays.deleteOverlay(_this.fadeSphere);
|
print('deleting fade sphere');
|
||||||
|
Script.update.disconnect(_this.updateFadeSphere);
|
||||||
|
Overlays.deleteOverlay(_this.fadeSphere);
|
||||||
|
_this.fadeSphere = null;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.deleteTargetOverlay = function() {
|
this.deleteTargetOverlay = function() {
|
||||||
|
@ -227,7 +253,6 @@ function Teleporter() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Script.update.disconnect(this.update);
|
Script.update.disconnect(this.update);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateConnected = null;
|
this.updateConnected = null;
|
||||||
|
@ -492,10 +517,12 @@ function Teleporter() {
|
||||||
|
|
||||||
this.teleport = function(value) {
|
this.teleport = function(value) {
|
||||||
|
|
||||||
if (_this.intersection !== null) {
|
if (this.intersection !== null) {
|
||||||
|
if (USE_FADE_MODE === true) {
|
||||||
|
this.createFadeSphere();
|
||||||
|
}
|
||||||
var offset = getAvatarFootOffset();
|
var offset = getAvatarFootOffset();
|
||||||
_this.intersection.intersection.y += offset;
|
this.intersection.intersection.y += offset;
|
||||||
// MyAvatar.position = _this.intersection.intersection;
|
// MyAvatar.position = _this.intersection.intersection;
|
||||||
this.exitTeleportMode();
|
this.exitTeleportMode();
|
||||||
this.smoothArrival();
|
this.smoothArrival();
|
||||||
|
@ -540,6 +567,7 @@ function Teleporter() {
|
||||||
var landingPoint = _this.arrivalPoints.shift();
|
var landingPoint = _this.arrivalPoints.shift();
|
||||||
print('landing at: ' + JSON.stringify(landingPoint))
|
print('landing at: ' + JSON.stringify(landingPoint))
|
||||||
MyAvatar.position = landingPoint;
|
MyAvatar.position = landingPoint;
|
||||||
|
|
||||||
if (_this.arrivalPoints.length === 1 || _this.arrivalPoints.length === 0) {
|
if (_this.arrivalPoints.length === 1 || _this.arrivalPoints.length === 0) {
|
||||||
print('clear target overlay')
|
print('clear target overlay')
|
||||||
_this.deleteTargetOverlay();
|
_this.deleteTargetOverlay();
|
||||||
|
@ -674,6 +702,7 @@ function cleanup() {
|
||||||
teleporter.disableMappings();
|
teleporter.disableMappings();
|
||||||
teleporter.deleteTargetOverlay();
|
teleporter.deleteTargetOverlay();
|
||||||
teleporter.turnOffOverlayBeams();
|
teleporter.turnOffOverlayBeams();
|
||||||
|
teleporter.deleteFadeSphere();
|
||||||
if (teleporter.updateConnected !== null) {
|
if (teleporter.updateConnected !== null) {
|
||||||
|
|
||||||
if (USE_THUMB_AND_TRIGGER_MODE === true) {
|
if (USE_THUMB_AND_TRIGGER_MODE === true) {
|
||||||
|
|
Loading…
Reference in a new issue