mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:58:09 +02:00
switching branches
This commit is contained in:
parent
8e2128c692
commit
a25feb5578
5 changed files with 131 additions and 66 deletions
|
@ -517,7 +517,7 @@ function MyController(hand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var intersection = Entities.findRayIntersection(pickRayBacked, true);
|
var intersection = Entities.findRayIntersection(pickRayBacked, true);
|
||||||
|
Messages.sendMessage('Hifi-Light-Overlay-Ray-Check', JSON.stringify(pickRayBacked));
|
||||||
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);
|
||||||
|
|
|
@ -20,7 +20,6 @@ SPACE_WORLD = "world";
|
||||||
SelectionManager = (function() {
|
SelectionManager = (function() {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
|
||||||
|
|
||||||
function subscribeToUpdateMessages() {
|
function subscribeToUpdateMessages() {
|
||||||
Messages.subscribe('entityToolUpdates');
|
Messages.subscribe('entityToolUpdates');
|
||||||
Messages.messageReceived.connect(handleEntitySelectionToolUpdates);
|
Messages.messageReceived.connect(handleEntitySelectionToolUpdates);
|
||||||
|
|
|
@ -22,10 +22,13 @@ var selectionDisplay;
|
||||||
var selectionManager;
|
var selectionManager;
|
||||||
var lightOverlayManager;
|
var lightOverlayManager;
|
||||||
|
|
||||||
|
//for when we make a block parent for the light
|
||||||
|
var PARENT_SCRIPT_URL = Script.resolvePath('lightParent.js?' + Math.random(0 - 100));
|
||||||
|
|
||||||
if (SHOW_OVERLAYS === true) {
|
if (SHOW_OVERLAYS === true) {
|
||||||
|
|
||||||
Script.include('../libraries/gridTool.js');
|
Script.include('../libraries/gridTool.js');
|
||||||
Script.include('../libraries/entitySelectionTool.js?'+Math.random(0-100));
|
Script.include('../libraries/entitySelectionTool.js?' + Math.random(0 - 100));
|
||||||
Script.include('../libraries/lightOverlayManager.js');
|
Script.include('../libraries/lightOverlayManager.js');
|
||||||
|
|
||||||
var grid = Grid();
|
var grid = Grid();
|
||||||
|
@ -90,8 +93,8 @@ var WHITE = {
|
||||||
|
|
||||||
var ORANGE = {
|
var ORANGE = {
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 0,
|
green: 165,
|
||||||
blue: 128
|
blue: 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var SLIDER_DIMENSIONS = {
|
var SLIDER_DIMENSIONS = {
|
||||||
|
@ -100,6 +103,18 @@ var SLIDER_DIMENSIONS = {
|
||||||
z: 0.075
|
z: 0.075
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var CLOSE_BUTTON_DIMENSIONS ={
|
||||||
|
x:0.1,
|
||||||
|
y:0.1,
|
||||||
|
z:0.1
|
||||||
|
}
|
||||||
|
|
||||||
|
var LIGHT_MODEL_DIMENSIONS={
|
||||||
|
x:0.04,
|
||||||
|
y:0.04,
|
||||||
|
z:0.09
|
||||||
|
}
|
||||||
|
|
||||||
var PER_ROW_OFFSET = {
|
var PER_ROW_OFFSET = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: -0.2,
|
y: -0.2,
|
||||||
|
@ -348,7 +363,6 @@ var light = null;
|
||||||
|
|
||||||
function makeSliders(light) { // selectionManager.setSelections([entityID]);
|
function makeSliders(light) { // selectionManager.setSelections([entityID]);
|
||||||
|
|
||||||
|
|
||||||
if (light.type === 'spotlight') {
|
if (light.type === 'spotlight') {
|
||||||
var USE_COLOR_SLIDER = true;
|
var USE_COLOR_SLIDER = true;
|
||||||
var USE_INTENSITY_SLIDER = true;
|
var USE_INTENSITY_SLIDER = true;
|
||||||
|
@ -383,9 +397,25 @@ function makeSliders(light) { // selectionManager.setSelections([entityID]);
|
||||||
slidersRef.exponent = new entitySlider(light, ORANGE, 'exponent', 6);
|
slidersRef.exponent = new entitySlider(light, ORANGE, 'exponent', 6);
|
||||||
sliders.push(slidersRef.exponent);
|
sliders.push(slidersRef.exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var closeButtonPosition;
|
||||||
|
|
||||||
|
createCloseButton(closeButtonPosition);
|
||||||
subscribeToSliderMessages();
|
subscribeToSliderMessages();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function createCloseButton(position){
|
||||||
|
var buttonProperties = {
|
||||||
|
type:'Model',
|
||||||
|
modelURL:CLOSE_BUTTON_MODEL_URL,
|
||||||
|
dimensions:CLOSE_BUTTON_DIMENSIONS,
|
||||||
|
position:position,
|
||||||
|
rotation:Quat.fromPitchYawRollDegrees(90,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var button = Entities.addEntity(buttonProperties);
|
||||||
|
}
|
||||||
|
|
||||||
function subScribeToNewLights() {
|
function subScribeToNewLights() {
|
||||||
Messages.subscribe('Hifi-Light-Mod-Receiver');
|
Messages.subscribe('Hifi-Light-Mod-Receiver');
|
||||||
Messages.messageReceived.connect(handleLightModMessages);
|
Messages.messageReceived.connect(handleLightModMessages);
|
||||||
|
@ -396,6 +426,12 @@ function subscribeToSliderMessages() {
|
||||||
Messages.messageReceived.connect(handleValueMessages);
|
Messages.messageReceived.connect(handleValueMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function subscribeToLightOverlayRayCheckMessages() {
|
||||||
|
Messages.subscribe('Hifi-Light-Overlay-Ray-Check');
|
||||||
|
Messages.messageReceived.connect(handleLightOverlayRayCheckMessages);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function handleLightModMessages(channel, message, sender) {
|
function handleLightModMessages(channel, message, sender) {
|
||||||
if (channel !== 'Hifi-Light-Mod-Receiver') {
|
if (channel !== 'Hifi-Light-Mod-Receiver') {
|
||||||
return;
|
return;
|
||||||
|
@ -425,6 +461,86 @@ function handleValueMessages(channel, message, sender) {
|
||||||
slidersRef[parsedMessage.sliderType].setValueFromMessage(parsedMessage);
|
slidersRef[parsedMessage.sliderType].setValueFromMessage(parsedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentLight;
|
||||||
|
|
||||||
|
function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
|
if (channel !== 'Hifi-Light-Overlay-Ray-Check') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ONLY_I_CAN_EDIT === true && sender !== MyAvatar.sessionUUID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
print('RAY CHECK GOT MESSAGE::' + message);
|
||||||
|
var pickRay = JSON.parse(message);
|
||||||
|
|
||||||
|
var doesIntersect = lightOverlayManager.findRayIntersection(pickRay);
|
||||||
|
print('DOES INTERSECT A LIGHT WE HAVE???' + doesIntersect.intersects);
|
||||||
|
if (doesIntersect.intersects === true) {
|
||||||
|
print('FULL MESSAGE:::' + JSON.stringify(doesIntersect))
|
||||||
|
|
||||||
|
var lightID = doesIntersect.entityID;
|
||||||
|
if (currentLight === lightID) {
|
||||||
|
print('ALREADY HAVE A BLOCK, EXIT')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
print('LIGHT ID::' + lightID);
|
||||||
|
currentLight = lightID;
|
||||||
|
var lightProperties = Entities.getEntityProperties(lightID);
|
||||||
|
var block = createBlock(lightProperties.position);
|
||||||
|
|
||||||
|
var light = {
|
||||||
|
id: lightID,
|
||||||
|
type: 'spotlight',
|
||||||
|
initialProperties: lightProperties
|
||||||
|
}
|
||||||
|
|
||||||
|
makeSliders(light);
|
||||||
|
print('AFTER MAKE SLIDERS')
|
||||||
|
if (SHOW_LIGHT_VOLUME === true) {
|
||||||
|
selectionManager.setSelections([lightID]);
|
||||||
|
print('SET SELECTIOIO MANAGER TO::: '+ lightID);
|
||||||
|
print('hasSelection???' + selectionManager.hasSelection())
|
||||||
|
}
|
||||||
|
print('BLOCK IS:::' + block);
|
||||||
|
Entities.editEntity(lightID, {
|
||||||
|
parentID: block
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function createBlock(position) {
|
||||||
|
print('CREATE BLOCK')
|
||||||
|
|
||||||
|
var blockProperties = {
|
||||||
|
name: 'Hifi-Spotlight-Block',
|
||||||
|
type: 'Box',
|
||||||
|
dimensions: {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
collisionsWillMove: true,
|
||||||
|
color: {
|
||||||
|
red: 0,
|
||||||
|
green: 0,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
position: position,
|
||||||
|
script: PARENT_SCRIPT_URL,
|
||||||
|
userData: JSON.stringify({
|
||||||
|
handControllerKey: {
|
||||||
|
disableReleaseVelocity: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
var block = Entities.addEntity(blockProperties);
|
||||||
|
|
||||||
|
return block
|
||||||
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
var i;
|
var i;
|
||||||
for (i = 0; i < sliders.length; i++) {
|
for (i = 0; i < sliders.length; i++) {
|
||||||
|
@ -440,7 +556,6 @@ function cleanup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
subScribeToNewLights();
|
|
||||||
|
|
||||||
function deleteEntity(entityID) {
|
function deleteEntity(entityID) {
|
||||||
if (entityID === light) {
|
if (entityID === light) {
|
||||||
|
@ -448,60 +563,10 @@ function deleteEntity(entityID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Entities.deletingEntity.connect(deleteEntity);
|
Entities.deletingEntity.connect(deleteEntity);
|
||||||
|
|
||||||
// search for lights to make grabbable
|
subscribeToLightOverlayRayCheckMessages();
|
||||||
|
subScribeToNewLights();
|
||||||
// var USE_DEBOUNCE = true;
|
|
||||||
// var sinceLastUpdate = 0;
|
|
||||||
|
|
||||||
// function searchForLightsToVisualize() {
|
|
||||||
|
|
||||||
// var deltaTime = interval();
|
|
||||||
|
|
||||||
// if (USE_DEBOUNCE === true) {
|
|
||||||
// sinceLastUpdate = sinceLastUpdate + deltaTime;
|
|
||||||
|
|
||||||
// if (sinceLastUpdate > 60) {
|
|
||||||
// sinceLastUpdate = 0;
|
|
||||||
// } else {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// print('SEARCHING FOR LIGHTS');
|
|
||||||
|
|
||||||
// var entitites = Entities.findEntities(MyAvatar.position, 50);
|
|
||||||
// for (i = 0; i < entities.length; i++) {
|
|
||||||
// var entityProperties = Entities.getEntityProperties(entities[i], ['type', 'parentID'])
|
|
||||||
// var parentID = entityProperties.parentID;
|
|
||||||
// var type = entityProperties.type;
|
|
||||||
|
|
||||||
// if (type !== 'Light') {
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (type === "Light" && parentID !== DEFAULT_PARENT_ID && parentID !== null) {
|
|
||||||
// var light = entities[i];
|
|
||||||
// //do something with the light.
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// function interval() {
|
|
||||||
// var lastTime = new Date().getTime();
|
|
||||||
|
|
||||||
// return function getInterval() {
|
|
||||||
// var newTime = new Date().getTime();
|
|
||||||
// var delta = newTime - lastTime;
|
|
||||||
// lastTime = newTime;
|
|
||||||
// return delta;
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,10 @@ var light, block;
|
||||||
|
|
||||||
function createLight() {
|
function createLight() {
|
||||||
var blockProperties = Entities.getEntityProperties(block, ["position", "rotation"]);
|
var blockProperties = Entities.getEntityProperties(block, ["position", "rotation"]);
|
||||||
var lightTransform = evalLightWorldTransform(blockProperties.position, blockProperties.rotation);
|
var position = basePosition;
|
||||||
|
position.y += 3;
|
||||||
|
var lightTransform = evalLightWorldTransform(position,avatarRot);
|
||||||
|
// var lightTransform = evalLightWorldTransform(blockProperties.position, blockProperties.rotation);
|
||||||
var lightProperties = {
|
var lightProperties = {
|
||||||
name: 'Hifi-Spotlight',
|
name: 'Hifi-Spotlight',
|
||||||
type: "Light",
|
type: "Light",
|
||||||
|
@ -29,7 +32,7 @@ function createLight() {
|
||||||
y: 2,
|
y: 2,
|
||||||
z: 8
|
z: 8
|
||||||
},
|
},
|
||||||
parentID: block,
|
// parentID: block,
|
||||||
color: {
|
color: {
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 0,
|
green: 0,
|
||||||
|
@ -53,7 +56,7 @@ function createLight() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Messages.sendMessage('Hifi-Light-Mod-Receiver', JSON.stringify(message));
|
// Messages.sendMessage('Hifi-Light-Mod-Receiver', JSON.stringify(message));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,11 +107,11 @@ function evalLightWorldTransform(modelPos, modelRot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(block);
|
//Entities.deleteEntity(block);
|
||||||
Entities.deleteEntity(light);
|
Entities.deleteEntity(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
||||||
createBlock();
|
//createBlock();
|
||||||
createLight();
|
createLight();
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
LightParent.prototype = {
|
LightParent.prototype = {
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
print('LIGHT PARENT SCRIPT GO')
|
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
var entityProperties = Entities.getEntityProperties(this.entityID, "userData");
|
var entityProperties = Entities.getEntityProperties(this.entityID, "userData");
|
||||||
this.initialProperties = entityProperties
|
this.initialProperties = entityProperties
|
||||||
|
@ -32,7 +31,6 @@
|
||||||
this.continueDistantGrab();
|
this.continueDistantGrab();
|
||||||
},
|
},
|
||||||
continueDistantGrab: function() {
|
continueDistantGrab: function() {
|
||||||
print('distant grab, should send message!')
|
|
||||||
Messages.sendMessage('entityToolUpdates', 'callUpdate');
|
Messages.sendMessage('entityToolUpdates', 'callUpdate');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue