Replace 3dOverlays for Local Entities - part 2

Replace 3dOverlays for Local Entities (developer's script)
This commit is contained in:
Alezia Kurdis 2023-03-20 23:11:26 -04:00 committed by ksuprynowicz
parent 0f663d1a4d
commit ca577f2802
6 changed files with 121 additions and 102 deletions

View file

@ -3,8 +3,9 @@
//
// EZrecord.js
//
// Created by David Rowe on 24 Jun 2017.
// Created by David Rowe on June 24th, 2017.
// Copyright 2017 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
@ -48,22 +49,23 @@
if (HMD.active) {
// 3D overlay attached to avatar.
//V8TODO: change to local entity
hmdOverlay = Overlays.addOverlay("text3d", {
text: recordingText,
dimensions: { x: 3 * HMD_FONT_SIZE, y: HMD_FONT_SIZE },
parentID: MyAvatar.sessionUUID,
parentJointIndex: CAMERA_JOINT_INDEX,
localPosition: { x: 0.95, y: 0.95, z: -2.0 },
color: { red: 255, green: 0, blue: 0 },
alpha: 0.9,
lineHeight: HMD_FONT_SIZE,
backgroundAlpha: 0,
ignoreRayIntersection: true,
isFacingAvatar: true,
drawInFront: true,
visible: true
});
hmdOverlay = Entities.addEntity({
"type": "Text",
"text": recordingText,
"dimensions": { "x": 3 * HMD_FONT_SIZE, "y": HMD_FONT_SIZE, "z": 0.01 },
"parentID": MyAvatar.sessionUUID,
"parentJointIndex": CAMERA_JOINT_INDEX,
"localPosition": { "x": 0.95, "y": 0.95, "z": -2.0 },
"color": { "red": 255, "green": 0, "blue": 0 },
"alpha": 0.9,
"unlit": true,
"lineHeight": HMD_FONT_SIZE,
"backgroundAlpha": 0,
"ignorePickIntersection": true,
"billboardMode": "full",
"renderLayer": "front",
"visible": true
},"local");
} else {
// 2D overlay on desktop.
desktopOverlay = Overlays.addOverlay("text", {
@ -86,7 +88,7 @@
Overlays.deleteOverlay(desktopOverlay);
}
if (hmdOverlay) {
Overlays.deleteOverlay(hmdOverlay);
Entities.deleteEntity(hmdOverlay);
}
}

View file

@ -4,13 +4,14 @@
// debugAvatarMixer.js
// 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 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
//
/* global Toolbars, Script, Users, Overlays, AvatarList, Controller, Camera, getControllerWorldLocation */
/* global Toolbars, Script, Users, Entities, AvatarList, Controller, Camera, getControllerWorldLocation */
(function() { // BEGIN LOCAL_SCOPE
@ -19,12 +20,12 @@ Script.include("/~/system/libraries/controllers.js");
var isShowingOverlays = true;
var debugOverlays = {};
//V8TODO: change to local entity
var textSizeOverlay = Overlays.addOverlay("text3d", {
position: MyAvatar.position,
lineHeight: 0.1,
visible: false
});
var textSizeOverlay = Entities.addEntity({
"type": "Text",
"position": MyAvatar.position,
"lineHeight": 0.1,
"visible": false
}, "local");
function removeOverlays() {
// enumerate the overlays and remove them
@ -33,11 +34,11 @@ function removeOverlays() {
for (var i = 0; i < overlayKeys.length; ++i) {
var avatarID = overlayKeys[i];
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 = {};
}
@ -91,27 +92,28 @@ function updateOverlays() {
//+" SM: " + AvatarManager.getAvatarSimulationRate(avatarID,"skeletonModel").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) {
// keep the overlay above the current position of this avatar
Overlays.editOverlay(debugOverlays[avatarID][0], {
dimensions: { x: 1.1 * dimensions.width, y: 0.6 * dimensions.height },
position: overlayPosition,
text: text
Entities.editEntity(debugOverlays[avatarID][0], {
"dimensions": { "x": 1.1 * dimensions.width, "y": 0.6 * dimensions.height },
"position": overlayPosition,
"text": text
});
} else {
// add the overlay above this avatar
var newOverlay = Overlays.addOverlay("text3d", {
position: overlayPosition,
dimensions: { x: 1.1 * dimensions.width, y: 0.6 * dimensions.height },
lineHeight: 0.1,
text: text,
color: { red: 255, green: 255, blue: 255},
alpha: 1,
solid: true,
isFacingAvatar: true,
drawInFront: true
});
var newOverlay = Entities.addEntity({
"type": "Text",
"position": overlayPosition,
"dimensions": { "x": 1.1 * dimensions.width, "y": 0.6 * dimensions.height },
"lineHeight": 0.1,
"text": text,
"color": { "red": 255, "green": 255, "blue": 255},
"alpha": 1,
"primitiveMode": "solid",
"billboardMode": "full",
"renderLayer": "front"
}, "local");
debugOverlays[avatarID]=[newOverlay];
}
@ -127,7 +129,7 @@ AvatarList.avatarRemovedEvent.connect(function(avatarID){
// first remove the rendered overlays
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

View file

@ -2,8 +2,9 @@
// grabInspector.js
// examples/debugging/
//
// Created by Seth Alves on 2015-12-19.
// Created by Seth Alves on December 19th, 2015.
// Copyright 2015 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
@ -26,24 +27,27 @@ function updateOverlay(entityID, queryAACube) {
if (entityID in overlays) {
var overlay = overlays[entityID];
Overlays.editOverlay(overlay, {
position: cubeCenter,
size: queryAACube.scale
Entities.editEntity(overlay, {
"position": cubeCenter,
"size": queryAACube.scale
});
} else {
//V8TODO: change to local entity
overlays[entityID] = Overlays.addOverlay("cube", {
position: cubeCenter,
size: queryAACube.scale,
color: {
red: 0,
green: 0,
blue: 255
overlays[entityID] = Entities.addEntity({
"type": "Shape",
"shape": "Cube",
"position": cubeCenter,
"size": queryAACube.scale,
"color": {
"red": 0,
"green": 0,
"blue": 255
},
alpha: 1,
solid: false,
grabbable: false
});
"alpha": 1,
"primitiveMode": "lines",
"grab": {
"grabbable": false
}
}, "local");
}
}
@ -58,7 +62,7 @@ Script.setInterval(function() {
function cleanup() {
for (var entityID in overlays) {
Overlays.deleteOverlay(overlays[entityID]);
Entities.deleteEntity((overlays[entityID]);
}
}

View file

@ -1,5 +1,10 @@
//
// 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
//
@ -11,17 +16,18 @@ var JOINT_NAME = HMD.active ? HAND_JOINT : 'Mouse';
var UPDATE_MS = 1000/30;
// create tect3d overlay to display hover results
//V8TODO: change to local entity
var overlayID = Overlays.addOverlay('text3d', {
text: 'hover',
visible: false,
backgroundAlpha: 0,
isFacingAvatar: true,
lineHeight: 0.05,
dimensions: Vec3.HALF,
});
var overlayID = Entities.addEntity({
"type": "Text",
"text": "hover",
"visible": false,
"backgroundAlpha": 0,
"billboardMode": "full",
"lineHeight": 0.05,
"dimensions": Vec3.HALF,
}, "local");
Script.scriptEnding.connect(function() {
Overlays.deleteOverlay(overlayID);
Entities.deleteEntity(overlayID);
});
// create raycast picker
@ -60,10 +66,10 @@ function updateOverlay(overlayID, result) {
['submesh: ' + extraInfo.subMeshIndex, 'part: '+extraInfo.partIndex, 'shape: '+extraInfo.shapeID].join(' | '),
].filter(Boolean).join('\n');
Overlays.editOverlay(overlayID, {
text: text,
position: position,
visible: result.intersects,
Entities.editEntity(overlayID, {
"text": text,
"position": position,
"visible": result.intersects
});
}

View file

@ -2,9 +2,10 @@
// sphereLodTest.js
// examples/tests
//
// Created by Eric Levin on 1/21/16.
// Created by Eric Levin on January 21st, 2016.
// Copyright 2016 High Fidelity, Inc.
// Copyright 2023 Overte e.V.
//
// A test script for testing LODing of sphere entities and sphere overlays
//
// 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});
//V8TODO: change to local entity
var overlaySphere = Overlays.addOverlay("sphere", {
position: overlaySpherePosition,
size: 0.01,
color: { red: 20, green: 200, blue: 0},
alpha: 1.0,
solid: true,
});
var overlaySphere = Entities.addEntity({
"type": "Sphere",
"position": overlaySpherePosition,
"dimensions": sphereDimensions,
"color": { "red": 20, "green": 200, "blue": 0},
"alpha": 1.0
}, "local");
function cleanup() {
Entities.deleteEntity(table);
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
//
@ -24,24 +29,24 @@ SPAWNER = function (properties) {
function makeObject(properties) {
//V8TODO: change to local entity
var overlay = Overlays.addOverlay("web3d", {
name: "Web",
url: "https://www.reddit.com/r/random",
localPosition: randomPositionXZ( { x: 0, y: 0, z: -1 }, 1),
localRotation: Quat.angleAxis(180, Vec3.Y_AXIS),
dimensions: {x: .8, y: .45, z: 0.1},
color: { red: 255, green: 255, blue: 255 },
alpha: 1.0,
showKeyboardFocusHighlight: false,
visible: true
});
var overlay = Entities.addEntity({
"type": "Web",
"name": "Web",
"sourceUrl": "https://www.reddit.com/r/random",
"localPosition": randomPositionXZ( { "x": 0, "y": 0, "z": -1 }, 1),
"localRotation": Quat.angleAxis(180, Vec3.Y_AXIS),
"dimensions": {"x": 0.8, "y": 0.45, "z": 0.1},
"color": { "red": 255, "green": 255, "blue": 255 },
"alpha": 1.0,
"showKeyboardFocusHighlight": false,
"visible": true
}, "local");
var now = Date.now();
return {
destroy: function () {
Overlays.deleteOverlay(overlay)
Entities.deleteEntity(overlay);
},
getAge: function () {
return (Date.now() - now) / 1000.0;