From b0bcbb03f2bee5fa5c299c9f20774fd0d7ddea04 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Wed, 16 Dec 2015 11:57:54 -0800 Subject: [PATCH] remove floor and move sliders up a bit --- examples/lights/lightModifier.js | 84 +++++++++++++++++++++-- examples/lights/lightModifierTestScene.js | 46 ++++--------- examples/lights/slider.js | 3 +- 3 files changed, 92 insertions(+), 41 deletions(-) diff --git a/examples/lights/lightModifier.js b/examples/lights/lightModifier.js index ffd1469a4a..0a584b127c 100644 --- a/examples/lights/lightModifier.js +++ b/examples/lights/lightModifier.js @@ -10,6 +10,19 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + +// Script.include('../libraries/lightOverlayManager.js'); +// var lightOverlayManager = new LightOverlayManager(); +// lightOverlayManager.setVisible(true); + + // var pickRay = Camera.computePickRay(event.x, event.y); + // var lightResult = lightOverlayManager.findRayIntersection(pickRay) + + +var DEFAULT_PARENT_ID = '{00000000-0000-0000-0000-000000000000}' +var SHOULD_STAY_WITH_AVATAR = false; +var VERTICAL_SLIDERS = false; + var AXIS_SCALE = 1; var COLOR_MAX = 255; var INTENSITY_MAX = 0.05; @@ -48,10 +61,10 @@ var WHITE = { blue: 255 }; -var ORANGE={ - red:255, - green:0, - blue:128 +var ORANGE = { + red: 255, + green: 0, + blue: 128 } var SLIDER_DIMENSIONS = { @@ -75,6 +88,7 @@ function entitySlider(light, color, sliderType, row) { 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(1.5, Quat.getFront(this.avatarRot))); + this.basePosition.y +=1; var message = { lightID: this.lightID, @@ -190,6 +204,10 @@ entitySlider.prototype = { sliderType: this.sliderType, axisStart: position, axisEnd: this.endOfAxis, + }, + releaseVelocityKey: { + disableReleaseVelocity: true, + customReleaseVelocity: false } }) }; @@ -201,13 +219,13 @@ entitySlider.prototype = { //message is not for our light if (message.lightID !== this.lightID) { - // print('not our light') + // print('not our light') return; } //message is not our type if (message.sliderType !== this.sliderType) { - // print('not our slider type') + // print('not our slider type') return } @@ -381,8 +399,62 @@ function deleteEntity(entityID) { } + Entities.deletingEntity.connect(deleteEntity); +// search for lights to make grabbable + +// 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; +// }; +// } + + + //other light properties // diffuseColor: { red: 255, green: 255, blue: 255 }, diff --git a/examples/lights/lightModifierTestScene.js b/examples/lights/lightModifierTestScene.js index 214d900130..5748f0d4ed 100644 --- a/examples/lights/lightModifierTestScene.js +++ b/examples/lights/lightModifierTestScene.js @@ -9,39 +9,10 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var MODEL_LIGHT_POSITION = { - x: 0, - y: -0.3, - z: 0 -}; -var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { - x: 1, - y: 0, - z: 0 -}); var basePosition, avatarRot; avatarRot = Quat.fromPitchYawRollDegrees(0, MyAvatar.bodyYaw, 0.0); -basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(-3, Quat.getUp(avatarRot))); - -var ground = Entities.addEntity({ - name: 'Hifi-Light-Mod-Floor', - //type: "Model", - type: 'Box', - color: { - red: 100, - green: 100, - blue: 100 - }, - //modelURL: "https://hifi-public.s3.amazonaws.com/eric/models/woodFloor.fbx", - dimensions: { - x: 100, - y: 2, - z: 100 - }, - position: basePosition, - shapeType: 'box' -}); +basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(0, Quat.getUp(avatarRot))); var light, block; @@ -87,7 +58,7 @@ function createLight() { function createBlock() { var position = basePosition; - position.y += 5; + position.y += 3; var blockProperties = { name: 'Hifi-Spotlight-Block', type: 'Box', @@ -103,12 +74,22 @@ function createBlock() { blue: 255 }, position: position - } + }; block = Entities.addEntity(blockProperties); } function evalLightWorldTransform(modelPos, modelRot) { + var MODEL_LIGHT_POSITION = { + x: 0, + y: -0.3, + z: 0 + }; + var MODEL_LIGHT_ROTATION = Quat.angleAxis(-90, { + x: 1, + y: 0, + z: 0 + }); return { p: Vec3.sum(modelPos, Vec3.multiplyQbyV(modelRot, MODEL_LIGHT_POSITION)), q: Quat.multiply(modelRot, MODEL_LIGHT_ROTATION) @@ -117,7 +98,6 @@ function evalLightWorldTransform(modelPos, modelRot) { function cleanup() { Entities.deleteEntity(block); - Entities.deleteEntity(ground); Entities.deleteEntity(light); } diff --git a/examples/lights/slider.js b/examples/lights/slider.js index c17704b0db..dc02e0bdba 100644 --- a/examples/lights/slider.js +++ b/examples/lights/slider.js @@ -9,6 +9,7 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // + (function() { var AXIS_SCALE = 1; @@ -61,9 +62,7 @@ this.sliderValue = this.scaleValueBasedOnDistanceFromStart(distance, EXPONENT_MAX); }; - //print('SLIDER VALUE:::' + this.sliderValue) this.sendValueToSlider(); - }, releaseGrab: function() { Entities.editEntity(this.entityID, {