mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:43:03 +02:00
prep for close button
This commit is contained in:
parent
a25feb5578
commit
7a542a678b
3 changed files with 106 additions and 33 deletions
41
examples/light_modifier/closeButton.js
Normal file
41
examples/light_modifier/closeButton.js
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// closeButton.js
|
||||||
|
//
|
||||||
|
// Created by James Pollack @imgntn on 12/15/2015
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Entity script that closes sliders when interacted with.
|
||||||
|
//
|
||||||
|
// 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 CloseButton() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseButton.prototype = {
|
||||||
|
preload: function(entityID) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
var entityProperties = Entities.getEntityProperties(this.entityID, "userData");
|
||||||
|
this.initialProperties = entityProperties
|
||||||
|
this.userData = JSON.parse(entityProperties.userData);
|
||||||
|
},
|
||||||
|
startNearGrab: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
startDistantGrab: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
continueNearGrab: function() {
|
||||||
|
this.continueDistantGrab();
|
||||||
|
},
|
||||||
|
continueDistantGrab: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return new CloseButton();
|
||||||
|
});
|
|
@ -60,6 +60,8 @@ 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 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 RED = {
|
var RED = {
|
||||||
red: 255,
|
red: 255,
|
||||||
|
@ -103,16 +105,16 @@ var SLIDER_DIMENSIONS = {
|
||||||
z: 0.075
|
z: 0.075
|
||||||
};
|
};
|
||||||
|
|
||||||
var CLOSE_BUTTON_DIMENSIONS ={
|
var CLOSE_BUTTON_DIMENSIONS = {
|
||||||
x:0.1,
|
x: 0.1,
|
||||||
y:0.1,
|
y: 0.1,
|
||||||
z:0.1
|
z: 0.1
|
||||||
}
|
}
|
||||||
|
|
||||||
var LIGHT_MODEL_DIMENSIONS={
|
var LIGHT_MODEL_DIMENSIONS = {
|
||||||
x:0.04,
|
x: 0.04,
|
||||||
y:0.04,
|
y: 0.04,
|
||||||
z:0.09
|
z: 0.09
|
||||||
}
|
}
|
||||||
|
|
||||||
var PER_ROW_OFFSET = {
|
var PER_ROW_OFFSET = {
|
||||||
|
@ -361,7 +363,7 @@ var slidersRef = {
|
||||||
}
|
}
|
||||||
var light = null;
|
var light = null;
|
||||||
|
|
||||||
function makeSliders(light) { // selectionManager.setSelections([entityID]);
|
function makeSliders(light) {
|
||||||
|
|
||||||
if (light.type === 'spotlight') {
|
if (light.type === 'spotlight') {
|
||||||
var USE_COLOR_SLIDER = true;
|
var USE_COLOR_SLIDER = true;
|
||||||
|
@ -398,22 +400,50 @@ function makeSliders(light) { // selectionManager.setSelections([entityID]);
|
||||||
sliders.push(slidersRef.exponent);
|
sliders.push(slidersRef.exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
var closeButtonPosition;
|
createCloseButton(7);
|
||||||
|
|
||||||
createCloseButton(closeButtonPosition);
|
|
||||||
subscribeToSliderMessages();
|
subscribeToSliderMessages();
|
||||||
};
|
};
|
||||||
|
|
||||||
function createCloseButton(position){
|
var closeButtons = [];
|
||||||
|
|
||||||
|
function createCloseButton(row) {
|
||||||
|
var basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1.5, Quat.getFront(this.avatarRot)));
|
||||||
|
var verticalOffset = Vec3.multiply(row, PER_ROW_OFFSET);
|
||||||
|
var downPosition = Vec3.sum(basePosition, verticalOffset);
|
||||||
|
var avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0);
|
||||||
|
var rightVector = Quat.getRight(avatarRot);
|
||||||
|
var extension = Vec3.multiply(AXIS_SCALE, rightVector);
|
||||||
|
var position = Vec3.sum(downPosition, extension);
|
||||||
|
|
||||||
var buttonProperties = {
|
var buttonProperties = {
|
||||||
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: position,
|
||||||
rotation:Quat.fromPitchYawRollDegrees(90,0,0);
|
rotation: Quat.fromPitchYawRollDegrees(90, 0, 0),
|
||||||
|
collisionsWillMove: false
|
||||||
|
//need to add wantsTrigger stuff so we can interact with it with our beamz
|
||||||
}
|
}
|
||||||
|
|
||||||
var button = Entities.addEntity(buttonProperties);
|
var button = Entities.addEntity(buttonProperties);
|
||||||
|
|
||||||
|
closeButtons.push(button);
|
||||||
|
|
||||||
|
Script.update.connect(rotateCloseButtons);
|
||||||
|
}
|
||||||
|
|
||||||
|
function rotateCloseButtons() {
|
||||||
|
closeButtons.forEach(function(button) {
|
||||||
|
Entities.editEntity(button, {
|
||||||
|
angularVelocity: {
|
||||||
|
x: 0,
|
||||||
|
y: 0.25,
|
||||||
|
z: 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function subScribeToNewLights() {
|
function subScribeToNewLights() {
|
||||||
|
@ -471,7 +501,6 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print('RAY CHECK GOT MESSAGE::' + message);
|
|
||||||
var pickRay = JSON.parse(message);
|
var pickRay = JSON.parse(message);
|
||||||
|
|
||||||
var doesIntersect = lightOverlayManager.findRayIntersection(pickRay);
|
var doesIntersect = lightOverlayManager.findRayIntersection(pickRay);
|
||||||
|
@ -484,7 +513,7 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
print('ALREADY HAVE A BLOCK, EXIT')
|
print('ALREADY HAVE A BLOCK, EXIT')
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
print('LIGHT ID::' + lightID);
|
|
||||||
currentLight = lightID;
|
currentLight = lightID;
|
||||||
var lightProperties = Entities.getEntityProperties(lightID);
|
var lightProperties = Entities.getEntityProperties(lightID);
|
||||||
var block = createBlock(lightProperties.position);
|
var block = createBlock(lightProperties.position);
|
||||||
|
@ -496,13 +525,13 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
}
|
}
|
||||||
|
|
||||||
makeSliders(light);
|
makeSliders(light);
|
||||||
print('AFTER MAKE SLIDERS')
|
|
||||||
if (SHOW_LIGHT_VOLUME === true) {
|
if (SHOW_LIGHT_VOLUME === true) {
|
||||||
selectionManager.setSelections([lightID]);
|
selectionManager.setSelections([lightID]);
|
||||||
print('SET SELECTIOIO MANAGER TO::: '+ lightID);
|
print('SET SELECTIOIO MANAGER TO::: ' + lightID);
|
||||||
print('hasSelection???' + selectionManager.hasSelection())
|
print('hasSelection???' + selectionManager.hasSelection())
|
||||||
}
|
}
|
||||||
print('BLOCK IS:::' + block);
|
|
||||||
Entities.editEntity(lightID, {
|
Entities.editEntity(lightID, {
|
||||||
parentID: block
|
parentID: block
|
||||||
});
|
});
|
||||||
|
@ -510,6 +539,7 @@ function handleLightOverlayRayCheckMessages(channel, message, sender) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createBlock(position) {
|
function createBlock(position) {
|
||||||
print('CREATE BLOCK')
|
print('CREATE BLOCK')
|
||||||
|
|
||||||
|
@ -553,6 +583,8 @@ function cleanup() {
|
||||||
Entities.deletingEntity.disconnect(deleteEntity);
|
Entities.deletingEntity.disconnect(deleteEntity);
|
||||||
|
|
||||||
lightOverlayManager.setVisible(false);
|
lightOverlayManager.setVisible(false);
|
||||||
|
Script.update.disconnect(rotateCloseButtons);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
//
|
//
|
||||||
// slider.js
|
// lightParent.js
|
||||||
//
|
//
|
||||||
// Created by James Pollack @imgntn on 12/15/2015
|
// Created by James Pollack @imgntn on 12/15/2015
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Entity script that sends a scaled value to a light based on its distance from the start of its constraint axis.
|
// Entity script that tells the light parent to update the selection tool when we move it.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue