History

add workload job to help debug entity proxies

Andrew Meadows committed 7 years ago

Commit cf08a411 parent 5f2f64712 files · +275 −6Browse files

Showing the changes to scripts/developer/debugging/debugWorkloadWithMouseHover.js (1 of 12 files). Show all

Unified · Split

scripts/developer/debugging/debugWorkloadWithMouseHover.js+124−0
@@ -0,0 +1,124 @@
1+//
2+// debugWorkloadWithMouseHover.js - render workload proxy for entity under mouse hover
3+//
4+// Copyright 2019 High Fidelity, Inc.
5+//
6+// Distributed under the Apache License, Version 2.0.
7+// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
8+//
9+
10+"use strict";
11+
12+(function() {
13+
14+ Script.scriptEnding.connect(function () {
15+ });
16+
17+ // Create a Laser pointer used to pick and add entity to selection
18+ var END_DIMENSIONS = { x: 0.05, y: 0.05, z: 0.05 };
19+ var COLOR1 = {red: 255, green: 0, blue: 255}; // magenta
20+ var COLOR2 = {red: 255, green: 255, blue: 0}; // yellow
21+ var end1 = {
22+ type: "sphere",
23+ dimensions: END_DIMENSIONS,
24+ color: COLOR1,
25+ ignorePickIntersection: true
26+ }
27+ var end2 = {
28+ type: "sphere",
29+ dimensions: END_DIMENSIONS,
30+ color: COLOR2,
31+ ignorePickIntersection: true
32+ }
33+ var laser = Pointers.createPointer(PickType.Ray, {
34+ joint: "Mouse",
35+ filter: Picks.PICK_ENTITIES | Picks.PICK_BYPASS_IGNORE | Picks.PICK_INCLUDE_COLLIDABLE | Picks.PICK_INCLUDE_NONCOLLIDABLE,
36+ renderStates: [{name: "one", end: end1}],
37+ defaultRenderStates: [{name: "one", end: end2, distance: 2.0}],
38+ enabled: true
39+ });
40+ Pointers.setRenderState(laser, "one");
41+ var hoveredObject = undefined;
42+
43+ var SelectionListName = "DebugWorkloadSelection"; // sekret undocumented selection list (hard coded in C++)
44+ var selectionStyle = {
45+ isOutlineSmooth: true,
46+ outlineWidth: 5,
47+ outlineUnoccludedColor: {red: 255, green: 128, blue: 128},
48+ outlineUnoccludedAlpha: 0.88,
49+ outlineOccludedColor: {red: 255, green: 128, blue: 128},
50+ outlineOccludedAlpha:0.5,
51+ fillUnoccludedColor: {red: 26, green: 0, blue: 0},
52+ fillUnoccludedAlpha: 0.0,
53+ fillOccludedColor: {red: 26, green: 0, blue: 0},
54+ fillOccludedAlpha: 0.0
55+ }
56+ Selection.enableListHighlight(SelectionListName, selectionStyle)
57+
58+ var isSelectionEnabled = false
59+
60+ function setSelectionEnabled(enabled) {
61+ if (isSelectionEnabled != enabled) {
62+ isSelectionEnabled = enabled;
63+ //print("isSelectionEnabled set to " + isSelectionEnabled.toString())
64+ if (isSelectionEnabled) {
65+ Pointers.enablePointer(laser)
66+ } else {
67+ Pointers.disablePointer(laser)
68+ Selection.clearSelectedItemsList(SelectionListName)
69+ }
70+ }
71+ }
72+ setSelectionEnabled(true);
73+
74+ function getIntersectionTypeString(type) {
75+ if (type === Picks.INTERSECTED_ENTITY) {
76+ return "entity";
77+ } else if (type === Picks.INTERSECTED_OVERLAY) {
78+ return "overlay";
79+ } else if (type === Picks.INTERSECTED_AVATAR) {
80+ return "avatar";
81+ }
82+ }
83+
84+ function update() {
85+ var result = Pointers.getPrevPickResult(laser);
86+ if (result.intersects) {
87+ if (hoveredObject !== undefined && result.objectID !== hoveredObject.objectID) {
88+ // Hovering on something different
89+ if (isSelectionEnabled) {
90+ Selection.removeFromSelectedItemsList(SelectionListName, getIntersectionTypeString(hoveredObject.type), hoveredObject.objectID)
91+ //print("remove helloDebugHighlight " + hoveredObject.objectID.toString());
92+ }
93+ }
94+
95+ if (isSelectionEnabled) {
96+ if (hoveredObject === undefined || result.objectID !== hoveredObject.objectID) {
97+ // Hovering over something new
98+ Selection.addToSelectedItemsList(SelectionListName, getIntersectionTypeString(result.type), result.objectID);
99+ hoveredObject = result;
100+ //print("add helloDebugHighlight " + hoveredObject.objectID.toString() + " type = '" + getIntersectionTypeString(result.type) + "'");
101+ }
102+ }
103+ } else if (hoveredObject !== undefined) {
104+ // Stopped hovering
105+ if (isSelectionEnabled) {
106+ Selection.removeFromSelectedItemsList(SelectionListName, getIntersectionTypeString(hoveredObject.type), hoveredObject.objectID)
107+ hoveredObject = undefined;
108+ //print("clear helloDebugHighlight");
109+ }
110+ }
111+ }
112+ Script.update.connect(update);
113+
114+ function cleanup() {
115+ Pointers.removePointer(laser);
116+ Selection.disableListHighlight(SelectionListName)
117+ Selection.removeListFromMap(SelectionListName)
118+
119+ }
120+ Script.scriptEnding.connect(cleanup);
121+
122+}());
123+
124+

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t