mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:24:35 +02:00
switch
This commit is contained in:
commit
f0a12e0251
3 changed files with 107 additions and 23 deletions
|
@ -116,6 +116,11 @@ var DEFAULT_GRABBABLE_DATA = {
|
||||||
invertSolidWhileHeld: false
|
invertSolidWhileHeld: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// sometimes we want to exclude objects from being picked
|
||||||
|
var USE_BLACKLIST = true;
|
||||||
|
var blacklist = [];
|
||||||
|
|
||||||
//we've created various ways of visualizing looking for and moving distant objects
|
//we've created various ways of visualizing looking for and moving distant objects
|
||||||
var USE_ENTITY_LINES_FOR_SEARCHING = false;
|
var USE_ENTITY_LINES_FOR_SEARCHING = false;
|
||||||
var USE_OVERLAY_LINES_FOR_SEARCHING = false;
|
var USE_OVERLAY_LINES_FOR_SEARCHING = false;
|
||||||
|
@ -774,9 +779,19 @@ function MyController(hand) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
var intersection = Entities.findRayIntersection(pickRayBacked, true);
|
|
||||||
Messages.sendMessage('Hifi-Light-Overlay-Ray-Check', JSON.stringify(pickRayBacked));
|
Messages.sendMessage('Hifi-Light-Overlay-Ray-Check', JSON.stringify(pickRayBacked));
|
||||||
|
|
||||||
|
var intersection;
|
||||||
|
|
||||||
|
if (USE_BLACKLIST === true && blacklist.length !== 0) {
|
||||||
|
intersection = Entities.findRayIntersection(pickRayBacked, true, [], blacklist);
|
||||||
|
} else {
|
||||||
|
intersection = Entities.findRayIntersection(pickRayBacked, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
|
|
||||||
// the ray is intersecting something we can move.
|
// the ray is intersecting something we can move.
|
||||||
var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection);
|
||||||
|
|
||||||
|
@ -1714,6 +1729,7 @@ function update() {
|
||||||
|
|
||||||
Messages.subscribe('Hifi-Hand-Disabler');
|
Messages.subscribe('Hifi-Hand-Disabler');
|
||||||
Messages.subscribe('Hifi-Hand-Grab');
|
Messages.subscribe('Hifi-Hand-Grab');
|
||||||
|
Messages.subscribe('Hifi-Hand-RayPick-Blacklist');
|
||||||
|
|
||||||
handleHandMessages = function(channel, message, sender) {
|
handleHandMessages = function(channel, message, sender) {
|
||||||
if (sender === MyAvatar.sessionUUID) {
|
if (sender === MyAvatar.sessionUUID) {
|
||||||
|
@ -1738,6 +1754,24 @@ handleHandMessages = function(channel, message, sender) {
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (channel === 'Hifi-Hand-RayPick-Blacklist') {
|
||||||
|
try {
|
||||||
|
var data = JSON.parse(message);
|
||||||
|
var action = data.action;
|
||||||
|
var id = data.id;
|
||||||
|
var index = blacklist.indexOf(id);
|
||||||
|
|
||||||
|
if (action === 'add' && index ===-1) {
|
||||||
|
blacklist.push(id);
|
||||||
|
}
|
||||||
|
if (action === 'remove') {
|
||||||
|
if (index > -1) {
|
||||||
|
blacklist.splice(index, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ var VISIBLE_PANEL = true;
|
||||||
var USE_LABELS = true;
|
var USE_LABELS = true;
|
||||||
var LEFT_LABELS = false;
|
var LEFT_LABELS = false;
|
||||||
var RIGHT_LABELS = true;
|
var RIGHT_LABELS = true;
|
||||||
|
var ROTATE_CLOSE_BUTTON = false;
|
||||||
|
|
||||||
//variables for managing overlays
|
//variables for managing overlays
|
||||||
var selectionDisplay;
|
var selectionDisplay;
|
||||||
|
@ -65,6 +66,7 @@ var LIGHT_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier
|
||||||
var CLOSE_BUTTON_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier/red_x.fbx';
|
var CLOSE_BUTTON_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier/red_x.fbx';
|
||||||
var CLOSE_BUTTON_SCRIPT_URL = Script.resolvePath('closeButton.js?' + Math.random(0, 100));
|
var CLOSE_BUTTON_SCRIPT_URL = Script.resolvePath('closeButton.js?' + Math.random(0, 100));
|
||||||
var TRANSPARENT_PANEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier/transparent_box_alpha_15.fbx';
|
var TRANSPARENT_PANEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier/transparent_box_alpha_15.fbx';
|
||||||
|
var VISIBLE_PANEL_SCRIPT_URL = Script.resolvePath('visiblePanel.js?' + Math.random(0, 100));
|
||||||
|
|
||||||
var RED = {
|
var RED = {
|
||||||
red: 255,
|
red: 255,
|
||||||
|
@ -150,7 +152,7 @@ function entitySlider(light, color, sliderType, displayText, row) {
|
||||||
this.avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
|
this.avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
|
||||||
this.basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(this.avatarRot)));
|
this.basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(this.avatarRot)));
|
||||||
this.basePosition.y += 1;
|
this.basePosition.y += 1;
|
||||||
basePosition=this.basePosition;
|
basePosition = this.basePosition;
|
||||||
avatarRot = this.avatarRot;
|
avatarRot = this.avatarRot;
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
|
@ -261,7 +263,7 @@ entitySlider.prototype = {
|
||||||
blue: 255
|
blue: 255
|
||||||
},
|
},
|
||||||
position: this.endOfAxis,
|
position: this.endOfAxis,
|
||||||
parentID:this.axis,
|
parentID: this.axis,
|
||||||
visible: false
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +314,7 @@ entitySlider.prototype = {
|
||||||
blue: 0
|
blue: 0
|
||||||
},
|
},
|
||||||
position: position,
|
position: position,
|
||||||
rotation:this.avatarRot,
|
rotation: this.avatarRot,
|
||||||
}
|
}
|
||||||
print('BEFORE CREATE LABEL' + JSON.stringify(labelProperties))
|
print('BEFORE CREATE LABEL' + JSON.stringify(labelProperties))
|
||||||
this.label = Entities.addEntity(labelProperties);
|
this.label = Entities.addEntity(labelProperties);
|
||||||
|
@ -499,7 +501,7 @@ function makeSliders(light) {
|
||||||
sliders.push(slidersRef.exponent);
|
sliders.push(slidersRef.exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
createCloseButton(slidersRef.exponent.endOfAxis);
|
createCloseButton(slidersRef.color_red.axisStart);
|
||||||
|
|
||||||
subscribeToSliderMessages();
|
subscribeToSliderMessages();
|
||||||
|
|
||||||
|
@ -566,28 +568,28 @@ function createPanelEntity(position) {
|
||||||
function createVisiblePanel() {
|
function createVisiblePanel() {
|
||||||
var totalOffset = -PER_ROW_OFFSET.y * sliders.length;
|
var totalOffset = -PER_ROW_OFFSET.y * sliders.length;
|
||||||
|
|
||||||
var moveRight =Vec3.sum(basePosition,Vec3.multiply(AXIS_SCALE/2,Quat.getRight(avatarRot)));
|
var moveRight = Vec3.sum(basePosition, Vec3.multiply(AXIS_SCALE / 2, Quat.getRight(avatarRot)));
|
||||||
|
|
||||||
var moveDown = Vec3.sum(moveRight,Vec3.multiply((sliders.length+1)/2,PER_ROW_OFFSET))
|
var moveDown = Vec3.sum(moveRight, Vec3.multiply((sliders.length + 1) / 2, PER_ROW_OFFSET))
|
||||||
var panelProperties = {
|
var panelProperties = {
|
||||||
name: 'Hifi-Visible-Transparent-Panel',
|
name: 'Hifi-Visible-Transparent-Panel',
|
||||||
type: 'Model',
|
type: 'Model',
|
||||||
modelURL: TRANSPARENT_PANEL_URL,
|
modelURL: TRANSPARENT_PANEL_URL,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: AXIS_SCALE+0.1,
|
x: AXIS_SCALE + 0.1,
|
||||||
y: totalOffset,
|
y: totalOffset,
|
||||||
z: SLIDER_DIMENSIONS.z/4
|
z: SLIDER_DIMENSIONS.z / 4
|
||||||
},
|
},
|
||||||
visible: true,
|
visible: true,
|
||||||
collisionsWillMove: false,
|
collisionsWillMove: false,
|
||||||
ignoreForCollisions: true,
|
ignoreForCollisions: true,
|
||||||
position: moveDown,
|
position: moveDown,
|
||||||
rotation:avatarRot
|
rotation: avatarRot,
|
||||||
|
script: VISIBLE_PANEL_SCRIPT_URL
|
||||||
}
|
}
|
||||||
|
|
||||||
var panel = Entities.addEntity(panelProperties);
|
var panel = Entities.addEntity(panelProperties);
|
||||||
var data = {action:'add', id:panel};
|
|
||||||
Messages.sendMessage ('Hifi-Hand-RayPick-Blacklist',JSON.stringify(data))
|
|
||||||
return panel
|
return panel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,19 +619,25 @@ function createLightModel(position, rotation) {
|
||||||
|
|
||||||
var closeButtons = [];
|
var closeButtons = [];
|
||||||
|
|
||||||
function createCloseButton(endOfAxis) {
|
function createCloseButton(axisStart) {
|
||||||
|
var MARGIN = 0.10;
|
||||||
|
var VERTICAL_OFFFSET = {
|
||||||
|
x: 0,
|
||||||
|
y: 0.15,
|
||||||
|
z: 0
|
||||||
|
};
|
||||||
|
var leftVector = Vec3.multiply(-1, Quat.getRight(avatarRot));
|
||||||
|
var extension = Vec3.multiply(MARGIN, leftVector);
|
||||||
|
var position = Vec3.sum(axisStart, extension);
|
||||||
|
|
||||||
var buttonProperties = {
|
var buttonProperties = {
|
||||||
name: 'Hifi-Close-Button',
|
name: 'Hifi-Close-Button',
|
||||||
type: 'Model',
|
type: 'Model',
|
||||||
modelURL: CLOSE_BUTTON_MODEL_URL,
|
modelURL: CLOSE_BUTTON_MODEL_URL,
|
||||||
dimensions: CLOSE_BUTTON_DIMENSIONS,
|
dimensions: CLOSE_BUTTON_DIMENSIONS,
|
||||||
position: Vec3.sum(endOfAxis, {
|
position: Vec3.sum(position, VERTICAL_OFFFSET),
|
||||||
x: 0,
|
rotation: Quat.multiply(avatarRot,Quat.fromPitchYawRollDegrees(90, 0, 45)),
|
||||||
y: -0.15,
|
//rotation: Quat.fromPitchYawRollDegrees(0, 0, 90),
|
||||||
z: 0
|
|
||||||
}),
|
|
||||||
rotation: Quat.fromPitchYawRollDegrees(0, 45, 90),
|
|
||||||
collisionsWillMove: false,
|
collisionsWillMove: false,
|
||||||
ignoreForCollisions: true,
|
ignoreForCollisions: true,
|
||||||
script: CLOSE_BUTTON_SCRIPT_URL,
|
script: CLOSE_BUTTON_SCRIPT_URL,
|
||||||
|
@ -644,7 +652,9 @@ function createCloseButton(endOfAxis) {
|
||||||
|
|
||||||
closeButtons.push(button);
|
closeButtons.push(button);
|
||||||
|
|
||||||
|
if(ROTATE_CLOSE_BUTTON===true){
|
||||||
Script.update.connect(rotateCloseButtons);
|
Script.update.connect(rotateCloseButtons);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function rotateCloseButtons() {
|
function rotateCloseButtons() {
|
||||||
|
@ -732,7 +742,7 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
|
|
||||||
var lightID = doesIntersect.entityID;
|
var lightID = doesIntersect.entityID;
|
||||||
if (currentLight === lightID) {
|
if (currentLight === lightID) {
|
||||||
print('ALREADY HAVE A BLOCK, EXIT')
|
// print('ALREADY HAVE A BLOCK, EXIT')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
examples/light_modifier/visiblePanel.js
Normal file
40
examples/light_modifier/visiblePanel.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// visiblePanel.js
|
||||||
|
//
|
||||||
|
// Created by James Pollack @imgntn on 12/15/2015
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Entity script that disables picking on this panel.
|
||||||
|
//
|
||||||
|
// 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 VisiblePanel() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisiblePanel.prototype = {
|
||||||
|
preload: function(entityID) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
action: 'add',
|
||||||
|
id: this.entityID
|
||||||
|
};
|
||||||
|
Messages.sendMessage('Hifi-Hand-RayPick-Blacklist', JSON.stringify(data))
|
||||||
|
},
|
||||||
|
unload: function() {
|
||||||
|
var data = {
|
||||||
|
action: 'remove',
|
||||||
|
id: this.entityID
|
||||||
|
};
|
||||||
|
Messages.sendMessage('Hifi-Hand-RayPick-Blacklist', JSON.stringify(data))
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return new VisiblePanel();
|
||||||
|
});
|
Loading…
Reference in a new issue