mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 04:25:49 +02:00
more work
This commit is contained in:
parent
ea0ffa5899
commit
8bdced8576
2 changed files with 32 additions and 16 deletions
|
@ -26,7 +26,8 @@
|
||||||
this.initialProperties = Entities.getEntityProperties(this.entityID);
|
this.initialProperties = Entities.getEntityProperties(this.entityID);
|
||||||
},
|
},
|
||||||
getClampedPosition: function() {
|
getClampedPosition: function() {
|
||||||
dPosition = Vec3.subtract(MyAvatar.position, previousPosition);
|
|
||||||
|
dPosition = Vec3.subtract(MyAvatar.position, this.previousPosition);
|
||||||
//convert to localFrame
|
//convert to localFrame
|
||||||
dPosition = Vec3.multiplyQbyV(Quat.inverse(MyAvatar.orientation), dPosition);
|
dPosition = Vec3.multiplyQbyV(Quat.inverse(MyAvatar.orientation), dPosition);
|
||||||
|
|
||||||
|
@ -39,8 +40,19 @@
|
||||||
continueDistantGrab: function() {
|
continueDistantGrab: function() {
|
||||||
var currentPosition = this.getClampedPosition();
|
var currentPosition = this.getClampedPosition();
|
||||||
var distance = Vec3.distance(this.initialProperties.position, currentPosition);
|
var distance = Vec3.distance(this.initialProperties.position, currentPosition);
|
||||||
if ()
|
|
||||||
this.sliderValue = scaleValueBasedOnDistanceFromStart(distance);
|
if (userData.sliderType === 'color_red' || userData.sliderType === 'color_green' || userData.sliderType === 'color_blue') {
|
||||||
|
this.sliderValue = scaleValueBasedOnDistanceFromStart(distance, COLOR_MAX);
|
||||||
|
}
|
||||||
|
if (userData.sliderType === 'intensity') {
|
||||||
|
this.sliderValue = scaleValueBasedOnDistanceFromStart(distance, INTENSITY_MAX);
|
||||||
|
}
|
||||||
|
if (userData.sliderType === 'cutoff') {
|
||||||
|
this.sliderValue = scaleValueBasedOnDistanceFromStart(distance, CUTOFF_MAX);
|
||||||
|
}
|
||||||
|
if (userData.sliderType === 'exponent') {
|
||||||
|
this.sliderValue = scaleValueBasedOnDistanceFromStart(distance, EXPONENT_MAX);
|
||||||
|
}
|
||||||
|
|
||||||
Entities.editEntity(this.entityID) {
|
Entities.editEntity(this.entityID) {
|
||||||
position: currentPosition,
|
position: currentPosition,
|
||||||
|
@ -67,8 +79,8 @@
|
||||||
},
|
},
|
||||||
sendValueToSlider: function() {
|
sendValueToSlider: function() {
|
||||||
var message = {
|
var message = {
|
||||||
lightID:userData.lightID,
|
lightID: userData.lightID,
|
||||||
sliderType:userData.sliderType,
|
sliderType: userData.sliderType,
|
||||||
sliderValue: this.sliderValue
|
sliderValue: this.sliderValue
|
||||||
}
|
}
|
||||||
Messages.sendMessage('Hifi-Slider-Value-Reciever', JSON.stringify(message));
|
Messages.sendMessage('Hifi-Slider-Value-Reciever', JSON.stringify(message));
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
// given a selected light, instantiate some entities that represent various values you can dynamically adjust
|
// given a selected light, instantiate some entities that represent various values you can dynamically adjust
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var BOX_SCRIPT_URL = Script.resolvePath('box.js');
|
var BOX_SCRIPT_URL = Script.resolvePath('box.js');
|
||||||
|
|
||||||
var RED = {
|
var RED = {
|
||||||
|
@ -54,6 +56,9 @@ function entitySlider(light, color, sliderType, row) {
|
||||||
this.sliderType = sliderType;
|
this.sliderType = sliderType;
|
||||||
this.verticalOffset = Vec3.multiply(row, PER_ROW_OFFSET);
|
this.verticalOffset = Vec3.multiply(row, PER_ROW_OFFSET);
|
||||||
|
|
||||||
|
this.avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
|
||||||
|
this.basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(this.avatarRot)));
|
||||||
|
|
||||||
var message = {
|
var message = {
|
||||||
lightID: this.lightID,
|
lightID: this.lightID,
|
||||||
sliderType: this.sliderType,
|
sliderType: this.sliderType,
|
||||||
|
@ -97,8 +102,14 @@ function entitySlider(light, color, sliderType, row) {
|
||||||
entitySlider.prototype = {
|
entitySlider.prototype = {
|
||||||
createAxis: function() {
|
createAxis: function() {
|
||||||
//start of line
|
//start of line
|
||||||
var position;
|
var position = Vec3.sum(this.basePosition, this.verticalOffset);
|
||||||
//1 meter along orientationAxis
|
|
||||||
|
//line starts on left and goes to right
|
||||||
|
//set the end of the line to the right
|
||||||
|
var rightVector = Quat.getRight(this.avatarRot);
|
||||||
|
var extension = Vec3.multiply(AXIS_SCALE, rightVector);
|
||||||
|
var endOfAxis = Vec3.sum(position, extension);
|
||||||
|
|
||||||
var endOfAxis;
|
var endOfAxis;
|
||||||
var properties = {
|
var properties = {
|
||||||
type: 'Line',
|
type: 'Line',
|
||||||
|
@ -139,8 +150,6 @@ entitySlider.prototype = {
|
||||||
this.boxIndicator = Entities.addEntity(properties);
|
this.boxIndicator = Entities.addEntity(properties);
|
||||||
},
|
},
|
||||||
setValueFromMessage: function(message) {
|
setValueFromMessage: function(message) {
|
||||||
print('VALUE MESSAGE::'+JSON.stringify(message))
|
|
||||||
print('LIGHT ID::'+this.lightID);
|
|
||||||
|
|
||||||
//message is not for our light
|
//message is not for our light
|
||||||
if (message.lightID !== this.lightID) {
|
if (message.lightID !== this.lightID) {
|
||||||
|
@ -154,10 +163,9 @@ entitySlider.prototype = {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
print('SHOULD SET SOME VALUE:::' + message.sliderType);
|
print('should set:::' + this.sliderType);
|
||||||
|
|
||||||
var lightProperties = Entities.getEntityProperties(this.lightID);
|
var lightProperties = Entities.getEntityProperties(this.lightID);
|
||||||
// print('LIGHT PROPERTIES::'+JSON.stringify(lightProperties));
|
|
||||||
|
|
||||||
if (this.sliderType === 'color_red') {
|
if (this.sliderType === 'color_red') {
|
||||||
Entities.editEntity(this.lightID, {
|
Entities.editEntity(this.lightID, {
|
||||||
|
@ -190,7 +198,6 @@ entitySlider.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.sliderType === 'intensity') {
|
if (this.sliderType === 'intensity') {
|
||||||
print('CHANGING INTENSITY TO::' + message.sliderValue)
|
|
||||||
Entities.editEntity(this.lightID, {
|
Entities.editEntity(this.lightID, {
|
||||||
intensity: message.sliderValue
|
intensity: message.sliderValue
|
||||||
});
|
});
|
||||||
|
@ -209,7 +216,6 @@ entitySlider.prototype = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
subscribeToBoxMessages: function() {
|
subscribeToBoxMessages: function() {
|
||||||
print('subscribing to box messages');
|
|
||||||
Messages.subscribe('Hifi-Slider-Value-Reciever');
|
Messages.subscribe('Hifi-Slider-Value-Reciever');
|
||||||
Messages.messageReceived.connect(handleValueMessages);
|
Messages.messageReceived.connect(handleValueMessages);
|
||||||
},
|
},
|
||||||
|
@ -296,17 +302,15 @@ function handleLightModMessages(channel, message, sender) {
|
||||||
}
|
}
|
||||||
var parsedMessage = JSON.parse(message);
|
var parsedMessage = JSON.parse(message);
|
||||||
|
|
||||||
print('MESSAGE LIGHT:::' + message)
|
|
||||||
makeSliders(parsedMessage.light);
|
makeSliders(parsedMessage.light);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleValueMessages(channel, message, sender) {
|
function handleValueMessages(channel, message, sender) {
|
||||||
|
|
||||||
|
|
||||||
if (channel !== 'Hifi-Slider-Value-Reciever') {
|
if (channel !== 'Hifi-Slider-Value-Reciever') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print('HANDLE VALUE MESSAGE')
|
|
||||||
//easily protect from other people editing your values, but group editing might be fun so lets try that first.
|
//easily protect from other people editing your values, but group editing might be fun so lets try that first.
|
||||||
// if (sender !== MyAvatar.sessionUUID) {
|
// if (sender !== MyAvatar.sessionUUID) {
|
||||||
// return;
|
// return;
|
||||||
|
|
Loading…
Reference in a new issue