mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
Fix sensor overlays not displaying after re-enter HMD mode
This commit is contained in:
parent
5ff2c36917
commit
858abaf6fc
1 changed files with 37 additions and 64 deletions
|
@ -159,7 +159,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS = { x: 0.1198, y: 0.2981, z: 0.1198 };
|
this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS = { x: 0.1198, y: 0.2981, z: 0.1198 };
|
||||||
this.PLAY_AREA_SENSOR_OVERLAY_ROTATION = Quat.fromVec3Degrees({ x: 0, y: -90, z: 0 });
|
this.PLAY_AREA_SENSOR_OVERLAY_ROTATION = Quat.fromVec3Degrees({ x: 0, y: -90, z: 0 });
|
||||||
this.playAreaSensorPositions = [];
|
this.playAreaSensorPositions = [];
|
||||||
this.playAreaSensorPositionOverlays = [];
|
|
||||||
this.playArea = { x: 0, y: 0 };
|
this.playArea = { x: 0, y: 0 };
|
||||||
this.playAreaCenterOffset = this.PLAY_AREA_OVERLAY_OFFSET;
|
this.playAreaCenterOffset = this.PLAY_AREA_OVERLAY_OFFSET;
|
||||||
this.isPlayAreaVisible = false;
|
this.isPlayAreaVisible = false;
|
||||||
|
@ -225,12 +224,14 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
for (var i = 0; i < _this.playAreaSensorPositionOverlays.length; i++) {
|
for (var i = 0; i < _this.playAreaSensorPositionOverlays.length; i++) {
|
||||||
Overlays.deleteOverlay(_this.playAreaSensorPositionOverlays[i]);
|
Overlays.deleteOverlay(_this.playAreaSensorPositionOverlays[i]);
|
||||||
}
|
}
|
||||||
|
_this.playAreaSensorPositionOverlays = [];
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initPointers = function() {
|
this.initPointers = function() {
|
||||||
if (_this.init) {
|
if (_this.init) {
|
||||||
_this.cleanup();
|
_this.cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
_this.teleportParabolaHandVisuals = Pointers.createPointer(PickType.Parabola, {
|
_this.teleportParabolaHandVisuals = Pointers.createPointer(PickType.Parabola, {
|
||||||
joint: (_this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
|
joint: (_this.hand === RIGHT_HAND) ? "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND",
|
||||||
dirOffset: { x: 0, y: 1, z: 0.1 },
|
dirOffset: { x: 0, y: 1, z: 0.1 },
|
||||||
|
@ -289,6 +290,12 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
maxDistance: 8.0
|
maxDistance: 8.0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHandVisuals));
|
||||||
|
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHandCollisions));
|
||||||
|
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHeadVisuals));
|
||||||
|
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHeadCollisions));
|
||||||
|
|
||||||
|
|
||||||
var capsuleData = MyAvatar.getCollisionCapsule();
|
var capsuleData = MyAvatar.getCollisionCapsule();
|
||||||
|
|
||||||
var sensorToWorldScale = MyAvatar.getSensorToWorldScale();
|
var sensorToWorldScale = MyAvatar.getSensorToWorldScale();
|
||||||
|
@ -330,6 +337,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
threshold: _this.capsuleThreshold
|
threshold: _this.capsuleThreshold
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
_this.playAreaOverlay = Overlays.addOverlay("model", {
|
_this.playAreaOverlay = Overlays.addOverlay("model", {
|
||||||
url: _this.PLAY_AREA_OVERLAY_MODEL,
|
url: _this.PLAY_AREA_OVERLAY_MODEL,
|
||||||
drawInFront: false,
|
drawInFront: false,
|
||||||
|
@ -342,14 +350,36 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHandVisuals));
|
|
||||||
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHandCollisions));
|
|
||||||
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHeadVisuals));
|
|
||||||
_this.addToSelectedItemsList(Pointers.getOverlayIDs(_this.teleportParabolaHeadCollisions));
|
|
||||||
|
|
||||||
Selection.addToSelectedItemsList(_this.teleporterSelectionName, "overlay", _this.playAreaOverlay);
|
Selection.addToSelectedItemsList(_this.teleporterSelectionName, "overlay", _this.playAreaOverlay);
|
||||||
Selection.addToSelectedItemsList(_this.teleporterSelectionName, "overlay", _this.teleportedTargetOverlay);
|
Selection.addToSelectedItemsList(_this.teleporterSelectionName, "overlay", _this.teleportedTargetOverlay);
|
||||||
Selection.addToSelectedItemsList(this.teleporterSelectionName, "overlay", this.playAreaOverlay);
|
|
||||||
|
|
||||||
|
_this.playArea = HMD.playArea;
|
||||||
|
_this.isPlayAreaAvailable = HMD.active && _this.playArea.width !== 0 && _this.playArea.height !== 0;
|
||||||
|
if (_this.isPlayAreaAvailable) {
|
||||||
|
_this.playAreaCenterOffset = Vec3.sum({ x: _this.playArea.x, y: 0, z: _this.playArea.y },
|
||||||
|
_this.PLAY_AREA_OVERLAY_OFFSET);
|
||||||
|
|
||||||
|
_this.playAreaSensorPositions = HMD.sensorPositions;
|
||||||
|
for (var i = 0; i < _this.playAreaSensorPositions.length; i++) {
|
||||||
|
if (i > _this.playAreaSensorPositionOverlays.length - 1) {
|
||||||
|
var overlay = Overlays.addOverlay("model", {
|
||||||
|
url: _this.PLAY_AREA_SENSOR_OVERLAY_MODEL,
|
||||||
|
dimensions: _this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS,
|
||||||
|
parentID: _this.playAreaOverlay,
|
||||||
|
localRotation: _this.PLAY_AREA_SENSOR_OVERLAY_ROTATION,
|
||||||
|
solid: true,
|
||||||
|
drawInFront: false,
|
||||||
|
visible: false
|
||||||
|
});
|
||||||
|
_this.playAreaSensorPositionOverlays.push(overlay);
|
||||||
|
Selection.addToSelectedItemsList(_this.teleporterSelectionName, "overlay", overlay);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_this.setPlayAreaDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_this.init = true;
|
_this.init = true;
|
||||||
};
|
};
|
||||||
|
@ -357,27 +387,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
_this.initPointers();
|
_this.initPointers();
|
||||||
|
|
||||||
|
|
||||||
this.addPlayAreaSensorPositionOverlay = function () {
|
|
||||||
var overlay = Overlays.addOverlay("model", {
|
|
||||||
url: this.PLAY_AREA_SENSOR_OVERLAY_MODEL,
|
|
||||||
dimensions: this.PLAY_AREA_SENSOR_OVERLAY_DIMENSIONS,
|
|
||||||
parentID: this.playAreaOverlay,
|
|
||||||
localRotation: this.PLAY_AREA_SENSOR_OVERLAY_ROTATION,
|
|
||||||
solid: true,
|
|
||||||
drawInFront: false,
|
|
||||||
visible: false
|
|
||||||
});
|
|
||||||
this.playAreaSensorPositionOverlays.push(overlay);
|
|
||||||
Selection.addToSelectedItemsList(this.teleporterSelectionName, "overlay", overlay);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.deletePlayAreaSensorPositionOverlay = function (index) {
|
|
||||||
var overlay = this.playAreaSensorPositionOverlays[index];
|
|
||||||
Selection.removeFromSelectedItemsList(this.teleporterSelectionName, "overlay", overlay);
|
|
||||||
Overlays.deleteOverlay(overlay);
|
|
||||||
this.playAreaSensorPositionOverlays.splice(index, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setPlayAreaDimensions = function () {
|
this.setPlayAreaDimensions = function () {
|
||||||
var avatarScale = MyAvatar.scale;
|
var avatarScale = MyAvatar.scale;
|
||||||
|
|
||||||
|
@ -509,35 +518,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setPlayAreaAvailable = function () {
|
|
||||||
this.playArea = HMD.playArea;
|
|
||||||
this.isPlayAreaAvailable = HMD.active && this.playArea.width !== 0 && this.playArea.height !== 0;
|
|
||||||
if (this.isPlayAreaAvailable) {
|
|
||||||
this.playAreaCenterOffset = Vec3.sum({ x: this.playArea.x, y: 0, z: this.playArea.y },
|
|
||||||
this.PLAY_AREA_OVERLAY_OFFSET);
|
|
||||||
|
|
||||||
this.playAreaSensorPositions = HMD.sensorPositions;
|
|
||||||
for (var i = 0; i < this.playAreaSensorPositions.length; i++) {
|
|
||||||
if (i > this.playAreaSensorPositionOverlays.length - 1) {
|
|
||||||
this.addPlayAreaSensorPositionOverlay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = this.playAreaSensorPositionOverlays.length; i > this.playAreaSensorPositions.length; i--) {
|
|
||||||
this.deletePlayAreaSensorPositionOverlay(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setPlayAreaDimensions();
|
|
||||||
} else {
|
|
||||||
Overlays.editOverlay(this.playAreaOverlay, { visible: false });
|
|
||||||
for (i = 0; i < this.playAreaSensorPositionOverlays.length; i++) {
|
|
||||||
Overlays.editOverlay(this.playAreaSensorPositionOverlays[i], { visible: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setPlayAreaAvailable();
|
|
||||||
|
|
||||||
this.updatePlayArea = function (position) {
|
this.updatePlayArea = function (position) {
|
||||||
var sensorToWorldMatrix = MyAvatar.sensorToWorldMatrix;
|
var sensorToWorldMatrix = MyAvatar.sensorToWorldMatrix;
|
||||||
var sensorToWorldRotation = Mat4.extractRotation(MyAvatar.sensorToWorldMatrix);
|
var sensorToWorldRotation = Mat4.extractRotation(MyAvatar.sensorToWorldMatrix);
|
||||||
|
@ -1006,8 +986,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
Script.setTimeout(function () {
|
Script.setTimeout(function () {
|
||||||
leftTeleporter.initPointers();
|
leftTeleporter.initPointers();
|
||||||
rightTeleporter.initPointers();
|
rightTeleporter.initPointers();
|
||||||
leftTeleporter.setPlayAreaAvailable();
|
|
||||||
rightTeleporter.setPlayAreaAvailable();
|
|
||||||
}, 500);
|
}, 500);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1016,11 +994,6 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
Messages.subscribe('Hifi-Teleport-Ignore-Remove');
|
Messages.subscribe('Hifi-Teleport-Ignore-Remove');
|
||||||
Messages.messageReceived.connect(handleTeleportMessages);
|
Messages.messageReceived.connect(handleTeleportMessages);
|
||||||
|
|
||||||
//HMD.displayModeChanged.connect(function () {
|
|
||||||
// leftTeleporter.setPlayAreaAvailable();
|
|
||||||
// rightTeleporter.setPlayAreaAvailable();
|
|
||||||
//});
|
|
||||||
|
|
||||||
MyAvatar.scaleChanged.connect(function () {
|
MyAvatar.scaleChanged.connect(function () {
|
||||||
leftTeleporter.updatePlayAreaScale();
|
leftTeleporter.updatePlayAreaScale();
|
||||||
rightTeleporter.updatePlayAreaScale();
|
rightTeleporter.updatePlayAreaScale();
|
||||||
|
|
Loading…
Reference in a new issue