Merge branch 'OverlaysMaster3' into feature/v8

This commit is contained in:
ksuprynowicz 2023-03-22 21:41:13 +01:00
commit 8969e7513c
20 changed files with 898 additions and 792 deletions

View file

@ -3,8 +3,9 @@
// //
// EZrecord.js // EZrecord.js
// //
// Created by David Rowe on 24 Jun 2017. // Created by David Rowe on June 24th, 2017.
// Copyright 2017 High Fidelity, Inc. // Copyright 2017 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -48,22 +49,23 @@
if (HMD.active) { if (HMD.active) {
// 3D overlay attached to avatar. // 3D overlay attached to avatar.
//V8TODO: change to local entity hmdOverlay = Entities.addEntity({
hmdOverlay = Overlays.addOverlay("text3d", { "type": "Text",
text: recordingText, "text": recordingText,
dimensions: { x: 3 * HMD_FONT_SIZE, y: HMD_FONT_SIZE }, "dimensions": { "x": 3 * HMD_FONT_SIZE, "y": HMD_FONT_SIZE, "z": 0.01 },
parentID: MyAvatar.sessionUUID, "parentID": MyAvatar.sessionUUID,
parentJointIndex: CAMERA_JOINT_INDEX, "parentJointIndex": CAMERA_JOINT_INDEX,
localPosition: { x: 0.95, y: 0.95, z: -2.0 }, "localPosition": { "x": 0.95, "y": 0.95, "z": -2.0 },
color: { red: 255, green: 0, blue: 0 }, "color": { "red": 255, "green": 0, "blue": 0 },
alpha: 0.9, "alpha": 0.9,
lineHeight: HMD_FONT_SIZE, "unlit": true,
backgroundAlpha: 0, "lineHeight": HMD_FONT_SIZE,
ignoreRayIntersection: true, "backgroundAlpha": 0,
isFacingAvatar: true, "ignorePickIntersection": true,
drawInFront: true, "billboardMode": "full",
visible: true "renderLayer": "front",
}); "visible": true
},"local");
} else { } else {
// 2D overlay on desktop. // 2D overlay on desktop.
desktopOverlay = Overlays.addOverlay("text", { desktopOverlay = Overlays.addOverlay("text", {
@ -86,7 +88,7 @@
Overlays.deleteOverlay(desktopOverlay); Overlays.deleteOverlay(desktopOverlay);
} }
if (hmdOverlay) { if (hmdOverlay) {
Overlays.deleteOverlay(hmdOverlay); Entities.deleteEntity(hmdOverlay);
} }
} }

View file

@ -4,13 +4,14 @@
// debugAvatarMixer.js // debugAvatarMixer.js
// scripts/developer/debugging // scripts/developer/debugging
// //
// Created by Brad Hefta-Gaub on 01/09/2017 // Created by Brad Hefta-Gaub on January 9th, 2017.
// Copyright 2017 High Fidelity, Inc. // Copyright 2017 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* global Toolbars, Script, Users, Overlays, AvatarList, Controller, Camera, getControllerWorldLocation */ /* global Toolbars, Script, Users, Entities, AvatarList, Controller, Camera, getControllerWorldLocation */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
@ -19,12 +20,12 @@ Script.include("/~/system/libraries/controllers.js");
var isShowingOverlays = true; var isShowingOverlays = true;
var debugOverlays = {}; var debugOverlays = {};
//V8TODO: change to local entity var textSizeOverlay = Entities.addEntity({
var textSizeOverlay = Overlays.addOverlay("text3d", { "type": "Text",
position: MyAvatar.position, "position": MyAvatar.position,
lineHeight: 0.1, "lineHeight": 0.1,
visible: false "visible": false
}); }, "local");
function removeOverlays() { function removeOverlays() {
// enumerate the overlays and remove them // enumerate the overlays and remove them
@ -33,11 +34,11 @@ function removeOverlays() {
for (var i = 0; i < overlayKeys.length; ++i) { for (var i = 0; i < overlayKeys.length; ++i) {
var avatarID = overlayKeys[i]; var avatarID = overlayKeys[i];
for (var j = 0; j < debugOverlays[avatarID].length; ++j) { for (var j = 0; j < debugOverlays[avatarID].length; ++j) {
Overlays.deleteOverlay(debugOverlays[avatarID][j]); Entities.deleteEntity(debugOverlays[avatarID][j]);
} }
} }
Overlays.deleteOverlay(textSizeOverlay); Entities.deleteEntity(textSizeOverlay);
debugOverlays = {}; debugOverlays = {};
} }
@ -91,27 +92,28 @@ function updateOverlays() {
//+" SM: " + AvatarManager.getAvatarSimulationRate(avatarID,"skeletonModel").toFixed(2) + "hz \n" //+" SM: " + AvatarManager.getAvatarSimulationRate(avatarID,"skeletonModel").toFixed(2) + "hz \n"
+" JD: " + AvatarManager.getAvatarSimulationRate(avatarID,"jointData").toFixed(2) + "hz \n" +" JD: " + AvatarManager.getAvatarSimulationRate(avatarID,"jointData").toFixed(2) + "hz \n"
var dimensions = Overlays.textSize(textSizeOverlay, text); var dimensions = Entities.textSize(textSizeOverlay, text);
if (avatarID in debugOverlays) { if (avatarID in debugOverlays) {
// keep the overlay above the current position of this avatar // keep the overlay above the current position of this avatar
Overlays.editOverlay(debugOverlays[avatarID][0], { Entities.editEntity(debugOverlays[avatarID][0], {
dimensions: { x: 1.1 * dimensions.width, y: 0.6 * dimensions.height }, "dimensions": { "x": 1.1 * dimensions.width, "y": 0.6 * dimensions.height },
position: overlayPosition, "position": overlayPosition,
text: text "text": text
}); });
} else { } else {
// add the overlay above this avatar // add the overlay above this avatar
var newOverlay = Overlays.addOverlay("text3d", { var newOverlay = Entities.addEntity({
position: overlayPosition, "type": "Text",
dimensions: { x: 1.1 * dimensions.width, y: 0.6 * dimensions.height }, "position": overlayPosition,
lineHeight: 0.1, "dimensions": { "x": 1.1 * dimensions.width, "y": 0.6 * dimensions.height },
text: text, "lineHeight": 0.1,
color: { red: 255, green: 255, blue: 255}, "text": text,
alpha: 1, "color": { "red": 255, "green": 255, "blue": 255},
solid: true, "alpha": 1,
isFacingAvatar: true, "primitiveMode": "solid",
drawInFront: true "billboardMode": "full",
}); "renderLayer": "front"
}, "local");
debugOverlays[avatarID]=[newOverlay]; debugOverlays[avatarID]=[newOverlay];
} }
@ -127,7 +129,7 @@ AvatarList.avatarRemovedEvent.connect(function(avatarID){
// first remove the rendered overlays // first remove the rendered overlays
for (var j = 0; j < debugOverlays[avatarID].length; ++j) { for (var j = 0; j < debugOverlays[avatarID].length; ++j) {
Overlays.deleteOverlay(debugOverlays[avatarID][j]); Entities.deleteEntity(debugOverlays[avatarID][j]);
} }
// delete the saved ID of the overlay from our mod overlays object // delete the saved ID of the overlay from our mod overlays object

View file

@ -2,8 +2,9 @@
// grabInspector.js // grabInspector.js
// examples/debugging/ // examples/debugging/
// //
// Created by Seth Alves on 2015-12-19. // Created by Seth Alves on December 19th, 2015.
// Copyright 2015 High Fidelity, Inc. // Copyright 2015 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -26,24 +27,27 @@ function updateOverlay(entityID, queryAACube) {
if (entityID in overlays) { if (entityID in overlays) {
var overlay = overlays[entityID]; var overlay = overlays[entityID];
Overlays.editOverlay(overlay, { Entities.editEntity(overlay, {
position: cubeCenter, "position": cubeCenter,
size: queryAACube.scale "size": queryAACube.scale
}); });
} else { } else {
//V8TODO: change to local entity overlays[entityID] = Entities.addEntity({
overlays[entityID] = Overlays.addOverlay("cube", { "type": "Shape",
position: cubeCenter, "shape": "Cube",
size: queryAACube.scale, "position": cubeCenter,
color: { "size": queryAACube.scale,
red: 0, "color": {
green: 0, "red": 0,
blue: 255 "green": 0,
"blue": 255
}, },
alpha: 1, "alpha": 1,
solid: false, "primitiveMode": "lines",
grabbable: false "grab": {
}); "grabbable": false
}
}, "local");
} }
} }
@ -58,7 +62,7 @@ Script.setInterval(function() {
function cleanup() { function cleanup() {
for (var entityID in overlays) { for (var entityID in overlays) {
Overlays.deleteOverlay(overlays[entityID]); Entities.deleteEntity((overlays[entityID]);
} }
} }

View file

@ -1,5 +1,10 @@
//
// raypickTester.js // raypickTester.js
// //
// Created by Humbletim on June 18th, 2018.
// Copyright 2018 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// display intersection details (including material) when hovering over entities/avatars/overlays // display intersection details (including material) when hovering over entities/avatars/overlays
// //
@ -11,17 +16,18 @@ var JOINT_NAME = HMD.active ? HAND_JOINT : 'Mouse';
var UPDATE_MS = 1000/30; var UPDATE_MS = 1000/30;
// create tect3d overlay to display hover results // create tect3d overlay to display hover results
//V8TODO: change to local entity var overlayID = Entities.addEntity({
var overlayID = Overlays.addOverlay('text3d', { "type": "Text",
text: 'hover', "text": "hover",
visible: false, "visible": false,
backgroundAlpha: 0, "backgroundAlpha": 0,
isFacingAvatar: true, "billboardMode": "full",
lineHeight: 0.05, "lineHeight": 0.05,
dimensions: Vec3.HALF, "dimensions": Vec3.HALF,
}); }, "local");
Script.scriptEnding.connect(function() { Script.scriptEnding.connect(function() {
Overlays.deleteOverlay(overlayID); Entities.deleteEntity(overlayID);
}); });
// create raycast picker // create raycast picker
@ -60,10 +66,10 @@ function updateOverlay(overlayID, result) {
['submesh: ' + extraInfo.subMeshIndex, 'part: '+extraInfo.partIndex, 'shape: '+extraInfo.shapeID].join(' | '), ['submesh: ' + extraInfo.subMeshIndex, 'part: '+extraInfo.partIndex, 'shape: '+extraInfo.shapeID].join(' | '),
].filter(Boolean).join('\n'); ].filter(Boolean).join('\n');
Overlays.editOverlay(overlayID, { Entities.editEntity(overlayID, {
text: text, "text": text,
position: position, "position": position,
visible: result.intersects, "visible": result.intersects
}); });
} }

View file

@ -2,9 +2,10 @@
// sphereLodTest.js // sphereLodTest.js
// examples/tests // examples/tests
// //
// Created by Eric Levin on 1/21/16. // Created by Eric Levin on January 21st, 2016.
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// A test script for testing LODing of sphere entities and sphere overlays // A test script for testing LODing of sphere entities and sphere overlays
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
@ -46,22 +47,21 @@ var entitySphere = Entities.addEntity({
}); });
var overlaySpherePosition = Vec3.sum(tablePosition, {x: sphereDimensions.x, y: tableDimensions.y/2 + sphereDimensions.y/2, z: 0}); var overlaySpherePosition = Vec3.sum(tablePosition, {x: sphereDimensions.x, y: tableDimensions.y/2 + sphereDimensions.y/2, z: 0});
//V8TODO: change to local entity var overlaySphere = Entities.addEntity({
var overlaySphere = Overlays.addOverlay("sphere", { "type": "Sphere",
position: overlaySpherePosition, "position": overlaySpherePosition,
size: 0.01, "dimensions": sphereDimensions,
color: { red: 20, green: 200, blue: 0}, "color": { "red": 20, "green": 200, "blue": 0},
alpha: 1.0, "alpha": 1.0
solid: true, }, "local");
});
function cleanup() { function cleanup() {
Entities.deleteEntity(table); Entities.deleteEntity(table);
Entities.deleteEntity(entitySphere); Entities.deleteEntity(entitySphere);
Overlays.deleteOverlay(overlaySphere); Entities.deleteEntity(overlaySphere);
} }
Script.scriptEnding.connect(cleanup); Script.scriptEnding.connect(cleanup);

View file

@ -1,4 +1,9 @@
// webSpawnTool.js //
// webOverlayTool.js
//
// Created by Bradley Austin Davis on March 16th, 2018.
// Copyright 2018 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Stress tests the rendering of web surfaces over time // Stress tests the rendering of web surfaces over time
// //
@ -24,24 +29,24 @@ SPAWNER = function (properties) {
function makeObject(properties) { function makeObject(properties) {
//V8TODO: change to local entity var overlay = Entities.addEntity({
var overlay = Overlays.addOverlay("web3d", { "type": "Web",
name: "Web", "name": "Web",
url: "https://www.reddit.com/r/random", "sourceUrl": "https://www.reddit.com/r/random",
localPosition: randomPositionXZ( { x: 0, y: 0, z: -1 }, 1), "localPosition": randomPositionXZ( { "x": 0, "y": 0, "z": -1 }, 1),
localRotation: Quat.angleAxis(180, Vec3.Y_AXIS), "localRotation": Quat.angleAxis(180, Vec3.Y_AXIS),
dimensions: {x: .8, y: .45, z: 0.1}, "dimensions": {"x": 0.8, "y": 0.45, "z": 0.1},
color: { red: 255, green: 255, blue: 255 }, "color": { "red": 255, "green": 255, "blue": 255 },
alpha: 1.0, "alpha": 1.0,
showKeyboardFocusHighlight: false, "showKeyboardFocusHighlight": false,
visible: true "visible": true
}); }, "local");
var now = Date.now(); var now = Date.now();
return { return {
destroy: function () { destroy: function () {
Overlays.deleteOverlay(overlay) Entities.deleteEntity(overlay);
}, },
getAge: function () { getAge: function () {
return (Date.now() - now) / 1000.0; return (Date.now() - now) / 1000.0;

View file

@ -1,19 +1,19 @@
"use strict";
// //
// audioMuteOverlay.js // audioMuteOverlay.js
// //
// client script that creates an overlay to provide mute feedback // Created by Triplelexx on March 9th, 2017
// // Reworked by Seth Alves on February 17th, 2019
// Created by Triplelexx on 17/03/09
// Reworked by Seth Alves on 2019-2-17
// Copyright 2017 High Fidelity, Inc. // Copyright 2017 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// client script that creates an overlay to provide mute feedback
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
"use strict"; /* global Audio, Script, Entities, Quat, MyAvatar, HMD */
/* global Audio, Script, Overlays, Quat, MyAvatar, HMD */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
@ -41,24 +41,27 @@
} }
if (HMD.active) { if (HMD.active) {
//V8TODO: change to local entity warningOverlayID = Entities.addEntity({
warningOverlayID = Overlays.addOverlay("text3d", { "type": "Text",
name: "Muted-Warning", "name": "Muted-Warning",
localPosition: { x: 0.0, y: -0.45, z: -1.0 }, "localPosition": { "x": 0.0, "y": -0.45, "z": -1.0 },
localOrientation: Quat.fromVec3Degrees({ x: 0.0, y: 0.0, z: 0.0, w: 1.0 }), "localRotation": Quat.fromVec3Degrees({ "x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0 }),
text: warningText, "text": warningText,
textAlpha: 1, "unlit": true,
textColor: { red: 226, green: 51, blue: 77 }, "textAlpha": 1.0,
backgroundAlpha: 0, "textColor": { "red": 245, "green": 44, "blue": 74 },
lineHeight: 0.042, "backgroundAlpha": 0.0,
dimensions: { x: 0.11, y: 0.05 }, "lineHeight": 0.042,
visible: true, "dimensions": {"x": 0.11, "y": 0.05, "z": 0.01 },
ignoreRayIntersection: true, "visible": true,
drawInFront: true, "ignorePickIntersection": true,
grabbable: false, "renderLayer": "front",
parentID: MyAvatar.SELF_ID, "grab": {
parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX") "grabbable": false
}); },
"parentID": MyAvatar.SELF_ID,
"parentJointIndex": MyAvatar.getJointIndex("_CAMERA_MATRIX")
}, "local");
} }
} }
@ -66,7 +69,7 @@
if (!warningOverlayID) { if (!warningOverlayID) {
return; return;
} }
Overlays.deleteOverlay(warningOverlayID); Entities.deleteEntity(warningOverlayID);
warningOverlayID = null; warningOverlayID = null;
} }

View file

@ -1,7 +1,8 @@
// avatarFinderBeacon.js // avatarFinderBeacon.js
// //
// Created by Thijs Wenker on 12/7/16 // Created by Thijs Wenker on December 7th, 2016
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Shows 2km long red beams for each avatar outside of the 20 meter radius of your avatar, tries to ignore AC Agents. // Shows 2km long red beams for each avatar outside of the 20 meter radius of your avatar, tries to ignore AC Agents.
// //
@ -9,7 +10,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
var MIN_DISPLAY_DISTANCE = 20.0; // meters var MIN_DISPLAY_DISTANCE = 20.0; // meters
var BEAM_COLOR = {red: 255, green: 0, blue: 0}; var BEAM_COLOR = {"red": 255, "green": 0, "blue": 0};
var SHOW_THROUGH_WALLS = false; var SHOW_THROUGH_WALLS = false;
var BEACON_LENGTH = 2000.0; // meters var BEACON_LENGTH = 2000.0; // meters
var TRY_TO_IGNORE_AC_AGENTS = true; var TRY_TO_IGNORE_AC_AGENTS = true;
@ -27,29 +28,38 @@ var POSSIBLE_AC_AVATARS = [
AvatarFinderBeacon = function(avatar) { AvatarFinderBeacon = function(avatar) {
var visible = false; var visible = false;
var avatarSessionUUID = avatar.sessionUUID; var avatarSessionUUID = avatar.sessionUUID;
//V8TODO: change to local entity var renderLayer = "world";
this.overlay = Overlays.addOverlay('line3d', { if (SHOW_THROUGH_WALLS) {
color: BEAM_COLOR, renderLayer = "front";
dashed: false, }
start: Vec3.sum(avatar.position, {x: 0, y: -HALF_BEACON_LENGTH, z: 0}), this.overlay = Entities.addEntity({
end: Vec3.sum(avatar.position, {x: 0, y: HALF_BEACON_LENGTH, z: 0}), "type": "PolyLine",
rotation: {x: 0, y: 0, z: 0, w: 1}, "color": BEAM_COLOR,
visible: visible, "linePoints": [
drawInFront: SHOW_THROUGH_WALLS, Vec3.sum(avatar.position, {"x": 0, "y": -HALF_BEACON_LENGTH, "z": 0}),
ignoreRayIntersection: true, Vec3.sum(avatar.position, {"x": 0, "y": HALF_BEACON_LENGTH, "z": 0})
parentID: avatarSessionUUID, ],
parentJointIndex: -2 "strokeWidths": [
}); 0.02,
0.02
],
"rotation": {"x": 0, "y": 0, "z": 0, "w": 1},
"visible": visible,
"renderLayer": renderLayer,
"ignorePickIntersection": true,
"parentID": avatarSessionUUID,
"parentJointIndex": -2
}, "local");
this.cleanup = function() { this.cleanup = function() {
Overlays.deleteOverlay(this.overlay); Entities.deleteEntity(this.overlay);
}; };
this.shouldShow = function() { this.shouldShow = function() {
return Vec3.distance(MyAvatar.position, avatar.position) >= MIN_DISPLAY_DISTANCE; return Vec3.distance(MyAvatar.position, avatar.position) >= MIN_DISPLAY_DISTANCE;
}; };
this.update = function() { this.update = function() {
avatar = AvatarList.getAvatar(avatarSessionUUID); avatar = AvatarList.getAvatar(avatarSessionUUID);
Overlays.editOverlay(this.overlay, { Entities.editEntity(this.overlay, {
visible: this.shouldShow() "visible": this.shouldShow()
}); });
}; };
}; };

View file

@ -1,11 +1,11 @@
"use strict"; "use strict";
// //
// away.js // away.js
// //
// Created by Howard Stearns 11/3/15 // Created by Howard Stearns November, 3rd, 2015
// Copyright 2015 High Fidelity, Inc. // Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors. // Copyright 2021 Vircadia contributors.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -21,31 +21,31 @@ var BASIC_TIMER_INTERVAL = 50; // 50ms = 20hz
var OVERLAY_WIDTH = 1920; var OVERLAY_WIDTH = 1920;
var OVERLAY_HEIGHT = 1080; var OVERLAY_HEIGHT = 1080;
var OVERLAY_DATA = { var OVERLAY_DATA = {
width: OVERLAY_WIDTH, "width": OVERLAY_WIDTH,
height: OVERLAY_HEIGHT, "height": OVERLAY_HEIGHT,
imageURL: Script.resolvePath("assets/images/Overlay-Viz-blank.png"), "imageURL": Script.resolvePath("assets/images/Overlay-Viz-blank.png"),
emissive: true, "emissive": true,
drawInFront: true, "drawInFront": true,
alpha: 1 "alpha": 1.0
}; };
var AVATAR_MOVE_FOR_ACTIVE_DISTANCE = 0.8; // meters -- no longer away if avatar moves this far while away var AVATAR_MOVE_FOR_ACTIVE_DISTANCE = 0.8; // meters -- no longer away if avatar moves this far while away
var CAMERA_MATRIX = -7; var CAMERA_MATRIX = -7;
var OVERLAY_DATA_HMD = { var OVERLAY_DATA_HMD = {
localPosition: {x: 0, y: 0, z: -1 * MyAvatar.sensorToWorldScale}, "type": "Image",
localRotation: {x: 0, y: 0, z: 0, w: 1}, "localPosition": {"x": 0, "y": 0, "z": -1 * MyAvatar.sensorToWorldScale},
width: OVERLAY_WIDTH, "localRotation": {"x": 0, "y": 0, "z": 0, "w": 1},
height: OVERLAY_HEIGHT, "keepAspectRatio": true,
url: Script.resolvePath("assets/images/Overlay-Viz-blank.png"), "imageURL": Script.resolvePath("assets/images/Overlay-Viz-blank.png"),
color: {red: 255, green: 255, blue: 255}, "color": {"red": 255, "green": 255, "blue": 255},
alpha: 1, "alpha": 1.0,
scale: 2 * MyAvatar.sensorToWorldScale, "dimensions": Vec3.multiply({"x": 2, "y": 2, "z": 2}, MyAvatar.sensorToWorldScale),
emissive: true, "emissive": true,
drawInFront: true, "renderLayer": "front",
parentID: MyAvatar.SELF_ID, "parentID": MyAvatar.SELF_ID,
parentJointIndex: CAMERA_MATRIX, "parentJointIndex": CAMERA_MATRIX,
ignorePickIntersection: true "ignorePickIntersection": true
}; };
var AWAY_INTRO = { var AWAY_INTRO = {
@ -89,33 +89,32 @@ function stopAwayAnimation() {
// OVERLAY // OVERLAY
var overlay = Overlays.addOverlay("image", OVERLAY_DATA); var overlay = Overlays.addOverlay("image", OVERLAY_DATA);
//V8TODO: change to local entity var overlayHMD = Entities.addEntity(OVERLAY_DATA_HMD, "local");
var overlayHMD = Overlays.addOverlay("image3d", OVERLAY_DATA_HMD);
function showOverlay() { function showOverlay() {
if (HMD.active) { if (HMD.active) {
// make sure desktop version is hidden // make sure desktop version is hidden
Overlays.editOverlay(overlay, { visible: false }); Overlays.editOverlay(overlay, { "visible": false });
Overlays.editOverlay(overlayHMD, { visible: true }); Entities.editEntity(overlayHMD, { "visible": true });
} else { } else {
// make sure HMD is hidden // make sure HMD is hidden
Overlays.editOverlay(overlayHMD, { visible: false }); Entities.editEntity(overlayHMD, { "visible": false });
// Update for current screen size, keeping overlay proportions constant. // Update for current screen size, keeping overlay proportions constant.
var screen = Controller.getViewportDimensions(); var screen = Controller.getViewportDimensions();
// keep the overlay it's natural size and always center it... // keep the overlay it's natural size and always center it...
Overlays.editOverlay(overlay, { Overlays.editOverlay(overlay, {
visible: true, "visible": true,
x: ((screen.x - OVERLAY_WIDTH) / 2), "x": ((screen.x - OVERLAY_WIDTH) / 2),
y: ((screen.y - OVERLAY_HEIGHT) / 2) "y": ((screen.y - OVERLAY_HEIGHT) / 2)
}); });
} }
} }
function hideOverlay() { function hideOverlay() {
Overlays.editOverlay(overlay, {visible: false}); Overlays.editOverlay(overlay, {"visible": false});
Overlays.editOverlay(overlayHMD, {visible: false}); Entities.editEntity(overlayHMD, {"visible": false});
} }
hideOverlay(); hideOverlay();
@ -132,10 +131,10 @@ function maybeMoveOverlay() {
var sensorScaleFactor = MyAvatar.sensorToWorldScale; var sensorScaleFactor = MyAvatar.sensorToWorldScale;
var localPosition = {x: 0, y: 0, z: -1 * sensorScaleFactor}; var localPosition = {x: 0, y: 0, z: -1 * sensorScaleFactor};
Overlays.editOverlay(overlayHMD, { visible: true, localPosition: localPosition, scale: 2 * sensorScaleFactor }); Entities.editEntity(overlayHMD, { "visible": true, "localPosition": localPosition, "dimensions": Vec3.multiply({"x": 2, "y": 2, "z": 2}, MyAvatar.sensorToWorldScale )});
// make sure desktop version is hidden // make sure desktop version is hidden
Overlays.editOverlay(overlay, { visible: false }); Overlays.editOverlay(overlay, { "visible": false });
// also remember avatar position // also remember avatar position
avatarPosition = MyAvatar.position; avatarPosition = MyAvatar.position;

View file

@ -1,16 +1,16 @@
"use strict"; "use strict";
// //
// bubble.js // bubble.js
// scripts/system/ // scripts/system/
// //
// Created by Brad Hefta-Gaub on 11/18/2016 // Created by Brad Hefta-Gaub on November 18th, 2016
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* global Script, Users, Overlays, AvatarList, Controller, Camera, getControllerWorldLocation, UserActivityLogger */ /* global Script, Users, Entities, AvatarList, Controller, Camera, getControllerWorldLocation, UserActivityLogger */
(function () { // BEGIN LOCAL_SCOPE (function () { // BEGIN LOCAL_SCOPE
var button; var button;
@ -21,16 +21,19 @@
// Affects bubble height // Affects bubble height
var BUBBLE_HEIGHT_SCALE = 0.15; var BUBBLE_HEIGHT_SCALE = 0.15;
// The bubble model itself // The bubble model itself
//V8TODO: change to local entity var bubbleOverlay = Entities.addEntity({
var bubbleOverlay = Overlays.addOverlay("model", { "type": "Model",
url: Script.resolvePath("assets/models/Bubble-v14.fbx"), // If you'd like to change the model, modify this line (and the dimensions below) "modelURL": Script.resolvePath("assets/models/Bubble-v14.fbx"), // If you'd like to change the model, modify this line (and the dimensions below)
dimensions: { x: MyAvatar.sensorToWorldScale, y: 0.75 * MyAvatar.sensorToWorldScale, z: MyAvatar.sensorToWorldScale }, "dimensions": {
position: { x: MyAvatar.position.x, y: -MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, z: MyAvatar.position.z }, "x": MyAvatar.sensorToWorldScale * 2,
rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), "y": (0.75 * MyAvatar.sensorToWorldScale) * ((MyAvatar.scale * 0.5) + 0.5),
scale: { x: 2 , y: MyAvatar.scale * 0.5 + 0.5, z: 2 }, "z": MyAvatar.sensorToWorldScale * 2
visible: false, },
ignoreRayIntersection: true "position": { "x": MyAvatar.position.x, "y": -MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, "z": MyAvatar.position.z },
}); "rotation": Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({"x": 0.0, "y": 180.0, "z": 0.0})),
"visible": false,
"ignorePickIntersection": true
}, "local");
// The bubble activation sound // The bubble activation sound
var bubbleActivateSound = SoundCache.getSound(Script.resolvePath("assets/sounds/bubble.wav")); var bubbleActivateSound = SoundCache.getSound(Script.resolvePath("assets/sounds/bubble.wav"));
// Is the update() function connected? // Is the update() function connected?
@ -42,8 +45,8 @@
// Hides the bubble model overlay // Hides the bubble model overlay
function hideOverlays() { function hideOverlays() {
Overlays.editOverlay(bubbleOverlay, { Entities.editEntity(bubbleOverlay, {
visible: false "visible": false
}); });
} }
@ -85,24 +88,19 @@
Script.update.disconnect(update); Script.update.disconnect(update);
} }
Overlays.editOverlay(bubbleOverlay, { Entities.editEntity(bubbleOverlay, {
dimensions: { "dimensions": {
x: MyAvatar.sensorToWorldScale, "x": MyAvatar.sensorToWorldScale * 2,
y: 0.75 * MyAvatar.sensorToWorldScale, "y": (0.75 * MyAvatar.sensorToWorldScale) * ((MyAvatar.scale * 0.5) + 0.5),
z: MyAvatar.sensorToWorldScale "z": MyAvatar.sensorToWorldScale * 2
}, },
position: { "position": {
x: MyAvatar.position.x, "x": MyAvatar.position.x,
y: -MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, "y": -MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE,
z: MyAvatar.position.z "z": MyAvatar.position.z
}, },
rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), "rotation": Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({"x": 0.0, "y": 180.0, "z": 0.0})),
scale: { "visible": true
x: 2 ,
y: MyAvatar.scale * 0.5 + 0.5 ,
z: 2
},
visible: true
}); });
bubbleOverlayTimestamp = nowTimestamp; bubbleOverlayTimestamp = nowTimestamp;
Script.update.connect(update); Script.update.connect(update);
@ -127,44 +125,34 @@
var overlayAlpha = 1.0 - (delay / BUBBLE_VISIBLE_DURATION_MS); var overlayAlpha = 1.0 - (delay / BUBBLE_VISIBLE_DURATION_MS);
if (overlayAlpha > 0) { if (overlayAlpha > 0) {
if (delay < BUBBLE_RAISE_ANIMATION_DURATION_MS) { if (delay < BUBBLE_RAISE_ANIMATION_DURATION_MS) {
Overlays.editOverlay(bubbleOverlay, { Entities.editEntity(bubbleOverlay, {
dimensions: { "dimensions": {
x: MyAvatar.sensorToWorldScale, "x": MyAvatar.sensorToWorldScale * 2,
y: 0.75 * MyAvatar.sensorToWorldScale, "y": (0.75 * MyAvatar.sensorToWorldScale) * ((1 - ((BUBBLE_RAISE_ANIMATION_DURATION_MS - delay) / BUBBLE_RAISE_ANIMATION_DURATION_MS)) * MyAvatar.scale * 0.5 + 0.5),
z: MyAvatar.sensorToWorldScale "z": MyAvatar.sensorToWorldScale * 2
}, },
// Quickly raise the bubble from the ground up // Quickly raise the bubble from the ground up
position: { "position": {
x: MyAvatar.position.x, "x": MyAvatar.position.x,
y: (-((BUBBLE_RAISE_ANIMATION_DURATION_MS - delay) / BUBBLE_RAISE_ANIMATION_DURATION_MS)) * MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, "y": (-((BUBBLE_RAISE_ANIMATION_DURATION_MS - delay) / BUBBLE_RAISE_ANIMATION_DURATION_MS)) * MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE,
z: MyAvatar.position.z "z": MyAvatar.position.z
}, },
rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), "rotation": Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({"x": 0.0, "y": 180.0, "z": 0.0}))
scale: {
x: 2 ,
y: ((1 - ((BUBBLE_RAISE_ANIMATION_DURATION_MS - delay) / BUBBLE_RAISE_ANIMATION_DURATION_MS)) * MyAvatar.scale * 0.5 + 0.5),
z: 2
}
}); });
} else { } else {
// Keep the bubble in place for a couple seconds // Keep the bubble in place for a couple seconds
Overlays.editOverlay(bubbleOverlay, { Entities.editEntity(bubbleOverlay, {
dimensions: { "dimensions": {
x: MyAvatar.sensorToWorldScale, "x": MyAvatar.sensorToWorldScale * 2,
y: 0.75 * MyAvatar.sensorToWorldScale, "y": (0.75 * MyAvatar.sensorToWorldScale) * ((MyAvatar.scale * 0.5) + 0.5),
z: MyAvatar.sensorToWorldScale "z": MyAvatar.sensorToWorldScale * 2
}, },
position: { "position": {
x: MyAvatar.position.x, "x": MyAvatar.position.x,
y: MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, "y": MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE,
z: MyAvatar.position.z "z": MyAvatar.position.z
}, },
rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), "rotation": Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({"x": 0.0, "y": 180.0, "z": 0.0}))
scale: {
x: 2,
y: MyAvatar.scale * 0.5 + 0.5 ,
z: 2
}
}); });
} }
} else { } else {
@ -222,7 +210,7 @@
} }
Users.ignoreRadiusEnabledChanged.disconnect(onBubbleToggled); Users.ignoreRadiusEnabledChanged.disconnect(onBubbleToggled);
Users.enteredIgnoreRadius.disconnect(enteredIgnoreRadius); Users.enteredIgnoreRadius.disconnect(enteredIgnoreRadius);
Overlays.deleteOverlay(bubbleOverlay); Entities.deleteEntity(bubbleOverlay);
if (updateConnected === true) { if (updateConnected === true) {
Script.update.disconnect(update); Script.update.disconnect(update);
} }

View file

@ -1,7 +1,11 @@
"use strict"; "use strict";
//
// Chat.js // Chat.js
// By Don Hopkins (dhopkins@donhopkins.com) //
// By Don Hopkins (dhopkins@donhopkins.com) on May 5th, 2017
// Copyright 2017 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -45,17 +49,19 @@
var speechBubbleLineHeight = 0.05; // The height of a line of text in the speech bubble. var speechBubbleLineHeight = 0.05; // The height of a line of text in the speech bubble.
var SPEECH_BUBBLE_MAX_WIDTH = 1; // meters var SPEECH_BUBBLE_MAX_WIDTH = 1; // meters
//V8TODO: change to local entity var textSizeOverlay = Entities.addEntity({
var textSizeOverlay = Overlays.addOverlay("text3d", { "type": "Text",
position: MyAvatar.position, "position": MyAvatar.position,
lineHeight: speechBubbleLineHeight, "lineHeight": speechBubbleLineHeight,
leftMargin: 0, "leftMargin": 0,
topMargin: 0, "topMargin": 0,
rightMargin: 0, "rightMargin": 0,
bottomMargin: 0, "bottomMargin": 0,
ignoreRayIntersection: true, "unlit": true,
visible: false "alignment": "center",
}); "ignorePickIntersection": true,
"visible": false
}, "local");
// Load the persistent variables from the Settings, with defaults. // Load the persistent variables from the Settings, with defaults.
function loadSettings() { function loadSettings() {
@ -75,8 +81,8 @@
speechBubbleOffset = Settings.getValue('Chat_speechBubbleOffset', {x: 0.0, y: 0.3, z:0.0}); speechBubbleOffset = Settings.getValue('Chat_speechBubbleOffset', {x: 0.0, y: 0.3, z:0.0});
speechBubbleJointName = Settings.getValue('Chat_speechBubbleJointName', 'Head'); speechBubbleJointName = Settings.getValue('Chat_speechBubbleJointName', 'Head');
speechBubbleLineHeight = Settings.getValue('Chat_speechBubbleLineHeight', 0.05); speechBubbleLineHeight = Settings.getValue('Chat_speechBubbleLineHeight', 0.05);
Overlays.editOverlay(textSizeOverlay, { Entities.editEntity(textSizeOverlay, {
lineHeight: speechBubbleLineHeight "lineHeight": speechBubbleLineHeight
}); });
saveSettings(); saveSettings();
@ -291,20 +297,23 @@
} }
var identifierParams = { var identifierParams = {
parentID: myAvatarID, "type": "PolyLine",
parentJointIndex: myJointIndex, "parentID": myAvatarID,
lifetime: identifyAvatarDuration, "parentJointIndex": myJointIndex,
start: myJointPosition, "lifetime": identifyAvatarDuration,
endParentID: yourAvatarID, "linePoints": [
endParentJointIndex: yourJointIndex, myJointPosition,
end: yourJointPosition, yourJointPosition
color: identifyAvatarLineColor, ],
alpha: 1 "strokeWidths": [ 0.02, 0.02],
//endParentID: yourAvatarID, //Currently doesn't work. Never implemented.
//endParentJointIndex: yourJointIndex, //Currently doesn't work. Never implemented.
"color": identifyAvatarLineColor
}; };
avatarIdentifiers[yourAvatarID] = identifierParams; avatarIdentifiers[yourAvatarID] = identifierParams;
identifierParams.lineID = Overlays.addOverlay("line3d", identifierParams); identifierParams.lineID = Entities.addEntity(identifierParams, "local");
//print("ADDOVERLAY lineID", lineID, "myJointPosition", JSON.stringify(myJointPosition), "yourJointPosition", JSON.stringify(yourJointPosition), "lineData", JSON.stringify(lineData)); //print("ADDOVERLAY lineID", lineID, "myJointPosition", JSON.stringify(myJointPosition), "yourJointPosition", JSON.stringify(yourJointPosition), "lineData", JSON.stringify(lineData));
@ -330,7 +339,7 @@
} }
if (identifierParams.lineID) { if (identifierParams.lineID) {
Overlays.deleteOverlay(identifierParams.lineID); Entities.deleteEntity(identifierParams.lineID);
} }
delete avatarIdentifiers[yourAvatarID]; delete avatarIdentifiers[yourAvatarID];
@ -624,37 +633,36 @@
var jointIndex = MyAvatar.getJointIndex(speechBubbleJointName); var jointIndex = MyAvatar.getJointIndex(speechBubbleJointName);
var dimensions = { var dimensions = {
x: 100.0, "x": 100.0,
y: 100.0, "y": 100.0,
z: 0.1 "z": 0.1
}; };
speechBubbleParams = { speechBubbleParams = {
type: "Text", "type": "Text",
lifetime: speechBubbleDuration, "lifetime": speechBubbleDuration,
parentID: MyAvatar.sessionUUID, "parentID": MyAvatar.sessionUUID,
jointIndex: jointIndex, "jointIndex": jointIndex,
dimensions: dimensions, "dimensions": dimensions,
lineHeight: speechBubbleLineHeight, "lineHeight": speechBubbleLineHeight,
leftMargin: 0, "leftMargin": 0,
topMargin: 0, "topMargin": 0,
rightMargin: 0, "rightMargin": 0,
bottomMargin: 0, "bottomMargin": 0,
faceCamera: true, "billboardMode": "full",
drawInFront: true, "renderLayer": "front",
ignoreRayIntersection: true, "ignorePickIntersection": true,
text: speechBubbleMessage, "text": speechBubbleMessage,
textColor: speechBubbleTextColor, "textColor": speechBubbleTextColor,
color: speechBubbleTextColor, "backgroundColor": speechBubbleBackgroundColor
backgroundColor: speechBubbleBackgroundColor
}; };
// Only overlay text3d has a way to measure the text, not entities. // Only overlay text3d has a way to measure the text, not entities.
// So we make a temporary one just for measuring text, then delete it. // So we make a temporary one just for measuring text, then delete it.
var speechBubbleTextOverlayID = Overlays.addOverlay("text3d", speechBubbleParams); var speechBubbleTextOverlayID = Entities.addEntity(speechBubbleParams, "local");
var textSize = Overlays.textSize(textSizeOverlay, speechBubbleMessage); var textSize = Entities.textSize(textSizeOverlay, speechBubbleMessage);
try { try {
Overlays.deleteOverlay(speechBubbleTextOverlayID); Entities.deleteEntity(speechBubbleTextOverlayID);
} catch (e) {} } catch (e) {}
//print("updateSpeechBubble:", "speechBubbleMessage", speechBubbleMessage, "textSize", textSize.width, textSize.height); //print("updateSpeechBubble:", "speechBubbleMessage", speechBubbleMessage, "textSize", textSize.width, textSize.height);
@ -986,7 +994,7 @@
unidentifyAvatars(); unidentifyAvatars();
disconnectWebHandler(); disconnectWebHandler();
Overlays.deleteOverlay(textSizeOverlay); Entities.deleteEntity(textSizeOverlay);
if (onChatPage) { if (onChatPage) {
tablet.gotoHomeScreen(); tablet.gotoHomeScreen();

View file

@ -2,8 +2,9 @@
// controllerDispatcher.js // controllerDispatcher.js
// //
// Copyright 2017-2020 High Fidelity, Inc. // Created by Seth Alves, July 27th, 2017.
// Copyright 2023 Overte e.V. // Copyright 2017 High Fidelity, Inc.
// Copyright 2023, Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -261,10 +262,11 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
_this.dataGatherers.rightControllerLocation() _this.dataGatherers.rightControllerLocation()
]; ];
// find 3d overlays near each hand // find 3d overlays/Local Entities near each hand
var nearbyOverlayIDs = []; var nearbyOverlayIDs = [];
var h; var h;
/*for (h = LEFT_HAND; h <= RIGHT_HAND; h++) { //V8TODO: Overlays.findOverlays might not work here
for (h = LEFT_HAND; h <= RIGHT_HAND; h++) {
if (controllerLocations[h].valid) { if (controllerLocations[h].valid) {
var nearbyOverlays = var nearbyOverlays =
Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor); Overlays.findOverlays(controllerLocations[h].position, NEAR_MAX_RADIUS * sensorScaleFactor);
@ -287,9 +289,9 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
} }
nearbyOverlays.sort(function (a, b) { nearbyOverlays.sort(function (a, b) {
var aPosition = Overlays.getProperty(a, "position"); var aPosition = Entities.getEntityProperties(a, ["position"]).position;
var aDistance = Vec3.distance(aPosition, controllerLocations[h].position); var aDistance = Vec3.distance(aPosition, controllerLocations[h].position);
var bPosition = Overlays.getProperty(b, "position"); var bPosition = Entities.getEntityProperties(b, ["position"]).position;
var bDistance = Vec3.distance(bPosition, controllerLocations[h].position); var bDistance = Vec3.distance(bPosition, controllerLocations[h].position);
return aDistance - bDistance; return aDistance - bDistance;
}); });
@ -298,7 +300,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
} else { } else {
nearbyOverlayIDs.push([]); nearbyOverlayIDs.push([]);
} }
}*/ }
// find entities near each hand // find entities near each hand
var nearbyEntityProperties = [[], []]; var nearbyEntityProperties = [[], []];
@ -310,21 +312,31 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
if (SHOW_GRAB_SPHERE) { if (SHOW_GRAB_SPHERE) {
if (this.grabSphereOverlays[h]) { if (this.grabSphereOverlays[h]) {
Overlays.editOverlay(this.grabSphereOverlays[h], { position: controllerLocations[h].position }); Entities.editEntity(this.grabSphereOverlays[h], { "position": controllerLocations[h].position });
} else { } else {
var grabSphereSize = findRadius * 2; var grabSphereSize = findRadius * 2;
//V8TODO: change to local entity this.grabSphereOverlays[h] = Entities.addEntity({
this.grabSphereOverlays[h] = Overlays.addOverlay("sphere", { "type": "Shape",
position: controllerLocations[h].position, "shape": "Sphere",
dimensions: { x: grabSphereSize, y: grabSphereSize, z: grabSphereSize }, "position": controllerLocations[h].position,
color: { red: 30, green: 30, blue: 255 }, "dimensions": {
alpha: 0.3, "x": grabSphereSize,
solid: true, "y": grabSphereSize,
visible: true, "z": grabSphereSize
// lineWidth: 2.0, },
drawInFront: false, "color": {
grabbable: false "red": 30,
}); "green": 30,
"blue": 255
},
"alpha": 0.3,
"primitiveMode": "solid",
"visible": true,
"renderLayer": "front",
"grab": {
"grabbable": false
}
}, "local");
} }
} }
@ -656,8 +668,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
Controller.disableMapping(MAPPING_NAME); Controller.disableMapping(MAPPING_NAME);
_this.pointerManager.removePointers(); _this.pointerManager.removePointers();
Pointers.removePointer(this.mouseRayPointer); Pointers.removePointer(this.mouseRayPointer);
Overlays.mouseReleaseOnOverlay.disconnect(mouseReleaseOnOverlay); Entities.mouseReleaseOnEntity.disconnect(mouseReleaseOn);
Overlays.mousePressOnOverlay.disconnect(mousePress);
Entities.mousePressOnEntity.disconnect(mousePress); Entities.mousePressOnEntity.disconnect(mousePress);
Messages.messageReceived.disconnect(controllerDispatcher.handleMessage); Messages.messageReceived.disconnect(controllerDispatcher.handleMessage);
if (_this.debugPanelID) { if (_this.debugPanelID) {
@ -668,30 +679,30 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
if (DEBUG) { if (DEBUG) {
this.debugPanelID = Entities.addEntity({ this.debugPanelID = Entities.addEntity({
name: "controllerDispatcher debug panel", "name": "controllerDispatcher debug panel",
type: "Text", "type": "Text",
dimensions: { x: 1.0, y: 0.3, z: 0.01 }, "dimensions": { "x": 1.0, "y": 0.3, "z": 0.01 },
parentID: MyAvatar.sessionUUID, "parentID": MyAvatar.sessionUUID,
// parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"), // parentJointIndex: MyAvatar.getJointIndex("_CAMERA_MATRIX"),
parentJointIndex: -1, "parentJointIndex": -1,
localPosition: { x: -0.25, y: 0.8, z: -1.2 }, "localPosition": { "x": -0.25, "y": 0.8, "z": -1.2 },
textColor: { red: 255, green: 255, blue: 255}, "textColor": { "red": 255, "green": 255, "blue": 255},
backgroundColor: { red: 0, green: 0, blue: 0}, "backgroundColor": { "red": 0, "green": 0, "blue": 0},
text: "", "text": "",
lineHeight: 0.03, "lineHeight": 0.03,
leftMargin: 0.015, "leftMargin": 0.015,
topMargin: 0.01, "topMargin": 0.01,
backgroundAlpha: 0.7, "backgroundAlpha": 0.7,
textAlpha: 1.0, "textAlpha": 1.0,
unlit: true, "unlit": true,
ignorePickIntersection: true "ignorePickIntersection": true
}, "local"); }, "local");
} }
} }
function mouseReleaseOnOverlay(overlayID, event) { function mouseReleaseOn(id, event) {
if (HMD.homeButtonID && overlayID === HMD.homeButtonID && event.button === "Primary") { if (HMD.homeButtonID && id === HMD.homeButtonID && event.button === "Primary") {
Messages.sendLocalMessage("home", overlayID); Messages.sendLocalMessage("home", id);
} }
} }
@ -708,8 +719,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
} }
} }
Overlays.mouseReleaseOnOverlay.connect(mouseReleaseOnOverlay); Entities.mouseReleaseOnEntity.connect(mouseReleaseOn);
Overlays.mousePressOnOverlay.connect(mousePress);
Entities.mousePressOnEntity.connect(mousePress); Entities.mousePressOnEntity.connect(mousePress);
var controllerDispatcher = new ControllerDispatcher(); var controllerDispatcher = new ControllerDispatcher();

View file

@ -3,11 +3,13 @@
// //
// Created by Anthony J. Thibault on 10/20/16 // Created by Anthony J. Thibault on 10/20/16
// Originally created by Ryan Huffman on 9/21/2016 // Originally created by Ryan Huffman on 9/21/2016
// Copyright 2016 High Fidelity, Inc.
// Copyright 2023, Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/* globals createControllerDisplay:true, deleteControllerDisplay:true, Controller, Overlays, Vec3, MyAvatar, Quat */ /* globals createControllerDisplay:true, deleteControllerDisplay:true, Controller, Entities, Vec3, MyAvatar, Quat */
function clamp(value, min, max) { function clamp(value, min, max) {
if (value < min) { if (value < min) {
@ -51,8 +53,8 @@ createControllerDisplay = function(config) {
setVisible: function(visible) { setVisible: function(visible) {
for (var i = 0; i < this.overlays.length; ++i) { for (var i = 0; i < this.overlays.length; ++i) {
Overlays.editOverlay(this.overlays[i], { Entities.editEntity(this.overlays[i], {
visible: visible "visible": visible
}); });
} }
}, },
@ -62,8 +64,8 @@ createControllerDisplay = function(config) {
/* /*
if (partName in this.partOverlays) { if (partName in this.partOverlays) {
for (var i = 0; i < this.partOverlays[partName].length; ++i) { for (var i = 0; i < this.partOverlays[partName].length; ++i) {
Overlays.editOverlay(this.partOverlays[partName][i], { Entities.editEntity(this.partOverlays[partName][i], {
//visible: visible //"visible": visible
}); });
} }
} }
@ -80,8 +82,8 @@ createControllerDisplay = function(config) {
textures[part.textureName] = layer.defaultTextureURL; textures[part.textureName] = layer.defaultTextureURL;
} }
for (var i = 0; i < this.partOverlays[partName].length; ++i) { for (var i = 0; i < this.partOverlays[partName].length; ++i) {
Overlays.editOverlay(this.partOverlays[partName][i], { Entities.editEntity(this.partOverlays[partName][i], {
textures: textures "textures": textures
}); });
} }
} }
@ -93,14 +95,14 @@ createControllerDisplay = function(config) {
var controller = config.controllers[0]; var controller = config.controllers[0];
var position = controller.position; var position = controller.position;
// first overlay is main body. // first overlay/Local Entity is main body.
var overlayID = this.overlays[0]; var overlayID = this.overlays[0];
var localPosition = Vec3.multiply(sensorScaleFactor, Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position)); var localPosition = Vec3.multiply(sensorScaleFactor, Vec3.sum(Vec3.multiplyQbyV(controller.rotation, controller.naturalPosition), position));
var dimensions = Vec3.multiply(sensorScaleFactor, controller.dimensions); var dimensions = Vec3.multiply(sensorScaleFactor, controller.dimensions);
Overlays.editOverlay(overlayID, { Entities.editEntity(overlayID, {
dimensions: dimensions, "dimensions": dimensions,
localPosition: localPosition "localPosition": localPosition
}); });
if (controller.parts) { if (controller.parts) {
@ -143,15 +145,15 @@ createControllerDisplay = function(config) {
} }
} }
if (localRotation !== undefined) { if (localRotation !== undefined) {
Overlays.editOverlay(overlayID, { Entities.editEntity(overlayID, {
dimensions: Vec3.multiply(sensorScaleFactor, part.naturalDimensions), "dimensions": Vec3.multiply(sensorScaleFactor, part.naturalDimensions),
localPosition: Vec3.multiply(sensorScaleFactor, localPosition), "localPosition": Vec3.multiply(sensorScaleFactor, localPosition),
localRotation: localRotation "localRotation": localRotation
}); });
} else { } else {
Overlays.editOverlay(overlayID, { Entities.editEntity(overlayID, {
dimensions: Vec3.multiply(sensorScaleFactor, part.naturalDimensions), "dimensions": Vec3.multiply(sensorScaleFactor, part.naturalDimensions),
localPosition: Vec3.multiply(sensorScaleFactor, localPosition) "localPosition": Vec3.multiply(sensorScaleFactor, localPosition)
}); });
} }
} }
@ -172,16 +174,16 @@ createControllerDisplay = function(config) {
controller.naturalPosition = { x: 0, y: 0, z: 0 }; controller.naturalPosition = { x: 0, y: 0, z: 0 };
} }
//V8TODO: change to local entity var baseOverlayID = Entities.addEntity({
var baseOverlayID = Overlays.addOverlay("model", { "type": "Model",
url: controller.modelURL, "modelURL": controller.modelURL,
dimensions: Vec3.multiply(sensorScaleFactor, controller.dimensions), "dimensions": Vec3.multiply(sensorScaleFactor, controller.dimensions),
localRotation: controller.rotation, "localRotation": controller.rotation,
localPosition: Vec3.multiply(sensorScaleFactor, position), "localPosition": Vec3.multiply(sensorScaleFactor, position),
parentID: MyAvatar.SELF_ID, "parentID": MyAvatar.SELF_ID,
parentJointIndex: controller.jointIndex, "parentJointIndex": controller.jointIndex,
ignoreRayIntersection: true "ignorePickIntersection": true
}); }, "local");
controllerDisplay.overlays.push(baseOverlayID); controllerDisplay.overlays.push(baseOverlayID);
@ -194,11 +196,12 @@ createControllerDisplay = function(config) {
controllerDisplay.parts[partName] = controller.parts[partName]; controllerDisplay.parts[partName] = controller.parts[partName];
var properties = { var properties = {
url: part.modelURL, "type": "Model",
localPosition: localPosition, "modelURL": part.modelURL,
localRotation: localRotation, "localPosition": localPosition,
parentID: baseOverlayID, "localRotation": localRotation,
ignoreRayIntersection: true "parentID": baseOverlayID,
"ignorePickIntersection": true
}; };
if (part.defaultTextureLayer) { if (part.defaultTextureLayer) {
@ -207,8 +210,7 @@ createControllerDisplay = function(config) {
properties.textures = textures; properties.textures = textures;
} }
//V8TODO: change to local entity var overlayID = Entities.addEntity(properties, "local");
var overlayID = Overlays.addOverlay("model", properties);
if (part.type === "rotational") { if (part.type === "rotational") {
var input = resolveHardware(part.input); var input = resolveHardware(part.input);
@ -288,7 +290,7 @@ createControllerDisplay = function(config) {
deleteControllerDisplay = function(controllerDisplay) { deleteControllerDisplay = function(controllerDisplay) {
for (var i = 0; i < controllerDisplay.overlays.length; ++i) { for (var i = 0; i < controllerDisplay.overlays.length; ++i) {
Overlays.deleteOverlay(controllerDisplay.overlays[i]); Entities.deleteEntity(controllerDisplay.overlays[i]);
} }
Controller.disableMapping(controllerDisplay.mappingName); Controller.disableMapping(controllerDisplay.mappingName);
}; };

View file

@ -2,6 +2,10 @@
// equipEntity.js // equipEntity.js
// //
// Created by Seth Alves, August 14th, 2017.
// Copyright 2017 High Fidelity, Inc.
// Copyright 2023, Overte e.V.
//
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -74,20 +78,20 @@ EquipHotspotBuddy.prototype.updateHotspot = function(hotspot, timestamp) {
} }
// override default sphere with a user specified model, if it exists. // override default sphere with a user specified model, if it exists.
//V8TODO: change to local entity overlayInfoSet.overlays.push(Entities.addEntity({
overlayInfoSet.overlays.push(Overlays.addOverlay("model", { "type": "Model",
name: "hotspot overlay", "name": "hotspot overlay",
url: hotspot.indicatorURL ? hotspot.indicatorURL : DEFAULT_SPHERE_MODEL_URL, "modelURL": hotspot.indicatorURL ? hotspot.indicatorURL : DEFAULT_SPHERE_MODEL_URL,
position: hotspot.worldPosition, "position": hotspot.worldPosition,
rotation: { "rotation": {
x: 0, "x": 0,
y: 0, "y": 0,
z: 0, "z": 0,
w: 1 "w": 1
}, },
dimensions: dimensions, "dimensions": dimensions,
ignoreRayIntersection: true "ignorePickIntersection": true
})); }, "local"));
overlayInfoSet.type = "model"; overlayInfoSet.type = "model";
this.map[hotspot.key] = overlayInfoSet; this.map[hotspot.key] = overlayInfoSet;
} else { } else {
@ -132,7 +136,7 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
if (overlayInfoSet.timestamp !== timestamp && overlayInfoSet.currentSize <= 0.05) { if (overlayInfoSet.timestamp !== timestamp && overlayInfoSet.currentSize <= 0.05) {
// this is an old overlay, that has finished fading out, delete it! // this is an old overlay, that has finished fading out, delete it!
overlayInfoSet.overlays.forEach(Overlays.deleteOverlay); overlayInfoSet.overlays.forEach(Entities.deleteEntity);
delete this.map[keys[i]]; delete this.map[keys[i]];
} else { } else {
// update overlay position, rotation to follow the object it's attached to. // update overlay position, rotation to follow the object it's attached to.
@ -154,14 +158,14 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp, controllerDa
} }
overlayInfoSet.overlays.forEach(function(overlay) { overlayInfoSet.overlays.forEach(function(overlay) {
Overlays.editOverlay(overlay, { Entities.editEntity(overlay, {
position: position, "position": position,
rotation: props.rotation, "rotation": props.rotation,
dimensions: dimensions "dimensions": dimensions
}); });
}); });
} else { } else {
overlayInfoSet.overlays.forEach(Overlays.deleteOverlay); overlayInfoSet.overlays.forEach(Entities.deleteEntity);
delete this.map[keys[i]]; delete this.map[keys[i]];
} }
} }

View file

@ -1,8 +1,9 @@
// //
// WebTablet.js // WebTablet.js
// //
// Created by Anthony J. Thibault on 8/8/2016 // Created by Anthony J. Thibault on August 8th, 2016
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2023, Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -119,17 +120,16 @@ WebTablet = function (url, width, dpi, hand, location, visible) {
var modelURL = LOCAL_TABLET_MODEL_PATH; var modelURL = LOCAL_TABLET_MODEL_PATH;
var tabletProperties = { var tabletProperties = {
name: "WebTablet Tablet", "name": "WebTablet Tablet",
type: "Model", "type": "Model",
modelURL: modelURL, "modelURL": modelURL,
url: modelURL, // for overlay "grab": {
grabbable: true, // for overlay "grabbable": true
loadPriority: 10.0, // for overlay },
grab: { grabbable: true }, "dimensions": { "x": tabletWidth, "y": tabletHeight, "z": tabletDepth },
dimensions: { x: tabletWidth, y: tabletHeight, z: tabletDepth }, "parentID": MyAvatar.SELF_ID,
parentID: MyAvatar.SELF_ID, "visible": visible,
visible: visible, "groupCulled": true
isGroupCulled: true
}; };
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
@ -142,68 +142,87 @@ WebTablet = function (url, width, dpi, hand, location, visible) {
this.cleanUpOldTablets(); this.cleanUpOldTablets();
cleanUpOldMaterialEntities(); cleanUpOldMaterialEntities();
//V8TODO: change to local entity this.tabletEntityID = Entities.addEntity(tabletProperties, "local");
this.tabletEntityID = Overlays.addOverlay("model", tabletProperties);
if (this.webOverlayID) { if (this.webOverlayID) {
Overlays.deleteOverlay(this.webOverlayID); Entities.deleteEntity(this.webOverlayID);
} }
var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.5) * sensorScaleFactor; var WEB_ENTITY_Z_OFFSET = (tabletDepth / 2.5) * sensorScaleFactor;
var WEB_ENTITY_Y_OFFSET = 1.25 * tabletScaleFactor; var WEB_ENTITY_Y_OFFSET = 1.25 * tabletScaleFactor;
var screenWidth = 0.9367 * tabletWidth; var screenWidth = 0.9367 * tabletWidth;
var screenHeight = 0.9000 * tabletHeight; var screenHeight = 0.9000 * tabletHeight;
//V8TODO: change to local entity this.webOverlayID = Entities.addEntity({
this.webOverlayID = Overlays.addOverlay("web3d", { "type": "Web",
name: "WebTablet Web", "name": "WebTablet Web",
url: url, "sourceUrl": url,
localPosition: { x: 0, y: WEB_ENTITY_Y_OFFSET, z: -WEB_ENTITY_Z_OFFSET }, "localPosition": { "x": 0, "y": WEB_ENTITY_Y_OFFSET, "z": -WEB_ENTITY_Z_OFFSET },
localRotation: Quat.angleAxis(180, Y_AXIS), "localRotation": Quat.angleAxis(180, Y_AXIS),
dimensions: {x: screenWidth, y: screenHeight, z: 1.0}, "dimensions": {"x": screenWidth, "y": screenHeight, "z": 1.0},
dpi: tabletDpi, "dpi": tabletDpi,
color: { red: 255, green: 255, blue: 255 }, "color": { "red": 255, "green": 255, "blue": 255 },
alpha: 1.0, "alpha": 1.0,
parentID: this.tabletEntityID, "parentID": this.tabletEntityID,
parentJointIndex: -1, "showKeyboardFocusHighlight": false,
showKeyboardFocusHighlight: false, "grab": {
grabbable: false, "grabbable": false
visible: visible },
}); "visible": visible
}, "local");
var homeButtonDim = 4.0 * tabletScaleFactor / 1.5; var homeButtonDim = 4.0 * tabletScaleFactor / 1.5;
var HOME_BUTTON_X_OFFSET = 0.00079 * sensorScaleFactor; var HOME_BUTTON_X_OFFSET = 0.00079 * sensorScaleFactor;
var HOME_BUTTON_Y_OFFSET = -1 * ((tabletHeight / 2) - (4.0 * tabletScaleFactor / 2)); var HOME_BUTTON_Y_OFFSET = -1 * ((tabletHeight / 2) - (4.0 * tabletScaleFactor / 2));
var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleFactor; var HOME_BUTTON_Z_OFFSET = (tabletDepth / 1.9) * sensorScaleFactor;
//V8TODO: change to local entity this.homeButtonID = Entities.addEntity({
this.homeButtonID = Overlays.addOverlay("circle3d", { "type": "Gizmo",
name: "homeButton", "gizmoType": "ring",
localPosition: { x: HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET }, "name": "homeButton",
localRotation: Quat.fromVec3Degrees({ x: 180, y: 180, z: 0}), "localPosition": { "x": HOME_BUTTON_X_OFFSET, "y": HOME_BUTTON_Y_OFFSET, "z": -HOME_BUTTON_Z_OFFSET },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }, "localRotation": Quat.fromVec3Degrees({ "x": 90, "y": 0, "z": 0}),
solid: true, "dimensions": { "x": homeButtonDim, "y": homeButtonDim, "z": homeButtonDim },
alpha: 0.0, "primitiveMode": "solid",
visible: visible, "ring": {
drawInFront: false, "innerStartAlpha": 0.0,
parentID: this.tabletEntityID, "innerEndAlpha": 0.0,
parentJointIndex: -1 "outerStartAlpha": 0.0,
}); "outerEndAlpha": 0.0,
},
"visible": visible,
"renderLayer": "world",
"grab": {
"grabbable": false
},
"parentID": this.tabletEntityID
}, "local");
//V8TODO: change to local entity this.homeButtonHighlightID = Entities.addEntity({
this.homeButtonHighlightID = Overlays.addOverlay("circle3d", { "type": "Gizmo",
name: "homeButtonHighlight", "gizmoType": "ring",
localPosition: { x: -HOME_BUTTON_X_OFFSET, y: HOME_BUTTON_Y_OFFSET, z: -HOME_BUTTON_Z_OFFSET }, "name": "homeButtonHighlight",
localRotation: Quat.fromVec3Degrees({ x: 180, y: 180, z: 0}), "localPosition": { "x": -HOME_BUTTON_X_OFFSET, "y": HOME_BUTTON_Y_OFFSET, "z": -HOME_BUTTON_Z_OFFSET },
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }, "localRotation": Quat.fromVec3Degrees({ "x": 90, "y": 0, "z": 0}),
color: {red: 255, green: 255, blue: 255}, "dimensions": { "x": homeButtonDim, "y": homeButtonDim, "z": homeButtonDim },
solid: true, "primitiveMode": "solid",
innerRadius: 0.9, "ring": {
ignorePickIntersection: true, "innerStartColor": {"red": 255, "green": 255, "blue": 255},
alpha: 0.0, "innerEndColor": {"red": 255, "green": 255, "blue": 255},
visible: visible, "outerStartColor": {"red": 255, "green": 255, "blue": 255},
drawInFront: false, "outerEndColor": {"red": 255, "green": 255, "blue": 255},
parentID: this.tabletEntityID, "innerStartAlpha": 0.0,
parentJointIndex: -1 "innerEndAlpha": 0.0,
}); "outerStartAlpha": 0.0,
"outerEndAlpha": 0.0,
"innerRadius": 0.9,
},
"ignorePickIntersection": true,
"visible": visible,
"renderLayer": "world",
"grab": {
"grabbable": false
},
"parentID": this.tabletEntityID
}, "local");
this.receive = function (channel, senderID, senderUUID, localOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) {
if (_this.homeButtonID === senderID) { if (_this.homeButtonID === senderID) {
@ -289,8 +308,8 @@ WebTablet.prototype.setLandscape = function(newLandscapeValue) {
this.landscape = newLandscapeValue; this.landscape = newLandscapeValue;
var cameraOrientation = Quat.cancelOutRollAndPitch(Camera.orientation); var cameraOrientation = Quat.cancelOutRollAndPitch(Camera.orientation);
var tabletRotation = Quat.multiply(cameraOrientation, this.landscape ? ROT_LANDSCAPE : ROT_Y_180); var tabletRotation = Quat.multiply(cameraOrientation, this.landscape ? ROT_LANDSCAPE : ROT_Y_180);
Overlays.editOverlay(this.tabletEntityID, { Entities.editEntity(this.tabletEntityID, {
rotation: tabletRotation "rotation": tabletRotation
}); });
var tabletWidth = getTabletWidthFromSettings() * MyAvatar.sensorToWorldScale; var tabletWidth = getTabletWidthFromSettings() * MyAvatar.sensorToWorldScale;
@ -299,18 +318,18 @@ WebTablet.prototype.setLandscape = function(newLandscapeValue) {
var screenWidth = 0.9275 * tabletWidth; var screenWidth = 0.9275 * tabletWidth;
var screenHeight = 0.8983 * tabletHeight; var screenHeight = 0.8983 * tabletHeight;
var screenRotation = Quat.angleAxis(180, Vec3.UP); var screenRotation = Quat.angleAxis(180, Vec3.UP);
Overlays.editOverlay(this.webOverlayID, { Entities.editEntity(this.webOverlayID, {
localRotation: this.landscape ? Quat.multiply(screenRotation, Quat.angleAxis(-90, Vec3.FRONT)) : screenRotation, "localRotation": this.landscape ? Quat.multiply(screenRotation, Quat.angleAxis(-90, Vec3.FRONT)) : screenRotation,
dimensions: {x: this.landscape ? screenHeight : screenWidth, y: this.landscape ? screenWidth : screenHeight, z: 0.1} "dimensions": {"x": this.landscape ? screenHeight : screenWidth, "y": this.landscape ? screenWidth : screenHeight, "z": 0.1}
}); });
}; };
WebTablet.prototype.getLocation = function() { WebTablet.prototype.getLocation = function() {
var location = Overlays.getProperty(this.tabletEntityID, "localPosition"); var location = Entities.getEntityProperties(this.tabletEntityID, ["localPosition"]).localPosition;
var orientation = Overlays.getProperty(this.tabletEntityID, "localOrientation"); var orientation = Entities.getEntityProperties(this.tabletEntityID, ["localRotation"]).localRotation;
return { return {
localPosition: location, "localPosition": location,
localRotation: orientation "localRotation": orientation
}; };
}; };
@ -320,11 +339,11 @@ WebTablet.prototype.setHomeButtonTexture = function() {
}; };
WebTablet.prototype.setURL = function (url) { WebTablet.prototype.setURL = function (url) {
Overlays.editOverlay(this.webOverlayID, { url: url }); Entities.editEntity(this.webOverlayID, { "sourceUrl": url });
}; };
WebTablet.prototype.setScriptURL = function (scriptURL) { WebTablet.prototype.setScriptURL = function (scriptURL) {
Overlays.editOverlay(this.webOverlayID, { scriptURL: scriptURL }); Entities.editEntity(this.webOverlayID, { "scriptURL": scriptURL });
}; };
WebTablet.prototype.getOverlayObject = function () { WebTablet.prototype.getOverlayObject = function () {
@ -337,10 +356,10 @@ WebTablet.prototype.setWidth = function (width) {
}; };
WebTablet.prototype.destroy = function () { WebTablet.prototype.destroy = function () {
Overlays.deleteOverlay(this.webOverlayID); Entities.deleteEntity(this.webOverlayID);
Overlays.deleteOverlay(this.tabletEntityID); Entities.deleteEntity(this.tabletEntityID);
Overlays.deleteOverlay(this.homeButtonID); Entities.deleteEntity(this.homeButtonID);
Overlays.deleteOverlay(this.homeButtonHighlightID); Entities.deleteEntity(this.homeButtonHighlightID);
HMD.displayModeChanged.disconnect(this.myOnHmdChanged); HMD.displayModeChanged.disconnect(this.myOnHmdChanged);
Controller.mousePressEvent.disconnect(this.myMousePressEvent); Controller.mousePressEvent.disconnect(this.myMousePressEvent);
@ -356,7 +375,7 @@ WebTablet.prototype.geometryChanged = function (geometry) {
var tabletProperties = {}; var tabletProperties = {};
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
Overlays.editOverlay(HMD.tabletID, tabletProperties); Entities.editEntity(HMD.tabletID, tabletProperties);
} }
}; };
@ -468,7 +487,7 @@ WebTablet.prototype.onHmdChanged = function () {
var tabletProperties = {}; var tabletProperties = {};
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties); this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
Overlays.editOverlay(HMD.tabletID, tabletProperties); Entities.editEntity(HMD.tabletID, tabletProperties);
}; };
WebTablet.prototype.pickle = function () { WebTablet.prototype.pickle = function () {
@ -514,7 +533,7 @@ WebTablet.unpickle = function (string) {
}; };
WebTablet.prototype.getPosition = function () { WebTablet.prototype.getPosition = function () {
return Overlays.getProperty(this.webOverlayID, "position"); return Entities.getEntityProperties(this.webOverlayID, ["position"]).position;
}; };
WebTablet.prototype.mousePressEvent = function (event) { WebTablet.prototype.mousePressEvent = function (event) {
@ -527,7 +546,7 @@ WebTablet.prototype.mousePressEvent = function (event) {
this.dragging = true; this.dragging = true;
var invCameraXform = new Xform(Camera.orientation, Camera.position).inv(); var invCameraXform = new Xform(Camera.orientation, Camera.position).inv();
this.initialLocalIntersectionPoint = invCameraXform.xformPoint(tabletBackPickResults.intersection); this.initialLocalIntersectionPoint = invCameraXform.xformPoint(tabletBackPickResults.intersection);
this.initialLocalPosition = Overlays.getProperty(this.tabletEntityID, "localPosition"); this.initialLocalPosition = Entities.getEntityProperties(this.tabletEntityID, ["localPosition"]).localPosition;
} }
} }
} }
@ -561,7 +580,15 @@ WebTablet.prototype.scheduleMouseMoveProcessor = function() {
WebTablet.prototype.handleHomeButtonHover = function(x, y) { WebTablet.prototype.handleHomeButtonHover = function(x, y) {
var pickRay = Camera.computePickRay(x, y); var pickRay = Camera.computePickRay(x, y);
var homePickResult = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID]); var homePickResult = Overlays.findRayIntersection(pickRay, true, [this.homeButtonID]);
Overlays.editOverlay(this.homeButtonHighlightID, { alpha: homePickResult.intersects ? 1.0 : 0.0 }); var alpha = homePickResult.intersects ? 1.0 : 0.0;
Entities.editEntity(this.homeButtonHighlightID, {
"ring": {
"innerStartAlpha": alpha,
"innerEndAlpha": alpha,
"outerStartAlpha": alpha,
"outerEndAlpha": alpha
}
});
}; };
WebTablet.prototype.mouseMoveEvent = function (event) { WebTablet.prototype.mouseMoveEvent = function (event) {
@ -594,8 +621,8 @@ WebTablet.prototype.mouseMoveProcessor = function () {
var localIntersectionPoint = Vec3.sum(localPickRay.origin, Vec3.multiply(localPickRay.direction, result.distance)); var localIntersectionPoint = Vec3.sum(localPickRay.origin, Vec3.multiply(localPickRay.direction, result.distance));
var localOffset = Vec3.subtract(localIntersectionPoint, this.initialLocalIntersectionPoint); var localOffset = Vec3.subtract(localIntersectionPoint, this.initialLocalIntersectionPoint);
var localPosition = Vec3.sum(this.initialLocalPosition, localOffset); var localPosition = Vec3.sum(this.initialLocalPosition, localOffset);
Overlays.editOverlay(this.tabletEntityID, { Entities.editEntity(this.tabletEntityID, {
localPosition: localPosition "localPosition": localPosition
}); });
} }
this.scheduleMouseMoveProcessor(); this.scheduleMouseMoveProcessor();

View file

@ -1,15 +1,16 @@
// //
// miniTablet.js // miniTablet.js
// //
// Created by David Rowe on 9 Aug 2018. // Created by David Rowe on August 9th, 2018.
// Copyright 2018 High Fidelity, Inc. // Copyright 2018 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* global getTabletWidthFromSettings, handsAreTracked, TRIGGER_OFF_VALUE, Controller, Script, Camera, Tablet, MyAvatar, /* global getTabletWidthFromSettings, handsAreTracked, TRIGGER_OFF_VALUE, Controller, Script, Camera, Tablet, MyAvatar,
Quat, SoundCache, HMD, Overlays, Vec3, Uuid, Messages */ Quat, SoundCache, HMD, Vec3, Uuid, Messages */
(function () { (function () {
@ -265,7 +266,7 @@
} }
function getMiniTabletProperties() { function getMiniTabletProperties() {
var properties = Overlays.getProperties(miniOverlay, ["position", "orientation"]); var properties = Entities.getEntityProperties(miniOverlay, ["position", "orientation"]);
return { return {
position: properties.position, position: properties.position,
orientation: properties.orientation orientation: properties.orientation
@ -282,22 +283,24 @@
uiHand = hand; uiHand = hand;
Overlays.editOverlay(miniOverlay, { Entities.editEntity(miniOverlay, {
parentID: MyAvatar.SELF_ID, "parentID": MyAvatar.SELF_ID,
parentJointIndex: handJointIndex(hand), "parentJointIndex": handJointIndex(hand),
localPosition: Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_POSITIONS[hand]), "localPosition": Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_POSITIONS[hand]),
localRotation: MINI_ROTATIONS[hand], "localRotation": MINI_ROTATIONS[hand],
dimensions: Vec3.multiply(initialScale, MINI_DIMENSIONS), "dimensions": Vec3.multiply(initialScale, MINI_DIMENSIONS),
grabbable: true, "grab": {
visible: true "grabbable": true
},
"visible": true
}); });
Overlays.editOverlay(miniUIOverlay, { Entities.editEntity(miniUIOverlay, {
url: handsAreTracked() ? MINI_HAND_UI_HTML : MINI_UI_HTML, "sourceUrl": handsAreTracked() ? MINI_HAND_UI_HTML : MINI_UI_HTML,
localPosition: Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_UI_LOCAL_POSITION), "localPosition": Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_UI_LOCAL_POSITION),
localRotation: MINI_UI_LOCAL_ROTATION, "localRotation": MINI_UI_LOCAL_ROTATION,
dimensions: Vec3.multiply(initialScale, MINI_UI_DIMENSIONS), "dimensions": Vec3.multiply(initialScale, MINI_UI_DIMENSIONS),
dpi: MINI_UI_DPI / initialScale, "dpi": MINI_UI_DPI / initialScale,
visible: true "visible": true
}); });
updateMiniTabletID(); updateMiniTabletID();
@ -306,20 +309,20 @@
// Overlay content is created the first time it is visible to the user. The initial creation displays artefacts. // Overlay content is created the first time it is visible to the user. The initial creation displays artefacts.
// Delay showing UI overlay until after giving it time for its content to be created. // Delay showing UI overlay until after giving it time for its content to be created.
Script.setTimeout(function () { Script.setTimeout(function () {
Overlays.editOverlay(miniUIOverlay, { alpha: 1.0 }); Entities.editEntity(miniUIOverlay, { "alpha": 1.0 });
}, MINI_UI_OVERLAY_ENABLED_DELAY); }, MINI_UI_OVERLAY_ENABLED_DELAY);
} }
} }
function size(scaleFactor) { function size(scaleFactor) {
// Scale UI in place. // Scale UI in place.
Overlays.editOverlay(miniOverlay, { Entities.editEntity(miniOverlay, {
dimensions: Vec3.multiply(scaleFactor, MINI_DIMENSIONS) "dimensions": Vec3.multiply(scaleFactor, MINI_DIMENSIONS)
}); });
Overlays.editOverlay(miniUIOverlay, { Entities.editEntity(miniUIOverlay, {
localPosition: Vec3.multiply(scaleFactor, MINI_UI_LOCAL_POSITION), "localPosition": Vec3.multiply(scaleFactor, MINI_UI_LOCAL_POSITION),
dimensions: Vec3.multiply(scaleFactor, MINI_UI_DIMENSIONS), "dimensions": Vec3.multiply(scaleFactor, MINI_UI_DIMENSIONS),
dpi: MINI_UI_DPI / scaleFactor "dpi": MINI_UI_DPI / scaleFactor
}); });
updateRotation(); updateRotation();
} }
@ -335,7 +338,7 @@
} }
// Grab details. // Grab details.
var properties = Overlays.getProperties(miniOverlay, ["localPosition", "localRotation"]); var properties = Entities.getEntityProperties(miniOverlay, ["localPosition", "localRotation"]);
miniExpandHand = hand; miniExpandHand = hand;
miniExpandLocalRotation = properties.localRotation; miniExpandLocalRotation = properties.localRotation;
miniExpandLocalPosition = Vec3.sum(properties.localPosition, miniExpandLocalPosition = Vec3.sum(properties.localPosition,
@ -369,19 +372,19 @@
Vec3.multiplyQbyV(miniExpandLocalRotation, { x: 0, y: 0.5 * -dimensions.y, z: 0 })); Vec3.multiplyQbyV(miniExpandLocalRotation, { x: 0, y: 0.5 * -dimensions.y, z: 0 }));
localPosition = Vec3.sum(localPosition, localPosition = Vec3.sum(localPosition,
Vec3.multiplyQbyV(localRotation, { x: 0, y: 0.5 * dimensions.y, z: 0 })); Vec3.multiplyQbyV(localRotation, { x: 0, y: 0.5 * dimensions.y, z: 0 }));
Overlays.editOverlay(miniOverlay, { Entities.editEntity(miniOverlay, {
localPosition: localPosition, "localPosition": localPosition,
localRotation: localRotation, "localRotation": localRotation,
dimensions: dimensions "dimensions": dimensions
}); });
// FIXME: Temporary code change to try not displaying UI when mini tablet is expanding to become the tablet proper. // FIXME: Temporary code change to try not displaying UI when mini tablet is expanding to become the tablet proper.
Overlays.editOverlay(miniUIOverlay, { Entities.editEntity(miniUIOverlay, {
/* /*
localPosition: Vec3.multiply(tabletScaleFactor, MINI_UI_LOCAL_POSITION), "localPosition": Vec3.multiply(tabletScaleFactor, MINI_UI_LOCAL_POSITION),
dimensions: Vec3.multiply(tabletScaleFactor, MINI_UI_DIMENSIONS), "dimensions": Vec3.multiply(tabletScaleFactor, MINI_UI_DIMENSIONS),
dpi: MINI_UI_DPI / tabletScaleFactor "dpi": MINI_UI_DPI / tabletScaleFactor
*/ */
visible: false "visible": false
}); });
} }
@ -402,7 +405,7 @@
deltaRotation, deltaRotation,
localRotation; localRotation;
if (Overlays.getProperty(miniOverlay, "parentJointIndex") !== handJointIndex(uiHand)) { if (Entities.getEntityProperties(miniOverlay, ["parentJointIndex"]).parentJointIndex !== handJointIndex(uiHand)) {
// Overlay has been grabbed by other hand but this script hasn't received notification yet. // Overlay has been grabbed by other hand but this script hasn't received notification yet.
return; return;
} }
@ -430,24 +433,26 @@
deltaRotation = Quat.angleAxis(deltaAngle, Vec3.multiplyQbyV(defaultLocalRotation, Vec3.UNIT_Z)); deltaRotation = Quat.angleAxis(deltaAngle, Vec3.multiplyQbyV(defaultLocalRotation, Vec3.UNIT_Z));
localRotation = Quat.multiply(deltaRotation, defaultLocalRotation); localRotation = Quat.multiply(deltaRotation, defaultLocalRotation);
} }
Overlays.editOverlay(miniOverlay, { Entities.editEntity(miniOverlay, {
localRotation: localRotation "localRotation": localRotation
}); });
} }
function release() { function release() {
Overlays.editOverlay(miniOverlay, { Entities.editEntity(miniOverlay, {
parentID: Uuid.NULL, // Release hold so that hand can grab tablet proper. "parentID": Uuid.NULL, // Release hold so that hand can grab tablet proper.
grabbable: false "grab": {
"grabbable": false
}
}); });
} }
function hide() { function hide() {
Overlays.editOverlay(miniOverlay, { Entities.editEntity(miniOverlay, {
visible: false "visible": false
}); });
Overlays.editOverlay(miniUIOverlay, { Entities.editEntity(miniUIOverlay, {
visible: false "visible": false
}); });
} }
@ -458,37 +463,40 @@
return; return;
} }
miniOverlayObject = Overlays.getOverlayObject(miniUIOverlay); miniOverlayObject = Entities.getEntityObject(miniUIOverlay);
if (miniOverlayObject) { if (miniOverlayObject) {
miniOverlayObject.webEventReceived.connect(onWebEventReceived); miniOverlayObject.webEventReceived.connect(onWebEventReceived);
} }
} }
function create() { function create() {
//V8TODO: change to local entity miniOverlay = Entities.addEntity({
miniOverlay = Overlays.addOverlay("model", { "type": "Model",
url: MINI_MODEL, "modelURL": MINI_MODEL,
dimensions: Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_DIMENSIONS), "dimensions": Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_DIMENSIONS),
solid: true, "primitiveMode": "solid",
grabbable: true, "grab": {
showKeyboardFocusHighlight: false, "grabbable": true
drawInFront: false, },
visible: false "renderLayer": "world",
}); "visible": false
//V8TODO: change to local entity }, "local");
miniUIOverlay = Overlays.addOverlay("web3d", { miniUIOverlay = Entities.addEntity({
url: handsAreTracked() ? MINI_HAND_UI_HTML : MINI_UI_HTML, "type": "Web",
parentID: miniOverlay, "sourceUrl": handsAreTracked() ? MINI_HAND_UI_HTML : MINI_UI_HTML,
localPosition: Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_UI_LOCAL_POSITION), "parentID": miniOverlay,
localRotation: MINI_UI_LOCAL_ROTATION, "localPosition": Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_UI_LOCAL_POSITION),
dimensions: Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_UI_DIMENSIONS), "localRotation": MINI_UI_LOCAL_ROTATION,
dpi: MINI_UI_DPI / MyAvatar.sensorToWorldScale, "dimensions": Vec3.multiply(MyAvatar.sensorToWorldScale, MINI_UI_DIMENSIONS),
alpha: 0, // Hide overlay while its content is being created. "dpi": MINI_UI_DPI / MyAvatar.sensorToWorldScale,
grabbable: false, "alpha": 0, // Hide overlay while its content is being created.
showKeyboardFocusHighlight: false, "grab": {
drawInFront: false, "grabbable": false
visible: false },
}); "showKeyboardFocusHighlight": false,
"renderLayer": "world",
"visible": false
}, "local");
miniUIOverlayEnabled = false; // This and alpha = 0 hides overlay while its content is being created. miniUIOverlayEnabled = false; // This and alpha = 0 hides overlay while its content is being created.
@ -498,8 +506,8 @@
function destroy() { function destroy() {
if (miniOverlayObject) { if (miniOverlayObject) {
miniOverlayObject.webEventReceived.disconnect(onWebEventReceived); miniOverlayObject.webEventReceived.disconnect(onWebEventReceived);
Overlays.deleteOverlay(miniUIOverlay); Entities.deleteEntity(miniUIOverlay);
Overlays.deleteOverlay(miniOverlay); Entities.deleteEntity(miniOverlay);
miniOverlayObject = null; miniOverlayObject = null;
miniUIOverlay = null; miniUIOverlay = null;
miniOverlay = null; miniOverlay = null;
@ -917,9 +925,9 @@
ui.release(); ui.release();
miniTabletProperties = ui.getMiniTabletProperties(); miniTabletProperties = ui.getMiniTabletProperties();
Overlays.editOverlay(HMD.tabletID, { Entities.editEntity(HMD.tabletID, {
position: miniTabletProperties.position, "position": miniTabletProperties.position,
orientation: miniTabletProperties.orientation "orientation": miniTabletProperties.orientation
}); });
HMD.openTablet(true); HMD.openTablet(true);

View file

@ -1,18 +1,17 @@
"use strict"; "use strict";
// //
// mod.js // mod.js
// scripts/system/ // scripts/system/
// //
// Created by Stephen Birarda on 07/11/2016 // Created by Stephen Birarda on July 11th, 2016
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* global Toolbars, Script, Users, Overlays, AvatarList, Controller, Camera, getControllerWorldLocation */ /* global Toolbars, Script, Users, Overlays, AvatarList, Controller, Camera, getControllerWorldLocation */
(function() { // BEGIN LOCAL_SCOPE (function() { // BEGIN LOCAL_SCOPE
Script.include("/~/system/libraries/controllers.js"); Script.include("/~/system/libraries/controllers.js");
@ -48,7 +47,7 @@ function removeOverlays() {
for (var i = 0; i < modOverlayKeys.length; ++i) { for (var i = 0; i < modOverlayKeys.length; ++i) {
var avatarID = modOverlayKeys[i]; var avatarID = modOverlayKeys[i];
for (var j = 0; j < modOverlays[avatarID].length; ++j) { for (var j = 0; j < modOverlays[avatarID].length; ++j) {
Overlays.deleteOverlay(modOverlays[avatarID][j]); Entities.deleteEntity(modOverlays[avatarID][j]);
} }
} }
@ -107,45 +106,44 @@ function updateOverlays() {
if (avatarID in modOverlays) { if (avatarID in modOverlays) {
// keep the overlay above the current position of this avatar // keep the overlay above the current position of this avatar
Overlays.editOverlay(modOverlays[avatarID][0], { Entities.editEntity(modOverlays[avatarID][0], {
position: kickOverlayPosition, "position": kickOverlayPosition,
url: kickOverlayURL() "imageURL": kickOverlayURL()
}); });
if (Users.canKick) { if (Users.canKick) {
Overlays.editOverlay(modOverlays[avatarID][1], { Entities.editEntity(modOverlays[avatarID][1], {
position: muteOverlayPosition, "position": muteOverlayPosition,
url: muteOverlayURL() "imageURL": muteOverlayURL()
}); });
} }
} else { } else {
// add the overlay above this avatar // add the overlay above this avatar
var newKickOverlay = Overlays.addOverlay("image3d", { var newKickOverlay = Entities.addEntity({
url: kickOverlayURL(), "type": "Image",
position: kickOverlayPosition, "imageURL": kickOverlayURL(),
size: 1, "position": kickOverlayPosition,
scale: 0.4, "dimensions": { "x": 0.4, "y": 0.4, "z": 0.4},
color: { red: 255, green: 255, blue: 255}, "color": { "red": 255, "green": 255, "blue": 255},
alpha: 1, "alpha": 1,
solid: true, "primitiveMode": "solid",
isFacingAvatar: true, "billboardMode": "full",
drawInFront: true "renderLayer": "front"
}); }, "local");
modOverlays[avatarID]=[newKickOverlay]; modOverlays[avatarID]=[newKickOverlay];
if (Users.canKick) { if (Users.canKick) {
//V8TODO: change to local entity var newMuteOverlay = Entities.addEntity({
var newMuteOverlay = Overlays.addOverlay("image3d", { "type": "Image",
url: muteOverlayURL(), "imageURL": muteOverlayURL(),
position: muteOverlayPosition, "position": muteOverlayPosition,
size: 1, "dimensions": { "x": 0.4, "y": 0.4, "z": 0.4},
scale: 0.4, "color": { "red": 255, "green": 255, "blue": 255},
color: { red: 255, green: 255, blue: 255}, "alpha": 1,
alpha: 1, "primitiveMode": "solid",
solid: true, "billboardMode": "full",
isFacingAvatar: true, "renderLayer": "front"
drawInFront: true }, "local");
});
// push this overlay to our array of overlays // push this overlay to our array of overlays
modOverlays[avatarID].push(newMuteOverlay); modOverlays[avatarID].push(newMuteOverlay);
} }
@ -162,7 +160,7 @@ AvatarList.avatarRemovedEvent.connect(function(avatarID){
// first remove the rendered overlays // first remove the rendered overlays
for (var j = 0; j < modOverlays[avatarID].length; ++j) { for (var j = 0; j < modOverlays[avatarID].length; ++j) {
Overlays.deleteOverlay(modOverlays[avatarID][j]); Entities.deleteEntity(modOverlays[avatarID][j]);
} }
// delete the saved ID of the overlay from our mod overlays object // delete the saved ID of the overlay from our mod overlays object

View file

@ -1,4 +1,14 @@
"use strict"; "use strict";
//
// pal.js
//
// Created by Howard Stearns on December 9th, 2016
// Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// Distributed under the Apache License, Version 2.0
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
/* jslint vars:true, plusplus:true, forin:true */ /* jslint vars:true, plusplus:true, forin:true */
/* global Tablet, Settings, Script, AvatarList, Users, Entities, /* global Tablet, Settings, Script, AvatarList, Users, Entities,
MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account, MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account,
@ -6,14 +16,6 @@
*/ */
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
// //
// pal.js
//
// Created by Howard Stearns on December 9, 2016
// Copyright 2016 High Fidelity, Inc
//
// Distributed under the Apache License, Version 2.0
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
(function () { // BEGIN LOCAL_SCOPE (function () { // BEGIN LOCAL_SCOPE
@ -62,14 +64,15 @@ function angleBetweenVectorsInPlane(from, to, normal) {
// //
var overlays = {}; // Keeps track of all our extended overlay data objects, keyed by target identifier. var overlays = {}; // Keeps track of all our extended overlay data objects, keyed by target identifier.
function ExtendedOverlay(key, type, properties, selected, hasModel) { // A wrapper around overlays to store the key it is associated with. function ExtendedOverlay(key, properties, selected, hasModel) { // A wrapper around overlays to store the key it is associated with.
overlays[key] = this; overlays[key] = this;
if (hasModel) { if (hasModel) {
var modelKey = key + "-m"; var modelKey = key + "-m";
this.model = new ExtendedOverlay(modelKey, "model", { this.model = new ExtendedOverlay(modelKey, {
url: Script.resolvePath("./assets/models/Avatar-Overlay-v1.fbx"), "type": "Model",
textures: textures(selected), "modelURL": Script.resolvePath("./assets/models/Avatar-Overlay-v1.fbx"),
ignoreRayIntersection: true "textures": textures(selected),
"ignorePickIntersection": true
}, false, false); }, false, false);
} else { } else {
this.model = undefined; this.model = undefined;
@ -77,17 +80,16 @@ function ExtendedOverlay(key, type, properties, selected, hasModel) { // A wrapp
this.key = key; this.key = key;
this.selected = selected || false; // not undefined this.selected = selected || false; // not undefined
this.hovering = false; this.hovering = false;
//V8TODO: check if it uses 3d overlays this.activeOverlay = Entities.addEntity(properties, "local"); // We could use different overlays for (un)selected...
this.activeOverlay = Overlays.addOverlay(type, properties); // We could use different overlays for (un)selected...
} }
// Instance methods: // Instance methods:
ExtendedOverlay.prototype.deleteOverlay = function () { // remove display and data of this overlay ExtendedOverlay.prototype.deleteOverlay = function () { // remove display and data of this overlay
Overlays.deleteOverlay(this.activeOverlay); Entities.deleteEntity(this.activeOverlay);
delete overlays[this.key]; delete overlays[this.key];
}; };
ExtendedOverlay.prototype.editOverlay = function (properties) { // change display of this overlay ExtendedOverlay.prototype.editOverlay = function (properties) { // change display of this overlay
Overlays.editOverlay(this.activeOverlay, properties); Entities.editEntity(this.activeOverlay, properties);
}; };
function color(selected, hovering, level) { function color(selected, hovering, level) {
@ -184,36 +186,37 @@ ExtendedOverlay.applyPickRay = function (pickRay, hit, noHit) {
// //
function HighlightedEntity(id, entityProperties) { function HighlightedEntity(id, entityProperties) {
this.id = id; this.id = id;
//V8TODO: change to local entity this.overlay = Entities.addEntity({
this.overlay = Overlays.addOverlay('cube', { "type": "Shape",
position: entityProperties.position, "shape": "Cube",
rotation: entityProperties.rotation, "position": entityProperties.position,
dimensions: entityProperties.dimensions, "rotation": entityProperties.rotation,
solid: false, "dimensions": entityProperties.dimensions,
color: { "primitiveMode": "solid",
red: 0xF3, "color": {
green: 0x91, "red": 0xF3,
blue: 0x29 "green": 0x91,
"blue": 0x29
}, },
ignoreRayIntersection: true, "ignorePickIntersection": true,
drawInFront: false // Arguable. For now, let's not distract with mysterious wires around the scene. "renderLayer": "world" // Arguable. For now, let's not distract with mysterious wires around the scene.
}); }, "local");
HighlightedEntity.overlays.push(this); HighlightedEntity.overlays.push(this);
} }
HighlightedEntity.overlays = []; HighlightedEntity.overlays = [];
HighlightedEntity.clearOverlays = function clearHighlightedEntities() { HighlightedEntity.clearOverlays = function clearHighlightedEntities() {
HighlightedEntity.overlays.forEach(function (highlighted) { HighlightedEntity.overlays.forEach(function (highlighted) {
Overlays.deleteOverlay(highlighted.overlay); Entities.deleteEntity(highlighted.overlay);
}); });
HighlightedEntity.overlays = []; HighlightedEntity.overlays = [];
}; };
HighlightedEntity.updateOverlays = function updateHighlightedEntities() { HighlightedEntity.updateOverlays = function updateHighlightedEntities() {
HighlightedEntity.overlays.forEach(function (highlighted) { HighlightedEntity.overlays.forEach(function (highlighted) {
var properties = Entities.getEntityProperties(highlighted.id, ['position', 'rotation', 'dimensions']); var properties = Entities.getEntityProperties(highlighted.id, ['position', 'rotation', 'dimensions']);
Overlays.editOverlay(highlighted.overlay, { Entities.editEntity(highlighted.overlay, {
position: properties.position, "position": properties.position,
rotation: properties.rotation, "rotation": properties.rotation,
dimensions: properties.dimensions "dimensions": properties.dimensions
}); });
}); });
}; };
@ -434,12 +437,14 @@ function getConnectionData(specificUsername, domain) { // Update all the usernam
// //
function addAvatarNode(id) { function addAvatarNode(id) {
var selected = ExtendedOverlay.isSelected(id); var selected = ExtendedOverlay.isSelected(id);
return new ExtendedOverlay(id, "sphere", { return new ExtendedOverlay(id, {
drawInFront: true, "type": "Shape",
solid: true, "shape": "Sphere",
alpha: 0.8, "renderLayer": "front",
color: color(selected, false, 0.0), "primitiveMode": "solid",
ignoreRayIntersection: false "alpha": 0.8,
"color": color(selected, false, 0.0),
"ignorePickIntersection": false
}, selected, true); }, selected, true);
} }
// Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter. // Each open/refresh will capture a stable set of avatarsOfInterest, within the specified filter.

View file

@ -1,4 +1,16 @@
"use strict"; "use strict";
//
// redirectOverlays.js
//
// Created by Wayne Chen on September 25th, 2018
// Copyright 2018 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// Overlays
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
(function() { (function() {
var ERROR_MESSAGE_MAP = [ var ERROR_MESSAGE_MAP = [
@ -38,126 +50,140 @@
var oopsDimensions = {x: 4.2, y: 0.8}; var oopsDimensions = {x: 4.2, y: 0.8};
//V8TODO: change to local entity var redirectOopsText = Entities.addEntity({
var redirectOopsText = Overlays.addOverlay("text3d", { "type": "Text",
name: "oopsText", "name": "oopsText",
position: {x: 0, y: 1.6763916015625, z: 1.45927095413208}, "position": {"x": 0, "y": 1.6763916015625, "z": 1.45927095413208},
rotation: {x: -4.57763671875e-05, y: 0.4957197904586792, z: -7.62939453125e-05, w: 0.8684672117233276}, "rotation": {"x": -4.57763671875e-05, "y": 0.4957197904586792, "z": -7.62939453125e-05, "w": 0.8684672117233276},
text: getOopsText(), "text": getOopsText(),
textAlpha: 1, "textAlpha": 1,
backgroundColor: {x: 0, y: 0, z:0}, "backgroundColor": {"x": 0, "y": 0, "z":0},
backgroundAlpha: 0, "backgroundAlpha": 0,
lineHeight: 0.10, "lineHeight": 0.10,
leftMargin: 0.538373570564886, "leftMargin": 0.538373570564886,
visible: false, "visible": false,
emissive: true, "unlit": true,
ignoreRayIntersection: true, "ignorePickIntersection": true,
dimensions: oopsDimensions, "dimensions": oopsDimensions,
grabbable: false, "grab": {
}); "grabbable": false
}
}, "local");
//V8TODO: change to local entity var tryAgainImageNeutral = Entities.addEntity({
var tryAgainImageNeutral = Overlays.addOverlay("image3d", { "type": "Image",
name: "tryAgainImage", "name": "tryAgainImage",
localPosition: {x: -0.6, y: -0.6, z: 0.0}, "localPosition": {"x": -0.6, "y": -0.6, "z": 0.0},
url: Script.resourcesPath() + "images/interstitialPage/button.png", "imageURL": Script.resourcesPath() + "images/interstitialPage/button.png",
alpha: 1, "alpha": 1,
visible: false, "visible": false,
emissive: true, "emissive": true,
ignoreRayIntersection: false, "ignorePickIntersection": false,
grabbable: false, "grab": {
orientation: Overlays.getProperty(redirectOopsText, "orientation"), "grabbable": false
parentID: redirectOopsText },
}); "rotation": Entities.getEntityProperties(redirectOopsText, ["rotation"]).rotation,
"parentID": redirectOopsText
}, "local");
//V8TODO: change to local entity var tryAgainImageHover = Entities.addEntity({
var tryAgainImageHover = Overlays.addOverlay("image3d", { "type": "Image",
name: "tryAgainImageHover", "name": "tryAgainImageHover",
localPosition: {x: -0.6, y: -0.6, z: 0.0}, "localPosition": {"x": -0.6, "y": -0.6, "z": 0.0},
url: Script.resourcesPath() + "images/interstitialPage/button_hover.png", "imageURL": Script.resourcesPath() + "images/interstitialPage/button_hover.png",
alpha: 1, "alpha": 1,
visible: false, "visible": false,
emissive: true, "emissive": true,
ignoreRayIntersection: false, "ignorePickIntersection": false,
grabbable: false, "grab": {
orientation: Overlays.getProperty(redirectOopsText, "orientation"), "grabbable": false
parentID: redirectOopsText },
}); "rotation": Entities.getEntityProperties(redirectOopsText, ["rotation"]).rotation,
"parentID": redirectOopsText
}, "local");
//V8TODO: change to local entity var tryAgainText = Entities.addEntity({
var tryAgainText = Overlays.addOverlay("text3d", { "type": "Text",
name: "tryAgainText", "name": "tryAgainText",
localPosition: {x: -0.6, y: -0.962, z: 0.0}, "localPosition": {"x": -0.6, "y": -0.962, "z": 0.0},
text: "Try Again", "text": "Try Again",
textAlpha: 1, "textAlpha": 1,
backgroundAlpha: 0.00393, "backgroundAlpha": 0.00393,
lineHeight: 0.08, "lineHeight": 0.08,
visible: false, "visible": false,
emissive: true, "unlit": true,
ignoreRayIntersection: true, "ignorePickIntersection": true,
grabbable: false, "grab": {
orientation: Overlays.getProperty(redirectOopsText, "orientation"), "grabbable": false
parentID: redirectOopsText },
}); "rotation": Entities.getEntityProperties(redirectOopsText, ["rotation"]).rotation,
"parentID": redirectOopsText
}, "local");
//V8TODO: change to local entity var backImageNeutral = Entities.addEntity({
var backImageNeutral = Overlays.addOverlay("image3d", { "type": "Image",
name: "backImage", "name": "backImage",
localPosition: {x: 0.6, y: -0.6, z: 0.0}, "localPosition": {"x": 0.6, "y": -0.6, "z": 0.0},
url: Script.resourcesPath() + "images/interstitialPage/button.png", "imageURL": Script.resourcesPath() + "images/interstitialPage/button.png",
alpha: 1, "alpha": 1,
visible: false, "visible": false,
emissive: true, "emissive": true,
ignoreRayIntersection: false, "ignorePickIntersection": false,
grabbable: false, "grab": {
orientation: Overlays.getProperty(redirectOopsText, "orientation"), "grabbable": false
parentID: redirectOopsText },
}); "rotation": Entities.getEntityProperties(redirectOopsText, ["rotation"]).rotation,
"parentID": redirectOopsText
}, "local");
//V8TODO: change to local entity var backImageHover = Entities.addEntity({
var backImageHover = Overlays.addOverlay("image3d", { "type": "Image",
name: "backImageHover", "name": "backImageHover",
localPosition: {x: 0.6, y: -0.6, z: 0.0}, "localPosition": {"x": 0.6, "y": -0.6, "z": 0.0},
url: Script.resourcesPath() + "images/interstitialPage/button_hover.png", "imageURL": Script.resourcesPath() + "images/interstitialPage/button_hover.png",
alpha: 1, "alpha": 1,
visible: false, "visible": false,
emissive: true, "emissive": true,
ignoreRayIntersection: false, "ignorePickIntersection": false,
grabbable: false, "grab": {
orientation: Overlays.getProperty(redirectOopsText, "orientation"), "grabbable": false
parentID: redirectOopsText },
}); "rotation": Entities.getEntityProperties(redirectOopsText, ["rotation"]).rotation,
"parentID": redirectOopsText
}, "local");
//V8TODO: change to local entity var backText = Entities.addEntity({
var backText = Overlays.addOverlay("text3d", { "type": "Text",
name: "backText", "name": "backText",
localPosition: {x: 0.6, y: -0.962, z: 0.0}, "localPosition": {"x": 0.6, "y": -0.962, "z": 0.0},
text: "Back", "text": "Back",
textAlpha: 1, "textAlpha": 1,
backgroundAlpha: 0.00393, "backgroundAlpha": 0.00393,
lineHeight: 0.08, "lineHeight": 0.08,
visible: false, "visible": false,
emissive: true, "unlit": true,
ignoreRayIntersection: true, "ignorePickIntersection": true,
grabbable: false, "grab": {
orientation: Overlays.getProperty(redirectOopsText, "orientation"), "grabbable": false
parentID: redirectOopsText },
}); "rotation": Entities.getEntityProperties(redirectOopsText, ["rotation"]).rotation,
"parentID": redirectOopsText
}, "local");
function toggleOverlays(isInErrorState) { function toggleOverlays(isInErrorState) {
isErrorState = isInErrorState; isErrorState = isInErrorState;
if (!isInErrorState) { if (!isInErrorState) {
var properties = { var properties = {
visible: false "visible": false
}; };
Overlays.editOverlay(redirectOopsText, properties); Entities.editEntity(redirectOopsText, properties);
Overlays.editOverlay(tryAgainImageNeutral, properties); Entities.editEntity(tryAgainImageNeutral, properties);
Overlays.editOverlay(tryAgainImageHover, properties); Entities.editEntity(tryAgainImageHover, properties);
Overlays.editOverlay(backImageNeutral, properties); Entities.editEntity(backImageNeutral, properties);
Overlays.editOverlay(backImageHover, properties); Entities.editEntity(backImageHover, properties);
Overlays.editOverlay(tryAgainText, properties); Entities.editEntity(tryAgainText, properties);
Overlays.editOverlay(backText, properties); Entities.editEntity(backText, properties);
return; return;
} }
var oopsText = getOopsText(); var oopsText = getOopsText();
@ -166,44 +192,44 @@
// for catching init or if error state were to be different. // for catching init or if error state were to be different.
isErrorState = overlaysVisible; isErrorState = overlaysVisible;
var properties = { var properties = {
visible: overlaysVisible "visible": overlaysVisible
}; };
var textWidth = Overlays.textSize(redirectOopsText, oopsText).width; var textWidth = Entities.textSize(redirectOopsText, oopsText).width;
var textOverlayWidth = oopsDimensions.x; var textOverlayWidth = oopsDimensions.x;
var oopsTextProperties = { var oopsTextProperties = {
visible: overlaysVisible, "visible": overlaysVisible,
text: oopsText, "text": oopsText,
textAlpha: overlaysVisible, "textAlpha": overlaysVisible,
// either visible or invisible. 0 doesn't work in Mac. // either visible or invisible. 0 doesn't work in Mac.
backgroundAlpha: overlaysVisible * 0.00393, "backgroundAlpha": overlaysVisible * 0.00393,
leftMargin: (textOverlayWidth - textWidth) / 2 "leftMargin": (textOverlayWidth - textWidth) / 2
}; };
var tryAgainTextWidth = Overlays.textSize(tryAgainText, "Try Again").width; var tryAgainTextWidth = Entities.textSize(tryAgainText, "Try Again").width;
var tryAgainImageWidth = Overlays.getProperty(tryAgainImageNeutral, "dimensions").x; var tryAgainImageWidth = Entities.getEntityProperties(tryAgainImageNeutral, ["dimensions"]).dimensions.x;
var tryAgainTextProperties = { var tryAgainTextProperties = {
visible: overlaysVisible, "visible": overlaysVisible,
leftMargin: (tryAgainImageWidth - tryAgainTextWidth) / 2 "leftMargin": (tryAgainImageWidth - tryAgainTextWidth) / 2
}; };
var backTextWidth = Overlays.textSize(backText, "Back").width; var backTextWidth = Entities.textSize(backText, "Back").width;
var backImageWidth = Overlays.getProperty(backImageNeutral, "dimensions").x; var backImageWidth = Entities.getEntityProperties(backImageNeutral, ["dimensions"]).dimensions.x;
var backTextProperties = { var backTextProperties = {
visible: overlaysVisible, "visible": overlaysVisible,
leftMargin: (backImageWidth - backTextWidth) / 2 "leftMargin": (backImageWidth - backTextWidth) / 2
}; };
Overlays.editOverlay(redirectOopsText, oopsTextProperties); Entities.editEntity(redirectOopsText, oopsTextProperties);
Overlays.editOverlay(tryAgainImageNeutral, properties); Entities.editEntity(tryAgainImageNeutral, properties);
Overlays.editOverlay(backImageNeutral, properties); Entities.editEntity(backImageNeutral, properties);
Overlays.editOverlay(tryAgainImageHover, {visible: false}); Entities.editEntity(tryAgainImageHover, {"visible": false});
Overlays.editOverlay(backImageHover, {visible: false}); Entities.editEntity(backImageHover, {"visible": false});
Overlays.editOverlay(tryAgainText, tryAgainTextProperties); Entities.editEntity(tryAgainText, tryAgainTextProperties);
Overlays.editOverlay(backText, backTextProperties); Entities.editEntity(backText, backTextProperties);
} }
@ -222,13 +248,13 @@
function cleanup() { function cleanup() {
Script.clearInterval(timer); Script.clearInterval(timer);
timer = null; timer = null;
Overlays.deleteOverlay(redirectOopsText); Entities.deleteEntity(redirectOopsText);
Overlays.deleteOverlay(tryAgainImageNeutral); Entities.deleteEntity(tryAgainImageNeutral);
Overlays.deleteOverlay(backImageNeutral); Entities.deleteEntity(backImageNeutral);
Overlays.deleteOverlay(tryAgainImageHover); Entities.deleteEntity(tryAgainImageHover);
Overlays.deleteOverlay(backImageHover); Entities.deleteEntity(backImageHover);
Overlays.deleteOverlay(tryAgainText); Entities.deleteEntity(tryAgainText);
Overlays.deleteOverlay(backText); Entities.deleteEntity(backText);
} }
toggleOverlays(true); toggleOverlays(true);
@ -240,12 +266,12 @@
return; return;
} }
if (overlayID === backImageNeutral && location.canGoBack()) { if (overlayID === backImageNeutral && location.canGoBack()) {
Overlays.editOverlay(backImageNeutral, {visible: false}); Entities.editEntity(backImageNeutral, {"visible": false});
Overlays.editOverlay(backImageHover, {visible: true}); Entities.editEntity(backImageHover, {"visible": true});
} }
if (overlayID === tryAgainImageNeutral) { if (overlayID === tryAgainImageNeutral) {
Overlays.editOverlay(tryAgainImageNeutral, {visible: false}); Entities.editEntity(tryAgainImageNeutral, {"visible": false});
Overlays.editOverlay(tryAgainImageHover, {visible: true}); Entities.editEntity(tryAgainImageHover, {"visible": true});
} }
}); });
@ -255,12 +281,12 @@
return; return;
} }
if (overlayID === backImageHover) { if (overlayID === backImageHover) {
Overlays.editOverlay(backImageHover, {visible: false}); Entities.editEntity(backImageHover, {"visible": false});
Overlays.editOverlay(backImageNeutral, {visible: true}); Entities.editEntity(backImageNeutral, {"visible": true});
} }
if (overlayID === tryAgainImageHover) { if (overlayID === tryAgainImageHover) {
Overlays.editOverlay(tryAgainImageHover, {visible: false}); Entities.editEntity(tryAgainImageHover, {"visible": false});
Overlays.editOverlay(tryAgainImageNeutral, {visible: true}); Entities.editEntity(tryAgainImageNeutral, {"visible": true});
} }
}); });

View file

@ -7,6 +7,7 @@
// //
// Created by Seth Alves 2016-9-29 // Created by Seth Alves 2016-9-29
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -50,14 +51,14 @@
if (!UIWebTablet) { if (!UIWebTablet) {
return false; return false;
} }
if (Overlays.getProperty(HMD.tabletID, "type") !== "model") { if (Entities.getEntityProperties(HMD.tabletID, ["type"]).type !== "Model") {
if (debugTablet) { if (debugTablet) {
print("TABLET is invalid due to frame: " + JSON.stringify(Overlays.getProperty(HMD.tabletID, "type"))); print("TABLET is invalid due to frame: " + JSON.stringify(Entities.getEntityProperties(HMD.tabletID, ["type"]).type));
} }
return false; return false;
} }
if (Overlays.getProperty(HMD.homeButtonID, "type") !== "circle3d" || if (Entities.getEntityProperties(HMD.homeButtonID, ["type"]).type !== "Gizmo" ||
Overlays.getProperty(HMD.tabletScreenID, "type") !== "web3d") { Entities.getEntityProperties(HMD.tabletScreenID, ["type"]).type !== "Web") {
if (debugTablet) { if (debugTablet) {
print("TABLET is invalid due to other"); print("TABLET is invalid due to other");
} }
@ -138,10 +139,10 @@
} }
tabletProperties.visible = true; tabletProperties.visible = true;
tabletProperties.ignorePickIntersection = false; tabletProperties.ignorePickIntersection = false;
Overlays.editOverlay(HMD.tabletID, tabletProperties); Entities.editEntity(HMD.tabletID, tabletProperties);
Overlays.editOverlay(HMD.homeButtonID, { visible: true, ignorePickIntersection: false }); Entities.editEntity(HMD.homeButtonID, { "visible": true, "ignorePickIntersection": false });
Overlays.editOverlay(HMD.homeButtonHighlightID, { visible: true, ignorePickIntersection: false }); Entities.editEntity(HMD.homeButtonHighlightID, { "visible": true, "ignorePickIntersection": false });
Overlays.editOverlay(HMD.tabletScreenID, { visible: true, ignorePickIntersection: false, maxFPS: 90 }); Entities.editEntity(HMD.tabletScreenID, { "visible": true, "ignorePickIntersection": false, "maxFPS": 90 });
updateTabletWidthFromSettings(true); updateTabletWidthFromSettings(true);
} }
gTablet.tabletShown = true; gTablet.tabletShown = true;
@ -158,10 +159,10 @@
print("TABLET hide"); print("TABLET hide");
} }
Overlays.editOverlay(HMD.tabletID, { visible: false, ignorePickIntersection: true }); Entities.editEntity(HMD.tabletID, { "visible": false, "ignorePickIntersection": true });
Overlays.editOverlay(HMD.homeButtonID, { visible: false, ignorePickIntersection: true }); Entities.editEntity(HMD.homeButtonID, { "visible": false, "ignorePickIntersection": true });
Overlays.editOverlay(HMD.homeButtonHighlightID, { visible: false, ignorePickIntersection: true }); Entities.editEntity(HMD.homeButtonHighlightID, { "visible": false, "ignorePickIntersection": true });
Overlays.editOverlay(HMD.tabletScreenID, { visible: false, ignorePickIntersection: true, maxFPS: 1 }); Entities.editEntity(HMD.tabletScreenID, { "visible": false, "ignorePickIntersection": true, "maxFPS": 1 });
} }
function closeTabletUI() { function closeTabletUI() {
@ -249,21 +250,20 @@
tabletShown = false; tabletShown = false;
// also cause the stylus model to be loaded // also cause the stylus model to be loaded
//V8TODO: change to local entity var tmpStylusID = Entities.addEntity({
var tmpStylusID = Overlays.addOverlay("model", { "type": "Model",
name: "stylus", "name": "stylus",
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", "modelURL": Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
loadPriority: 10.0, "position": Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {"x": 0, "y": 0.1, "z": -2})),
position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.1, z: -2})), "dimensions": { "x": 0.01, "y": 0.01, "z": 0.2 },
dimensions: { x: 0.01, y: 0.01, z: 0.2 }, "primitiveMode": "solid",
solid: true, "visible": true,
visible: true, "ignorePickIntersection": true,
ignoreRayIntersection: true, "renderLayer": "world",
drawInFront: false, "lifetime": 3
lifetime: 3 }, "local");
});
Script.setTimeout(function() { Script.setTimeout(function() {
Overlays.deleteOverlay(tmpStylusID); Entities.deleteEntity(tmpStylusID);
}, 300); }, 300);
} else if (!tabletShown) { } else if (!tabletShown) {
hideTabletUI(); hideTabletUI();
@ -331,7 +331,6 @@
var tabletID = HMD.tabletID; var tabletID = HMD.tabletID;
Entities.deleteEntity(tabletID); Entities.deleteEntity(tabletID);
Overlays.deleteOverlay(tabletID);
HMD.tabletID = null; HMD.tabletID = null;
HMD.homeButtonID = null; HMD.homeButtonID = null;
HMD.homeButtonHighlightID = null; HMD.homeButtonHighlightID = null;