mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:19:05 +02:00
close button
This commit is contained in:
parent
f84a441c7d
commit
387c30d83f
4 changed files with 41 additions and 27 deletions
|
@ -842,7 +842,7 @@ function MyController(hand) {
|
||||||
this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change);
|
this.currentObjectPosition = Vec3.sum(this.currentObjectPosition, change);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print('should not head move!');
|
// print('should not head move!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,15 @@ This PR demonstrates one way in-world editing of objects might work. We start w
|
||||||
To test: https://rawgit.com/imgntn/hifi/light_mod/examples/lights/lightLoader.js
|
To test: https://rawgit.com/imgntn/hifi/light_mod/examples/lights/lightLoader.js
|
||||||
To reset, I recommend stopping all scripts then re-loading lightLoader.js
|
To reset, I recommend stopping all scripts then re-loading lightLoader.js
|
||||||
|
|
||||||
When you run the lightLoader.js script, 4 scripts will be loaded:
|
When you run the lightLoader.js script, several scripts will be loaded:
|
||||||
- handControllerGrab.js (custom)
|
- handControllerGrab.js (custom)
|
||||||
- lightModifier.js (listens for message to create sliders for a given light)
|
- lightModifier.js (listens for message to create sliders for a given light)
|
||||||
- lightModifierTestScene.js (creates a light and parents it to a block, then sends a message ^^)
|
- lightModifierTestScene.js (creates a light and parents it to a block, then sends a message ^^)
|
||||||
- slider.js (attached to each slider entity)
|
- slider.js (attached to each slider entity)
|
||||||
|
- lightParent.js (attached to the entity to which a light is parented, so you can move it around)
|
||||||
|
- closeButton.js (for closing the ui)
|
||||||
|
- ../libraries/lightOverlayManager.js (custom)
|
||||||
|
- ../libraries/entitySelectionTool.js
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ var CUTOFF_MAX = 360;
|
||||||
var EXPONENT_MAX = 1;
|
var EXPONENT_MAX = 1;
|
||||||
|
|
||||||
var SLIDER_SCRIPT_URL = Script.resolvePath('slider.js?' + Math.random(0, 100));
|
var SLIDER_SCRIPT_URL = Script.resolvePath('slider.js?' + Math.random(0, 100));
|
||||||
var LIGHT_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier/source4_good.fbx';
|
var LIGHT_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/james/light_modifier/source4_rotated.fbx';
|
||||||
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));
|
||||||
|
|
||||||
|
@ -108,14 +108,14 @@ var SLIDER_DIMENSIONS = {
|
||||||
|
|
||||||
var CLOSE_BUTTON_DIMENSIONS = {
|
var CLOSE_BUTTON_DIMENSIONS = {
|
||||||
x: 0.1,
|
x: 0.1,
|
||||||
y: 0.1,
|
y: 0.025,
|
||||||
z: 0.1
|
z: 0.1
|
||||||
}
|
}
|
||||||
|
|
||||||
var LIGHT_MODEL_DIMENSIONS = {
|
var LIGHT_MODEL_DIMENSIONS = {
|
||||||
x: 0.68,
|
x: 0.58,
|
||||||
y: 0.68,
|
y: 1.21,
|
||||||
z: 1.54
|
z: 0.57
|
||||||
}
|
}
|
||||||
|
|
||||||
var PER_ROW_OFFSET = {
|
var PER_ROW_OFFSET = {
|
||||||
|
@ -262,6 +262,7 @@ entitySlider.prototype = {
|
||||||
color: this.color,
|
color: this.color,
|
||||||
position: sliderPosition,
|
position: sliderPosition,
|
||||||
script: SLIDER_SCRIPT_URL,
|
script: SLIDER_SCRIPT_URL,
|
||||||
|
ignoreForCollisions:true,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
lightModifierKey: {
|
lightModifierKey: {
|
||||||
lightID: this.lightID,
|
lightID: this.lightID,
|
||||||
|
@ -401,29 +402,34 @@ function makeSliders(light) {
|
||||||
sliders.push(slidersRef.exponent);
|
sliders.push(slidersRef.exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
createCloseButton(7);
|
createCloseButton(slidersRef.exponent.endOfAxis);
|
||||||
|
|
||||||
subscribeToSliderMessages();
|
subscribeToSliderMessages();
|
||||||
};
|
};
|
||||||
|
|
||||||
var closeButtons = [];
|
var closeButtons = [];
|
||||||
|
|
||||||
function createCloseButton(row) {
|
function createCloseButton(endOfAxis) {
|
||||||
var avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
|
// var avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
|
||||||
var basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(avatarRot)));
|
// var basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(avatarRot)));
|
||||||
var verticalOffset = Vec3.multiply(row, PER_ROW_OFFSET);
|
// var verticalOffset = Vec3.multiply(row, PER_ROW_OFFSET);
|
||||||
var downPosition = Vec3.sum(basePosition, verticalOffset);
|
// var verticalOffset = lastRowVerticalOffset;
|
||||||
var rightVector = Quat.getRight(avatarRot);
|
// var downPosition = Vec3.sum(basePosition, verticalOffset);
|
||||||
var extension = Vec3.multiply(AXIS_SCALE, rightVector);
|
// var rightVector = Quat.getRight(avatarRot);
|
||||||
var position = Vec3.sum(downPosition, extension);
|
// var extension = Vec3.multiply(AXIS_SCALE, rightVector);
|
||||||
|
// var position = Vec3.sum(downPosition, 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: position,
|
position: Vec3.sum(endOfAxis,{
|
||||||
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
x:0,
|
||||||
|
y:-0.15,
|
||||||
|
z:0
|
||||||
|
}),
|
||||||
|
rotation: Quat.fromPitchYawRollDegrees(0, 45, 90),
|
||||||
collisionsWillMove: false
|
collisionsWillMove: false
|
||||||
//need to add wantsTrigger stuff so we can interact with it with our beamz
|
//need to add wantsTrigger stuff so we can interact with it with our beamz
|
||||||
}
|
}
|
||||||
|
@ -440,7 +446,7 @@ function rotateCloseButtons() {
|
||||||
Entities.editEntity(button, {
|
Entities.editEntity(button, {
|
||||||
angularVelocity: {
|
angularVelocity: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0.25,
|
y: 0.5,
|
||||||
z: 0
|
z: 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -519,8 +525,8 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
|
|
||||||
currentLight = lightID;
|
currentLight = lightID;
|
||||||
var lightProperties = Entities.getEntityProperties(lightID);
|
var lightProperties = Entities.getEntityProperties(lightID);
|
||||||
block = createBlock(lightProperties.position);
|
// block = createBlock(lightProperties.position);
|
||||||
// block = createLightModel(lightProperties.position);
|
block = createLightModel(lightProperties.position);
|
||||||
|
|
||||||
var light = {
|
var light = {
|
||||||
id: lightID,
|
id: lightID,
|
||||||
|
@ -532,12 +538,11 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
|
|
||||||
if (SHOW_LIGHT_VOLUME === true) {
|
if (SHOW_LIGHT_VOLUME === true) {
|
||||||
selectionManager.setSelections([lightID]);
|
selectionManager.setSelections([lightID]);
|
||||||
print('SET SELECTIOIO MANAGER TO::: ' + lightID);
|
|
||||||
print('hasSelection???' + selectionManager.hasSelection())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Entities.editEntity(lightID, {
|
Entities.editEntity(lightID, {
|
||||||
parentID: block
|
parentID: block,
|
||||||
|
parentJointIndex:-1
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -551,10 +556,11 @@ function createLightModel(position) {
|
||||||
type: 'Model',
|
type: 'Model',
|
||||||
shapeType: 'box',
|
shapeType: 'box',
|
||||||
modelURL: LIGHT_MODEL_URL,
|
modelURL: LIGHT_MODEL_URL,
|
||||||
|
// modelURL:"http://hifi-content.s3.amazonaws.com/james/light_modifier/box4.fbx",
|
||||||
dimensions: LIGHT_MODEL_DIMENSIONS,
|
dimensions: LIGHT_MODEL_DIMENSIONS,
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
position: position,
|
position: position,
|
||||||
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
// rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||||
script: PARENT_SCRIPT_URL,
|
script: PARENT_SCRIPT_URL,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
handControllerKey: {
|
handControllerKey: {
|
||||||
|
@ -576,7 +582,7 @@ function createBlock(position) {
|
||||||
type: 'Box',
|
type: 'Box',
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 1,
|
y: 4,
|
||||||
z: 1
|
z: 1
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
|
@ -606,6 +612,10 @@ function cleanup() {
|
||||||
Entities.deleteEntity(sliders[i].sliderIndicator);
|
Entities.deleteEntity(sliders[i].sliderIndicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while(closeButtons.length>0){
|
||||||
|
Entities.deleteEntity(closeButtons.pop());
|
||||||
|
}
|
||||||
|
|
||||||
Entities.deleteEntity(block);
|
Entities.deleteEntity(block);
|
||||||
Messages.messageReceived.disconnect(handleLightModMessages);
|
Messages.messageReceived.disconnect(handleLightModMessages);
|
||||||
Messages.messageReceived.disconnect(handleValueMessages);
|
Messages.messageReceived.disconnect(handleValueMessages);
|
||||||
|
|
|
@ -20,7 +20,7 @@ var light, block;
|
||||||
function createLight() {
|
function createLight() {
|
||||||
var blockProperties = Entities.getEntityProperties(block, ["position", "rotation"]);
|
var blockProperties = Entities.getEntityProperties(block, ["position", "rotation"]);
|
||||||
var position = basePosition;
|
var position = basePosition;
|
||||||
position.y += 3;
|
position.y += 2;
|
||||||
var lightTransform = evalLightWorldTransform(position,avatarRot);
|
var lightTransform = evalLightWorldTransform(position,avatarRot);
|
||||||
// var lightTransform = evalLightWorldTransform(blockProperties.position, blockProperties.rotation);
|
// var lightTransform = evalLightWorldTransform(blockProperties.position, blockProperties.rotation);
|
||||||
var lightProperties = {
|
var lightProperties = {
|
||||||
|
|
Loading…
Reference in a new issue