diff --git a/cmake/macros/GenerateInstallers.cmake b/cmake/macros/GenerateInstallers.cmake index 8d1eca84d7..0def701739 100644 --- a/cmake/macros/GenerateInstallers.cmake +++ b/cmake/macros/GenerateInstallers.cmake @@ -19,7 +19,7 @@ macro(GENERATE_INSTALLERS) set(CPACK_PACKAGE_NAME ${_DISPLAY_NAME}) set(CPACK_PACKAGE_VENDOR "High Fidelity") set(CPACK_PACKAGE_VERSION ${BUILD_VERSION}) - set(CPACK_PACKAGE_FILE_NAME "HighFidelity-Alpha-${BUILD_VERSION}") + set(CPACK_PACKAGE_FILE_NAME "HighFidelity-Beta-${BUILD_VERSION}") set(CPACK_NSIS_DISPLAY_NAME ${_DISPLAY_NAME}) set(CPACK_NSIS_PACKAGE_NAME ${_DISPLAY_NAME}) set(CPACK_PACKAGE_INSTALL_DIRECTORY ${_DISPLAY_NAME}) diff --git a/examples/clap.js b/examples/clap.js deleted file mode 100644 index 9b21075ae7..0000000000 --- a/examples/clap.js +++ /dev/null @@ -1,148 +0,0 @@ -// -// clap.js -// examples -// -// Copyright 2014 High Fidelity, Inc. -// -// This sample script watches your hydra hands and makes clapping sound when they come close together fast, -// and also watches for the 'shift' key and claps when that key is pressed. Clapping multiple times by pressing -// the shift key again makes the animation and sound match your pace of clapping. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; - -var clapAnimation = HIFI_PUBLIC_BUCKET + "animations/ClapAnimations/ClapHands_Standing.fbx"; -var ANIMATION_FRAMES_PER_CLAP = 10.0; -var startEndFrames = []; -startEndFrames.push({ start: 0, end: 10}); -startEndFrames.push({ start: 10, end: 20}); -startEndFrames.push({ start: 20, end: 30}); -startEndFrames.push({ start: 30, end: 40}); -startEndFrames.push({ start: 41, end: 51}); -startEndFrames.push({ start: 53, end: 0}); - -var lastClapFrame = 0; -var lastAnimFrame = 0; - -var claps = []; -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap1Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap2Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap3Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap4Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap5Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap6Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap7Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap8Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap9Rvb.wav")); -claps.push(SoundCache.getSound(HIFI_PUBLIC_BUCKET + "sounds/claps/BClap10Rvb.wav")); -var numberOfSounds = claps.length; - -var clappingNow = false; -var collectedClicks = 0; - -var clickStartTime, clickEndTime; -var clickClappingNow = false; -var CLAP_START_RATE = 15.0; -var clapRate = CLAP_START_RATE; -var startedTimer = false; - -function maybePlaySound(deltaTime) { - // Set the location and other info for the sound to play - - var animationDetails = MyAvatar.getAnimationDetails(clapAnimation); - - var frame = Math.floor(animationDetails.frameIndex); - - if (frame != lastAnimFrame) { - lastAnimFrame = frame; - } - - for (var i = 0; i < startEndFrames.length; i++) { - if (frame == startEndFrames[i].start && (frame != lastClapFrame)) { - playClap(1.0, Camera.getPosition()); - lastClapFrame = frame; - } - } - - var palm1Position = MyAvatar.getLeftPalmPosition(); - var palm2Position = MyAvatar.getRightPalmPosition(); - var distanceBetween = Vec3.length(Vec3.subtract(palm1Position, palm2Position)); - - var palm1Velocity = Controller.getPoseValue(Controller.Standard.LeftHand).velocity; - var palm2Velocity = Controller.getPoseValue(Controller.Standard.RightHand).velocity; - var closingVelocity = Vec3.length(Vec3.subtract(palm1Velocity, palm2Velocity)); - - const CLAP_SPEED = 0.7; - const CLAP_DISTANCE = 0.15; - - if ((closingVelocity > CLAP_SPEED) && (distanceBetween < CLAP_DISTANCE) && !clappingNow) { - var volume = closingVelocity / 2.0; - if (volume > 1.0) volume = 1.0; - playClap(volume, palm1Position); - clappingNow = true; - } else if (clappingNow && (distanceBetween > CLAP_DISTANCE * 1.2)) { - clappingNow = false; - } -} - -function playClap(volume, position) { - var clip = Math.floor(Math.random() * numberOfSounds); - Audio.playSound(claps[clip], { - position: position, - volume: volume - }); -} - -var FASTEST_CLAP_INTERVAL = 150.0; -var SLOWEST_CLAP_INTERVAL = 750.0; - -Controller.keyPressEvent.connect(function(event) { - if(event.text == "SHIFT") { - if (!clickClappingNow) { - clickClappingNow = true; - clickStartTime = new Date(); - lastClapFrame = 0; - } else { - // start or adjust clapping speed based on the duration between clicks - clickEndTime = new Date(); - var milliseconds = Math.max(clickEndTime - clickStartTime, FASTEST_CLAP_INTERVAL); - clickStartTime = new Date(); - if (milliseconds < SLOWEST_CLAP_INTERVAL) { - clapRate = ANIMATION_FRAMES_PER_CLAP * (1000.0 / milliseconds); - playClap(1.0, Camera.getPosition()); - MyAvatar.stopAnimation(clapAnimation); - MyAvatar.startAnimation(clapAnimation, clapRate, 1.0, true, false); - } - collectedClicks = collectedClicks + 1; - } - } -}); - -var CLAP_END_WAIT_MSECS = 300; -Controller.keyReleaseEvent.connect(function(event) { - if (event.text == "SHIFT") { - collectedClicks = 0; - if (!startedTimer) { - collectedClicks = 0; - Script.setTimeout(stopClapping, CLAP_END_WAIT_MSECS); - startedTimer = true; - } - } -}); - -function stopClapping() { - if (collectedClicks == 0) { - startedTimer = false; - MyAvatar.stopAnimation(clapAnimation); - clapRate = CLAP_START_RATE; - clickClappingNow = false; - } else { - startedTimer = false; - } -} - -// Connect a call back that happens every frame -Script.update.connect(maybePlaySound); \ No newline at end of file diff --git a/examples/cows/cowEntityScript.js b/examples/cows/cowEntityScript.js deleted file mode 100644 index 1150be6b36..0000000000 --- a/examples/cows/cowEntityScript.js +++ /dev/null @@ -1,68 +0,0 @@ - -// cowEntityScript.js -// examples/cows -// -// Created by Eric Levin on 3/25/16 -// Copyright 2016 High Fidelity, Inc. -// -// This entity script handles the logic for untipping a cow after it collides with something -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - - - -(function() { - Script.include("../libraries/utils.js"); - - var _this = this; - _this.COLLISION_COOLDOWN_TIME = 5000; - - - this.preload = function(entityID) { - print("EBL Preload!!"); - _this.entityID = entityID; - _this.mooSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/moo.wav") - _this.mooSoundOptions = {volume: 0.7, loop: false}; - _this.timeSinceLastCollision = 0; - _this.shouldUntipCow = true; - } - - this.collisionWithEntity = function(myID, otherID, collisionInfo) { - if(_this.shouldUntipCow) { - Script.setTimeout(function() { - _this.untipCow(); - _this.shouldUntipCow = true; - }, _this.COLLISION_COOLDOWN_TIME); - } - - _this.shouldUntipCow = false; - - } - - this.untipCow = function() { - // keep yaw but reset pitch and roll - var cowProps = Entities.getEntityProperties(_this.entityID, ["rotation", "position"]); - var eulerRotation = Quat.safeEulerAngles(cowProps.rotation); - eulerRotation.x = 0; - eulerRotation.z = 0; - var newRotation = Quat.fromVec3Degrees(eulerRotation); - Entities.editEntity(_this.entityID, { - rotation: newRotation, - velocity: {x: 0, y: 0, z: 0}, - angularVelocity: {x: 0, y: 0, z:0} - }); - - - _this.mooSoundOptions.position = cowProps.position; - if (!_this.soundInjector) { - _this.soundInjector = Audio.playSound(_this.mooSound, _this.mooSoundOptions); - } else { - _this.soundInjector.setOptions(_this.mooSoundOptions); - _this.soundInjector.restart(); - } - } - - -}); diff --git a/examples/cows/cowSpawner.js b/examples/cows/cowSpawner.js deleted file mode 100644 index 7ff59b2e38..0000000000 --- a/examples/cows/cowSpawner.js +++ /dev/null @@ -1,53 +0,0 @@ - -// cowSpawner.js -// examples/cows -// -// Created by Eric Levin on 3/25/16 -// Copyright 2016 High Fidelity, Inc. -// -// This spawns a cow which will untip itself -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - - var orientation = MyAvatar.orientation; - orientation = Quat.safeEulerAngles(orientation); - orientation.x = 0; - orientation = Quat.fromVec3Degrees(orientation); - var center = Vec3.sum(MyAvatar.getHeadPosition(), Vec3.multiply(2, Quat.getFront(orientation))); - - - var SCRIPT_URL = Script.resolvePath("cowEntityScript.js?"); - var cow = Entities.addEntity({ - type: "Model", - modelURL: "http://hifi-content.s3.amazonaws.com/DomainContent/production/cow/newMooCow.fbx", - name: "playa_model_throwinCow", - position: center, - animation: { - currentFrame: 278, - running: true, - url: "http://hifi-content.s3.amazonaws.com/DomainContent/Junkyard/Playa/newMooCow.fbx" - }, - dimensions: { - x: 0.739, - y: 1.613, - z: 2.529 - }, - dynamic: true, - gravity: { - x: 0, - y: -5, - z: 0 - }, - shapeType: "box", - script: SCRIPT_URL, - userData: "{\"grabbableKey\":{\"grabbable\":true}}" - }); - - - function cleanup() { - Entities.deleteEntity(cow); - } - - Script.scriptEnding.connect(cleanup); diff --git a/examples/defaultScripts.js b/examples/defaultScripts.js deleted file mode 100644 index a4c8c36169..0000000000 --- a/examples/defaultScripts.js +++ /dev/null @@ -1,22 +0,0 @@ -// -// defaultScripts.js -// examples -// -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -Script.load("away.js"); -Script.load("progress.js"); -Script.load("edit.js"); -Script.load("examples.js"); -Script.load("selectAudioDevice.js"); -Script.load("notifications.js"); -Script.load("controllers/handControllerGrab.js"); -Script.load("controllers/squeezeHands.js"); -Script.load("grab.js"); -Script.load("directory.js"); -Script.load("dialTone.js"); -Script.load("depthReticle.js"); diff --git a/examples/example/games/exterminatorGame/pistol.js b/examples/example/games/exterminatorGame/pistol.js deleted file mode 100644 index 2cccf95986..0000000000 --- a/examples/example/games/exterminatorGame/pistol.js +++ /dev/null @@ -1,477 +0,0 @@ -// -// pistol.js -// examples -// -// Created by Eric Levin on 11/12/2015 -// Copyright 2013 High Fidelity, Inc. -// -// This is an example script that turns the hydra controllers and mouse into a entity gun. -// It reads the controller, watches for trigger pulls, and adds a force to any entity it hits - -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - - -Script.include("../../../libraries/utils.js"); -Script.include("../../../libraries/constants.js"); - -var GUN_FORCE =20; - -Messages.sendMessage('Hifi-Hand-Disabler', "both"); - -var gameName = "Kill All The Rats!" -// var HOST = "localhost:5000" -var HOST = "desolate-bastion-1742.herokuapp.com"; -var socketClient = new WebSocket("ws://" + HOST); -var username = GlobalServices.username; -var currentScore = 0; - -function score() { - currentScore++; - socketClient.send(JSON.stringify({ - username: username, - score: currentScore, - gameName: gameName - })) -} - - -HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; -var fireSound = SoundCache.getSound("https://s3.amazonaws.com/hifi-public/sounds/Guns/GUN-SHOT2.raw"); -var LASER_LENGTH = 100; -var LASER_WIDTH = 2; -var POSE_CONTROLS = [Controller.Standard.LeftHand, Controller.Standard.RightHand]; -var TRIGGER_CONTROLS = [Controller.Standard.LT, Controller.Standard.RT]; -var MIN_THROWER_DELAY = 1000; -var MAX_THROWER_DELAY = 1000; -var RELOAD_INTERVAL = 5; -var GUN_MODEL = HIFI_PUBLIC_BUCKET + "cozza13/gun/m1911-handgun+1.fbx?v=4"; -var BULLET_VELOCITY = 10.0; -var GUN_OFFSETS = [{ - x: 0.04, - y: 0.26, - z: 0.04 -}, { - x: 0.04, - y: 0.26, - z: 0.04 -}]; - -var GUN_ORIENTATIONS = [Quat.fromPitchYawRollDegrees(0, 90, 90), Quat.fromPitchYawRollDegrees(0, -90, 270)]; - -//x -> y -//y -> z -// z -> x -var BARREL_OFFSETS = [ { - x: -0.12, - y: 0.12, - z: 0.04 -}, { - x: 0.12, - y: 0.12, - z: 0.04 -} ]; - - - -var pointers = []; - -pointers.push(Overlays.addOverlay("line3d", { - start: ZERO_VECTOR, - end: ZERO_VECTOR, - color: COLORS.RED, - alpha: 1, - visible: true, - lineWidth: LASER_WIDTH -})); - -pointers.push(Overlays.addOverlay("line3d", { - start: ZERO_VECTOR, - end: ZERO_VECTOR, - color: COLORS.RED, - alpha: 1, - visible: true, - lineWidth: LASER_WIDTH -})); - -var mapping = Controller.newMapping(); -var validPoses = [false, false]; -var barrelVectors = [0, 0]; -var barrelTips = [0, 0]; - - -// If enabled, anything can be shot, otherwise, an entity needs to have "isShootable" set in its userData -var shootAnything = true; - - -function update(deltaTime) { - // FIXME we should also expose MyAvatar.handPoses[2], MyAvatar.tipPoses[2] - var tipPoses = [MyAvatar.leftHandTipPose, MyAvatar.rightHandTipPose]; - - for (var side = 0; side < 2; side++) { - // First check if the controller is valid - var controllerPose = Controller.getPoseValue(POSE_CONTROLS[side]); - validPoses[side] = controllerPose.valid; - // Need to adjust the laser - var tipPose = tipPoses[side]; - var handRotation = tipPoses[side].rotation; - var barrelOffset = Vec3.multiplyQbyV(handRotation, BARREL_OFFSETS[side]); - barrelTips[side] = Vec3.sum(tipPose.translation, barrelOffset); - barrelVectors[side] = Vec3.multiplyQbyV(handRotation, { - x: 0, - y: 1, - z: 0 - }); - - var laserTip = Vec3.sum(Vec3.multiply(LASER_LENGTH, barrelVectors[side]), barrelTips[side]); - // Update Lasers - Overlays.editOverlay(pointers[side], { - start: barrelTips[side], - end: laserTip, - alpha: 1, - }); - - } -} - - - -function displayPointer(side) { - Overlays.editOverlay(pointers[side], { - visible: true - }); -} - -function hidePointer(side) { - Overlays.editOverlay(pointers[side], { - visible: false - }); -} - -function fire(side, value) { - if (value == 0) { - return; - } - Audio.playSound(fireSound, { - position: barrelTips[side], - volume: 0.5 - }); - - var shotDirection = Vec3.normalize(barrelVectors[side]); - var pickRay = { - origin: barrelTips[side], - direction: shotDirection - }; - createMuzzleFlash(barrelTips[side]); - - var intersection = Entities.findRayIntersectionBlocking(pickRay, true); - if (intersection.intersects) { - Script.setTimeout(function() { - createEntityHitEffect(intersection.intersection); - if (shootAnything && intersection.properties.dynamic === 1) { - // Any dynamic entity can be shot - Entities.editEntity(intersection.entityID, { - velocity: Vec3.multiply(shotDirection, GUN_FORCE) - }); - } - - if (intersection.properties.name === "rat") { - score(); - createBloodSplatter(intersection.intersection); - Entities.deleteEntity(intersection.entityID); - - } - //Attempt to call entity method's shot method - var forceDirection = JSON.stringify({ - forceDirection: shotDirection - }); - Entities.callEntityMethod(intersection.entityID, 'onShot', [forceDirection]); - - }, 0); - - } -} - - -function scriptEnding() { - Messages.sendMessage('Hifi-Hand-Disabler', 'none'); - mapping.disable(); - for (var i = 0; i < pointers.length; ++i) { - Overlays.deleteOverlay(pointers[i]); - } - MyAvatar.detachOne(GUN_MODEL); - MyAvatar.detachOne(GUN_MODEL); - clearPose(); -} - -MyAvatar.attach(GUN_MODEL, "LeftHand", GUN_OFFSETS[0], GUN_ORIENTATIONS[0], 0.40); -MyAvatar.attach(GUN_MODEL, "RightHand", GUN_OFFSETS[1], GUN_ORIENTATIONS[1], 0.40); - -function showPointer(side) { - Overlays.editOverlay(pointers[side], { - visible: true - }); -} - - - -mapping.from(Controller.Standard.LT).hysteresis(0.0, 0.5).to(function(value) { - fire(0, value); -}); - - -mapping.from(Controller.Standard.RT).hysteresis(0.0, 0.5).to(function(value) { - fire(1, value); -}); -mapping.enable(); - -Script.scriptEnding.connect(scriptEnding); -Script.update.connect(update); - - -function createEntityHitEffect(position) { - var flash = Entities.addEntity({ - type: "ParticleEffect", - position: position, - lifetime: 4, - "name": "Flash Emitter", - "color": { - red: 228, - green: 128, - blue: 12 - }, - "maxParticles": 1000, - "lifespan": 0.15, - "emitRate": 1000, - "emitSpeed": 1, - "speedSpread": 0, - "emitOrientation": { - "x": -0.4, - "y": 1, - "z": -0.2, - "w": 0.7071068286895752 - }, - "emitDimensions": { - "x": 0, - "y": 0, - "z": 0 - }, - "polarStart": 0, - "polarFinish": Math.PI, - "azimuthStart": -3.1415927410125732, - "azimuthFinish": 2, - "emitAcceleration": { - "x": 0, - "y": 0, - "z": 0 - }, - "accelerationSpread": { - "x": 0, - "y": 0, - "z": 0 - }, - "particleRadius": 0.03, - "radiusSpread": 0.02, - "radiusStart": 0.02, - "radiusFinish": 0.03, - "colorSpread": { - red: 100, - green: 100, - blue: 20 - }, - "alpha": 1, - "alphaSpread": 0, - "alphaStart": 0, - "alphaFinish": 0, - "additiveBlending": true, - "textures": "http://ericrius1.github.io/PartiArt/assets/star.png" - }); - - Script.setTimeout(function() { - Entities.editEntity(flash, { - isEmitting: false - }); - }, 100); - -} - - -function createBloodSplatter(position) { - var splatter = Entities.addEntity({ - type: "ParticleEffect", - position: position, - lifetime: 4, - "name": "Blood Splatter", - "color": { - red: 230, - green: 2, - blue: 30 - }, - "maxParticles": 1000, - "lifespan": 0.3, - "emitRate": 1000, - "emitSpeed": 0.5, - "speedSpread": 0, - "emitOrientation": { - "x": -0.4, - "y": 1, - "z": -0.2, - "w": 0.7071068286895752 - }, - "emitDimensions": { - "x": 0, - "y": 0, - "z": 0 - }, - "polarStart": 0, - "polarFinish": Math.PI, - "azimuthStart": -3.1415927410125732, - "azimuthFinish": 2, - "emitAcceleration": { - "x": 0, - "y": -5, - "z": 0 - }, - "accelerationSpread": { - "x": 0, - "y": 0, - "z": 0 - }, - "particleRadius": 0.05, - "radiusSpread": 0.03, - "radiusStart": 0.05, - "radiusFinish": 0.05, - "colorSpread": { - red: 40, - green: 0, - blue: 30 - }, - "alpha": 1, - "alphaSpread": 0, - "alphaStart": 0, - "alphaFinish": 0, - "textures": "http://ericrius1.github.io/PartiArt/assets/star.png" - }); - - Script.setTimeout(function() { - Entities.editEntity(splatter, { - isEmitting: false - }); - }, 100) - -} - - -function createMuzzleFlash(position) { - var smoke = Entities.addEntity({ - type: "ParticleEffect", - position: position, - lifetime: 1, - "name": "Smoke Hit Emitter", - "maxParticles": 1000, - "lifespan": 4, - "emitRate": 20, - emitSpeed: 0, - "speedSpread": 0, - "emitDimensions": { - "x": 0, - "y": 0, - "z": 0 - }, - "polarStart": 0, - "polarFinish": 0, - "azimuthStart": -3.1415927410125732, - "azimuthFinish": 3.14, - "emitAcceleration": { - "x": 0, - "y": 0.5, - "z": 0 - }, - "accelerationSpread": { - "x": .2, - "y": 0, - "z": .2 - }, - "radiusSpread": .04, - "particleRadius": 0.07, - "radiusStart": 0.07, - "radiusFinish": 0.07, - "alpha": 0.7, - "alphaSpread": 0, - "alphaStart": 0, - "alphaFinish": 0, - "additiveBlending": 0, - "textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png" - }); - Script.setTimeout(function() { - Entities.editEntity(smoke, { - isEmitting: false - }); - }, 100); - - var flash = Entities.addEntity({ - type: "ParticleEffect", - position: position, - lifetime: 4, - "name": "Muzzle Flash", - "color": { - red: 228, - green: 128, - blue: 12 - }, - "maxParticles": 1000, - "lifespan": 0.1, - "emitRate": 1000, - "emitSpeed": 0.5, - "speedSpread": 0, - "emitOrientation": { - "x": -0.4, - "y": 1, - "z": -0.2, - "w": 0.7071068286895752 - }, - "emitDimensions": { - "x": 0, - "y": 0, - "z": 0 - }, - "polarStart": 0, - "polarFinish": Math.PI, - "azimuthStart": -3.1415927410125732, - "azimuthFinish": 2, - "emitAcceleration": { - "x": 0, - "y": 0, - "z": 0 - }, - "accelerationSpread": { - "x": 0, - "y": 0, - "z": 0 - }, - "particleRadius": 0.05, - "radiusSpread": 0.01, - "radiusStart": 0.05, - "radiusFinish": 0.05, - "colorSpread": { - red: 100, - green: 100, - blue: 20 - }, - "alpha": 1, - "alphaSpread": 0, - "alphaStart": 0, - "alphaFinish": 0, - "additiveBlending": true, - "textures": "http://ericrius1.github.io/PartiArt/assets/star.png" - }); - - Script.setTimeout(function() { - Entities.editEntity(flash, { - isEmitting: false - }); - }, 100) - - -} diff --git a/examples/example/games/exterminatorGame/pistolScriptSpawner.js b/examples/example/games/exterminatorGame/pistolScriptSpawner.js deleted file mode 100644 index 2a5a72096f..0000000000 --- a/examples/example/games/exterminatorGame/pistolScriptSpawner.js +++ /dev/null @@ -1,37 +0,0 @@ -// -// Rat.js -// examples/toybox/entityScripts -// -// Created by Eric Levin on11/11/15. -// Copyright 2015 High Fidelity, Inc. -// - -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -/*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt */ - - -(function() { - var scriptURL = Script.resolvePath('pistol.js'); - var _this; - PistolScriptSpawner = function() { - _this = this; - this.forceMultiplier = 1; - }; - - PistolScriptSpawner.prototype = { - - enterEntity: function() { - - Script.load(scriptURL); - }, - - preload: function(entityID) { - this.entityID = entityID; - }, - - }; - - // entity scripts always need to return a newly constructed object of our type - return new PistolScriptSpawner(); -}); \ No newline at end of file diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index fcade5980c..800cadf72f 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -243,7 +243,7 @@ else (APPLE) "${PROJECT_SOURCE_DIR}/resources" $/resources COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${CMAKE_SOURCE_DIR}/examples" + "${CMAKE_SOURCE_DIR}/scripts" $/scripts ) @@ -269,7 +269,7 @@ endif (APPLE) if (SCRIPTS_INSTALL_DIR) # setup install of scripts beside interface executable install( - DIRECTORY "${CMAKE_SOURCE_DIR}/examples/" + DIRECTORY "${CMAKE_SOURCE_DIR}/scripts/" DESTINATION ${SCRIPTS_INSTALL_DIR}/scripts COMPONENT ${CLIENT_COMPONENT} ) diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index 495d13d118..370bc92d81 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -24,7 +24,6 @@ Window { title: "Asset Browser" resizable: true destroyOnInvisible: true - x: 40; y: 40 implicitWidth: 384; implicitHeight: 640 minSize: Qt.vector2d(200, 300) diff --git a/interface/resources/qml/AvatarInputs.qml b/interface/resources/qml/AvatarInputs.qml index 75f379a425..4150979cd4 100644 --- a/interface/resources/qml/AvatarInputs.qml +++ b/interface/resources/qml/AvatarInputs.qml @@ -25,7 +25,7 @@ Hifi.AvatarInputs { readonly property int iconPadding: 5 readonly property bool shouldReposition: true - + Settings { category: "Overlay.AvatarInputs" property alias x: root.x diff --git a/interface/resources/qml/InfoView.qml b/interface/resources/qml/InfoView.qml index bc268baeb4..2e93c401d4 100644 --- a/interface/resources/qml/InfoView.qml +++ b/interface/resources/qml/InfoView.qml @@ -22,4 +22,19 @@ Windows.Window { url: infoView.url } } + + Component.onCompleted: { + centerWindow(root); + } + + onVisibleChanged: { + if (visible) { + centerWindow(root); + } + } + + function centerWindow() { + desktop.centerOnVisible(root); + } + } diff --git a/interface/resources/qml/desktop/Desktop.qml b/interface/resources/qml/desktop/Desktop.qml index c0804a967d..62a72e3d8c 100644 --- a/interface/resources/qml/desktop/Desktop.qml +++ b/interface/resources/qml/desktop/Desktop.qml @@ -21,7 +21,9 @@ FocusScope { objectName: "desktop" anchors.fill: parent - property rect recommendedRect: rect(0,0,0,0); + readonly property int invalid_position: -9999; + property rect recommendedRect: Qt.rect(0,0,0,0); + property var expectedChildren; onHeightChanged: d.handleSizeChanged(); @@ -55,13 +57,18 @@ FocusScope { function handleSizeChanged() { var oldRecommendedRect = recommendedRect; - var newRecommendedRectJS = Controller.getRecommendedOverlayRect(); + var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect(); var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y, newRecommendedRectJS.width, newRecommendedRectJS.height); - if (oldRecommendedRect != Qt.rect(0,0,0,0) - && oldRecommendedRect != newRecommendedRect) { + var oldChildren = expectedChildren; + var newChildren = d.getRepositionChildren(); + if (oldRecommendedRect != Qt.rect(0,0,0,0) + && (oldRecommendedRect != newRecommendedRect + || oldChildren != newChildren) + ) { + expectedChildren = newChildren; d.repositionAll(); } recommendedRect = newRecommendedRect; @@ -279,13 +286,56 @@ FocusScope { targetWindow.focus = true; } + showDesktop(); + } + + function centerOnVisible(item) { + var targetWindow = d.getDesktopWindow(item); + if (!targetWindow) { + console.warn("Could not find top level window for " + item); + return; + } + + if (typeof Controller === "undefined") { + console.warn("Controller not yet available... can't center"); + return; + } + + var newRecommendedRectJS = (typeof Controller === "undefined") ? Qt.rect(0,0,0,0) : Controller.getRecommendedOverlayRect(); + var newRecommendedRect = Qt.rect(newRecommendedRectJS.x, newRecommendedRectJS.y, + newRecommendedRectJS.width, + newRecommendedRectJS.height); + var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height }; + var newX = newRecommendedRect.x + ((newRecommendedRect.width - targetWindow.width) / 2); + var newY = newRecommendedRect.y + ((newRecommendedRect.height - targetWindow.height) / 2); + targetWindow.x = newX; + targetWindow.y = newY; + + // If we've noticed that our recommended desktop rect has changed, record that change here. + if (recommendedRect != newRecommendedRect) { + recommendedRect = newRecommendedRect; + } + + } + + function repositionOnVisible(item) { + var targetWindow = d.getDesktopWindow(item); + if (!targetWindow) { + console.warn("Could not find top level window for " + item); + return; + } + + if (typeof Controller === "undefined") { + console.warn("Controller not yet available... can't reposition targetWindow:" + targetWindow); + return; + } + + var oldRecommendedRect = recommendedRect; var oldRecommendedDimmensions = { x: oldRecommendedRect.width, y: oldRecommendedRect.height }; var newRecommendedRect = Controller.getRecommendedOverlayRect(); var newRecommendedDimmensions = { x: newRecommendedRect.width, y: newRecommendedRect.height }; repositionWindow(targetWindow, false, oldRecommendedRect, oldRecommendedDimmensions, newRecommendedRect, newRecommendedDimmensions); - - showDesktop(); } function repositionWindow(targetWindow, forceReposition, @@ -324,10 +374,8 @@ FocusScope { } var fractionX = Utils.clamp(originRelativeX / oldRecommendedDimmensions.x, 0, 1); var fractionY = Utils.clamp(originRelativeY / oldRecommendedDimmensions.y, 0, 1); - var newX = (fractionX * newRecommendedDimmensions.x) + newRecommendedRect.x; var newY = (fractionY * newRecommendedDimmensions.y) + newRecommendedRect.y; - newPosition = Qt.vector2d(newX, newY); } targetWindow.x = newPosition.x; diff --git a/interface/resources/qml/hifi/dialogs/RunningScripts.qml b/interface/resources/qml/hifi/dialogs/RunningScripts.qml index 9b35d55f11..071789fe16 100644 --- a/interface/resources/qml/hifi/dialogs/RunningScripts.qml +++ b/interface/resources/qml/hifi/dialogs/RunningScripts.qml @@ -23,7 +23,6 @@ Window { title: "Running Scripts" resizable: true destroyOnInvisible: true - x: 40; y: 40 implicitWidth: 400 implicitHeight: isHMD ? 695 : 728 minSize: Qt.vector2d(200, 300) diff --git a/interface/resources/qml/windows-uit/Window.qml b/interface/resources/qml/windows-uit/Window.qml index dbbf2b3eb6..e9477f3c7e 100644 --- a/interface/resources/qml/windows-uit/Window.qml +++ b/interface/resources/qml/windows-uit/Window.qml @@ -31,7 +31,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: -1; y: -1 + x: desktop.invalid_position; y: desktop.invalid_position; enabled: visible signal windowDestroyed(); @@ -252,6 +252,7 @@ Fadable { window.parentChanged.connect(raise); raise(); setDefaultFocus(); + centerOrReposition(); } Component.onDestruction: { window.parentChanged.disconnect(raise); // Prevent warning on shutdown @@ -267,6 +268,18 @@ Fadable { raise(); } enabled = visible + + if (visible && parent) { + centerOrReposition(); + } + } + + function centerOrReposition() { + if (x == desktop.invalid_position && y == desktop.invalid_position) { + desktop.centerOnVisible(window); + } else { + desktop.repositionOnVisible(window); + } } function raise() { diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index 06be0cd9e7..3abdbacc64 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -19,7 +19,7 @@ Fadable { // decorations can extend outside it. implicitHeight: content ? content.height : 0 implicitWidth: content ? content.width : 0 - x: -1; y: -1 + x: desktop.invalid_position; y: desktop.invalid_position; enabled: visible signal windowDestroyed(); @@ -117,12 +117,21 @@ Fadable { Component.onCompleted: { window.parentChanged.connect(raise); raise(); + centerOrReposition(); } Component.onDestruction: { window.parentChanged.disconnect(raise); // Prevent warning on shutdown windowDestroyed(); } + function centerOrReposition() { + if (x == desktop.invalid_position && y == desktop.invalid_position) { + desktop.centerOnVisible(window); + } else { + desktop.repositionOnVisible(window); + } + } + onVisibleChanged: { if (!visible && destroyOnInvisible) { destroy(); @@ -132,6 +141,10 @@ Fadable { raise(); } enabled = visible + + if (visible && parent) { + centerOrReposition(); + } } function raise() { diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index fcf1425287..c2a4088dcc 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -4315,6 +4315,7 @@ void Application::nodeKilled(SharedNodePointer node) { } } } + void Application::trackIncomingOctreePacket(ReceivedMessage& message, SharedNodePointer sendingNode, bool wasStatsPacket) { // Attempt to identify the sender from its address. if (sendingNode) { diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 9a61c00712..614f7bd9fe 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -235,7 +235,12 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) { return AvatarData::toByteArray(cullSmallChanges, sendAll); } -void MyAvatar::reset(bool andReload) { +void MyAvatar::reset(bool andRecenter) { + + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter)); + return; + } // Reset dynamic state. _wasPushing = _isPushing = _isBraking = false; @@ -245,7 +250,7 @@ void MyAvatar::reset(bool andReload) { _targetVelocity = glm::vec3(0.0f); setThrust(glm::vec3(0.0f)); - if (andReload) { + if (andRecenter) { // derive the desired body orientation from the *old* hmd orientation, before the sensor reset. auto newBodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation.. @@ -911,7 +916,8 @@ void MyAvatar::updateLookAtTargetAvatar() { avatar->setIsLookAtTarget(false); if (!avatar->isMyAvatar() && avatar->isInitialized() && (distanceTo < GREATEST_LOOKING_AT_DISTANCE * getUniformScale())) { - float angleTo = glm::angle(lookForward, glm::normalize(avatar->getHead()->getEyePosition() - getHead()->getEyePosition())); + float radius = glm::length(avatar->getHead()->getEyePosition() - avatar->getHead()->getRightEyePosition()); + float angleTo = coneSphereAngle(getHead()->getEyePosition(), lookForward, avatar->getHead()->getEyePosition(), radius); if (angleTo < (smallestAngleTo * (isCurrentTarget ? KEEP_LOOKING_AT_CURRENT_ANGLE_FACTOR : 1.0f))) { _lookAtTargetAvatar = avatarPointer; _targetAvatarPosition = avatarPointer->getPosition(); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 69bb7ea4c2..e320c0e3de 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -93,7 +93,7 @@ public: AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; } AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; } - void reset(bool andReload = false); + Q_INVOKABLE void reset(bool andRecenter = false); void update(float deltaTime); void preRender(RenderArgs* renderArgs); diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.cpp b/interface/src/scripting/AssetMappingsScriptingInterface.cpp index 3f11bd1fd8..965b3a9e0c 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.cpp +++ b/interface/src/scripting/AssetMappingsScriptingInterface.cpp @@ -292,6 +292,8 @@ void AssetMappingModel::refresh() { } else { emit errorGettingMappings(request->getErrorString()); } + + request->deleteLater(); }); request->start(); diff --git a/interface/src/ui/overlays/Text3DOverlay.cpp b/interface/src/ui/overlays/Text3DOverlay.cpp index 9fa8f6556b..0ae1c306ba 100644 --- a/interface/src/ui/overlays/Text3DOverlay.cpp +++ b/interface/src/ui/overlays/Text3DOverlay.cpp @@ -110,7 +110,14 @@ void Text3DOverlay::render(RenderArgs* args) { glm::vec4 textColor = { _color.red / MAX_COLOR, _color.green / MAX_COLOR, _color.blue / MAX_COLOR, getTextAlpha() }; + + // FIXME: Factor out textRenderer so that Text3DOverlay overlay parts can be grouped by pipeline + // for a gpu performance increase. Currently, + // Text renderer sets its own pipeline, _textRenderer->draw(batch, 0, 0, _text, textColor, glm::vec2(-1.0f), getDrawInFront()); + // so before we continue, we must reset the pipeline + batch.setPipeline(args->_pipeline->pipeline); + args->_pipeline->prepare(batch); } const render::ShapeKey Text3DOverlay::getShapeKey() { diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 7955b20728..c4ac9b09e5 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -339,15 +339,16 @@ void RenderableModelEntityItem::updateModelBounds() { return; } bool movingOrAnimating = isMovingRelativeToParent() || isAnimatingSomething(); + glm::vec3 dimensions = getDimensions(); if ((movingOrAnimating || _needsInitialSimulation || _needsJointSimulation || _model->getTranslation() != getPosition() || - _model->getScaleToFitDimensions() != getDimensions() || + _model->getScaleToFitDimensions() != dimensions || _model->getRotation() != getRotation() || _model->getRegistrationPoint() != getRegistrationPoint()) && _model->isActive() && _dimensionsInitialized) { - _model->setScaleToFit(true, getDimensions()); + _model->setScaleToFit(true, dimensions); _model->setSnapModelToRegistrationPoint(true, getRegistrationPoint()); _model->setRotation(getRotation()); _model->setTranslation(getPosition()); @@ -518,6 +519,7 @@ void RenderableModelEntityItem::update(const quint64& now) { if (!_dimensionsInitialized && _model && _model->isActive()) { if (_model->isLoaded()) { EntityItemProperties properties; + properties.setLastEdited(usecTimestampNow()); // we must set the edit time since we're editing it auto extents = _model->getMeshExtents(); properties.setDimensions(extents.maximum - extents.minimum); qCDebug(entitiesrenderer) << "Autoresizing:" << (!getName().isEmpty() ? getName() : getModelURL()); diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index c9c4c8503a..6c4e3994c6 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -206,13 +206,14 @@ glm::mat4 RenderablePolyVoxEntityItem::voxelToLocalMatrix() const { voxelVolumeSize = _voxelVolumeSize; }); - glm::vec3 scale = getDimensions() / voxelVolumeSize; // meters / voxel-units + glm::vec3 dimensions = getDimensions(); + glm::vec3 scale = dimensions / voxelVolumeSize; // meters / voxel-units bool success; // TODO -- Does this actually have to happen in world space? glm::vec3 center = getCenterPosition(success); // this handles registrationPoint changes glm::vec3 position = getPosition(success); glm::vec3 positionToCenter = center - position; - positionToCenter -= getDimensions() * Vectors::HALF - getSurfacePositionAdjustment(); + positionToCenter -= dimensions * Vectors::HALF - getSurfacePositionAdjustment(); glm::mat4 centerToCorner = glm::translate(glm::mat4(), positionToCenter); glm::mat4 scaled = glm::scale(centerToCorner, scale); return scaled; @@ -445,7 +446,8 @@ bool RenderablePolyVoxEntityItem::findDetailedRayIntersection(const glm::vec3& o // the PolyVox ray intersection code requires a near and far point. // set ray cast length to long enough to cover all of the voxel space float distanceToEntity = glm::distance(origin, getPosition()); - float largestDimension = glm::max(getDimensions().x, getDimensions().y, getDimensions().z) * 2.0f; + glm::vec3 dimensions = getDimensions(); + float largestDimension = glm::max(dimensions.x, dimensions.y, dimensions.z) * 2.0f; glm::vec3 farPoint = origin + normDirection * (distanceToEntity + largestDimension); glm::vec4 originInVoxel = wtvMatrix * glm::vec4(origin, 1.0f); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 855fd16408..26aecf6050 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -119,12 +119,13 @@ bool RenderableWebEntityItem::buildWebSurface(EntityTreeRenderer* renderer) { // Map the intersection point to an actual offscreen pixel glm::vec3 point = intersection.intersection; + glm::vec3 dimensions = getDimensions(); point -= getPosition(); point = glm::inverse(getRotation()) * point; - point /= getDimensions(); + point /= dimensions; point += 0.5f; point.y = 1.0f - point.y; - point *= getDimensions() * METERS_TO_INCHES * DPI; + point *= dimensions * (METERS_TO_INCHES * DPI); if (event->button() == Qt::MouseButton::LeftButton) { if (event->type() == QEvent::MouseButtonPress) { diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 938fbe12ac..2d1bbf2f88 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -781,7 +781,8 @@ void EntityItem::adjustEditPacketForClockSkew(QByteArray& buffer, qint64 clockSk } float EntityItem::computeMass() const { - return _density * _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z; + glm::vec3 dimensions = getDimensions(); + return _density * _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z; } void EntityItem::setDensity(float density) { @@ -801,7 +802,8 @@ void EntityItem::setMass(float mass) { // we must protect the density range to help maintain stability of physics simulation // therefore this method might not accept the mass that is supplied. - float volume = _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z; + glm::vec3 dimensions = getDimensions(); + float volume = _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z; // compute new density const float MIN_VOLUME = 1.0e-6f; // 0.001mm^3 @@ -1222,11 +1224,13 @@ AACube EntityItem::getMaximumAACube(bool& success) const { // * we know that the position is the center of rotation glm::vec3 centerOfRotation = getPosition(success); // also where _registration point is if (success) { + _recalcMaxAACube = false; // * we know that the registration point is the center of rotation // * we can calculate the length of the furthest extent from the registration point // as the dimensions * max (registrationPoint, (1.0,1.0,1.0) - registrationPoint) - glm::vec3 registrationPoint = (getDimensions() * getRegistrationPoint()); - glm::vec3 registrationRemainder = (getDimensions() * (glm::vec3(1.0f, 1.0f, 1.0f) - getRegistrationPoint())); + glm::vec3 dimensions = getDimensions(); + glm::vec3 registrationPoint = (dimensions * _registrationPoint); + glm::vec3 registrationRemainder = (dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint)); glm::vec3 furthestExtentFromRegistration = glm::max(registrationPoint, registrationRemainder); // * we know that if you rotate in any direction you would create a sphere @@ -1238,7 +1242,6 @@ AACube EntityItem::getMaximumAACube(bool& success) const { glm::vec3 minimumCorner = centerOfRotation - glm::vec3(radius, radius, radius); _maxAACube = AACube(minimumCorner, radius * 2.0f); - _recalcMaxAACube = false; } } else { success = true; @@ -1251,28 +1254,27 @@ AACube EntityItem::getMaximumAACube(bool& success) const { /// AACube EntityItem::getMinimumAACube(bool& success) const { if (_recalcMinAACube) { - // _position represents the position of the registration point. - glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint; - - glm::vec3 unrotatedMinRelativeToEntity = - (getDimensions() * getRegistrationPoint()); - glm::vec3 unrotatedMaxRelativeToEntity = getDimensions() * registrationRemainder; - Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; - Extents rotatedExtentsRelativeToRegistrationPoint = - unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation()); - - // shift the extents to be relative to the position/registration point - rotatedExtentsRelativeToRegistrationPoint.shiftBy(getPosition(success)); - + // position represents the position of the registration point. + glm::vec3 position = getPosition(success); if (success) { + _recalcMinAACube = false; + glm::vec3 dimensions = getDimensions(); + glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint); + glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint); + Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; + extents.rotate(getRotation()); + + // shift the extents to be relative to the position/registration point + extents.shiftBy(position); + // the cube that best encompasses extents is... - AABox box(rotatedExtentsRelativeToRegistrationPoint); + AABox box(extents); glm::vec3 centerOfBox = box.calcCenter(); float longestSide = box.getLargestDimension(); float halfLongestSide = longestSide / 2.0f; glm::vec3 cornerOfCube = centerOfBox - glm::vec3(halfLongestSide, halfLongestSide, halfLongestSide); _minAACube = AACube(cornerOfCube, longestSide); - _recalcMinAACube = false; } } else { success = true; @@ -1282,21 +1284,20 @@ AACube EntityItem::getMinimumAACube(bool& success) const { AABox EntityItem::getAABox(bool& success) const { if (_recalcAABox) { - // _position represents the position of the registration point. - glm::vec3 registrationRemainder = glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint; - - glm::vec3 unrotatedMinRelativeToEntity = - (getDimensions() * _registrationPoint); - glm::vec3 unrotatedMaxRelativeToEntity = getDimensions() * registrationRemainder; - Extents unrotatedExtentsRelativeToRegistrationPoint = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; - Extents rotatedExtentsRelativeToRegistrationPoint = - unrotatedExtentsRelativeToRegistrationPoint.getRotated(getRotation()); - - // shift the extents to be relative to the position/registration point - rotatedExtentsRelativeToRegistrationPoint.shiftBy(getPosition(success)); - + // position represents the position of the registration point. + glm::vec3 position = getPosition(success); if (success) { - _cachedAABox = AABox(rotatedExtentsRelativeToRegistrationPoint); _recalcAABox = false; + glm::vec3 dimensions = getDimensions(); + glm::vec3 unrotatedMinRelativeToEntity = - (dimensions * _registrationPoint); + glm::vec3 unrotatedMaxRelativeToEntity = dimensions * (glm::vec3(1.0f, 1.0f, 1.0f) - _registrationPoint); + Extents extents = { unrotatedMinRelativeToEntity, unrotatedMaxRelativeToEntity }; + extents.rotate(getRotation()); + + // shift the extents to be relative to the position/registration point + extents.shiftBy(position); + + _cachedAABox = AABox(extents); } } else { success = true; @@ -1373,6 +1374,11 @@ void EntityItem::computeShapeInfo(ShapeInfo& info) { adjustShapeInfoByRegistration(info); } +float EntityItem::getVolumeEstimate() const { + glm::vec3 dimensions = getDimensions(); + return dimensions.x * dimensions.y * dimensions.z; +} + void EntityItem::updateRegistrationPoint(const glm::vec3& value) { if (value != _registrationPoint) { setRegistrationPoint(value); @@ -1433,7 +1439,8 @@ void EntityItem::updateMass(float mass) { // we must protect the density range to help maintain stability of physics simulation // therefore this method might not accept the mass that is supplied. - float volume = _volumeMultiplier * getDimensions().x * getDimensions().y * getDimensions().z; + glm::vec3 dimensions = getDimensions(); + float volume = _volumeMultiplier * dimensions.x * dimensions.y * dimensions.z; // compute new density float newDensity = _density; diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 5e34d942f6..b3689b9b56 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -314,7 +314,7 @@ public: virtual bool isReadyToComputeShape() { return !isDead(); } virtual void computeShapeInfo(ShapeInfo& info); - virtual float getVolumeEstimate() const { return getDimensions().x * getDimensions().y * getDimensions().z; } + virtual float getVolumeEstimate() const; /// return preferred shape type (actual physical shape may differ) virtual ShapeType getShapeType() const { return SHAPE_TYPE_NONE; } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 71b6f1364f..b4f0c484d5 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -1459,10 +1459,12 @@ void EntityTree::trackIncomingEntityLastEdited(quint64 lastEditedTime, int bytes void EntityTree::callLoader(EntityItemID entityID) { // this is used to bounce from the networking thread to the main thread - EntityItemPointer entity = findEntityByEntityItemID(entityID); - if (entity) { - entity->loader(); - } + this->withWriteLock([&] { + EntityItemPointer entity = findEntityByEntityItemID(entityID); + if (entity) { + entity->loader(); + } + }); } int EntityTree::getJointIndex(const QUuid& entityID, const QString& name) const { diff --git a/libraries/entities/src/LightEntityItem.cpp b/libraries/entities/src/LightEntityItem.cpp index 852b37a751..1be133463c 100644 --- a/libraries/entities/src/LightEntityItem.cpp +++ b/libraries/entities/src/LightEntityItem.cpp @@ -76,12 +76,13 @@ void LightEntityItem::setIsSpotlight(bool value) { if (value != _isSpotlight) { _isSpotlight = value; + glm::vec3 dimensions = getDimensions(); if (_isSpotlight) { - const float length = getDimensions().z; + const float length = dimensions.z; const float width = length * glm::sin(glm::radians(_cutoff)); setDimensions(glm::vec3(width, width, length)); } else { - float maxDimension = glm::max(getDimensions().x, getDimensions().y, getDimensions().z); + float maxDimension = glm::max(dimensions.x, dimensions.y, dimensions.z); setDimensions(glm::vec3(maxDimension, maxDimension, maxDimension)); } } diff --git a/libraries/entities/src/LineEntityItem.cpp b/libraries/entities/src/LineEntityItem.cpp index d48780845f..78b6107d88 100644 --- a/libraries/entities/src/LineEntityItem.cpp +++ b/libraries/entities/src/LineEntityItem.cpp @@ -101,15 +101,13 @@ bool LineEntityItem::setLinePoints(const QVector& points) { if (points.size() > MAX_POINTS_PER_LINE) { return false; } + glm::vec3 halfBox = getDimensions() * 0.5f; for (int i = 0; i < points.size(); i++) { glm::vec3 point = points.at(i); - // glm::vec3 pos = getPosition(); - glm::vec3 halfBox = getDimensions() * 0.5f; if ( (point.x < - halfBox.x || point.x > halfBox.x) || (point.y < -halfBox.y || point.y > halfBox.y) || (point.z < - halfBox.z || point.z > halfBox.z) ) { qDebug() << "Point is outside entity's bounding box"; return false; } - } _points = points; _pointsChanged = true; diff --git a/libraries/model/src/model/Material.cpp b/libraries/model/src/model/Material.cpp index 802650df93..1ea407122f 100755 --- a/libraries/model/src/model/Material.cpp +++ b/libraries/model/src/model/Material.cpp @@ -18,13 +18,15 @@ using namespace gpu; Material::Material() : _key(0), _schemaBuffer(), + _texMapArrayBuffer(), _textureMaps() { // created from nothing: create the Buffer to store the properties Schema schema; _schemaBuffer = gpu::BufferView(std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema)); - + TexMapArraySchema TexMapArraySchema; + _texMapArrayBuffer = gpu::BufferView(std::make_shared(sizeof(TexMapArraySchema), (const gpu::Byte*) &TexMapArraySchema)); } Material::Material(const Material& material) : @@ -35,6 +37,10 @@ Material::Material(const Material& material) : Schema schema; _schemaBuffer = gpu::BufferView(std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema)); _schemaBuffer.edit() = material._schemaBuffer.get(); + + TexMapArraySchema texMapArraySchema; + _texMapArrayBuffer = gpu::BufferView(std::make_shared(sizeof(TexMapArraySchema), (const gpu::Byte*) &texMapArraySchema)); + _texMapArrayBuffer.edit() = material._texMapArrayBuffer.get(); } Material& Material::operator= (const Material& material) { @@ -46,6 +52,10 @@ Material& Material::operator= (const Material& material) { _schemaBuffer = gpu::BufferView(std::make_shared(sizeof(Schema), (const gpu::Byte*) &schema)); _schemaBuffer.edit() = material._schemaBuffer.get(); + TexMapArraySchema texMapArraySchema; + _texMapArrayBuffer = gpu::BufferView(std::make_shared(sizeof(TexMapArraySchema), (const gpu::Byte*) &texMapArraySchema)); + _texMapArrayBuffer.edit() = material._texMapArrayBuffer.get(); + return (*this); } @@ -101,6 +111,15 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur if (channel == MaterialKey::ALBEDO_MAP) { resetOpacityMap(); + + // update the texcoord0 with albedo + _texMapArrayBuffer.edit()._texcoordTransforms[0] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4()); + } + + if (channel == MaterialKey::LIGHTMAP_MAP) { + // update the texcoord1 with lightmap + _texMapArrayBuffer.edit()._texcoordTransforms[1] = (textureMap ? textureMap->getTextureTransform().getMatrix() : glm::mat4()); + _texMapArrayBuffer.edit()._lightmapParams = (textureMap ? glm::vec4(textureMap->getLightmapOffsetScale(), 0.0, 0.0) : glm::vec4(0.0, 1.0, 0.0, 0.0)); } _schemaBuffer.edit()._key = (uint32)_key._flags.to_ulong(); diff --git a/libraries/model/src/model/Material.h b/libraries/model/src/model/Material.h index c500e9ec10..4cfb2120ee 100755 --- a/libraries/model/src/model/Material.h +++ b/libraries/model/src/model/Material.h @@ -298,9 +298,21 @@ public: // conversion from legacy material properties to PBR equivalent static float shininessToRoughness(float shininess) { return 1.0f - shininess / 100.0f; } + // Texture Map Array Schema + static const int NUM_TEXCOORD_TRANSFORMS{ 2 }; + class TexMapArraySchema { + public: + glm::mat4 _texcoordTransforms[NUM_TEXCOORD_TRANSFORMS]; + glm::vec4 _lightmapParams{ 0.0, 1.0, 0.0, 0.0 }; + TexMapArraySchema() {} + }; + + const UniformBufferView& getTexMapArrayBuffer() const { return _texMapArrayBuffer; } private: mutable MaterialKey _key; mutable UniformBufferView _schemaBuffer; + mutable UniformBufferView _texMapArrayBuffer; + TextureMaps _textureMaps; }; typedef std::shared_ptr< Material > MaterialPointer; diff --git a/libraries/model/src/model/TextureMap.cpp b/libraries/model/src/model/TextureMap.cpp index 7200793bed..349980b702 100755 --- a/libraries/model/src/model/TextureMap.cpp +++ b/libraries/model/src/model/TextureMap.cpp @@ -413,9 +413,15 @@ gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImag class CubeLayout { public: + + enum SourceProjection { + FLAT = 0, + EQUIRECTANGULAR, + }; + int _type = FLAT; int _widthRatio = 1; int _heightRatio = 1; - + class Face { public: int _x = 0; @@ -435,6 +441,7 @@ public: Face _faceZNeg; CubeLayout(int wr, int hr, Face fXP, Face fXN, Face fYP, Face fYN, Face fZP, Face fZN) : + _type(FLAT), _widthRatio(wr), _heightRatio(hr), _faceXPos(fXP), @@ -444,6 +451,11 @@ public: _faceZPos(fZP), _faceZNeg(fZN) {} + CubeLayout(int wr, int hr) : + _type(EQUIRECTANGULAR), + _widthRatio(wr), + _heightRatio(hr) {} + static const CubeLayout CUBEMAP_LAYOUTS[]; static const int NUM_CUBEMAP_LAYOUTS; @@ -459,9 +471,102 @@ public: } return foundLayout; } + + static QImage extractEquirectangularFace(const QImage& source, gpu::Texture::CubeFace face, int faceWidth) { + QImage image(faceWidth, faceWidth, source.format()); + + glm::vec2 dstInvSize(1.0f / (float)image.width(), 1.0f / (float)image.height()); + + struct CubeToXYZ { + gpu::Texture::CubeFace _face; + CubeToXYZ(gpu::Texture::CubeFace face) : _face(face) {} + + glm::vec3 xyzFrom(const glm::vec2& uv) { + auto faceDir = glm::normalize(glm::vec3(-1.0f + 2.0f * uv.x, -1.0f + 2.0f * uv.y, 1.0f)); + + switch (_face) { + case gpu::Texture::CubeFace::CUBE_FACE_BACK_POS_Z: + return glm::vec3(-faceDir.x, faceDir.y, faceDir.z); + case gpu::Texture::CubeFace::CUBE_FACE_FRONT_NEG_Z: + return glm::vec3(faceDir.x, faceDir.y, -faceDir.z); + case gpu::Texture::CubeFace::CUBE_FACE_LEFT_NEG_X: + return glm::vec3(faceDir.z, faceDir.y, faceDir.x); + case gpu::Texture::CubeFace::CUBE_FACE_RIGHT_POS_X: + return glm::vec3(-faceDir.z, faceDir.y, -faceDir.x); + case gpu::Texture::CubeFace::CUBE_FACE_BOTTOM_NEG_Y: + return glm::vec3(-faceDir.x, -faceDir.z, faceDir.y); + case gpu::Texture::CubeFace::CUBE_FACE_TOP_POS_Y: + default: + return glm::vec3(-faceDir.x, faceDir.z, -faceDir.y); + } + } + }; + CubeToXYZ cubeToXYZ(face); + + struct RectToXYZ { + RectToXYZ() {} + + glm::vec2 uvFrom(const glm::vec3& xyz) { + auto flatDir = glm::normalize(glm::vec2(xyz.x, xyz.z)); + auto uvRad = glm::vec2(atan2(flatDir.x, flatDir.y), asin(xyz.y)); + + const float LON_TO_RECT_U = 1.0f / (glm::pi()); + const float LAT_TO_RECT_V = 2.0f / glm::pi(); + return glm::vec2(0.5f * uvRad.x * LON_TO_RECT_U + 0.5f, 0.5f * uvRad.y * LAT_TO_RECT_V + 0.5f); + } + }; + RectToXYZ rectToXYZ; + + int srcFaceHeight = source.height(); + int srcFaceWidth = source.width(); + + glm::vec2 dstCoord; + glm::ivec2 srcPixel; + for (int y = 0; y < faceWidth; ++y) { + dstCoord.y = 1.0f - (y + 0.5f) * dstInvSize.y; // Fill cube face images from top to bottom + for (int x = 0; x < faceWidth; ++x) { + dstCoord.x = (x + 0.5f) * dstInvSize.x; + + auto xyzDir = cubeToXYZ.xyzFrom(dstCoord); + auto srcCoord = rectToXYZ.uvFrom(xyzDir); + + srcPixel.x = floor(srcCoord.x * srcFaceWidth); + // Flip the vertical axis to QImage going top to bottom + srcPixel.y = floor((1.0f - srcCoord.y) * srcFaceHeight); + + if (((uint32) srcPixel.x < (uint32) source.width()) && ((uint32) srcPixel.y < (uint32) source.height())) { + image.setPixel(x, y, source.pixel(QPoint(srcPixel.x, srcPixel.y))); + + // Keep for debug, this is showing the dir as a color + // glm::u8vec4 rgba((xyzDir.x + 1.0)*0.5 * 256, (xyzDir.y + 1.0)*0.5 * 256, (xyzDir.z + 1.0)*0.5 * 256, 256); + // unsigned int val = 0xff000000 | (rgba.r) | (rgba.g << 8) | (rgba.b << 16); + // image.setPixel(x, y, val); + } + } + } + return image; + } }; const CubeLayout CubeLayout::CUBEMAP_LAYOUTS[] = { + + // Here is the expected layout for the faces in an image with the 2/1 aspect ratio: + // THis is detected as an Equirectangular projection + // WIDTH + // <---------------------------> + // ^ +------+------+------+------+ + // H | | | | | + // E | | | | | + // I | | | | | + // G +------+------+------+------+ + // H | | | | | + // T | | | | | + // | | | | | | + // v +------+------+------+------+ + // + // FaceWidth = width = height / 6 + { 2, 1 }, + // Here is the expected layout for the faces in an image with the 1/6 aspect ratio: // // WIDTH @@ -582,14 +687,25 @@ gpu::Texture* TextureUsage::processCubeTextureColorFromImage(const QImage& srcIm // If found, go extract the faces as separate images if (foundLayout >= 0) { auto& layout = CubeLayout::CUBEMAP_LAYOUTS[foundLayout]; - int faceWidth = image.width() / layout._widthRatio; + if (layout._type == CubeLayout::FLAT) { + int faceWidth = image.width() / layout._widthRatio; - faces.push_back(image.copy(QRect(layout._faceXPos._x * faceWidth, layout._faceXPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXPos._horizontalMirror, layout._faceXPos._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceXNeg._x * faceWidth, layout._faceXNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXNeg._horizontalMirror, layout._faceXNeg._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceYPos._x * faceWidth, layout._faceYPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYPos._horizontalMirror, layout._faceYPos._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceYNeg._x * faceWidth, layout._faceYNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYNeg._horizontalMirror, layout._faceYNeg._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceZPos._x * faceWidth, layout._faceZPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZPos._horizontalMirror, layout._faceZPos._verticalMirror)); - faces.push_back(image.copy(QRect(layout._faceZNeg._x * faceWidth, layout._faceZNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZNeg._horizontalMirror, layout._faceZNeg._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceXPos._x * faceWidth, layout._faceXPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXPos._horizontalMirror, layout._faceXPos._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceXNeg._x * faceWidth, layout._faceXNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceXNeg._horizontalMirror, layout._faceXNeg._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceYPos._x * faceWidth, layout._faceYPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYPos._horizontalMirror, layout._faceYPos._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceYNeg._x * faceWidth, layout._faceYNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceYNeg._horizontalMirror, layout._faceYNeg._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceZPos._x * faceWidth, layout._faceZPos._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZPos._horizontalMirror, layout._faceZPos._verticalMirror)); + faces.push_back(image.copy(QRect(layout._faceZNeg._x * faceWidth, layout._faceZNeg._y * faceWidth, faceWidth, faceWidth)).mirrored(layout._faceZNeg._horizontalMirror, layout._faceZNeg._verticalMirror)); + } else if (layout._type == CubeLayout::EQUIRECTANGULAR) { + // THe face width is estimated from the input image + const int EQUIRECT_FACE_RATIO_TO_WIDTH = 4; + const int EQUIRECT_MAX_FACE_WIDTH = 2048; + int faceWidth = std::min(image.width() / EQUIRECT_FACE_RATIO_TO_WIDTH, EQUIRECT_MAX_FACE_WIDTH); + for (int face = gpu::Texture::CUBE_FACE_RIGHT_POS_X; face < gpu::Texture::NUM_CUBE_FACES; face++) { + QImage faceImage = CubeLayout::extractEquirectangularFace(image, (gpu::Texture::CubeFace) face, faceWidth); + faces.push_back(faceImage); + } + } } else { qCDebug(modelLog) << "Failed to find a known cube map layout from this image:" << QString(srcImageName.c_str()); return nullptr; diff --git a/libraries/networking/src/AssetClient.cpp b/libraries/networking/src/AssetClient.cpp index 34ba5fc785..080b0c9b90 100644 --- a/libraries/networking/src/AssetClient.cpp +++ b/libraries/networking/src/AssetClient.cpp @@ -325,47 +325,117 @@ void AssetClient::handleAssetGetReply(QSharedPointer message, S // Check if we have any pending requests for this node auto messageMapIt = _pendingRequests.find(senderNode); - if (messageMapIt != _pendingRequests.end()) { + if (messageMapIt == _pendingRequests.end()) { + return; + } - // Found the node, get the MessageID -> Callback map - auto& messageCallbackMap = messageMapIt->second; - - // Check if we have this pending request - auto requestIt = messageCallbackMap.find(messageID); - if (requestIt != messageCallbackMap.end()) { - auto& callbacks = requestIt->second; - - // Store message in case we need to disconnect from it later. - callbacks.message = message; - - if (message->isComplete()) { - callbacks.completeCallback(true, error, message->readAll()); - messageCallbackMap.erase(requestIt); - } else { - connect(message.data(), &ReceivedMessage::progress, this, [this, length, message, &callbacks]() { - callbacks.progressCallback(message->getSize(), length); - }); - connect(message.data(), &ReceivedMessage::completed, this, [this, messageID, message, &messageCallbackMap, &callbacks]() { - if (message->failed()) { - callbacks.completeCallback(false, AssetServerError::NoError, QByteArray()); - } else { - callbacks.completeCallback(true, AssetServerError::NoError, message->readAll()); - } - - // We should never get to this point without the associated senderNode and messageID - // in our list of pending requests. If the senderNode had disconnected or the message - // had been canceled, we should have been disconnected from the ReceivedMessage - // signals and thus never had this lambda called. - messageCallbackMap.erase(messageID); - }); - } - } + // Found the node, get the MessageID -> Callback map + auto& messageCallbackMap = messageMapIt->second; + // Check if we have this pending request + auto requestIt = messageCallbackMap.find(messageID); + if (requestIt == messageCallbackMap.end()) { // Although the messageCallbackMap may now be empty, we won't delete the node until we have disconnected from // it to avoid constantly creating/deleting the map on subsequent requests. + return; + } + + auto& callbacks = requestIt->second; + + // Store message in case we need to disconnect from it later. + callbacks.message = message; + + if (message->isComplete()) { + callbacks.completeCallback(true, error, message->readAll()); + messageCallbackMap.erase(requestIt); + } else { + auto weakNode = senderNode.toWeakRef(); + + connect(message.data(), &ReceivedMessage::progress, this, [this, weakNode, messageID, length]() { + handleProgressCallback(weakNode, messageID, length); + }); + connect(message.data(), &ReceivedMessage::completed, this, [this, weakNode, messageID]() { + handleCompleteCallback(weakNode, messageID); + }); } } +void AssetClient::handleProgressCallback(const QWeakPointer& node, MessageID messageID, DataOffset length) { + auto senderNode = node.toStrongRef(); + + if (!senderNode) { + return; + } + + // Check if we have any pending requests for this node + auto messageMapIt = _pendingRequests.find(senderNode); + if (messageMapIt == _pendingRequests.end()) { + return; + } + + // Found the node, get the MessageID -> Callback map + auto& messageCallbackMap = messageMapIt->second; + + // Check if we have this pending request + auto requestIt = messageCallbackMap.find(messageID); + if (requestIt == messageCallbackMap.end()) { + return; + } + + auto& callbacks = requestIt->second; + auto& message = callbacks.message; + + if (!message) { + return; + } + + callbacks.progressCallback(message->getSize(), length); +} + +void AssetClient::handleCompleteCallback(const QWeakPointer& node, MessageID messageID) { + auto senderNode = node.toStrongRef(); + + if (!senderNode) { + return; + } + + // Check if we have any pending requests for this node + auto messageMapIt = _pendingRequests.find(senderNode); + if (messageMapIt == _pendingRequests.end()) { + return; + } + + // Found the node, get the MessageID -> Callback map + auto& messageCallbackMap = messageMapIt->second; + + // Check if we have this pending request + auto requestIt = messageCallbackMap.find(messageID); + if (requestIt == messageCallbackMap.end()) { + return; + } + + auto& callbacks = requestIt->second; + auto& message = callbacks.message; + + if (!message) { + return; + } + + + if (message->failed()) { + callbacks.completeCallback(false, AssetServerError::NoError, QByteArray()); + } else { + callbacks.completeCallback(true, AssetServerError::NoError, message->readAll()); + } + + // We should never get to this point without the associated senderNode and messageID + // in our list of pending requests. If the senderNode had disconnected or the message + // had been canceled, we should have been disconnected from the ReceivedMessage + // signals and thus never had this lambda called. + messageCallbackMap.erase(messageID); +} + + MessageID AssetClient::getAssetMapping(const AssetPath& path, MappingOperationCallback callback) { Q_ASSERT(QThread::currentThread() == thread()); diff --git a/libraries/networking/src/AssetClient.h b/libraries/networking/src/AssetClient.h index c0e95c0d1d..f951be762d 100644 --- a/libraries/networking/src/AssetClient.h +++ b/libraries/networking/src/AssetClient.h @@ -93,6 +93,9 @@ private: bool cancelGetAssetRequest(MessageID id); bool cancelUploadAssetRequest(MessageID id); + void handleProgressCallback(const QWeakPointer& node, MessageID messageID, DataOffset length); + void handleCompleteCallback(const QWeakPointer& node, MessageID messageID); + struct GetAssetRequestData { QSharedPointer message; ReceivedAssetCallback completeCallback; diff --git a/libraries/networking/src/UserActivityLogger.cpp b/libraries/networking/src/UserActivityLogger.cpp index 8eefaac9b0..0d7690840d 100644 --- a/libraries/networking/src/UserActivityLogger.cpp +++ b/libraries/networking/src/UserActivityLogger.cpp @@ -25,15 +25,12 @@ UserActivityLogger& UserActivityLogger::getInstance() { return sharedInstance; } -UserActivityLogger::UserActivityLogger() : _disabled(false) { -} - void UserActivityLogger::disable(bool disable) { - _disabled = disable; + _disabled.set(disable); } void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCallbackParameters params) { - if (_disabled) { + if (_disabled.get()) { return; } @@ -63,7 +60,7 @@ void UserActivityLogger::logAction(QString action, QJsonObject details, JSONCall } accountManager.sendRequest(USER_ACTIVITY_URL, - AccountManagerAuth::Required, + AccountManagerAuth::Optional, QNetworkAccessManager::PostOperation, params, NULL, multipart); } diff --git a/libraries/networking/src/UserActivityLogger.h b/libraries/networking/src/UserActivityLogger.h index c48169d207..5c1cb03e3a 100644 --- a/libraries/networking/src/UserActivityLogger.h +++ b/libraries/networking/src/UserActivityLogger.h @@ -19,6 +19,8 @@ #include #include +#include + class UserActivityLogger : public QObject { Q_OBJECT @@ -44,8 +46,8 @@ private slots: void requestError(QNetworkReply& errorReply); private: - UserActivityLogger(); - bool _disabled; + UserActivityLogger() {}; + Setting::Handle _disabled { "UserActivityLoggerDisabled", false }; }; #endif // hifi_UserActivityLogger_h diff --git a/libraries/plugins/src/plugins/DisplayPlugin.h b/libraries/plugins/src/plugins/DisplayPlugin.h index 64a73ab12a..91dcf9398f 100644 --- a/libraries/plugins/src/plugins/DisplayPlugin.h +++ b/libraries/plugins/src/plugins/DisplayPlugin.h @@ -107,7 +107,8 @@ public: // The recommended bounds for primary overlay placement virtual QRect getRecommendedOverlayRect() const { - auto recommendedSize = getRecommendedUiSize(); + const int DESKTOP_SCREEN_PADDING = 50; + auto recommendedSize = getRecommendedUiSize() - glm::uvec2(DESKTOP_SCREEN_PADDING); return QRect(0, 0, recommendedSize.x, recommendedSize.y); } diff --git a/libraries/render-utils/src/MaterialTextures.slh b/libraries/render-utils/src/MaterialTextures.slh index 34bb7c429b..512b7a533c 100644 --- a/libraries/render-utils/src/MaterialTextures.slh +++ b/libraries/render-utils/src/MaterialTextures.slh @@ -11,6 +11,39 @@ <@if not MODEL_MATERIAL_TEXTURES_SLH@> <@def MODEL_MATERIAL_TEXTURES_SLH@> + +<@func declareMaterialTexMapArrayBuffer()@> + +const int MAX_TEXCOORDS = 2; + +struct TexMapArray { + mat4 _texcoordTransforms[MAX_TEXCOORDS]; + vec4 _lightmapParams; +}; + +uniform texMapArrayBuffer { + TexMapArray _texMapArray; +}; + +TexMapArray getTexMapArray() { + return _texMapArray; +} + +<@func evalTexMapArrayTexcoord0(texMapArray, inTexcoord0, outTexcoord0)@> +{ + <$outTexcoord0$> = (<$texMapArray$>._texcoordTransforms[0] * vec4(<$inTexcoord0$>.st, 0.0, 1.0)).st; +} +<@endfunc@> + +<@func evalTexMapArrayTexcoord1(texMapArray, inTexcoord1, outTexcoord1)@> +{ + <$outTexcoord1$> = (<$texMapArray$>._texcoordTransforms[1] * vec4(<$inTexcoord1$>.st, 0.0, 1.0)).st; +} +<@endfunc@> + +<@endfunc@> + + <@func declareMaterialTextures(withAlbedo, withRoughness, withNormal, withMetallic, withEmissive, withOcclusion)@> <@if withAlbedo@> @@ -80,9 +113,12 @@ float fetchOcclusionMap(vec2 uv) { <@func declareMaterialLightmap()@> + +<$declareMaterialTexMapArrayBuffer()$> + uniform sampler2D emissiveMap; -uniform vec2 emissiveParams; vec3 fetchLightmapMap(vec2 uv) { + vec2 emissiveParams = getTexMapArray()._lightmapParams.xy; return (vec3(emissiveParams.x) + emissiveParams.y * texture(emissiveMap, uv).rgb); } <@endfunc@> diff --git a/libraries/render-utils/src/MeshPartPayload.cpp b/libraries/render-utils/src/MeshPartPayload.cpp index a273d92112..6571674e44 100644 --- a/libraries/render-utils/src/MeshPartPayload.cpp +++ b/libraries/render-utils/src/MeshPartPayload.cpp @@ -138,21 +138,17 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat auto textureCache = DependencyManager::get(); - batch.setUniformBuffer(ShapePipeline::Slot::MATERIAL_GPU, _drawMaterial->getSchemaBuffer()); + batch.setUniformBuffer(ShapePipeline::Slot::MATERIAL_BUFFER, _drawMaterial->getSchemaBuffer()); + batch.setUniformBuffer(ShapePipeline::Slot::TEXMAPARRAY_BUFFER, _drawMaterial->getTexMapArrayBuffer()); auto materialKey = _drawMaterial->getKey(); auto textureMaps = _drawMaterial->getTextureMaps(); - glm::mat4 texcoordTransform[2]; // Albedo if (materialKey.isAlbedoMap()) { auto albedoMap = textureMaps[model::MaterialKey::ALBEDO_MAP]; if (albedoMap && albedoMap->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, albedoMap->getTextureView()); - - if (!albedoMap->getTextureTransform().isIdentity()) { - albedoMap->getTextureTransform().getMatrix(texcoordTransform[0]); - } } else { batch.setResourceTexture(ShapePipeline::Slot::ALBEDO_MAP, textureCache->getGrayTexture()); } @@ -222,13 +218,6 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat if (lightmapMap && lightmapMap->isDefined()) { batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, lightmapMap->getTextureView()); - - auto lightmapOffsetScale = lightmapMap->getLightmapOffsetScale(); - batch._glUniform2f(locations->emissiveParams, lightmapOffsetScale.x, lightmapOffsetScale.y); - - if (!lightmapMap->getTextureTransform().isIdentity()) { - lightmapMap->getTextureTransform().getMatrix(texcoordTransform[1]); - } } else { batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, textureCache->getGrayTexture()); } @@ -243,12 +232,6 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat } else { batch.setResourceTexture(ShapePipeline::Slot::EMISSIVE_LIGHTMAP_MAP, nullptr); } - - // Texcoord transforms ? - if (locations->texcoordMatrices >= 0) { - batch._glUniformMatrix4fv(locations->texcoordMatrices, 2, false, (const float*)&texcoordTransform); - // batch._glUniformMatrix4fv(locations->texcoordMatrices, (materialKey.isLightmapMap() ? 2 : 1), false, (const float*)&texcoordTransform); - } } void MeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline::LocationsPointer locations, bool canCauterize) const { @@ -491,9 +474,9 @@ void ModelMeshPartPayload::bindTransform(gpu::Batch& batch, const ShapePipeline: Transform transform; if (state.clusterBuffer) { if (canCauterize && _model->getCauterizeBones()) { - batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.cauterizedClusterBuffer); + batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_BUFFER, state.cauterizedClusterBuffer); } else { - batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_GPU, state.clusterBuffer); + batch.setUniformBuffer(ShapePipeline::Slot::SKINNING_BUFFER, state.clusterBuffer); } } else { if (canCauterize && _model->getCauterizeBones()) { diff --git a/libraries/render-utils/src/RenderPipelines.cpp b/libraries/render-utils/src/RenderPipelines.cpp index aa0f9dc7d9..bca8f3791f 100644 --- a/libraries/render-utils/src/RenderPipelines.cpp +++ b/libraries/render-utils/src/RenderPipelines.cpp @@ -80,15 +80,11 @@ void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch) { // Set a default normal map batch.setResourceTexture(render::ShapePipeline::Slot::NORMAL_FITTING_MAP, DependencyManager::get()->getNormalFittingTexture()); - // Set default coordinates - if (pipeline.locations->texcoordMatrices >= 0) { - static const glm::mat4 TEX_COORDS[2]; - batch._glUniformMatrix4fv(pipeline.locations->texcoordMatrices, 2, false, (const float*)&TEX_COORDS); - } + // Set a default material if (pipeline.locations->materialBufferUnit >= 0) { static const gpu::BufferView OPAQUE_SCHEMA_BUFFER = getDefaultMaterialBuffer(); - batch.setUniformBuffer(ShapePipeline::Slot::MATERIAL_GPU, OPAQUE_SCHEMA_BUFFER); + batch.setUniformBuffer(ShapePipeline::Slot::MATERIAL_BUFFER, OPAQUE_SCHEMA_BUFFER); } } diff --git a/libraries/render-utils/src/Skinning.slh b/libraries/render-utils/src/Skinning.slh index 63992c35ad..687dab536b 100644 --- a/libraries/render-utils/src/Skinning.slh +++ b/libraries/render-utils/src/Skinning.slh @@ -11,7 +11,6 @@ <@if not SKINNING_SLH@> <@def SKINNING_SLH@> -const int MAX_TEXCOORDS = 2; const int MAX_CLUSTERS = 128; const int INDICES_PER_VERTEX = 4; diff --git a/libraries/render-utils/src/model.slv b/libraries/render-utils/src/model.slv index 0507f1c6c5..f1989dcf76 100755 --- a/libraries/render-utils/src/model.slv +++ b/libraries/render-utils/src/model.slv @@ -16,8 +16,8 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -const int MAX_TEXCOORDS = 2; -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; +<@include MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> out vec3 _color; out float _alpha; @@ -29,7 +29,8 @@ void main(void) { _color = colorToLinearRGB(inColor.xyz); _alpha = inColor.w; - _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st; + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_lightmap.slf b/libraries/render-utils/src/model_lightmap.slf index 46d81d39e1..3afbbfd405 100755 --- a/libraries/render-utils/src/model_lightmap.slf +++ b/libraries/render-utils/src/model_lightmap.slf @@ -30,7 +30,7 @@ void main(void) { Material mat = getMaterial(); int matKey = getMaterialKey(mat); <$fetchMaterialTextures(matKey, _texCoord0, albedo, roughness)$> - <$fetchMaterialLightmap(_texCoord1, emissive)$> + <$fetchMaterialLightmap(_texCoord1, lightmapVal)$> packDeferredFragmentLightmap( @@ -40,5 +40,5 @@ void main(void) { getMaterialRoughness(mat) * roughness, getMaterialMetallic(mat), getMaterialFresnel(mat), - (vec3(emissiveParams.x) + emissiveParams.y * emissive.rgb)); + lightmapVal); } diff --git a/libraries/render-utils/src/model_lightmap.slv b/libraries/render-utils/src/model_lightmap.slv index 8696b70373..f73b6a02a7 100755 --- a/libraries/render-utils/src/model_lightmap.slv +++ b/libraries/render-utils/src/model_lightmap.slv @@ -17,9 +17,8 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -const int MAX_TEXCOORDS = 2; - -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; +<@include MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> out vec4 _position; out vec2 _texCoord0; @@ -32,8 +31,9 @@ void main(void) { _color = colorToLinearRGB(inColor.xyz); // and the texture coordinates - _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st; - _texCoord1 = (texcoordMatrices[1] * vec4(inTexCoord1.st, 0.0, 1.0)).st; + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_lightmap_normal_map.slv b/libraries/render-utils/src/model_lightmap_normal_map.slv index eb8f80656d..cb333f50e3 100755 --- a/libraries/render-utils/src/model_lightmap_normal_map.slv +++ b/libraries/render-utils/src/model_lightmap_normal_map.slv @@ -17,9 +17,8 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -const int MAX_TEXCOORDS = 2; - -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; +<@include MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> out vec4 _position; out vec2 _texCoord0; @@ -32,9 +31,9 @@ void main(void) { // pass along the color in linear space _color = colorToLinearRGB(inColor.xyz); - // and the texture coordinates - _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st; - _texCoord1 = (texcoordMatrices[1] * vec4(inTexCoord1.st, 0.0, 1.0)).st; + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> + <$evalTexMapArrayTexcoord1(texMapArray, inTexCoord1, _texCoord1)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/model_normal_map.slv b/libraries/render-utils/src/model_normal_map.slv index 4f45902dae..ded37923c2 100755 --- a/libraries/render-utils/src/model_normal_map.slv +++ b/libraries/render-utils/src/model_normal_map.slv @@ -17,9 +17,8 @@ <@include gpu/Transform.slh@> <$declareStandardTransform()$> -const int MAX_TEXCOORDS = 2; - -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; +<@include MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> out vec4 _position; out vec2 _texCoord0; @@ -33,8 +32,8 @@ void main(void) { _color = colorToLinearRGB(inColor.rgb); _alpha = inColor.a; - // and the texture coordinates - _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.xy, 0.0, 1.0)).st; + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> // standard transform TransformCamera cam = getTransformCamera(); diff --git a/libraries/render-utils/src/skin_model.slv b/libraries/render-utils/src/skin_model.slv index e5d1857d44..c8501b8ddf 100755 --- a/libraries/render-utils/src/skin_model.slv +++ b/libraries/render-utils/src/skin_model.slv @@ -19,7 +19,8 @@ <@include Skinning.slh@> -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; +<@include MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> out vec4 _position; out vec2 _texCoord0; @@ -37,9 +38,9 @@ void main(void) { _color = colorToLinearRGB(inColor.rgb); _alpha = inColor.a; - // and the texture coordinates - _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st; - + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> + // standard transform TransformCamera cam = getTransformCamera(); TransformObject obj = getTransformObject(); diff --git a/libraries/render-utils/src/skin_model_normal_map.slv b/libraries/render-utils/src/skin_model_normal_map.slv index 5348ad5234..db4b206405 100755 --- a/libraries/render-utils/src/skin_model_normal_map.slv +++ b/libraries/render-utils/src/skin_model_normal_map.slv @@ -19,7 +19,8 @@ <@include Skinning.slh@> -uniform mat4 texcoordMatrices[MAX_TEXCOORDS]; +<@include MaterialTextures.slh@> +<$declareMaterialTexMapArrayBuffer()$> out vec4 _position; out vec2 _texCoord0; @@ -39,9 +40,9 @@ void main(void) { _color = colorToLinearRGB(inColor.rgb); _alpha = inColor.a; - // and the texture coordinates - _texCoord0 = (texcoordMatrices[0] * vec4(inTexCoord0.st, 0.0, 1.0)).st; - + TexMapArray texMapArray = getTexMapArray(); + <$evalTexMapArrayTexcoord0(texMapArray, inTexCoord0, _texCoord0)$> + interpolatedNormal = vec4(normalize(interpolatedNormal.xyz), 0.0); interpolatedTangent = vec4(normalize(interpolatedTangent.xyz), 0.0); diff --git a/libraries/render/src/render/ShapePipeline.cpp b/libraries/render/src/render/ShapePipeline.cpp index 6974a7e385..b09d4b1356 100644 --- a/libraries/render/src/render/ShapePipeline.cpp +++ b/libraries/render/src/render/ShapePipeline.cpp @@ -51,8 +51,9 @@ void ShapePlumber::addPipeline(const Key& key, const gpu::ShaderPointer& program void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& program, const gpu::StatePointer& state, BatchSetter batchSetter) { gpu::Shader::BindingSet slotBindings; - slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::SKINNING_GPU)); - slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slot::MATERIAL_GPU)); + slotBindings.insert(gpu::Shader::Binding(std::string("skinClusterBuffer"), Slot::SKINNING_BUFFER)); + slotBindings.insert(gpu::Shader::Binding(std::string("materialBuffer"), Slot::MATERIAL_BUFFER)); + slotBindings.insert(gpu::Shader::Binding(std::string("texMapArrayBuffer"), Slot::TEXMAPARRAY_BUFFER)); slotBindings.insert(gpu::Shader::Binding(std::string("albedoMap"), Slot::ALBEDO_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("roughnessMap"), Slot::ROUGHNESS_MAP)); slotBindings.insert(gpu::Shader::Binding(std::string("normalMap"), Slot::NORMAL_MAP)); @@ -65,8 +66,6 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p gpu::Shader::makeProgram(*program, slotBindings); auto locations = std::make_shared(); - locations->texcoordMatrices = program->getUniforms().findLocation("texcoordMatrices"); - locations->emissiveParams = program->getUniforms().findLocation("emissiveParams"); locations->normalFittingMapUnit = program->getTextures().findLocation("normalFittingMap"); locations->albedoTextureUnit = program->getTextures().findLocation("albedoMap"); locations->roughnessTextureUnit = program->getTextures().findLocation("roughnessMap"); @@ -76,6 +75,7 @@ void ShapePlumber::addPipeline(const Filter& filter, const gpu::ShaderPointer& p locations->occlusionTextureUnit = program->getTextures().findLocation("occlusionMap"); locations->skinClusterBufferUnit = program->getBuffers().findLocation("skinClusterBuffer"); locations->materialBufferUnit = program->getBuffers().findLocation("materialBuffer"); + locations->texMapArrayBufferUnit = program->getBuffers().findLocation("texMapArrayBuffer"); locations->lightBufferUnit = program->getBuffers().findLocation("lightBuffer"); ShapeKey key{filter._flags}; diff --git a/libraries/render/src/render/ShapePipeline.h b/libraries/render/src/render/ShapePipeline.h index 0f795aadde..22aa22d4c9 100644 --- a/libraries/render/src/render/ShapePipeline.h +++ b/libraries/render/src/render/ShapePipeline.h @@ -193,8 +193,9 @@ class ShapePipeline { public: class Slot { public: - static const int SKINNING_GPU = 2; - static const int MATERIAL_GPU = 3; + static const int SKINNING_BUFFER = 2; + static const int MATERIAL_BUFFER = 3; + static const int TEXMAPARRAY_BUFFER = 4; static const int ALBEDO_MAP = 0; static const int NORMAL_MAP = 1; static const int METALLIC_MAP = 2; @@ -202,23 +203,22 @@ public: static const int ROUGHNESS_MAP = 4; static const int OCCLUSION_MAP = 5; - static const int LIGHT_BUFFER = 4; + static const int LIGHT_BUFFER = 5; static const int NORMAL_FITTING_MAP = 10; }; class Locations { public: - int texcoordMatrices; int albedoTextureUnit; int normalTextureUnit; int roughnessTextureUnit; int metallicTextureUnit; int emissiveTextureUnit; int occlusionTextureUnit; - int emissiveParams; int normalFittingMapUnit; int skinClusterBufferUnit; int materialBufferUnit; + int texMapArrayBufferUnit; int lightBufferUnit; }; using LocationsPointer = std::shared_ptr; diff --git a/libraries/shared/src/GPUIdent.cpp b/libraries/shared/src/GPUIdent.cpp index 917020d223..19838964a4 100644 --- a/libraries/shared/src/GPUIdent.cpp +++ b/libraries/shared/src/GPUIdent.cpp @@ -147,7 +147,7 @@ GPUIdent* GPUIdent::ensureQuery(const QString& vendor, const QString& renderer) _isValid = true; } - hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance, &uNumOfInstances); + hr = spEnumInst->Next(WBEM_INFINITE, 1, &spInstance.p, &uNumOfInstances); } #endif return this; diff --git a/libraries/shared/src/GeometryUtil.cpp b/libraries/shared/src/GeometryUtil.cpp index 96c4d3bdea..92fe138021 100644 --- a/libraries/shared/src/GeometryUtil.cpp +++ b/libraries/shared/src/GeometryUtil.cpp @@ -564,3 +564,17 @@ void swingTwistDecomposition(const glm::quat& rotation, // rotation = swing * twist --> swing = rotation * invTwist swing = rotation * glm::inverse(twist); } + +// calculate the minimum angle between a point and a sphere. +float coneSphereAngle(const glm::vec3& coneCenter, const glm::vec3& coneDirection, const glm::vec3& sphereCenter, float sphereRadius) { + glm::vec3 d = sphereCenter - coneCenter; + float dLen = glm::length(d); + + // theta is the angle between the coneDirection normal and the center of the sphere. + float theta = acosf(glm::dot(d, coneDirection) / dLen); + + // phi is the deflection angle from the center of the sphere to a point tangent to the sphere. + float phi = atanf(sphereRadius / dLen); + + return glm::max(0.0f, theta - phi); +} diff --git a/libraries/shared/src/GeometryUtil.h b/libraries/shared/src/GeometryUtil.h index 7224aaacff..a66b16b0fd 100644 --- a/libraries/shared/src/GeometryUtil.h +++ b/libraries/shared/src/GeometryUtil.h @@ -110,6 +110,8 @@ bool doLineSegmentsIntersect(glm::vec2 r1p1, glm::vec2 r1p2, glm::vec2 r2p1, glm bool isOnSegment(float xi, float yi, float xj, float yj, float xk, float yk); int computeDirection(float xi, float yi, float xj, float yj, float xk, float yk); +// calculate the angle between a point on a sphere that is closest to the cone. +float coneSphereAngle(const glm::vec3& coneCenter, const glm::vec3& coneDirection, const glm::vec3& sphereCenter, float sphereRadius); typedef glm::vec2 LineSegment2[2]; diff --git a/examples/FlockOfFish.js b/script-archive/FlockOfFish.js similarity index 100% rename from examples/FlockOfFish.js rename to script-archive/FlockOfFish.js diff --git a/examples/FlockOfbirds.js b/script-archive/FlockOfbirds.js similarity index 100% rename from examples/FlockOfbirds.js rename to script-archive/FlockOfbirds.js diff --git a/examples/acScripts/AgentPoolController.js b/script-archive/acScripts/AgentPoolController.js similarity index 100% rename from examples/acScripts/AgentPoolController.js rename to script-archive/acScripts/AgentPoolController.js diff --git a/examples/acScripts/ControlACs.js b/script-archive/acScripts/ControlACs.js similarity index 100% rename from examples/acScripts/ControlACs.js rename to script-archive/acScripts/ControlACs.js diff --git a/examples/acScripts/ControlledAC.js b/script-archive/acScripts/ControlledAC.js similarity index 100% rename from examples/acScripts/ControlledAC.js rename to script-archive/acScripts/ControlledAC.js diff --git a/examples/acScripts/PlayRecordingOnAC.js b/script-archive/acScripts/PlayRecordingOnAC.js similarity index 100% rename from examples/acScripts/PlayRecordingOnAC.js rename to script-archive/acScripts/PlayRecordingOnAC.js diff --git a/examples/acScripts/ambiance.js b/script-archive/acScripts/ambiance.js similarity index 100% rename from examples/acScripts/ambiance.js rename to script-archive/acScripts/ambiance.js diff --git a/examples/acScripts/animatedAvatarAgent.js b/script-archive/acScripts/animatedAvatarAgent.js similarity index 100% rename from examples/acScripts/animatedAvatarAgent.js rename to script-archive/acScripts/animatedAvatarAgent.js diff --git a/examples/acScripts/botProceduralWayPoints.js b/script-archive/acScripts/botProceduralWayPoints.js similarity index 100% rename from examples/acScripts/botProceduralWayPoints.js rename to script-archive/acScripts/botProceduralWayPoints.js diff --git a/examples/acScripts/bot_randomExpression.js b/script-archive/acScripts/bot_randomExpression.js similarity index 100% rename from examples/acScripts/bot_randomExpression.js rename to script-archive/acScripts/bot_randomExpression.js diff --git a/examples/acScripts/entitySpawnerAC.js b/script-archive/acScripts/entitySpawnerAC.js similarity index 100% rename from examples/acScripts/entitySpawnerAC.js rename to script-archive/acScripts/entitySpawnerAC.js diff --git a/examples/acScripts/playbackAgents.js b/script-archive/acScripts/playbackAgents.js similarity index 100% rename from examples/acScripts/playbackAgents.js rename to script-archive/acScripts/playbackAgents.js diff --git a/examples/acScripts/playbackMaster.js b/script-archive/acScripts/playbackMaster.js similarity index 100% rename from examples/acScripts/playbackMaster.js rename to script-archive/acScripts/playbackMaster.js diff --git a/examples/acScripts/proceduralAnimationAPI.js b/script-archive/acScripts/proceduralAnimationAPI.js similarity index 100% rename from examples/acScripts/proceduralAnimationAPI.js rename to script-archive/acScripts/proceduralAnimationAPI.js diff --git a/examples/acScripts/rain.js b/script-archive/acScripts/rain.js similarity index 100% rename from examples/acScripts/rain.js rename to script-archive/acScripts/rain.js diff --git a/examples/acScripts/triggeredRecordingOnAC.js b/script-archive/acScripts/triggeredRecordingOnAC.js similarity index 100% rename from examples/acScripts/triggeredRecordingOnAC.js rename to script-archive/acScripts/triggeredRecordingOnAC.js diff --git a/examples/afk.js b/script-archive/afk.js similarity index 100% rename from examples/afk.js rename to script-archive/afk.js diff --git a/examples/airship/airship.js b/script-archive/airship/airship.js similarity index 100% rename from examples/airship/airship.js rename to script-archive/airship/airship.js diff --git a/examples/airship/makeAirship.js b/script-archive/airship/makeAirship.js similarity index 100% rename from examples/airship/makeAirship.js rename to script-archive/airship/makeAirship.js diff --git a/examples/animationPerfTest.js b/script-archive/animationPerfTest.js similarity index 100% rename from examples/animationPerfTest.js rename to script-archive/animationPerfTest.js diff --git a/examples/audioExamples/acAudioSearching/ACAudioSearchAndInject.js b/script-archive/audioExamples/acAudioSearching/ACAudioSearchAndInject.js similarity index 100% rename from examples/audioExamples/acAudioSearching/ACAudioSearchAndInject.js rename to script-archive/audioExamples/acAudioSearching/ACAudioSearchAndInject.js diff --git a/examples/audioExamples/acAudioSearching/acAudioSearchCompatibleEntitySpawner.js b/script-archive/audioExamples/acAudioSearching/acAudioSearchCompatibleEntitySpawner.js similarity index 100% rename from examples/audioExamples/acAudioSearching/acAudioSearchCompatibleEntitySpawner.js rename to script-archive/audioExamples/acAudioSearching/acAudioSearchCompatibleEntitySpawner.js diff --git a/examples/audioExamples/injectorLoadTest.js b/script-archive/audioExamples/injectorLoadTest.js similarity index 100% rename from examples/audioExamples/injectorLoadTest.js rename to script-archive/audioExamples/injectorLoadTest.js diff --git a/examples/avatarMover/avatarMover.js b/script-archive/avatarMover/avatarMover.js similarity index 100% rename from examples/avatarMover/avatarMover.js rename to script-archive/avatarMover/avatarMover.js diff --git a/examples/avatarMover/avatarMoverSpawner.js b/script-archive/avatarMover/avatarMoverSpawner.js similarity index 100% rename from examples/avatarMover/avatarMoverSpawner.js rename to script-archive/avatarMover/avatarMoverSpawner.js diff --git a/examples/avatarSelector.js b/script-archive/avatarSelector.js similarity index 100% rename from examples/avatarSelector.js rename to script-archive/avatarSelector.js diff --git a/examples/baseball/assets.json b/script-archive/baseball/assets.json similarity index 100% rename from examples/baseball/assets.json rename to script-archive/baseball/assets.json diff --git a/examples/baseball/baseballCrowd.js b/script-archive/baseball/baseballCrowd.js similarity index 100% rename from examples/baseball/baseballCrowd.js rename to script-archive/baseball/baseballCrowd.js diff --git a/examples/baseball/bat.js b/script-archive/baseball/bat.js similarity index 100% rename from examples/baseball/bat.js rename to script-archive/baseball/bat.js diff --git a/examples/baseball/createBatButton.js b/script-archive/baseball/createBatButton.js similarity index 100% rename from examples/baseball/createBatButton.js rename to script-archive/baseball/createBatButton.js diff --git a/examples/baseball/firework.js b/script-archive/baseball/firework.js similarity index 100% rename from examples/baseball/firework.js rename to script-archive/baseball/firework.js diff --git a/examples/baseball/line.js b/script-archive/baseball/line.js similarity index 100% rename from examples/baseball/line.js rename to script-archive/baseball/line.js diff --git a/examples/baseball/pitching.js b/script-archive/baseball/pitching.js similarity index 100% rename from examples/baseball/pitching.js rename to script-archive/baseball/pitching.js diff --git a/examples/baseball/utils.js b/script-archive/baseball/utils.js similarity index 100% rename from examples/baseball/utils.js rename to script-archive/baseball/utils.js diff --git a/examples/blockWorld.js b/script-archive/blockWorld.js similarity index 100% rename from examples/blockWorld.js rename to script-archive/blockWorld.js diff --git a/examples/blocks.js b/script-archive/blocks.js similarity index 100% rename from examples/blocks.js rename to script-archive/blocks.js diff --git a/examples/breakdanceCore.js b/script-archive/breakdanceCore.js similarity index 100% rename from examples/breakdanceCore.js rename to script-archive/breakdanceCore.js diff --git a/examples/breakdanceToy.js b/script-archive/breakdanceToy.js similarity index 100% rename from examples/breakdanceToy.js rename to script-archive/breakdanceToy.js diff --git a/examples/controlPanel.js b/script-archive/controlPanel.js similarity index 100% rename from examples/controlPanel.js rename to script-archive/controlPanel.js diff --git a/examples/controllers/RealSense/realsenseHands.js b/script-archive/controllers/RealSense/realsenseHands.js similarity index 100% rename from examples/controllers/RealSense/realsenseHands.js rename to script-archive/controllers/RealSense/realsenseHands.js diff --git a/examples/controllers/Spacemouse/spacemouseExample.js b/script-archive/controllers/Spacemouse/spacemouseExample.js similarity index 100% rename from examples/controllers/Spacemouse/spacemouseExample.js rename to script-archive/controllers/Spacemouse/spacemouseExample.js diff --git a/examples/controllers/controllerMappings.js b/script-archive/controllers/controllerMappings.js similarity index 100% rename from examples/controllers/controllerMappings.js rename to script-archive/controllers/controllerMappings.js diff --git a/examples/controllers/gamepad/gamepad.js b/script-archive/controllers/gamepad/gamepad.js similarity index 100% rename from examples/controllers/gamepad/gamepad.js rename to script-archive/controllers/gamepad/gamepad.js diff --git a/examples/controllers/getHUDLookAtPositionTest.js b/script-archive/controllers/getHUDLookAtPositionTest.js similarity index 100% rename from examples/controllers/getHUDLookAtPositionTest.js rename to script-archive/controllers/getHUDLookAtPositionTest.js diff --git a/examples/controllers/handPosesDebug.js b/script-archive/controllers/handPosesDebug.js similarity index 100% rename from examples/controllers/handPosesDebug.js rename to script-archive/controllers/handPosesDebug.js diff --git a/examples/controllers/hydra/airGuitar.js b/script-archive/controllers/hydra/airGuitar.js similarity index 100% rename from examples/controllers/hydra/airGuitar.js rename to script-archive/controllers/hydra/airGuitar.js diff --git a/examples/controllers/hydra/drumStick.js b/script-archive/controllers/hydra/drumStick.js similarity index 100% rename from examples/controllers/hydra/drumStick.js rename to script-archive/controllers/hydra/drumStick.js diff --git a/examples/controllers/hydra/frisbee.js b/script-archive/controllers/hydra/frisbee.js similarity index 100% rename from examples/controllers/hydra/frisbee.js rename to script-archive/controllers/hydra/frisbee.js diff --git a/examples/controllers/hydra/gun.js b/script-archive/controllers/hydra/gun.js similarity index 100% rename from examples/controllers/hydra/gun.js rename to script-archive/controllers/hydra/gun.js diff --git a/examples/controllers/hydra/laserPointer.js b/script-archive/controllers/hydra/laserPointer.js similarity index 100% rename from examples/controllers/hydra/laserPointer.js rename to script-archive/controllers/hydra/laserPointer.js diff --git a/examples/controllers/hydra/paddleBall.js b/script-archive/controllers/hydra/paddleBall.js similarity index 100% rename from examples/controllers/hydra/paddleBall.js rename to script-archive/controllers/hydra/paddleBall.js diff --git a/examples/controllers/hydra/toyball.js b/script-archive/controllers/hydra/toyball.js similarity index 100% rename from examples/controllers/hydra/toyball.js rename to script-archive/controllers/hydra/toyball.js diff --git a/examples/controllers/leap/laserPointer.js b/script-archive/controllers/leap/laserPointer.js similarity index 100% rename from examples/controllers/leap/laserPointer.js rename to script-archive/controllers/leap/laserPointer.js diff --git a/examples/controllers/leap/leapHands.js b/script-archive/controllers/leap/leapHands.js similarity index 100% rename from examples/controllers/leap/leapHands.js rename to script-archive/controllers/leap/leapHands.js diff --git a/examples/controllers/leap/leapOfFaith.js b/script-archive/controllers/leap/leapOfFaith.js similarity index 100% rename from examples/controllers/leap/leapOfFaith.js rename to script-archive/controllers/leap/leapOfFaith.js diff --git a/examples/controllers/neuron/neuronAvatar.js b/script-archive/controllers/neuron/neuronAvatar.js similarity index 100% rename from examples/controllers/neuron/neuronAvatar.js rename to script-archive/controllers/neuron/neuronAvatar.js diff --git a/examples/controllers/oculus/goTo.js b/script-archive/controllers/oculus/goTo.js similarity index 100% rename from examples/controllers/oculus/goTo.js rename to script-archive/controllers/oculus/goTo.js diff --git a/examples/controllers/oculus/virtualKeyboardTextEntityExample.js b/script-archive/controllers/oculus/virtualKeyboardTextEntityExample.js similarity index 100% rename from examples/controllers/oculus/virtualKeyboardTextEntityExample.js rename to script-archive/controllers/oculus/virtualKeyboardTextEntityExample.js diff --git a/examples/controllers/philipsVersion.js b/script-archive/controllers/philipsVersion.js similarity index 100% rename from examples/controllers/philipsVersion.js rename to script-archive/controllers/philipsVersion.js diff --git a/examples/controllers/proceduralHandPoseExample.js b/script-archive/controllers/proceduralHandPoseExample.js similarity index 100% rename from examples/controllers/proceduralHandPoseExample.js rename to script-archive/controllers/proceduralHandPoseExample.js diff --git a/examples/controllers/reticleHandAngularVelocityTest.js b/script-archive/controllers/reticleHandAngularVelocityTest.js similarity index 100% rename from examples/controllers/reticleHandAngularVelocityTest.js rename to script-archive/controllers/reticleHandAngularVelocityTest.js diff --git a/examples/controllers/reticleTests.js b/script-archive/controllers/reticleTests.js similarity index 100% rename from examples/controllers/reticleTests.js rename to script-archive/controllers/reticleTests.js diff --git a/examples/controllers/rightClickExample.js b/script-archive/controllers/rightClickExample.js similarity index 100% rename from examples/controllers/rightClickExample.js rename to script-archive/controllers/rightClickExample.js diff --git a/examples/controllers/toybox.js b/script-archive/controllers/toybox.js similarity index 100% rename from examples/controllers/toybox.js rename to script-archive/controllers/toybox.js diff --git a/examples/cubePerfTest.js b/script-archive/cubePerfTest.js similarity index 100% rename from examples/cubePerfTest.js rename to script-archive/cubePerfTest.js diff --git a/examples/dancing_bot.js b/script-archive/dancing_bot.js similarity index 100% rename from examples/dancing_bot.js rename to script-archive/dancing_bot.js diff --git a/examples/data_visualization/earthquakes_live.js b/script-archive/data_visualization/earthquakes_live.js similarity index 100% rename from examples/data_visualization/earthquakes_live.js rename to script-archive/data_visualization/earthquakes_live.js diff --git a/examples/data_visualization/photo_sphere.js b/script-archive/data_visualization/photo_sphere.js similarity index 100% rename from examples/data_visualization/photo_sphere.js rename to script-archive/data_visualization/photo_sphere.js diff --git a/examples/debug-actions.js b/script-archive/debug-actions.js similarity index 100% rename from examples/debug-actions.js rename to script-archive/debug-actions.js diff --git a/examples/dressing_room/createPlatformWithLights.js b/script-archive/dressing_room/createPlatformWithLights.js similarity index 100% rename from examples/dressing_room/createPlatformWithLights.js rename to script-archive/dressing_room/createPlatformWithLights.js diff --git a/examples/dressing_room/createTableWithItems.js b/script-archive/dressing_room/createTableWithItems.js similarity index 100% rename from examples/dressing_room/createTableWithItems.js rename to script-archive/dressing_room/createTableWithItems.js diff --git a/examples/dressing_room/doppelganger.js b/script-archive/dressing_room/doppelganger.js similarity index 100% rename from examples/dressing_room/doppelganger.js rename to script-archive/dressing_room/doppelganger.js diff --git a/examples/dressing_room/freezeToggler.js b/script-archive/dressing_room/freezeToggler.js similarity index 100% rename from examples/dressing_room/freezeToggler.js rename to script-archive/dressing_room/freezeToggler.js diff --git a/examples/dressing_room/loadingAreaEntity.js b/script-archive/dressing_room/loadingAreaEntity.js similarity index 100% rename from examples/dressing_room/loadingAreaEntity.js rename to script-archive/dressing_room/loadingAreaEntity.js diff --git a/examples/dressing_room/mirroredEntity.js b/script-archive/dressing_room/mirroredEntity.js similarity index 100% rename from examples/dressing_room/mirroredEntity.js rename to script-archive/dressing_room/mirroredEntity.js diff --git a/examples/dressing_room/setupDressingRoom.js b/script-archive/dressing_room/setupDressingRoom.js similarity index 100% rename from examples/dressing_room/setupDressingRoom.js rename to script-archive/dressing_room/setupDressingRoom.js diff --git a/examples/dressing_room/wearablesManager.js b/script-archive/dressing_room/wearablesManager.js similarity index 100% rename from examples/dressing_room/wearablesManager.js rename to script-archive/dressing_room/wearablesManager.js diff --git a/examples/dropStuffNearMe.js b/script-archive/dropStuffNearMe.js similarity index 100% rename from examples/dropStuffNearMe.js rename to script-archive/dropStuffNearMe.js diff --git a/examples/drylake/createAvatarDetector.js b/script-archive/drylake/createAvatarDetector.js similarity index 100% rename from examples/drylake/createAvatarDetector.js rename to script-archive/drylake/createAvatarDetector.js diff --git a/examples/drylake/explodeHelicopter.js b/script-archive/drylake/explodeHelicopter.js similarity index 100% rename from examples/drylake/explodeHelicopter.js rename to script-archive/drylake/explodeHelicopter.js diff --git a/examples/drylake/helicopter.js b/script-archive/drylake/helicopter.js similarity index 100% rename from examples/drylake/helicopter.js rename to script-archive/drylake/helicopter.js diff --git a/examples/drylake/ratCreator.js b/script-archive/drylake/ratCreator.js similarity index 100% rename from examples/drylake/ratCreator.js rename to script-archive/drylake/ratCreator.js diff --git a/examples/drylake/ratSteer.js b/script-archive/drylake/ratSteer.js similarity index 100% rename from examples/drylake/ratSteer.js rename to script-archive/drylake/ratSteer.js diff --git a/examples/entityScripts/alternativeLightController.js b/script-archive/entityScripts/alternativeLightController.js similarity index 100% rename from examples/entityScripts/alternativeLightController.js rename to script-archive/entityScripts/alternativeLightController.js diff --git a/examples/entityScripts/boombox.js b/script-archive/entityScripts/boombox.js similarity index 100% rename from examples/entityScripts/boombox.js rename to script-archive/entityScripts/boombox.js diff --git a/examples/entityScripts/breakdanceEntity.js b/script-archive/entityScripts/breakdanceEntity.js similarity index 100% rename from examples/entityScripts/breakdanceEntity.js rename to script-archive/entityScripts/breakdanceEntity.js diff --git a/examples/entityScripts/changeColorOnCollision.js b/script-archive/entityScripts/changeColorOnCollision.js similarity index 100% rename from examples/entityScripts/changeColorOnCollision.js rename to script-archive/entityScripts/changeColorOnCollision.js diff --git a/examples/entityScripts/changeColorOnEnterLeave.js b/script-archive/entityScripts/changeColorOnEnterLeave.js similarity index 100% rename from examples/entityScripts/changeColorOnEnterLeave.js rename to script-archive/entityScripts/changeColorOnEnterLeave.js diff --git a/examples/entityScripts/changeColorOnHover.js b/script-archive/entityScripts/changeColorOnHover.js similarity index 100% rename from examples/entityScripts/changeColorOnHover.js rename to script-archive/entityScripts/changeColorOnHover.js diff --git a/examples/entityScripts/changeColorOnHoverClass.js b/script-archive/entityScripts/changeColorOnHoverClass.js similarity index 100% rename from examples/entityScripts/changeColorOnHoverClass.js rename to script-archive/entityScripts/changeColorOnHoverClass.js diff --git a/examples/entityScripts/changeColorOnTouch.js b/script-archive/entityScripts/changeColorOnTouch.js similarity index 100% rename from examples/entityScripts/changeColorOnTouch.js rename to script-archive/entityScripts/changeColorOnTouch.js diff --git a/examples/entityScripts/chessPiece.js b/script-archive/entityScripts/chessPiece.js similarity index 100% rename from examples/entityScripts/chessPiece.js rename to script-archive/entityScripts/chessPiece.js diff --git a/examples/entityScripts/crazylegsOnClick.js b/script-archive/entityScripts/crazylegsOnClick.js similarity index 100% rename from examples/entityScripts/crazylegsOnClick.js rename to script-archive/entityScripts/crazylegsOnClick.js diff --git a/examples/entityScripts/createParamsEntity.js b/script-archive/entityScripts/createParamsEntity.js similarity index 100% rename from examples/entityScripts/createParamsEntity.js rename to script-archive/entityScripts/createParamsEntity.js diff --git a/examples/entityScripts/createRecorder.js b/script-archive/entityScripts/createRecorder.js similarity index 100% rename from examples/entityScripts/createRecorder.js rename to script-archive/entityScripts/createRecorder.js diff --git a/examples/entityScripts/detectGrabExample.js b/script-archive/entityScripts/detectGrabExample.js similarity index 100% rename from examples/entityScripts/detectGrabExample.js rename to script-archive/entityScripts/detectGrabExample.js diff --git a/examples/entityScripts/detectTouchExample.js b/script-archive/entityScripts/detectTouchExample.js similarity index 100% rename from examples/entityScripts/detectTouchExample.js rename to script-archive/entityScripts/detectTouchExample.js diff --git a/examples/entityScripts/inspect.js b/script-archive/entityScripts/inspect.js similarity index 100% rename from examples/entityScripts/inspect.js rename to script-archive/entityScripts/inspect.js diff --git a/examples/entityScripts/lightController.js b/script-archive/entityScripts/lightController.js similarity index 100% rename from examples/entityScripts/lightController.js rename to script-archive/entityScripts/lightController.js diff --git a/examples/entityScripts/lightningEntity.js b/script-archive/entityScripts/lightningEntity.js similarity index 100% rename from examples/entityScripts/lightningEntity.js rename to script-archive/entityScripts/lightningEntity.js diff --git a/examples/entityScripts/messagesReceiverEntityExample.js b/script-archive/entityScripts/messagesReceiverEntityExample.js similarity index 100% rename from examples/entityScripts/messagesReceiverEntityExample.js rename to script-archive/entityScripts/messagesReceiverEntityExample.js diff --git a/examples/entityScripts/movable.js b/script-archive/entityScripts/movable.js similarity index 100% rename from examples/entityScripts/movable.js rename to script-archive/entityScripts/movable.js diff --git a/examples/entityScripts/paramsEntity.js b/script-archive/entityScripts/paramsEntity.js similarity index 100% rename from examples/entityScripts/paramsEntity.js rename to script-archive/entityScripts/paramsEntity.js diff --git a/examples/entityScripts/playSoundOnClick.js b/script-archive/entityScripts/playSoundOnClick.js similarity index 100% rename from examples/entityScripts/playSoundOnClick.js rename to script-archive/entityScripts/playSoundOnClick.js diff --git a/examples/entityScripts/playSoundOnEnterOrLeave.js b/script-archive/entityScripts/playSoundOnEnterOrLeave.js similarity index 100% rename from examples/entityScripts/playSoundOnEnterOrLeave.js rename to script-archive/entityScripts/playSoundOnEnterOrLeave.js diff --git a/examples/entityScripts/portal.js b/script-archive/entityScripts/portal.js similarity index 100% rename from examples/entityScripts/portal.js rename to script-archive/entityScripts/portal.js diff --git a/examples/entityScripts/recordingEntityScript.js b/script-archive/entityScripts/recordingEntityScript.js similarity index 100% rename from examples/entityScripts/recordingEntityScript.js rename to script-archive/entityScripts/recordingEntityScript.js diff --git a/examples/entityScripts/recordingMaster.js b/script-archive/entityScripts/recordingMaster.js similarity index 100% rename from examples/entityScripts/recordingMaster.js rename to script-archive/entityScripts/recordingMaster.js diff --git a/examples/entityScripts/sitOnEntity.js b/script-archive/entityScripts/sitOnEntity.js similarity index 100% rename from examples/entityScripts/sitOnEntity.js rename to script-archive/entityScripts/sitOnEntity.js diff --git a/examples/entityScripts/teleportOnClick.js b/script-archive/entityScripts/teleportOnClick.js similarity index 100% rename from examples/entityScripts/teleportOnClick.js rename to script-archive/entityScripts/teleportOnClick.js diff --git a/examples/entityScripts/virtualBaton/batonSimpleEntityScript.js b/script-archive/entityScripts/virtualBaton/batonSimpleEntityScript.js similarity index 100% rename from examples/entityScripts/virtualBaton/batonSimpleEntityScript.js rename to script-archive/entityScripts/virtualBaton/batonSimpleEntityScript.js diff --git a/examples/entityScripts/virtualBaton/batonSimpleEntitySpawner.js b/script-archive/entityScripts/virtualBaton/batonSimpleEntitySpawner.js similarity index 100% rename from examples/entityScripts/virtualBaton/batonSimpleEntitySpawner.js rename to script-archive/entityScripts/virtualBaton/batonSimpleEntitySpawner.js diff --git a/examples/example/assetsExample.js b/script-archive/example/assetsExample.js similarity index 100% rename from examples/example/assetsExample.js rename to script-archive/example/assetsExample.js diff --git a/examples/example/audio/audioBall.js b/script-archive/example/audio/audioBall.js similarity index 100% rename from examples/example/audio/audioBall.js rename to script-archive/example/audio/audioBall.js diff --git a/examples/example/audio/audioDeviceExample.js b/script-archive/example/audio/audioDeviceExample.js similarity index 100% rename from examples/example/audio/audioDeviceExample.js rename to script-archive/example/audio/audioDeviceExample.js diff --git a/examples/example/audio/audioMuteExample.js b/script-archive/example/audio/audioMuteExample.js similarity index 100% rename from examples/example/audio/audioMuteExample.js rename to script-archive/example/audio/audioMuteExample.js diff --git a/examples/example/audio/audioReverbOn.js b/script-archive/example/audio/audioReverbOn.js similarity index 100% rename from examples/example/audio/audioReverbOn.js rename to script-archive/example/audio/audioReverbOn.js diff --git a/examples/example/audio/birdSongs.js b/script-archive/example/audio/birdSongs.js similarity index 100% rename from examples/example/audio/birdSongs.js rename to script-archive/example/audio/birdSongs.js diff --git a/examples/example/audio/jsstreamplayer.js b/script-archive/example/audio/jsstreamplayer.js similarity index 100% rename from examples/example/audio/jsstreamplayer.js rename to script-archive/example/audio/jsstreamplayer.js diff --git a/examples/example/audio/largeHall.js b/script-archive/example/audio/largeHall.js similarity index 100% rename from examples/example/audio/largeHall.js rename to script-archive/example/audio/largeHall.js diff --git a/examples/example/audio/radio.js b/script-archive/example/audio/radio.js similarity index 100% rename from examples/example/audio/radio.js rename to script-archive/example/audio/radio.js diff --git a/examples/example/audio/smallRoom.js b/script-archive/example/audio/smallRoom.js similarity index 100% rename from examples/example/audio/smallRoom.js rename to script-archive/example/audio/smallRoom.js diff --git a/examples/example/audio/speechControl.js b/script-archive/example/audio/speechControl.js similarity index 100% rename from examples/example/audio/speechControl.js rename to script-archive/example/audio/speechControl.js diff --git a/examples/example/avatarcontrol/cameraExample.js b/script-archive/example/avatarcontrol/cameraExample.js similarity index 100% rename from examples/example/avatarcontrol/cameraExample.js rename to script-archive/example/avatarcontrol/cameraExample.js diff --git a/examples/example/avatarcontrol/controllerExample.js b/script-archive/example/avatarcontrol/controllerExample.js similarity index 100% rename from examples/example/avatarcontrol/controllerExample.js rename to script-archive/example/avatarcontrol/controllerExample.js diff --git a/examples/example/avatarcontrol/graspHands.js b/script-archive/example/avatarcontrol/graspHands.js similarity index 100% rename from examples/example/avatarcontrol/graspHands.js rename to script-archive/example/avatarcontrol/graspHands.js diff --git a/examples/example/avatarcontrol/guidedTour.js b/script-archive/example/avatarcontrol/guidedTour.js similarity index 100% rename from examples/example/avatarcontrol/guidedTour.js rename to script-archive/example/avatarcontrol/guidedTour.js diff --git a/examples/example/avatarcontrol/handControlledHead.js b/script-archive/example/avatarcontrol/handControlledHead.js similarity index 100% rename from examples/example/avatarcontrol/handControlledHead.js rename to script-archive/example/avatarcontrol/handControlledHead.js diff --git a/examples/example/avatarcontrol/hideAvatarExample.js b/script-archive/example/avatarcontrol/hideAvatarExample.js similarity index 100% rename from examples/example/avatarcontrol/hideAvatarExample.js rename to script-archive/example/avatarcontrol/hideAvatarExample.js diff --git a/examples/example/avatarcontrol/lookAtExample.js b/script-archive/example/avatarcontrol/lookAtExample.js similarity index 100% rename from examples/example/avatarcontrol/lookAtExample.js rename to script-archive/example/avatarcontrol/lookAtExample.js diff --git a/examples/example/avatarcontrol/multipleCursorsExample.js b/script-archive/example/avatarcontrol/multipleCursorsExample.js similarity index 100% rename from examples/example/avatarcontrol/multipleCursorsExample.js rename to script-archive/example/avatarcontrol/multipleCursorsExample.js diff --git a/examples/example/avatarcontrol/multitouchExample.js b/script-archive/example/avatarcontrol/multitouchExample.js similarity index 100% rename from examples/example/avatarcontrol/multitouchExample.js rename to script-archive/example/avatarcontrol/multitouchExample.js diff --git a/examples/example/brownianFun.js b/script-archive/example/brownianFun.js similarity index 100% rename from examples/example/brownianFun.js rename to script-archive/example/brownianFun.js diff --git a/examples/example/downloadInfoExample.js b/script-archive/example/downloadInfoExample.js similarity index 100% rename from examples/example/downloadInfoExample.js rename to script-archive/example/downloadInfoExample.js diff --git a/examples/example/dynamicLandscape.js b/script-archive/example/dynamicLandscape.js similarity index 100% rename from examples/example/dynamicLandscape.js rename to script-archive/example/dynamicLandscape.js diff --git a/examples/example/entities/ZZZ-MOVE-TO_DOCS-animationStateExample.js b/script-archive/example/entities/ZZZ-MOVE-TO_DOCS-animationStateExample.js similarity index 100% rename from examples/example/entities/ZZZ-MOVE-TO_DOCS-animationStateExample.js rename to script-archive/example/entities/ZZZ-MOVE-TO_DOCS-animationStateExample.js diff --git a/examples/example/entities/animatedModelExample.js b/script-archive/example/entities/animatedModelExample.js similarity index 100% rename from examples/example/entities/animatedModelExample.js rename to script-archive/example/entities/animatedModelExample.js diff --git a/examples/example/entities/collidingEntities.js b/script-archive/example/entities/collidingEntities.js similarity index 100% rename from examples/example/entities/collidingEntities.js rename to script-archive/example/entities/collidingEntities.js diff --git a/examples/example/entities/editEntityExample.js b/script-archive/example/entities/editEntityExample.js similarity index 100% rename from examples/example/entities/editEntityExample.js rename to script-archive/example/entities/editEntityExample.js diff --git a/examples/example/entities/editModelExample.js b/script-archive/example/entities/editModelExample.js similarity index 100% rename from examples/example/entities/editModelExample.js rename to script-archive/example/entities/editModelExample.js diff --git a/examples/example/entities/entityModelExample.js b/script-archive/example/entities/entityModelExample.js similarity index 100% rename from examples/example/entities/entityModelExample.js rename to script-archive/example/entities/entityModelExample.js diff --git a/examples/example/entities/findEntitiesExample.js b/script-archive/example/entities/findEntitiesExample.js similarity index 100% rename from examples/example/entities/findEntitiesExample.js rename to script-archive/example/entities/findEntitiesExample.js diff --git a/examples/example/entities/flockingBirds.js b/script-archive/example/entities/flockingBirds.js similarity index 100% rename from examples/example/entities/flockingBirds.js rename to script-archive/example/entities/flockingBirds.js diff --git a/examples/example/entities/fullDomainZoneEntityExample.js b/script-archive/example/entities/fullDomainZoneEntityExample.js similarity index 100% rename from examples/example/entities/fullDomainZoneEntityExample.js rename to script-archive/example/entities/fullDomainZoneEntityExample.js diff --git a/examples/example/entities/jsstreamplayerdomain-zone-entity.js b/script-archive/example/entities/jsstreamplayerdomain-zone-entity.js similarity index 100% rename from examples/example/entities/jsstreamplayerdomain-zone-entity.js rename to script-archive/example/entities/jsstreamplayerdomain-zone-entity.js diff --git a/examples/example/entities/lightExample.js b/script-archive/example/entities/lightExample.js similarity index 100% rename from examples/example/entities/lightExample.js rename to script-archive/example/entities/lightExample.js diff --git a/examples/example/entities/makeHouses.js b/script-archive/example/entities/makeHouses.js similarity index 100% rename from examples/example/entities/makeHouses.js rename to script-archive/example/entities/makeHouses.js diff --git a/examples/example/entities/particlesTest.js b/script-archive/example/entities/particlesTest.js similarity index 100% rename from examples/example/entities/particlesTest.js rename to script-archive/example/entities/particlesTest.js diff --git a/examples/example/entities/platform.js b/script-archive/example/entities/platform.js similarity index 100% rename from examples/example/entities/platform.js rename to script-archive/example/entities/platform.js diff --git a/examples/example/entities/rideAlongWithAnEntityExample.js b/script-archive/example/entities/rideAlongWithAnEntityExample.js similarity index 100% rename from examples/example/entities/rideAlongWithAnEntityExample.js rename to script-archive/example/entities/rideAlongWithAnEntityExample.js diff --git a/examples/example/entities/spotlightExample.js b/script-archive/example/entities/spotlightExample.js similarity index 100% rename from examples/example/entities/spotlightExample.js rename to script-archive/example/entities/spotlightExample.js diff --git a/examples/example/entities/zoneEntityExample.js b/script-archive/example/entities/zoneEntityExample.js similarity index 100% rename from examples/example/entities/zoneEntityExample.js rename to script-archive/example/entities/zoneEntityExample.js diff --git a/examples/example/entities/zoneSkyboxExample.js b/script-archive/example/entities/zoneSkyboxExample.js similarity index 100% rename from examples/example/entities/zoneSkyboxExample.js rename to script-archive/example/entities/zoneSkyboxExample.js diff --git a/examples/example/entityCollisionExample.js b/script-archive/example/entityCollisionExample.js similarity index 100% rename from examples/example/entityCollisionExample.js rename to script-archive/example/entityCollisionExample.js diff --git a/examples/example/games/airHockey.js b/script-archive/example/games/airHockey.js similarity index 100% rename from examples/example/games/airHockey.js rename to script-archive/example/games/airHockey.js diff --git a/examples/example/games/billiards.js b/script-archive/example/games/billiards.js similarity index 100% rename from examples/example/games/billiards.js rename to script-archive/example/games/billiards.js diff --git a/examples/example/games/cleanupChessboards.js b/script-archive/example/games/cleanupChessboards.js similarity index 100% rename from examples/example/games/cleanupChessboards.js rename to script-archive/example/games/cleanupChessboards.js diff --git a/examples/example/games/clonedOverlaysExample.js b/script-archive/example/games/clonedOverlaysExample.js similarity index 100% rename from examples/example/games/clonedOverlaysExample.js rename to script-archive/example/games/clonedOverlaysExample.js diff --git a/examples/example/games/color_busters/colorBusterWand.js b/script-archive/example/games/color_busters/colorBusterWand.js similarity index 100% rename from examples/example/games/color_busters/colorBusterWand.js rename to script-archive/example/games/color_busters/colorBusterWand.js diff --git a/examples/example/games/color_busters/createColorBusterCubes.js b/script-archive/example/games/color_busters/createColorBusterCubes.js similarity index 100% rename from examples/example/games/color_busters/createColorBusterCubes.js rename to script-archive/example/games/color_busters/createColorBusterCubes.js diff --git a/examples/example/games/color_busters/createColorBusterWand.js b/script-archive/example/games/color_busters/createColorBusterWand.js similarity index 100% rename from examples/example/games/color_busters/createColorBusterWand.js rename to script-archive/example/games/color_busters/createColorBusterWand.js diff --git a/examples/example/games/exterminatorGame/gameServer/.gitignore b/script-archive/example/games/exterminatorGame/gameServer/.gitignore similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/.gitignore rename to script-archive/example/games/exterminatorGame/gameServer/.gitignore diff --git a/examples/example/games/exterminatorGame/gameServer/Procfile b/script-archive/example/games/exterminatorGame/gameServer/Procfile similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/Procfile rename to script-archive/example/games/exterminatorGame/gameServer/Procfile diff --git a/examples/example/games/exterminatorGame/gameServer/README.txt b/script-archive/example/games/exterminatorGame/gameServer/README.txt similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/README.txt rename to script-archive/example/games/exterminatorGame/gameServer/README.txt diff --git a/examples/example/games/exterminatorGame/gameServer/app.js b/script-archive/example/games/exterminatorGame/gameServer/app.js similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/app.js rename to script-archive/example/games/exterminatorGame/gameServer/app.js diff --git a/examples/example/games/exterminatorGame/gameServer/client/app.jsx b/script-archive/example/games/exterminatorGame/gameServer/client/app.jsx similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/client/app.jsx rename to script-archive/example/games/exterminatorGame/gameServer/client/app.jsx diff --git a/examples/example/games/exterminatorGame/gameServer/gulpfile.js b/script-archive/example/games/exterminatorGame/gameServer/gulpfile.js similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/gulpfile.js rename to script-archive/example/games/exterminatorGame/gameServer/gulpfile.js diff --git a/examples/example/games/exterminatorGame/gameServer/package.json b/script-archive/example/games/exterminatorGame/gameServer/package.json similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/package.json rename to script-archive/example/games/exterminatorGame/gameServer/package.json diff --git a/examples/example/games/exterminatorGame/gameServer/public/css/style.css b/script-archive/example/games/exterminatorGame/gameServer/public/css/style.css similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/public/css/style.css rename to script-archive/example/games/exterminatorGame/gameServer/public/css/style.css diff --git a/examples/example/games/exterminatorGame/gameServer/public/index.html b/script-archive/example/games/exterminatorGame/gameServer/public/index.html similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/public/index.html rename to script-archive/example/games/exterminatorGame/gameServer/public/index.html diff --git a/examples/example/games/exterminatorGame/gameServer/public/js/app.js b/script-archive/example/games/exterminatorGame/gameServer/public/js/app.js similarity index 100% rename from examples/example/games/exterminatorGame/gameServer/public/js/app.js rename to script-archive/example/games/exterminatorGame/gameServer/public/js/app.js diff --git a/examples/example/games/exterminatorGame/pistolScriptSpawnerSpawner.js b/script-archive/example/games/exterminatorGame/pistolScriptSpawnerSpawner.js similarity index 100% rename from examples/example/games/exterminatorGame/pistolScriptSpawnerSpawner.js rename to script-archive/example/games/exterminatorGame/pistolScriptSpawnerSpawner.js diff --git a/examples/example/games/grabHockey.js b/script-archive/example/games/grabHockey.js similarity index 100% rename from examples/example/games/grabHockey.js rename to script-archive/example/games/grabHockey.js diff --git a/examples/example/games/hitEffect.js b/script-archive/example/games/hitEffect.js similarity index 100% rename from examples/example/games/hitEffect.js rename to script-archive/example/games/hitEffect.js diff --git a/examples/example/games/hydraGrabHockey.js b/script-archive/example/games/hydraGrabHockey.js similarity index 100% rename from examples/example/games/hydraGrabHockey.js rename to script-archive/example/games/hydraGrabHockey.js diff --git a/examples/example/games/make-dummy.js b/script-archive/example/games/make-dummy.js similarity index 100% rename from examples/example/games/make-dummy.js rename to script-archive/example/games/make-dummy.js diff --git a/examples/example/games/planky.js b/script-archive/example/games/planky.js similarity index 94% rename from examples/example/games/planky.js rename to script-archive/example/games/planky.js index 22388eba47..742cc3b7d0 100644 --- a/examples/example/games/planky.js +++ b/script-archive/example/games/planky.js @@ -10,9 +10,9 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; +HIFI_PUBLIC_BUCKET = 'http://s3.amazonaws.com/hifi-public/'; -Script.include("../../libraries/toolBars.js"); +Script.include('../../libraries/toolBars.js'); const DEFAULT_NUM_LAYERS = 16; const DEFAULT_BASE_DIMENSION = { x: 7, y: 2, z: 7 }; @@ -30,6 +30,8 @@ const DEFAULT_RESTITUTION = 0.0; const DEFAULT_SPAWN_DISTANCE = 3; const DEFAULT_BLOCK_YAW_OFFSET = 45; +const PLANKY_LIFETIME = 3600; // 1 hour (3600 seconds) + var editMode = false; const BUTTON_DIMENSIONS = {width: 49, height: 49}; @@ -51,13 +53,17 @@ SettingsWindow = function() { this.plankyStack = null; this.webWindow = null; this.init = function(plankyStack) { - _this.webWindow = new OverlayWebWindow('Planky', Script.resolvePath('../../html/plankySettings.html'), 255, 500, true); + _this.webWindow = new OverlayWebWindow({ + title: 'Planky', + source: Script.resolvePath('../../html/plankySettings.html'), + toolWindow: true + }); _this.webWindow.setVisible(false); - _this.webWindow.eventBridge.webEventReceived.connect(_this.onWebEventReceived); + _this.webWindow.webEventReceived.connect(_this.onWebEventReceived); _this.plankyStack = plankyStack; }; this.sendData = function(data) { - _this.webWindow.eventBridge.emitScriptEvent(JSON.stringify(data)); + _this.webWindow.emitScriptEvent(JSON.stringify(data)); }; this.onWebEventReceived = function(data) { data = JSON.parse(data); @@ -188,7 +194,8 @@ PlankyStack = function() { dimensions: _this.options.baseDimension, position: Vec3.sum(_this.basePosition, {y: -(_this.options.baseDimension.y / 2)}), rotation: _this.baseRotation, - shapeType: 'box' + shapeType: 'box', + lifetime: PLANKY_LIFETIME }); return; } @@ -254,7 +261,8 @@ PlankyStack = function() { density: _this.options.density, velocity: {x: 0, y: 0, z: 0}, angularVelocity: Quat.fromPitchYawRollDegrees(0, 0, 0), - collisionless: true + collisionless: true, + lifetime: PLANKY_LIFETIME }; _this.planks.forEach(function(plank, index, object) { if (plank.layer === layer && plank.row === row) { @@ -304,6 +312,7 @@ var settingsWindow = new SettingsWindow(); var plankyStack = new PlankyStack(); settingsWindow.init(plankyStack); +// This function is used to get the ideal y-location for a floor function grabLowestJointY() { var jointNames = MyAvatar.getJointNames(); var floorY = MyAvatar.position.y; diff --git a/examples/example/games/playChess.js b/script-archive/example/games/playChess.js similarity index 100% rename from examples/example/games/playChess.js rename to script-archive/example/games/playChess.js diff --git a/examples/example/games/satellite.js b/script-archive/example/games/satellite.js similarity index 100% rename from examples/example/games/satellite.js rename to script-archive/example/games/satellite.js diff --git a/examples/example/games/spaceInvadersExample.js b/script-archive/example/games/spaceInvadersExample.js similarity index 100% rename from examples/example/games/spaceInvadersExample.js rename to script-archive/example/games/spaceInvadersExample.js diff --git a/examples/example/games/sword.js b/script-archive/example/games/sword.js similarity index 100% rename from examples/example/games/sword.js rename to script-archive/example/games/sword.js diff --git a/examples/example/globalCollisionsExample.js b/script-archive/example/globalCollisionsExample.js similarity index 100% rename from examples/example/globalCollisionsExample.js rename to script-archive/example/globalCollisionsExample.js diff --git a/examples/example/hmd/colorCube.fs b/script-archive/example/hmd/colorCube.fs similarity index 100% rename from examples/example/hmd/colorCube.fs rename to script-archive/example/hmd/colorCube.fs diff --git a/examples/example/hmd/colorCube.js b/script-archive/example/hmd/colorCube.js similarity index 100% rename from examples/example/hmd/colorCube.js rename to script-archive/example/hmd/colorCube.js diff --git a/examples/example/hmd/ipdScalingTest.js b/script-archive/example/hmd/ipdScalingTest.js similarity index 100% rename from examples/example/hmd/ipdScalingTest.js rename to script-archive/example/hmd/ipdScalingTest.js diff --git a/examples/example/hmd/pickerTest.js b/script-archive/example/hmd/pickerTest.js similarity index 100% rename from examples/example/hmd/pickerTest.js rename to script-archive/example/hmd/pickerTest.js diff --git a/examples/example/lineExample.js b/script-archive/example/lineExample.js similarity index 100% rename from examples/example/lineExample.js rename to script-archive/example/lineExample.js diff --git a/examples/example/messages/messagesExample.js b/script-archive/example/messages/messagesExample.js similarity index 100% rename from examples/example/messages/messagesExample.js rename to script-archive/example/messages/messagesExample.js diff --git a/examples/example/messages/messagesReceiverExample.js b/script-archive/example/messages/messagesReceiverExample.js similarity index 100% rename from examples/example/messages/messagesReceiverExample.js rename to script-archive/example/messages/messagesReceiverExample.js diff --git a/examples/example/messages/messagesTestReceive.js b/script-archive/example/messages/messagesTestReceive.js similarity index 100% rename from examples/example/messages/messagesTestReceive.js rename to script-archive/example/messages/messagesTestReceive.js diff --git a/examples/example/messages/messagesTestSend.js b/script-archive/example/messages/messagesTestSend.js similarity index 100% rename from examples/example/messages/messagesTestSend.js rename to script-archive/example/messages/messagesTestSend.js diff --git a/examples/example/misc/collectHifiStats.js b/script-archive/example/misc/collectHifiStats.js similarity index 100% rename from examples/example/misc/collectHifiStats.js rename to script-archive/example/misc/collectHifiStats.js diff --git a/examples/example/misc/listAllScripts.js b/script-archive/example/misc/listAllScripts.js similarity index 100% rename from examples/example/misc/listAllScripts.js rename to script-archive/example/misc/listAllScripts.js diff --git a/examples/example/misc/statsExample.js b/script-archive/example/misc/statsExample.js similarity index 100% rename from examples/example/misc/statsExample.js rename to script-archive/example/misc/statsExample.js diff --git a/examples/example/misc/sunLightExample.js b/script-archive/example/misc/sunLightExample.js similarity index 100% rename from examples/example/misc/sunLightExample.js rename to script-archive/example/misc/sunLightExample.js diff --git a/examples/example/painting/hydraPaint.js b/script-archive/example/painting/hydraPaint.js similarity index 100% rename from examples/example/painting/hydraPaint.js rename to script-archive/example/painting/hydraPaint.js diff --git a/examples/example/painting/mousePaint.js b/script-archive/example/painting/mousePaint.js similarity index 100% rename from examples/example/painting/mousePaint.js rename to script-archive/example/painting/mousePaint.js diff --git a/examples/example/planets-ui.js b/script-archive/example/planets-ui.js similarity index 100% rename from examples/example/planets-ui.js rename to script-archive/example/planets-ui.js diff --git a/examples/example/scripts/controllerScriptingExamples.js b/script-archive/example/scripts/controllerScriptingExamples.js similarity index 100% rename from examples/example/scripts/controllerScriptingExamples.js rename to script-archive/example/scripts/controllerScriptingExamples.js diff --git a/examples/example/scripts/includeExample.js b/script-archive/example/scripts/includeExample.js similarity index 100% rename from examples/example/scripts/includeExample.js rename to script-archive/example/scripts/includeExample.js diff --git a/examples/example/scripts/locationExample.js b/script-archive/example/scripts/locationExample.js similarity index 100% rename from examples/example/scripts/locationExample.js rename to script-archive/example/scripts/locationExample.js diff --git a/examples/example/scripts/rayPickExample.js b/script-archive/example/scripts/rayPickExample.js similarity index 100% rename from examples/example/scripts/rayPickExample.js rename to script-archive/example/scripts/rayPickExample.js diff --git a/examples/example/scripts/settingsExample.js b/script-archive/example/scripts/settingsExample.js similarity index 100% rename from examples/example/scripts/settingsExample.js rename to script-archive/example/scripts/settingsExample.js diff --git a/examples/example/scripts/streetAreaExample.js b/script-archive/example/scripts/streetAreaExample.js similarity index 100% rename from examples/example/scripts/streetAreaExample.js rename to script-archive/example/scripts/streetAreaExample.js diff --git a/examples/example/scripts/timer.js b/script-archive/example/scripts/timer.js similarity index 100% rename from examples/example/scripts/timer.js rename to script-archive/example/scripts/timer.js diff --git a/examples/example/securityCamera.js b/script-archive/example/securityCamera.js similarity index 100% rename from examples/example/securityCamera.js rename to script-archive/example/securityCamera.js diff --git a/examples/example/solarsystem.js b/script-archive/example/solarsystem.js similarity index 100% rename from examples/example/solarsystem.js rename to script-archive/example/solarsystem.js diff --git a/examples/example/soundToys.js b/script-archive/example/soundToys.js similarity index 100% rename from examples/example/soundToys.js rename to script-archive/example/soundToys.js diff --git a/examples/example/tests/test-includes/a.js b/script-archive/example/tests/test-includes/a.js similarity index 100% rename from examples/example/tests/test-includes/a.js rename to script-archive/example/tests/test-includes/a.js diff --git a/examples/example/tests/test-includes/b.js b/script-archive/example/tests/test-includes/b.js similarity index 100% rename from examples/example/tests/test-includes/b.js rename to script-archive/example/tests/test-includes/b.js diff --git a/examples/example/tests/test-includes/start.js b/script-archive/example/tests/test-includes/start.js similarity index 100% rename from examples/example/tests/test-includes/start.js rename to script-archive/example/tests/test-includes/start.js diff --git a/examples/example/ui/LODManagerExample.js b/script-archive/example/ui/LODManagerExample.js similarity index 100% rename from examples/example/ui/LODManagerExample.js rename to script-archive/example/ui/LODManagerExample.js diff --git a/examples/example/ui/MyEnergyBar.js b/script-archive/example/ui/MyEnergyBar.js similarity index 100% rename from examples/example/ui/MyEnergyBar.js rename to script-archive/example/ui/MyEnergyBar.js diff --git a/examples/example/ui/dialogExample.js b/script-archive/example/ui/dialogExample.js similarity index 100% rename from examples/example/ui/dialogExample.js rename to script-archive/example/ui/dialogExample.js diff --git a/examples/example/ui/energyBar.js b/script-archive/example/ui/energyBar.js similarity index 100% rename from examples/example/ui/energyBar.js rename to script-archive/example/ui/energyBar.js diff --git a/examples/example/ui/fileBrowserExample.js b/script-archive/example/ui/fileBrowserExample.js similarity index 100% rename from examples/example/ui/fileBrowserExample.js rename to script-archive/example/ui/fileBrowserExample.js diff --git a/examples/example/ui/menuExample.js b/script-archive/example/ui/menuExample.js similarity index 100% rename from examples/example/ui/menuExample.js rename to script-archive/example/ui/menuExample.js diff --git a/examples/example/ui/overlayPanelExample.js b/script-archive/example/ui/overlayPanelExample.js similarity index 100% rename from examples/example/ui/overlayPanelExample.js rename to script-archive/example/ui/overlayPanelExample.js diff --git a/examples/example/ui/overlaysExample.js b/script-archive/example/ui/overlaysExample.js similarity index 100% rename from examples/example/ui/overlaysExample.js rename to script-archive/example/ui/overlaysExample.js diff --git a/examples/example/ui/textInputOverlayExample.js b/script-archive/example/ui/textInputOverlayExample.js similarity index 100% rename from examples/example/ui/textInputOverlayExample.js rename to script-archive/example/ui/textInputOverlayExample.js diff --git a/examples/example/ui/windowExample.js b/script-archive/example/ui/windowExample.js similarity index 100% rename from examples/example/ui/windowExample.js rename to script-archive/example/ui/windowExample.js diff --git a/examples/example/widgets-example.js b/script-archive/example/widgets-example.js similarity index 100% rename from examples/example/widgets-example.js rename to script-archive/example/widgets-example.js diff --git a/examples/faceBlendCoefficients.js b/script-archive/faceBlendCoefficients.js similarity index 100% rename from examples/faceBlendCoefficients.js rename to script-archive/faceBlendCoefficients.js diff --git a/examples/fireflies/firefly.js b/script-archive/fireflies/firefly.js similarity index 100% rename from examples/fireflies/firefly.js rename to script-archive/fireflies/firefly.js diff --git a/examples/fireflies/makeFireflies.js b/script-archive/fireflies/makeFireflies.js similarity index 100% rename from examples/fireflies/makeFireflies.js rename to script-archive/fireflies/makeFireflies.js diff --git a/examples/fireworks.js b/script-archive/fireworks.js similarity index 100% rename from examples/fireworks.js rename to script-archive/fireworks.js diff --git a/examples/flowArts/arcBall/arcBall.js b/script-archive/flowArts/arcBall/arcBall.js similarity index 100% rename from examples/flowArts/arcBall/arcBall.js rename to script-archive/flowArts/arcBall/arcBall.js diff --git a/examples/flowArts/arcBall/arcBallEntityScript.js b/script-archive/flowArts/arcBall/arcBallEntityScript.js similarity index 100% rename from examples/flowArts/arcBall/arcBallEntityScript.js rename to script-archive/flowArts/arcBall/arcBallEntityScript.js diff --git a/examples/flowArts/flowArtsHutSpawner.js b/script-archive/flowArts/flowArtsHutSpawner.js similarity index 100% rename from examples/flowArts/flowArtsHutSpawner.js rename to script-archive/flowArts/flowArtsHutSpawner.js diff --git a/examples/flowArts/lightBall/lightBall.js b/script-archive/flowArts/lightBall/lightBall.js similarity index 100% rename from examples/flowArts/lightBall/lightBall.js rename to script-archive/flowArts/lightBall/lightBall.js diff --git a/examples/flowArts/lightSaber/lightSaber.js b/script-archive/flowArts/lightSaber/lightSaber.js similarity index 100% rename from examples/flowArts/lightSaber/lightSaber.js rename to script-archive/flowArts/lightSaber/lightSaber.js diff --git a/examples/flowArts/lightSaber/lightSaberEntityScript.js b/script-archive/flowArts/lightSaber/lightSaberEntityScript.js similarity index 100% rename from examples/flowArts/lightSaber/lightSaberEntityScript.js rename to script-archive/flowArts/lightSaber/lightSaberEntityScript.js diff --git a/examples/flowArts/lightTrails.js b/script-archive/flowArts/lightTrails.js similarity index 100% rename from examples/flowArts/lightTrails.js rename to script-archive/flowArts/lightTrails.js diff --git a/examples/flowArts/raveStick/raveStick.js b/script-archive/flowArts/raveStick/raveStick.js similarity index 100% rename from examples/flowArts/raveStick/raveStick.js rename to script-archive/flowArts/raveStick/raveStick.js diff --git a/examples/flowArts/raveStick/raveStickEntityScript.js b/script-archive/flowArts/raveStick/raveStickEntityScript.js similarity index 100% rename from examples/flowArts/raveStick/raveStickEntityScript.js rename to script-archive/flowArts/raveStick/raveStickEntityScript.js diff --git a/examples/golfclub/golfClub.js b/script-archive/golfclub/golfClub.js similarity index 100% rename from examples/golfclub/golfClub.js rename to script-archive/golfclub/golfClub.js diff --git a/examples/golfclub/golfClub.json b/script-archive/golfclub/golfClub.json similarity index 100% rename from examples/golfclub/golfClub.json rename to script-archive/golfclub/golfClub.json diff --git a/examples/gracefulControls.js b/script-archive/gracefulControls.js similarity index 100% rename from examples/gracefulControls.js rename to script-archive/gracefulControls.js diff --git a/examples/grenade.js b/script-archive/grenade.js similarity index 100% rename from examples/grenade.js rename to script-archive/grenade.js diff --git a/examples/gridTest.js b/script-archive/gridTest.js similarity index 100% rename from examples/gridTest.js rename to script-archive/gridTest.js diff --git a/examples/growth.js b/script-archive/growth.js similarity index 100% rename from examples/growth.js rename to script-archive/growth.js diff --git a/examples/harmonicOscillator.js b/script-archive/harmonicOscillator.js similarity index 100% rename from examples/harmonicOscillator.js rename to script-archive/harmonicOscillator.js diff --git a/examples/headMove.js b/script-archive/headMove.js similarity index 100% rename from examples/headMove.js rename to script-archive/headMove.js diff --git a/examples/homeContent/whiteboardV2/eraserEntityScript.js b/script-archive/homeContent/whiteboardV2/eraserEntityScript.js similarity index 100% rename from examples/homeContent/whiteboardV2/eraserEntityScript.js rename to script-archive/homeContent/whiteboardV2/eraserEntityScript.js diff --git a/examples/homeContent/whiteboardV2/markerEntityScript.js b/script-archive/homeContent/whiteboardV2/markerEntityScript.js similarity index 100% rename from examples/homeContent/whiteboardV2/markerEntityScript.js rename to script-archive/homeContent/whiteboardV2/markerEntityScript.js diff --git a/examples/homeContent/whiteboardV2/whiteboardSpawner.js b/script-archive/homeContent/whiteboardV2/whiteboardSpawner.js similarity index 100% rename from examples/homeContent/whiteboardV2/whiteboardSpawner.js rename to script-archive/homeContent/whiteboardV2/whiteboardSpawner.js diff --git a/examples/hotPlaces.js b/script-archive/hotPlaces.js similarity index 100% rename from examples/hotPlaces.js rename to script-archive/hotPlaces.js diff --git a/examples/html/jsstreamplayer.html b/script-archive/html/jsstreamplayer.html similarity index 100% rename from examples/html/jsstreamplayer.html rename to script-archive/html/jsstreamplayer.html diff --git a/examples/html/magBalls/addMode.html b/script-archive/html/magBalls/addMode.html similarity index 100% rename from examples/html/magBalls/addMode.html rename to script-archive/html/magBalls/addMode.html diff --git a/examples/html/magBalls/deleteMode.html b/script-archive/html/magBalls/deleteMode.html similarity index 100% rename from examples/html/magBalls/deleteMode.html rename to script-archive/html/magBalls/deleteMode.html diff --git a/examples/html/magBalls/magBalls.css b/script-archive/html/magBalls/magBalls.css similarity index 100% rename from examples/html/magBalls/magBalls.css rename to script-archive/html/magBalls/magBalls.css diff --git a/examples/html/magBalls/moveMode.html b/script-archive/html/magBalls/moveMode.html similarity index 100% rename from examples/html/magBalls/moveMode.html rename to script-archive/html/magBalls/moveMode.html diff --git a/examples/html/plankySettings.html b/script-archive/html/plankySettings.html similarity index 93% rename from examples/html/plankySettings.html rename to script-archive/html/plankySettings.html index 0eea4948ad..836d5454b6 100644 --- a/examples/html/plankySettings.html +++ b/script-archive/html/plankySettings.html @@ -3,11 +3,15 @@ + +
- \ No newline at end of file + diff --git a/examples/html/qmlWebTest.html b/script-archive/html/qmlWebTest.html similarity index 100% rename from examples/html/qmlWebTest.html rename to script-archive/html/qmlWebTest.html diff --git a/examples/html/spinButtons.js b/script-archive/html/spinButtons.js similarity index 100% rename from examples/html/spinButtons.js rename to script-archive/html/spinButtons.js diff --git a/examples/html/style.css b/script-archive/html/style.css similarity index 100% rename from examples/html/style.css rename to script-archive/html/style.css diff --git a/examples/html/walkSettings.html b/script-archive/html/walkSettings.html similarity index 100% rename from examples/html/walkSettings.html rename to script-archive/html/walkSettings.html diff --git a/examples/html/walkStyle.css b/script-archive/html/walkStyle.css similarity index 100% rename from examples/html/walkStyle.css rename to script-archive/html/walkStyle.css diff --git a/examples/inspect.js b/script-archive/inspect.js similarity index 100% rename from examples/inspect.js rename to script-archive/inspect.js diff --git a/examples/junkyard/junkyardClientReset.js b/script-archive/junkyard/junkyardClientReset.js similarity index 100% rename from examples/junkyard/junkyardClientReset.js rename to script-archive/junkyard/junkyardClientReset.js diff --git a/examples/junkyard/junkyardResetEntityScript.js b/script-archive/junkyard/junkyardResetEntityScript.js similarity index 100% rename from examples/junkyard/junkyardResetEntityScript.js rename to script-archive/junkyard/junkyardResetEntityScript.js diff --git a/examples/junkyard/junkyardResetEntitySpawner.js b/script-archive/junkyard/junkyardResetEntitySpawner.js similarity index 100% rename from examples/junkyard/junkyardResetEntitySpawner.js rename to script-archive/junkyard/junkyardResetEntitySpawner.js diff --git a/examples/kneel.js b/script-archive/kneel.js similarity index 100% rename from examples/kneel.js rename to script-archive/kneel.js diff --git a/examples/leaves.js b/script-archive/leaves.js similarity index 100% rename from examples/leaves.js rename to script-archive/leaves.js diff --git a/examples/libraries/avatarRelativeOverlays.js b/script-archive/libraries/avatarRelativeOverlays.js similarity index 100% rename from examples/libraries/avatarRelativeOverlays.js rename to script-archive/libraries/avatarRelativeOverlays.js diff --git a/examples/libraries/constants.js b/script-archive/libraries/constants.js similarity index 100% rename from examples/libraries/constants.js rename to script-archive/libraries/constants.js diff --git a/examples/libraries/easyStar.js b/script-archive/libraries/easyStar.js similarity index 100% rename from examples/libraries/easyStar.js rename to script-archive/libraries/easyStar.js diff --git a/examples/libraries/easyStarExample.js b/script-archive/libraries/easyStarExample.js similarity index 100% rename from examples/libraries/easyStarExample.js rename to script-archive/libraries/easyStarExample.js diff --git a/examples/libraries/fjs.js b/script-archive/libraries/fjs.js similarity index 100% rename from examples/libraries/fjs.js rename to script-archive/libraries/fjs.js diff --git a/examples/libraries/fjsExample.js b/script-archive/libraries/fjsExample.js similarity index 100% rename from examples/libraries/fjsExample.js rename to script-archive/libraries/fjsExample.js diff --git a/examples/libraries/highlighter.js b/script-archive/libraries/highlighter.js similarity index 100% rename from examples/libraries/highlighter.js rename to script-archive/libraries/highlighter.js diff --git a/examples/libraries/htmlColors.js b/script-archive/libraries/htmlColors.js similarity index 100% rename from examples/libraries/htmlColors.js rename to script-archive/libraries/htmlColors.js diff --git a/examples/libraries/httpMultiPart.js b/script-archive/libraries/httpMultiPart.js similarity index 100% rename from examples/libraries/httpMultiPart.js rename to script-archive/libraries/httpMultiPart.js diff --git a/examples/libraries/line.js b/script-archive/libraries/line.js similarity index 100% rename from examples/libraries/line.js rename to script-archive/libraries/line.js diff --git a/examples/libraries/omniTool.js b/script-archive/libraries/omniTool.js similarity index 100% rename from examples/libraries/omniTool.js rename to script-archive/libraries/omniTool.js diff --git a/examples/libraries/omniTool/models/invisibleWand.js b/script-archive/libraries/omniTool/models/invisibleWand.js similarity index 100% rename from examples/libraries/omniTool/models/invisibleWand.js rename to script-archive/libraries/omniTool/models/invisibleWand.js diff --git a/examples/libraries/omniTool/models/modelBase.js b/script-archive/libraries/omniTool/models/modelBase.js similarity index 100% rename from examples/libraries/omniTool/models/modelBase.js rename to script-archive/libraries/omniTool/models/modelBase.js diff --git a/examples/libraries/omniTool/models/wand.js b/script-archive/libraries/omniTool/models/wand.js similarity index 100% rename from examples/libraries/omniTool/models/wand.js rename to script-archive/libraries/omniTool/models/wand.js diff --git a/examples/libraries/omniTool/modules/breakdanceOmniToolModule.js b/script-archive/libraries/omniTool/modules/breakdanceOmniToolModule.js similarity index 100% rename from examples/libraries/omniTool/modules/breakdanceOmniToolModule.js rename to script-archive/libraries/omniTool/modules/breakdanceOmniToolModule.js diff --git a/examples/libraries/omniTool/modules/test.js b/script-archive/libraries/omniTool/modules/test.js similarity index 100% rename from examples/libraries/omniTool/modules/test.js rename to script-archive/libraries/omniTool/modules/test.js diff --git a/examples/libraries/overlayManager.js b/script-archive/libraries/overlayManager.js similarity index 100% rename from examples/libraries/overlayManager.js rename to script-archive/libraries/overlayManager.js diff --git a/examples/libraries/promise.js b/script-archive/libraries/promise.js similarity index 100% rename from examples/libraries/promise.js rename to script-archive/libraries/promise.js diff --git a/examples/libraries/promiseExample.js b/script-archive/libraries/promiseExample.js similarity index 100% rename from examples/libraries/promiseExample.js rename to script-archive/libraries/promiseExample.js diff --git a/examples/libraries/tinyColor.js b/script-archive/libraries/tinyColor.js similarity index 100% rename from examples/libraries/tinyColor.js rename to script-archive/libraries/tinyColor.js diff --git a/examples/libraries/tween.js b/script-archive/libraries/tween.js similarity index 100% rename from examples/libraries/tween.js rename to script-archive/libraries/tween.js diff --git a/examples/libraries/uiwidgets.js b/script-archive/libraries/uiwidgets.js similarity index 100% rename from examples/libraries/uiwidgets.js rename to script-archive/libraries/uiwidgets.js diff --git a/examples/libraries/unitTest.js b/script-archive/libraries/unitTest.js similarity index 100% rename from examples/libraries/unitTest.js rename to script-archive/libraries/unitTest.js diff --git a/examples/libraries/usertiming.js b/script-archive/libraries/usertiming.js similarity index 100% rename from examples/libraries/usertiming.js rename to script-archive/libraries/usertiming.js diff --git a/examples/libraries/usertimingExample.js b/script-archive/libraries/usertimingExample.js similarity index 100% rename from examples/libraries/usertimingExample.js rename to script-archive/libraries/usertimingExample.js diff --git a/examples/libraries/virtualKeyboard.js b/script-archive/libraries/virtualKeyboard.js similarity index 100% rename from examples/libraries/virtualKeyboard.js rename to script-archive/libraries/virtualKeyboard.js diff --git a/examples/libraries/walkApi.js b/script-archive/libraries/walkApi.js similarity index 100% rename from examples/libraries/walkApi.js rename to script-archive/libraries/walkApi.js diff --git a/examples/libraries/walkConstants.js b/script-archive/libraries/walkConstants.js similarity index 100% rename from examples/libraries/walkConstants.js rename to script-archive/libraries/walkConstants.js diff --git a/examples/libraries/walkFilters.js b/script-archive/libraries/walkFilters.js similarity index 100% rename from examples/libraries/walkFilters.js rename to script-archive/libraries/walkFilters.js diff --git a/examples/libraries/walkSettings.js b/script-archive/libraries/walkSettings.js similarity index 100% rename from examples/libraries/walkSettings.js rename to script-archive/libraries/walkSettings.js diff --git a/examples/light_modifier/README.md b/script-archive/light_modifier/README.md similarity index 100% rename from examples/light_modifier/README.md rename to script-archive/light_modifier/README.md diff --git a/examples/light_modifier/closeButton.js b/script-archive/light_modifier/closeButton.js similarity index 100% rename from examples/light_modifier/closeButton.js rename to script-archive/light_modifier/closeButton.js diff --git a/examples/light_modifier/lightLoader.js b/script-archive/light_modifier/lightLoader.js similarity index 100% rename from examples/light_modifier/lightLoader.js rename to script-archive/light_modifier/lightLoader.js diff --git a/examples/light_modifier/lightModifier.js b/script-archive/light_modifier/lightModifier.js similarity index 100% rename from examples/light_modifier/lightModifier.js rename to script-archive/light_modifier/lightModifier.js diff --git a/examples/light_modifier/lightModifierTestScene.js b/script-archive/light_modifier/lightModifierTestScene.js similarity index 100% rename from examples/light_modifier/lightModifierTestScene.js rename to script-archive/light_modifier/lightModifierTestScene.js diff --git a/examples/light_modifier/lightParent.js b/script-archive/light_modifier/lightParent.js similarity index 100% rename from examples/light_modifier/lightParent.js rename to script-archive/light_modifier/lightParent.js diff --git a/examples/light_modifier/slider.js b/script-archive/light_modifier/slider.js similarity index 100% rename from examples/light_modifier/slider.js rename to script-archive/light_modifier/slider.js diff --git a/examples/light_modifier/visiblePanel.js b/script-archive/light_modifier/visiblePanel.js similarity index 100% rename from examples/light_modifier/visiblePanel.js rename to script-archive/light_modifier/visiblePanel.js diff --git a/examples/lineRider.js b/script-archive/lineRider.js similarity index 100% rename from examples/lineRider.js rename to script-archive/lineRider.js diff --git a/examples/lobby.js b/script-archive/lobby.js similarity index 100% rename from examples/lobby.js rename to script-archive/lobby.js diff --git a/examples/lotsoBlocks.js b/script-archive/lotsoBlocks.js similarity index 100% rename from examples/lotsoBlocks.js rename to script-archive/lotsoBlocks.js diff --git a/examples/magBalls.js b/script-archive/magBalls.js similarity index 100% rename from examples/magBalls.js rename to script-archive/magBalls.js diff --git a/examples/magBalls/constants.js b/script-archive/magBalls/constants.js similarity index 100% rename from examples/magBalls/constants.js rename to script-archive/magBalls/constants.js diff --git a/examples/magBalls/debugUtils.js b/script-archive/magBalls/debugUtils.js similarity index 100% rename from examples/magBalls/debugUtils.js rename to script-archive/magBalls/debugUtils.js diff --git a/examples/magBalls/edgeSpring.js b/script-archive/magBalls/edgeSpring.js similarity index 100% rename from examples/magBalls/edgeSpring.js rename to script-archive/magBalls/edgeSpring.js diff --git a/examples/magBalls/graph.js b/script-archive/magBalls/graph.js similarity index 100% rename from examples/magBalls/graph.js rename to script-archive/magBalls/graph.js diff --git a/examples/magBalls/magBalls.js b/script-archive/magBalls/magBalls.js similarity index 100% rename from examples/magBalls/magBalls.js rename to script-archive/magBalls/magBalls.js diff --git a/examples/marketplace/S3Server/Procfile b/script-archive/marketplace/S3Server/Procfile similarity index 100% rename from examples/marketplace/S3Server/Procfile rename to script-archive/marketplace/S3Server/Procfile diff --git a/examples/marketplace/S3Server/index.js b/script-archive/marketplace/S3Server/index.js similarity index 100% rename from examples/marketplace/S3Server/index.js rename to script-archive/marketplace/S3Server/index.js diff --git a/examples/marketplace/S3Server/package.json b/script-archive/marketplace/S3Server/package.json similarity index 100% rename from examples/marketplace/S3Server/package.json rename to script-archive/marketplace/S3Server/package.json diff --git a/examples/marketplace/dynamicLoader.js b/script-archive/marketplace/dynamicLoader.js similarity index 100% rename from examples/marketplace/dynamicLoader.js rename to script-archive/marketplace/dynamicLoader.js diff --git a/examples/mouseLook.js b/script-archive/mouseLook.js similarity index 100% rename from examples/mouseLook.js rename to script-archive/mouseLook.js diff --git a/examples/move.js b/script-archive/move.js similarity index 100% rename from examples/move.js rename to script-archive/move.js diff --git a/examples/moving-platform.js b/script-archive/moving-platform.js similarity index 100% rename from examples/moving-platform.js rename to script-archive/moving-platform.js diff --git a/examples/painting/closePaint.js b/script-archive/painting/closePaint.js similarity index 100% rename from examples/painting/closePaint.js rename to script-archive/painting/closePaint.js diff --git a/examples/painting/paint.js b/script-archive/painting/paint.js similarity index 100% rename from examples/painting/paint.js rename to script-archive/painting/paint.js diff --git a/examples/painting/whiteboard/blackInk.fs b/script-archive/painting/whiteboard/blackInk.fs similarity index 100% rename from examples/painting/whiteboard/blackInk.fs rename to script-archive/painting/whiteboard/blackInk.fs diff --git a/examples/painting/whiteboard/colorIndicatorEntityScript.js b/script-archive/painting/whiteboard/colorIndicatorEntityScript.js similarity index 100% rename from examples/painting/whiteboard/colorIndicatorEntityScript.js rename to script-archive/painting/whiteboard/colorIndicatorEntityScript.js diff --git a/examples/painting/whiteboard/colorSelectorEntityScript.js b/script-archive/painting/whiteboard/colorSelectorEntityScript.js similarity index 100% rename from examples/painting/whiteboard/colorSelectorEntityScript.js rename to script-archive/painting/whiteboard/colorSelectorEntityScript.js diff --git a/examples/painting/whiteboard/eraseBoardEntityScript.js b/script-archive/painting/whiteboard/eraseBoardEntityScript.js similarity index 100% rename from examples/painting/whiteboard/eraseBoardEntityScript.js rename to script-archive/painting/whiteboard/eraseBoardEntityScript.js diff --git a/examples/painting/whiteboard/whiteboardEntityScript.js b/script-archive/painting/whiteboard/whiteboardEntityScript.js similarity index 100% rename from examples/painting/whiteboard/whiteboardEntityScript.js rename to script-archive/painting/whiteboard/whiteboardEntityScript.js diff --git a/examples/painting/whiteboard/whiteboardSpawner.js b/script-archive/painting/whiteboard/whiteboardSpawner.js similarity index 100% rename from examples/painting/whiteboard/whiteboardSpawner.js rename to script-archive/painting/whiteboard/whiteboardSpawner.js diff --git a/examples/particleDance.js b/script-archive/particleDance.js similarity index 100% rename from examples/particleDance.js rename to script-archive/particleDance.js diff --git a/examples/particles.js b/script-archive/particles.js similarity index 100% rename from examples/particles.js rename to script-archive/particles.js diff --git a/examples/planets.js b/script-archive/planets.js similarity index 100% rename from examples/planets.js rename to script-archive/planets.js diff --git a/examples/playTestSound.js b/script-archive/playTestSound.js similarity index 100% rename from examples/playTestSound.js rename to script-archive/playTestSound.js diff --git a/examples/playa/fireworks/fireworksLaunchButtonEntityScript.js b/script-archive/playa/fireworks/fireworksLaunchButtonEntityScript.js similarity index 100% rename from examples/playa/fireworks/fireworksLaunchButtonEntityScript.js rename to script-archive/playa/fireworks/fireworksLaunchButtonEntityScript.js diff --git a/examples/playa/fireworks/fireworksLaunchButtonSpawner.js b/script-archive/playa/fireworks/fireworksLaunchButtonSpawner.js similarity index 100% rename from examples/playa/fireworks/fireworksLaunchButtonSpawner.js rename to script-archive/playa/fireworks/fireworksLaunchButtonSpawner.js diff --git a/examples/playa/playaSpawner.js b/script-archive/playa/playaSpawner.js similarity index 100% rename from examples/playa/playaSpawner.js rename to script-archive/playa/playaSpawner.js diff --git a/examples/pointer.js b/script-archive/pointer.js similarity index 100% rename from examples/pointer.js rename to script-archive/pointer.js diff --git a/examples/popcorn.js b/script-archive/popcorn.js similarity index 100% rename from examples/popcorn.js rename to script-archive/popcorn.js diff --git a/examples/rayPickingFilterExample.js b/script-archive/rayPickingFilterExample.js similarity index 100% rename from examples/rayPickingFilterExample.js rename to script-archive/rayPickingFilterExample.js diff --git a/examples/shaders/example.fs b/script-archive/shaders/example.fs similarity index 100% rename from examples/shaders/example.fs rename to script-archive/shaders/example.fs diff --git a/examples/shaders/exampleFloor.fs b/script-archive/shaders/exampleFloor.fs similarity index 100% rename from examples/shaders/exampleFloor.fs rename to script-archive/shaders/exampleFloor.fs diff --git a/examples/shaders/exampleSkyboxUserDataV2.json b/script-archive/shaders/exampleSkyboxUserDataV2.json similarity index 100% rename from examples/shaders/exampleSkyboxUserDataV2.json rename to script-archive/shaders/exampleSkyboxUserDataV2.json diff --git a/examples/shaders/exampleSphere.fs b/script-archive/shaders/exampleSphere.fs similarity index 100% rename from examples/shaders/exampleSphere.fs rename to script-archive/shaders/exampleSphere.fs diff --git a/examples/shaders/exampleSphereDisco.fs b/script-archive/shaders/exampleSphereDisco.fs similarity index 100% rename from examples/shaders/exampleSphereDisco.fs rename to script-archive/shaders/exampleSphereDisco.fs diff --git a/examples/shaders/exampleUserDataV2.json b/script-archive/shaders/exampleUserDataV2.json similarity index 100% rename from examples/shaders/exampleUserDataV2.json rename to script-archive/shaders/exampleUserDataV2.json diff --git a/examples/shaders/exampleV2.fs b/script-archive/shaders/exampleV2.fs similarity index 100% rename from examples/shaders/exampleV2.fs rename to script-archive/shaders/exampleV2.fs diff --git a/examples/shaders/grid.fs b/script-archive/shaders/grid.fs similarity index 100% rename from examples/shaders/grid.fs rename to script-archive/shaders/grid.fs diff --git a/examples/shaders/hex.fs b/script-archive/shaders/hex.fs similarity index 100% rename from examples/shaders/hex.fs rename to script-archive/shaders/hex.fs diff --git a/examples/shaders/noise.fs b/script-archive/shaders/noise.fs similarity index 100% rename from examples/shaders/noise.fs rename to script-archive/shaders/noise.fs diff --git a/examples/shaders/rainyDayNightSkybox.fs b/script-archive/shaders/rainyDayNightSkybox.fs similarity index 100% rename from examples/shaders/rainyDayNightSkybox.fs rename to script-archive/shaders/rainyDayNightSkybox.fs diff --git a/examples/shaders/scratch.fs b/script-archive/shaders/scratch.fs similarity index 100% rename from examples/shaders/scratch.fs rename to script-archive/shaders/scratch.fs diff --git a/examples/shaders/shadertoyWrapper.fs b/script-archive/shaders/shadertoyWrapper.fs similarity index 100% rename from examples/shaders/shadertoyWrapper.fs rename to script-archive/shaders/shadertoyWrapper.fs diff --git a/examples/shaders/shadertoys/clock.fs b/script-archive/shaders/shadertoys/clock.fs similarity index 100% rename from examples/shaders/shadertoys/clock.fs rename to script-archive/shaders/shadertoys/clock.fs diff --git a/examples/shaders/shadertoys/relentless.fs b/script-archive/shaders/shadertoys/relentless.fs similarity index 100% rename from examples/shaders/shadertoys/relentless.fs rename to script-archive/shaders/shadertoys/relentless.fs diff --git a/examples/shaders/shadertoys/relentlessSkybox.fs b/script-archive/shaders/shadertoys/relentlessSkybox.fs similarity index 100% rename from examples/shaders/shadertoys/relentlessSkybox.fs rename to script-archive/shaders/shadertoys/relentlessSkybox.fs diff --git a/examples/shaders/shadertoys/topologica.fs b/script-archive/shaders/shadertoys/topologica.fs similarity index 100% rename from examples/shaders/shadertoys/topologica.fs rename to script-archive/shaders/shadertoys/topologica.fs diff --git a/examples/shaders/test.fs b/script-archive/shaders/test.fs similarity index 100% rename from examples/shaders/test.fs rename to script-archive/shaders/test.fs diff --git a/examples/sit.js b/script-archive/sit.js similarity index 100% rename from examples/sit.js rename to script-archive/sit.js diff --git a/examples/stick-hydra.js b/script-archive/stick-hydra.js similarity index 100% rename from examples/stick-hydra.js rename to script-archive/stick-hydra.js diff --git a/examples/stick.js b/script-archive/stick.js similarity index 100% rename from examples/stick.js rename to script-archive/stick.js diff --git a/examples/tPose.js b/script-archive/tPose.js similarity index 100% rename from examples/tPose.js rename to script-archive/tPose.js diff --git a/examples/tests/performance/renderableMatrix.js b/script-archive/tests/performance/renderableMatrix.js similarity index 100% rename from examples/tests/performance/renderableMatrix.js rename to script-archive/tests/performance/renderableMatrix.js diff --git a/examples/tests/playbackAcTest.js b/script-archive/tests/playbackAcTest.js similarity index 100% rename from examples/tests/playbackAcTest.js rename to script-archive/tests/playbackAcTest.js diff --git a/examples/tests/qmlWebTest.js b/script-archive/tests/qmlWebTest.js similarity index 100% rename from examples/tests/qmlWebTest.js rename to script-archive/tests/qmlWebTest.js diff --git a/examples/theBird.js b/script-archive/theBird.js similarity index 100% rename from examples/theBird.js rename to script-archive/theBird.js diff --git a/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js b/script-archive/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js similarity index 100% rename from examples/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js rename to script-archive/tutorials/fireworks/chapter1/fireworksLaunchButtonEntityScript.js diff --git a/examples/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js b/script-archive/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js similarity index 100% rename from examples/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js rename to script-archive/tutorials/fireworks/chapter1/fireworksLaunchButtonSpawner.js diff --git a/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js b/script-archive/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js similarity index 100% rename from examples/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js rename to script-archive/tutorials/fireworks/chapter2/fireworksLaunchButtonEntityScript.js diff --git a/examples/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js b/script-archive/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js similarity index 100% rename from examples/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js rename to script-archive/tutorials/fireworks/chapter2/fireworksLaunchButtonSpawner.js diff --git a/examples/tutorials/fireworks/chapter3/fireworksLaunchButtonEntityScript.js b/script-archive/tutorials/fireworks/chapter3/fireworksLaunchButtonEntityScript.js similarity index 100% rename from examples/tutorials/fireworks/chapter3/fireworksLaunchButtonEntityScript.js rename to script-archive/tutorials/fireworks/chapter3/fireworksLaunchButtonEntityScript.js diff --git a/examples/tutorials/fireworks/chapter3/fireworksLaunchButtonSpawner.js b/script-archive/tutorials/fireworks/chapter3/fireworksLaunchButtonSpawner.js similarity index 100% rename from examples/tutorials/fireworks/chapter3/fireworksLaunchButtonSpawner.js rename to script-archive/tutorials/fireworks/chapter3/fireworksLaunchButtonSpawner.js diff --git a/examples/utilities/diagnostics/inWorldTestTone.js b/script-archive/utilities/diagnostics/inWorldTestTone.js similarity index 100% rename from examples/utilities/diagnostics/inWorldTestTone.js rename to script-archive/utilities/diagnostics/inWorldTestTone.js diff --git a/examples/utilities/diagnostics/moveJoints.js b/script-archive/utilities/diagnostics/moveJoints.js similarity index 100% rename from examples/utilities/diagnostics/moveJoints.js rename to script-archive/utilities/diagnostics/moveJoints.js diff --git a/examples/utilities/diagnostics/orbitingSound.js b/script-archive/utilities/diagnostics/orbitingSound.js similarity index 100% rename from examples/utilities/diagnostics/orbitingSound.js rename to script-archive/utilities/diagnostics/orbitingSound.js diff --git a/examples/utilities/diagnostics/playSoundLoop.js b/script-archive/utilities/diagnostics/playSoundLoop.js similarity index 100% rename from examples/utilities/diagnostics/playSoundLoop.js rename to script-archive/utilities/diagnostics/playSoundLoop.js diff --git a/examples/utilities/diagnostics/playSoundWave.js b/script-archive/utilities/diagnostics/playSoundWave.js similarity index 100% rename from examples/utilities/diagnostics/playSoundWave.js rename to script-archive/utilities/diagnostics/playSoundWave.js diff --git a/examples/utilities/tools/cookies.js b/script-archive/utilities/tools/cookies.js similarity index 100% rename from examples/utilities/tools/cookies.js rename to script-archive/utilities/tools/cookies.js diff --git a/examples/utilities/tools/crazylegs.js b/script-archive/utilities/tools/crazylegs.js similarity index 100% rename from examples/utilities/tools/crazylegs.js rename to script-archive/utilities/tools/crazylegs.js diff --git a/examples/utilities/tools/vector.js b/script-archive/utilities/tools/vector.js similarity index 100% rename from examples/utilities/tools/vector.js rename to script-archive/utilities/tools/vector.js diff --git a/examples/vrShop/README.txt b/script-archive/vrShop/README.txt similarity index 100% rename from examples/vrShop/README.txt rename to script-archive/vrShop/README.txt diff --git a/examples/vrShop/cart/shopCartEntityScript.js b/script-archive/vrShop/cart/shopCartEntityScript.js similarity index 100% rename from examples/vrShop/cart/shopCartEntityScript.js rename to script-archive/vrShop/cart/shopCartEntityScript.js diff --git a/examples/vrShop/cart/shopCartSpawnEntityScript.js b/script-archive/vrShop/cart/shopCartSpawnEntityScript.js similarity index 100% rename from examples/vrShop/cart/shopCartSpawnEntityScript.js rename to script-archive/vrShop/cart/shopCartSpawnEntityScript.js diff --git a/examples/vrShop/cart/shopCartZeroEntityScript.js b/script-archive/vrShop/cart/shopCartZeroEntityScript.js similarity index 100% rename from examples/vrShop/cart/shopCartZeroEntityScript.js rename to script-archive/vrShop/cart/shopCartZeroEntityScript.js diff --git a/examples/vrShop/cash/shopCashEntityScript.js b/script-archive/vrShop/cash/shopCashEntityScript.js similarity index 100% rename from examples/vrShop/cash/shopCashEntityScript.js rename to script-archive/vrShop/cash/shopCashEntityScript.js diff --git a/examples/vrShop/cash/shopCashRegisterEntityScript.js b/script-archive/vrShop/cash/shopCashRegisterEntityScript.js similarity index 100% rename from examples/vrShop/cash/shopCashRegisterEntityScript.js rename to script-archive/vrShop/cash/shopCashRegisterEntityScript.js diff --git a/examples/vrShop/cash/shopCashierAC.js b/script-archive/vrShop/cash/shopCashierAC.js similarity index 100% rename from examples/vrShop/cash/shopCashierAC.js rename to script-archive/vrShop/cash/shopCashierAC.js diff --git a/examples/vrShop/cash/shopCreditCardEntityScript.js b/script-archive/vrShop/cash/shopCreditCardEntityScript.js similarity index 100% rename from examples/vrShop/cash/shopCreditCardEntityScript.js rename to script-archive/vrShop/cash/shopCreditCardEntityScript.js diff --git a/examples/vrShop/inspect/shopInspectEntityScript.js b/script-archive/vrShop/inspect/shopInspectEntityScript.js similarity index 100% rename from examples/vrShop/inspect/shopInspectEntityScript.js rename to script-archive/vrShop/inspect/shopInspectEntityScript.js diff --git a/examples/vrShop/item/shopItemEntityScript.js b/script-archive/vrShop/item/shopItemEntityScript.js similarity index 100% rename from examples/vrShop/item/shopItemEntityScript.js rename to script-archive/vrShop/item/shopItemEntityScript.js diff --git a/examples/vrShop/item/shopItemGrab.js b/script-archive/vrShop/item/shopItemGrab.js similarity index 100% rename from examples/vrShop/item/shopItemGrab.js rename to script-archive/vrShop/item/shopItemGrab.js diff --git a/examples/vrShop/review/shopReviewEntityScript.js b/script-archive/vrShop/review/shopReviewEntityScript.js similarity index 100% rename from examples/vrShop/review/shopReviewEntityScript.js rename to script-archive/vrShop/review/shopReviewEntityScript.js diff --git a/examples/vrShop/review/shopReviewerAC.js b/script-archive/vrShop/review/shopReviewerAC.js similarity index 100% rename from examples/vrShop/review/shopReviewerAC.js rename to script-archive/vrShop/review/shopReviewerAC.js diff --git a/examples/vrShop/shop/shopGrabSwapperEntityScript.js b/script-archive/vrShop/shop/shopGrabSwapperEntityScript.js similarity index 100% rename from examples/vrShop/shop/shopGrabSwapperEntityScript.js rename to script-archive/vrShop/shop/shopGrabSwapperEntityScript.js diff --git a/examples/vrShop/vendor/shopVendorAddItem.js b/script-archive/vrShop/vendor/shopVendorAddItem.js similarity index 100% rename from examples/vrShop/vendor/shopVendorAddItem.js rename to script-archive/vrShop/vendor/shopVendorAddItem.js diff --git a/examples/walk.js b/script-archive/walk.js similarity index 100% rename from examples/walk.js rename to script-archive/walk.js diff --git a/examples/weapons/shootingRangeSpawner.js b/script-archive/weapons/shootingRangeSpawner.js similarity index 100% rename from examples/weapons/shootingRangeSpawner.js rename to script-archive/weapons/shootingRangeSpawner.js diff --git a/examples/winterSmashUp/targetPractice/shooterPlatform.js b/script-archive/winterSmashUp/targetPractice/shooterPlatform.js similarity index 100% rename from examples/winterSmashUp/targetPractice/shooterPlatform.js rename to script-archive/winterSmashUp/targetPractice/shooterPlatform.js diff --git a/examples/winterSmashUp/targetPractice/startTargetPractice.js b/script-archive/winterSmashUp/targetPractice/startTargetPractice.js similarity index 100% rename from examples/winterSmashUp/targetPractice/startTargetPractice.js rename to script-archive/winterSmashUp/targetPractice/startTargetPractice.js diff --git a/examples/winterSmashUp/targetPractice/targetPracticeGame.js b/script-archive/winterSmashUp/targetPractice/targetPracticeGame.js similarity index 100% rename from examples/winterSmashUp/targetPractice/targetPracticeGame.js rename to script-archive/winterSmashUp/targetPractice/targetPracticeGame.js diff --git a/examples/zones/RainyDayNightZone.json b/script-archive/zones/RainyDayNightZone.json similarity index 100% rename from examples/zones/RainyDayNightZone.json rename to script-archive/zones/RainyDayNightZone.json diff --git a/examples/zones/jsstreamplayerdomain-zone-entity.js b/script-archive/zones/jsstreamplayerdomain-zone-entity.js similarity index 100% rename from examples/zones/jsstreamplayerdomain-zone-entity.js rename to script-archive/zones/jsstreamplayerdomain-zone-entity.js diff --git a/examples/zones/jsstreamplayerdomain-zone.html b/script-archive/zones/jsstreamplayerdomain-zone.html similarity index 100% rename from examples/zones/jsstreamplayerdomain-zone.html rename to script-archive/zones/jsstreamplayerdomain-zone.html diff --git a/examples/zones/jsstreamplayerdomain-zone.js b/script-archive/zones/jsstreamplayerdomain-zone.js similarity index 100% rename from examples/zones/jsstreamplayerdomain-zone.js rename to script-archive/zones/jsstreamplayerdomain-zone.js diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js new file mode 100644 index 0000000000..ceccf20647 --- /dev/null +++ b/scripts/defaultScripts.js @@ -0,0 +1,21 @@ +// +// defaultScripts.js +// examples +// +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +Script.load("system/away.js"); +Script.load("system/progress.js"); +Script.load("system/edit.js"); +Script.load("system/examples.js"); +Script.load("system/selectAudioDevice.js"); +Script.load("system/notifications.js"); +Script.load("system/controllers/handControllerGrab.js"); +Script.load("system/controllers/squeezeHands.js"); +Script.load("system/controllers/grab.js"); +Script.load("system/dialTone.js"); +Script.load("system/depthReticle.js"); \ No newline at end of file diff --git a/examples/debugging/actionInspector.js b/scripts/developer/debugging/actionInspector.js similarity index 88% rename from examples/debugging/actionInspector.js rename to scripts/developer/debugging/actionInspector.js index 303dcbebbd..71bf928d57 100644 --- a/examples/debugging/actionInspector.js +++ b/scripts/developer/debugging/actionInspector.js @@ -17,7 +17,7 @@ var overlays = {}; var toType = function(obj) { - return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() + return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() } @@ -50,7 +50,11 @@ function actionArgumentsToString(actionArguments) { function updateOverlay(entityID, actionText) { var properties = Entities.getEntityProperties(entityID, ["position", "dimensions"]); - var position = Vec3.sum(properties.position, {x:0, y:properties.dimensions.y, z:0}); + var position = Vec3.sum(properties.position, { + x: 0, + y: properties.dimensions.y, + z: 0 + }); // print("position: " + vec3toStr(position) + " " + actionText); if (entityID in overlays) { var overlay = overlays[entityID]; @@ -76,9 +80,20 @@ function updateOverlay(entityID, actionText) { overlays[entityID] = Overlays.addOverlay("text3d", { position: position, - dimensions: { x: textWidth, y: textHeight }, - backgroundColor: { red: 0, green: 0, blue: 0}, - color: { red: 255, green: 255, blue: 255}, + dimensions: { + x: textWidth, + y: textHeight + }, + backgroundColor: { + red: 0, + green: 0, + blue: 0 + }, + color: { + red: 255, + green: 255, + blue: 255 + }, topMargin: textMargin, leftMargin: textMargin, bottomMargin: textMargin, @@ -143,4 +158,4 @@ Script.setInterval(function() { }, 100); -Script.scriptEnding.connect(cleanup); +Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/debugging/grabInspector.js b/scripts/developer/debugging/grabInspector.js similarity index 88% rename from examples/debugging/grabInspector.js rename to scripts/developer/debugging/grabInspector.js index 6b6dfc5d69..35993194ea 100644 --- a/examples/debugging/grabInspector.js +++ b/scripts/developer/debugging/grabInspector.js @@ -37,7 +37,7 @@ function grabDataToString(grabData) { argString = arg.toFixed(2); } result += argumentName + ": " - // + toType(arg) + " -- " + // + toType(arg) + " -- " + argString + "\n"; } } @@ -49,7 +49,11 @@ function grabDataToString(grabData) { function updateOverlay(entityID, grabText) { var properties = Entities.getEntityProperties(entityID, ["position", "dimensions"]); - var position = Vec3.sum(properties.position, {x:0, y:properties.dimensions.y, z:0}); + var position = Vec3.sum(properties.position, { + x: 0, + y: properties.dimensions.y, + z: 0 + }); if (entityID in overlays) { var overlay = overlays[entityID]; Overlays.editOverlay(overlay, { @@ -74,9 +78,20 @@ function updateOverlay(entityID, grabText) { overlays[entityID] = Overlays.addOverlay("text3d", { position: position, - dimensions: { x: textWidth, y: textHeight }, - backgroundColor: { red: 0, green: 0, blue: 0}, - color: { red: 255, green: 255, blue: 255}, + dimensions: { + x: textWidth, + y: textHeight + }, + backgroundColor: { + red: 0, + green: 0, + blue: 0 + }, + color: { + red: 255, + green: 255, + blue: 255 + }, topMargin: textMargin, leftMargin: textMargin, bottomMargin: textMargin, @@ -134,4 +149,4 @@ Script.setInterval(function() { }, 100); -Script.scriptEnding.connect(cleanup); +Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/debugging/queryAACubeInspector.js b/scripts/developer/debugging/queryAACubeInspector.js similarity index 81% rename from examples/debugging/queryAACubeInspector.js rename to scripts/developer/debugging/queryAACubeInspector.js index 2735617bc1..2d585ffce4 100644 --- a/examples/debugging/queryAACubeInspector.js +++ b/scripts/developer/debugging/queryAACubeInspector.js @@ -18,9 +18,11 @@ var INSPECT_RADIUS = 10; var overlays = {}; function updateOverlay(entityID, queryAACube) { - var cubeCenter = {x: queryAACube.x + queryAACube.scale / 2.0, - y: queryAACube.y + queryAACube.scale / 2.0, - z: queryAACube.z + queryAACube.scale / 2.0}; + var cubeCenter = { + x: queryAACube.x + queryAACube.scale / 2.0, + y: queryAACube.y + queryAACube.scale / 2.0, + z: queryAACube.z + queryAACube.scale / 2.0 + }; if (entityID in overlays) { var overlay = overlays[entityID]; @@ -32,7 +34,11 @@ function updateOverlay(entityID, queryAACube) { overlays[entityID] = Overlays.addOverlay("cube", { position: cubeCenter, size: queryAACube.scale, - color: { red: 0, green: 0, blue: 255}, + color: { + red: 0, + green: 0, + blue: 255 + }, alpha: 1, // borderSize: ..., solid: false @@ -55,4 +61,4 @@ function cleanup() { } } -Script.scriptEnding.connect(cleanup); +Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/examples/libraries/jasmine/hifi-boot.js b/scripts/developer/libraries/jasmine/hifi-boot.js similarity index 100% rename from examples/libraries/jasmine/hifi-boot.js rename to scripts/developer/libraries/jasmine/hifi-boot.js diff --git a/examples/libraries/jasmine/jasmine.js b/scripts/developer/libraries/jasmine/jasmine.js similarity index 100% rename from examples/libraries/jasmine/jasmine.js rename to scripts/developer/libraries/jasmine/jasmine.js diff --git a/examples/libraries/utils.js b/scripts/developer/libraries/utils.js similarity index 100% rename from examples/libraries/utils.js rename to scripts/developer/libraries/utils.js diff --git a/examples/libraries/virtualBaton.js b/scripts/developer/libraries/virtualBaton.js similarity index 100% rename from examples/libraries/virtualBaton.js rename to scripts/developer/libraries/virtualBaton.js diff --git a/examples/tests/avatarAttachmentTest.js b/scripts/developer/tests/avatarAttachmentTest.js similarity index 100% rename from examples/tests/avatarAttachmentTest.js rename to scripts/developer/tests/avatarAttachmentTest.js diff --git a/examples/tests/avatarUnitTests.js b/scripts/developer/tests/avatarUnitTests.js similarity index 100% rename from examples/tests/avatarUnitTests.js rename to scripts/developer/tests/avatarUnitTests.js diff --git a/examples/tests/basicEntityTest/entitySpawner.js b/scripts/developer/tests/basicEntityTest/entitySpawner.js similarity index 100% rename from examples/tests/basicEntityTest/entitySpawner.js rename to scripts/developer/tests/basicEntityTest/entitySpawner.js diff --git a/examples/tests/basicEntityTest/myEntityScript.js b/scripts/developer/tests/basicEntityTest/myEntityScript.js similarity index 84% rename from examples/tests/basicEntityTest/myEntityScript.js rename to scripts/developer/tests/basicEntityTest/myEntityScript.js index b4a8885c70..17d9f0c0aa 100644 --- a/examples/tests/basicEntityTest/myEntityScript.js +++ b/scripts/developer/tests/basicEntityTest/myEntityScript.js @@ -1,22 +1,21 @@ - (function() { + var _this; + MyEntity = function() { _this = this; - + }; MyEntity.prototype = { - preload: function(entityID) { this.entityID = entityID; var randNum = Math.random().toFixed(3); - print("EBL PRELOAD ENTITY SCRIPT!!!", randNum) + print("PRELOAD ENTITY SCRIPT!!!", randNum) }, - }; // entity scripts always need to return a newly constructed object of our type diff --git a/examples/tests/batonSoundEntityTest/batonSoundTestEntityScript.js b/scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntityScript.js similarity index 100% rename from examples/tests/batonSoundEntityTest/batonSoundTestEntityScript.js rename to scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntityScript.js diff --git a/examples/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js b/scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js similarity index 100% rename from examples/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js rename to scripts/developer/tests/batonSoundEntityTest/batonSoundTestEntitySpawner.js diff --git a/examples/tests/controllerInterfaceTest.js b/scripts/developer/tests/controllerInterfaceTest.js similarity index 100% rename from examples/tests/controllerInterfaceTest.js rename to scripts/developer/tests/controllerInterfaceTest.js diff --git a/examples/tests/cube_texture.png b/scripts/developer/tests/cube_texture.png similarity index 100% rename from examples/tests/cube_texture.png rename to scripts/developer/tests/cube_texture.png diff --git a/examples/tests/dot.png b/scripts/developer/tests/dot.png similarity index 100% rename from examples/tests/dot.png rename to scripts/developer/tests/dot.png diff --git a/examples/tests/entityEditStressTest.js b/scripts/developer/tests/entityEditStressTest.js similarity index 100% rename from examples/tests/entityEditStressTest.js rename to scripts/developer/tests/entityEditStressTest.js diff --git a/examples/tests/injectorTest.js b/scripts/developer/tests/injectorTest.js similarity index 100% rename from examples/tests/injectorTest.js rename to scripts/developer/tests/injectorTest.js diff --git a/examples/tests/lodTest.js b/scripts/developer/tests/lodTest.js similarity index 100% rename from examples/tests/lodTest.js rename to scripts/developer/tests/lodTest.js diff --git a/examples/tests/mat4test.js b/scripts/developer/tests/mat4test.js similarity index 100% rename from examples/tests/mat4test.js rename to scripts/developer/tests/mat4test.js diff --git a/examples/tests/overlayMouseTrackingTest.js b/scripts/developer/tests/overlayMouseTrackingTest.js similarity index 100% rename from examples/tests/overlayMouseTrackingTest.js rename to scripts/developer/tests/overlayMouseTrackingTest.js diff --git a/examples/tests/particleOrientationTest.js b/scripts/developer/tests/particleOrientationTest.js similarity index 100% rename from examples/tests/particleOrientationTest.js rename to scripts/developer/tests/particleOrientationTest.js diff --git a/examples/tests/performance/consoleSpawner.js b/scripts/developer/tests/performance/consoleSpawner.js similarity index 100% rename from examples/tests/performance/consoleSpawner.js rename to scripts/developer/tests/performance/consoleSpawner.js diff --git a/examples/entityScripts/simpleKeepAway.js b/scripts/developer/tests/performance/keepAwayEntity.js similarity index 70% rename from examples/entityScripts/simpleKeepAway.js rename to scripts/developer/tests/performance/keepAwayEntity.js index 87beaa8794..b8f40523ba 100644 --- a/examples/entityScripts/simpleKeepAway.js +++ b/scripts/developer/tests/performance/keepAwayEntity.js @@ -1,24 +1,26 @@ -(function () { +(function() { // The attached entity will move away from you if you are too close, checking at distanceRate. // See tests/performance/simpleKeepAway.js var entityID, - distanceRate = 1, // hertz - distanceAllowance = 3, // meters - distanceScale = 0.5, // meters/second + distanceRate = 1, // hertz + distanceAllowance = 3, // meters + distanceScale = 0.5, // meters/second distanceTimer; - function moveDistance() { // every user checks their distance and tries to claim if close enough. + function moveDistance() { // every user checks their distance and tries to claim if close enough. var me = MyAvatar.position, ball = Entities.getEntityProperties(entityID, ['position']).position; ball.y = me.y; var vector = Vec3.subtract(ball, me); if (Vec3.length(vector) < distanceAllowance) { - Entities.editEntity(entityID, {velocity: Vec3.multiply(distanceScale, Vec3.normalize(vector))}); + Entities.editEntity(entityID, { + velocity: Vec3.multiply(distanceScale, Vec3.normalize(vector)) + }); } } - this.preload = function (givenEntityID) { + this.preload = function(givenEntityID) { var properties = Entities.getEntityProperties(givenEntityID, ['userData']), userData = properties.userData && JSON.parse(properties.userData); entityID = givenEntityID; @@ -31,7 +33,7 @@ // run all the time by everyone: distanceTimer = Script.setInterval(moveDistance, distanceRate); }; - this.unload = function () { + this.unload = function() { Script.clearTimeout(distanceTimer); }; -}) +}) \ No newline at end of file diff --git a/examples/tests/performance/simpleKeepAway.js b/scripts/developer/tests/performance/simpleKeepAway.js similarity index 98% rename from examples/tests/performance/simpleKeepAway.js rename to scripts/developer/tests/performance/simpleKeepAway.js index 05c0dd8159..9718600a9c 100644 --- a/examples/tests/performance/simpleKeepAway.js +++ b/scripts/developer/tests/performance/simpleKeepAway.js @@ -94,7 +94,7 @@ Script.setInterval(function () { gravity: GRAVITY, collisionsWillMove: true, lifetime: LIFETIME, - script: Script.resolvePath("../../entityScripts/simpleKeepAway.js") + script: Script.resolvePath("keepAwayEntity.js") }; Entities.addEntity(properties); totalCreated++; diff --git a/examples/tests/performance/staticEdits.js b/scripts/developer/tests/performance/staticEdits.js similarity index 100% rename from examples/tests/performance/staticEdits.js rename to scripts/developer/tests/performance/staticEdits.js diff --git a/examples/entityScripts/tribble.js b/scripts/developer/tests/performance/tribbleEntity.js similarity index 98% rename from examples/entityScripts/tribble.js rename to scripts/developer/tests/performance/tribbleEntity.js index 22990af1d1..78b88ca48e 100644 --- a/examples/entityScripts/tribble.js +++ b/scripts/developer/tests/performance/tribbleEntity.js @@ -1,6 +1,6 @@ (function () { // See tests/performance/tribbles.js - Script.include("../libraries/virtualBaton.js"); + Script.include("../../libraries/virtualBaton.js"); var dimensions, oldColor, entityID, editRate = 60, moveRate = 1, diff --git a/examples/tests/performance/tribbles.js b/scripts/developer/tests/performance/tribbles.js similarity index 97% rename from examples/tests/performance/tribbles.js rename to scripts/developer/tests/performance/tribbles.js index f4eef2ff1a..c9ae347a82 100644 --- a/examples/tests/performance/tribbles.js +++ b/scripts/developer/tests/performance/tribbles.js @@ -86,7 +86,7 @@ Script.setInterval(function () { gravity: GRAVITY, collisionsWillMove: true, lifetime: LIFETIME, - script: Script.resolvePath("../../entityScripts/tribble.js") + script: Script.resolvePath("tribbleEntity.js") }); totalCreated++; diff --git a/examples/tests/playaPerformanceTest.js b/scripts/developer/tests/playaPerformanceTest.js similarity index 100% rename from examples/tests/playaPerformanceTest.js rename to scripts/developer/tests/playaPerformanceTest.js diff --git a/examples/tests/playaPerformanceTest.qml b/scripts/developer/tests/playaPerformanceTest.qml similarity index 99% rename from examples/tests/playaPerformanceTest.qml rename to scripts/developer/tests/playaPerformanceTest.qml index 6eb0061598..cd8171a0f6 100644 --- a/examples/tests/playaPerformanceTest.qml +++ b/scripts/developer/tests/playaPerformanceTest.qml @@ -220,4 +220,3 @@ Rectangle { } } - diff --git a/examples/tests/qmlTest.js b/scripts/developer/tests/qmlTest.js similarity index 100% rename from examples/tests/qmlTest.js rename to scripts/developer/tests/qmlTest.js diff --git a/examples/tests/rapidProceduralChange/rapidProceduralChangeTest.js b/scripts/developer/tests/rapidProceduralChange/rapidProceduralChangeTest.js similarity index 100% rename from examples/tests/rapidProceduralChange/rapidProceduralChangeTest.js rename to scripts/developer/tests/rapidProceduralChange/rapidProceduralChangeTest.js diff --git a/examples/tests/rapidProceduralChange/timerTest.fs b/scripts/developer/tests/rapidProceduralChange/timerTest.fs similarity index 100% rename from examples/tests/rapidProceduralChange/timerTest.fs rename to scripts/developer/tests/rapidProceduralChange/timerTest.fs diff --git a/examples/tests/rapidProceduralChange/uniformTest.fs b/scripts/developer/tests/rapidProceduralChange/uniformTest.fs similarity index 100% rename from examples/tests/rapidProceduralChange/uniformTest.fs rename to scripts/developer/tests/rapidProceduralChange/uniformTest.fs diff --git a/examples/tests/skybox/px.fs b/scripts/developer/tests/skybox/px.fs similarity index 100% rename from examples/tests/skybox/px.fs rename to scripts/developer/tests/skybox/px.fs diff --git a/examples/tests/skybox/px_rgba.fs b/scripts/developer/tests/skybox/px_rgba.fs similarity index 100% rename from examples/tests/skybox/px_rgba.fs rename to scripts/developer/tests/skybox/px_rgba.fs diff --git a/examples/tests/skybox/px_tex.fs b/scripts/developer/tests/skybox/px_tex.fs similarity index 100% rename from examples/tests/skybox/px_tex.fs rename to scripts/developer/tests/skybox/px_tex.fs diff --git a/examples/tests/skybox/px_tex_rgba.fs b/scripts/developer/tests/skybox/px_tex_rgba.fs similarity index 100% rename from examples/tests/skybox/px_tex_rgba.fs rename to scripts/developer/tests/skybox/px_tex_rgba.fs diff --git a/examples/tests/skybox/skyboxTest.js b/scripts/developer/tests/skybox/skyboxTest.js similarity index 100% rename from examples/tests/skybox/skyboxTest.js rename to scripts/developer/tests/skybox/skyboxTest.js diff --git a/examples/tests/sphereLODTest.js b/scripts/developer/tests/sphereLODTest.js similarity index 100% rename from examples/tests/sphereLODTest.js rename to scripts/developer/tests/sphereLODTest.js diff --git a/examples/tests/textureStress.fs b/scripts/developer/tests/textureStress.fs similarity index 100% rename from examples/tests/textureStress.fs rename to scripts/developer/tests/textureStress.fs diff --git a/examples/tests/textureStress.js b/scripts/developer/tests/textureStress.js similarity index 100% rename from examples/tests/textureStress.js rename to scripts/developer/tests/textureStress.js diff --git a/examples/tests/textureStress.qml b/scripts/developer/tests/textureStress.qml similarity index 100% rename from examples/tests/textureStress.qml rename to scripts/developer/tests/textureStress.qml diff --git a/examples/tests/toolWindowStressTest.js b/scripts/developer/tests/toolWindowStressTest.js similarity index 100% rename from examples/tests/toolWindowStressTest.js rename to scripts/developer/tests/toolWindowStressTest.js diff --git a/examples/utilities/cache/cacheStats.js b/scripts/developer/utilities/cache/cacheStats.js similarity index 100% rename from examples/utilities/cache/cacheStats.js rename to scripts/developer/utilities/cache/cacheStats.js diff --git a/examples/utilities/cache/stats.qml b/scripts/developer/utilities/cache/stats.qml similarity index 100% rename from examples/utilities/cache/stats.qml rename to scripts/developer/utilities/cache/stats.qml diff --git a/examples/utilities/diagnostics/XMLHttpRequest.js b/scripts/developer/utilities/diagnostics/XMLHttpRequest.js similarity index 100% rename from examples/utilities/diagnostics/XMLHttpRequest.js rename to scripts/developer/utilities/diagnostics/XMLHttpRequest.js diff --git a/examples/utilities/diagnostics/loadTestServers.js b/scripts/developer/utilities/diagnostics/loadTestServers.js similarity index 100% rename from examples/utilities/diagnostics/loadTestServers.js rename to scripts/developer/utilities/diagnostics/loadTestServers.js diff --git a/examples/utilities/diagnostics/testWebSocket.js b/scripts/developer/utilities/diagnostics/testWebSocket.js similarity index 100% rename from examples/utilities/diagnostics/testWebSocket.js rename to scripts/developer/utilities/diagnostics/testWebSocket.js diff --git a/examples/utilities/diagnostics/typedArraysUnitTest.js b/scripts/developer/utilities/diagnostics/typedArraysUnitTest.js similarity index 100% rename from examples/utilities/diagnostics/typedArraysUnitTest.js rename to scripts/developer/utilities/diagnostics/typedArraysUnitTest.js diff --git a/examples/utilities/lib/plotperf/PlotPerf.qml b/scripts/developer/utilities/lib/plotperf/PlotPerf.qml similarity index 100% rename from examples/utilities/lib/plotperf/PlotPerf.qml rename to scripts/developer/utilities/lib/plotperf/PlotPerf.qml diff --git a/examples/utilities/lib/plotperf/qmldir b/scripts/developer/utilities/lib/plotperf/qmldir similarity index 100% rename from examples/utilities/lib/plotperf/qmldir rename to scripts/developer/utilities/lib/plotperf/qmldir diff --git a/examples/utilities/record/recorder.js b/scripts/developer/utilities/record/recorder.js similarity index 100% rename from examples/utilities/record/recorder.js rename to scripts/developer/utilities/record/recorder.js diff --git a/examples/utilities/render/BG.qml b/scripts/developer/utilities/render/BG.qml similarity index 100% rename from examples/utilities/render/BG.qml rename to scripts/developer/utilities/render/BG.qml diff --git a/examples/utilities/render/configSlider/ConfigSlider.qml b/scripts/developer/utilities/render/configSlider/ConfigSlider.qml similarity index 100% rename from examples/utilities/render/configSlider/ConfigSlider.qml rename to scripts/developer/utilities/render/configSlider/ConfigSlider.qml diff --git a/examples/utilities/render/configSlider/qmldir b/scripts/developer/utilities/render/configSlider/qmldir similarity index 100% rename from examples/utilities/render/configSlider/qmldir rename to scripts/developer/utilities/render/configSlider/qmldir diff --git a/examples/utilities/render/culling.qml b/scripts/developer/utilities/render/culling.qml similarity index 100% rename from examples/utilities/render/culling.qml rename to scripts/developer/utilities/render/culling.qml diff --git a/examples/utilities/render/debug.js b/scripts/developer/utilities/render/debug.js similarity index 100% rename from examples/utilities/render/debug.js rename to scripts/developer/utilities/render/debug.js diff --git a/examples/utilities/render/debugBG.js b/scripts/developer/utilities/render/debugBG.js similarity index 100% rename from examples/utilities/render/debugBG.js rename to scripts/developer/utilities/render/debugBG.js diff --git a/examples/utilities/render/debugFramebuffer.js b/scripts/developer/utilities/render/debugFramebuffer.js similarity index 100% rename from examples/utilities/render/debugFramebuffer.js rename to scripts/developer/utilities/render/debugFramebuffer.js diff --git a/examples/utilities/render/debugRender.js b/scripts/developer/utilities/render/debugRender.js similarity index 100% rename from examples/utilities/render/debugRender.js rename to scripts/developer/utilities/render/debugRender.js diff --git a/examples/utilities/render/framebuffer.qml b/scripts/developer/utilities/render/framebuffer.qml similarity index 100% rename from examples/utilities/render/framebuffer.qml rename to scripts/developer/utilities/render/framebuffer.qml diff --git a/examples/utilities/render/main.qml b/scripts/developer/utilities/render/main.qml similarity index 100% rename from examples/utilities/render/main.qml rename to scripts/developer/utilities/render/main.qml diff --git a/examples/utilities/render/rates.qml b/scripts/developer/utilities/render/rates.qml similarity index 100% rename from examples/utilities/render/rates.qml rename to scripts/developer/utilities/render/rates.qml diff --git a/examples/utilities/render/renderRates.js b/scripts/developer/utilities/render/renderRates.js similarity index 100% rename from examples/utilities/render/renderRates.js rename to scripts/developer/utilities/render/renderRates.js diff --git a/examples/utilities/render/renderStats.js b/scripts/developer/utilities/render/renderStats.js similarity index 100% rename from examples/utilities/render/renderStats.js rename to scripts/developer/utilities/render/renderStats.js diff --git a/examples/utilities/render/stats.qml b/scripts/developer/utilities/render/stats.qml similarity index 99% rename from examples/utilities/render/stats.qml rename to scripts/developer/utilities/render/stats.qml index 312deac7f8..322af5389e 100644 --- a/examples/utilities/render/stats.qml +++ b/scripts/developer/utilities/render/stats.qml @@ -243,4 +243,6 @@ Item { ] } } + } + diff --git a/examples/entityScripts/exampleSelfCallingTimeoutNoCleanup.js b/scripts/developer/utilities/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js similarity index 100% rename from examples/entityScripts/exampleSelfCallingTimeoutNoCleanup.js rename to scripts/developer/utilities/templates/entityScripts/exampleSelfCallingTimeoutNoCleanup.js diff --git a/examples/entityScripts/exampleTimeoutNoCleanup.js b/scripts/developer/utilities/templates/entityScripts/exampleTimeoutNoCleanup.js similarity index 100% rename from examples/entityScripts/exampleTimeoutNoCleanup.js rename to scripts/developer/utilities/templates/entityScripts/exampleTimeoutNoCleanup.js diff --git a/examples/entityScripts/exampleUpdate.js b/scripts/developer/utilities/templates/entityScripts/exampleUpdate.js similarity index 100% rename from examples/entityScripts/exampleUpdate.js rename to scripts/developer/utilities/templates/entityScripts/exampleUpdate.js diff --git a/examples/entityScripts/exampleUpdateNoDisconnect.js b/scripts/developer/utilities/templates/entityScripts/exampleUpdateNoDisconnect.js similarity index 100% rename from examples/entityScripts/exampleUpdateNoDisconnect.js rename to scripts/developer/utilities/templates/entityScripts/exampleUpdateNoDisconnect.js diff --git a/examples/utilities/tests/allPerfTests.js b/scripts/developer/utilities/tests/allPerfTests.js similarity index 100% rename from examples/utilities/tests/allPerfTests.js rename to scripts/developer/utilities/tests/allPerfTests.js diff --git a/scripts/developer/utilities/tests/editEntityStressTest.js b/scripts/developer/utilities/tests/editEntityStressTest.js new file mode 100644 index 0000000000..61f10c5d80 --- /dev/null +++ b/scripts/developer/utilities/tests/editEntityStressTest.js @@ -0,0 +1,176 @@ +// entityEditStressTest.js +// +// Created by Seiji Emery on 8/31/15 +// Copyright 2015 High Fidelity, Inc. +// +// Stress tests the client + server-side entity trees by spawning huge numbers of entities in +// close proximity to your avatar and updating them continuously (ie. applying position edits), +// with the intent of discovering crashes and other bugs related to the entity, scripting, +// rendering, networking, and/or physics subsystems. +// +// This script was originally created to find + diagnose an a clientside crash caused by improper +// locking of the entity tree, but can be reused for other purposes. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +var NUM_ENTITIES = 20000; // number of entities to spawn +var ENTITY_SPAWN_LIMIT = 1000; +var ENTITY_SPAWN_INTERVAL = 0.1; + +var UPDATE_INTERVAL = 0.05; // Re-randomize the entity's position every x seconds / ms +var ENTITY_LIFETIME = 30; // Entity timeout (when/if we crash, we need the entities to delete themselves) +var KEEPALIVE_INTERVAL = 5; // Refreshes the timeout every X seconds + +var RADIUS = 5.0; // Spawn within this radius (square) +var Y_OFFSET = 1.5; // Spawn at an offset below the avatar +var TEST_ENTITY_NAME = "EntitySpawnTest"; + +(function () { + this.makeEntity = function (properties) { + var entity = Entities.addEntity(properties); + // print("spawning entity: " + JSON.stringify(properties)); + + return { + update: function (properties) { + Entities.editEntity(entity, properties); + }, + destroy: function () { + Entities.deleteEntity(entity) + }, + getAge: function () { + return Entities.getEntityProperties(entity).age; + } + }; + } + + this.randomPositionXZ = function (center, radius) { + return { + x: center.x + (Math.random() * radius * 2.0) - radius, + y: center.y, + z: center.z + (Math.random() * radius * 2.0) - radius + }; + } + this.randomColor = function () { + var shade = Math.floor(Math.random() * 255); + var hue = Math.floor(Math.random() * (255 - shade)); + + return { + red: shade + hue, + green: shade, + blue: shade + }; + } + this.randomDimensions = function () { + return { + x: 0.1 + Math.random() * 0.5, + y: 0.1 + Math.random() * 0.1, + z: 0.1 + Math.random() * 0.5 + }; + } +})(); + +(function () { + var entities = []; + var entitiesToCreate = 0; + var entitiesSpawned = 0; + + + function clear () { + var ids = Entities.findEntities(MyAvatar.position, 50); + var that = this; + ids.forEach(function(id) { + var properties = Entities.getEntityProperties(id); + if (properties.name == TEST_ENTITY_NAME) { + Entities.deleteEntity(id); + } + }, this); + } + + function createEntities () { + print("Creating " + NUM_ENTITIES + " entities (UPDATE_INTERVAL = " + UPDATE_INTERVAL + ", KEEPALIVE_INTERVAL = " + KEEPALIVE_INTERVAL + ")"); + entitiesToCreate = NUM_ENTITIES; + Script.update.connect(spawnEntities); + } + + var spawnTimer = 0.0; + function spawnEntities (dt) { + if (entitiesToCreate <= 0) { + Script.update.disconnect(spawnEntities); + print("Finished spawning entities"); + } + else if ((spawnTimer -= dt) < 0.0){ + spawnTimer = ENTITY_SPAWN_INTERVAL; + + var n = Math.min(entitiesToCreate, ENTITY_SPAWN_LIMIT); + print("Spawning " + n + " entities (" + (entitiesSpawned += n) + ")"); + + + entitiesToCreate -= n; + + var center = MyAvatar.position; + center.y -= Y_OFFSET; + + for (; n > 0; --n) { + entities.push(makeEntity({ + type: "Box", + name: TEST_ENTITY_NAME, + position: randomPositionXZ(center, RADIUS), + color: randomColor(), + dimensions: randomDimensions(), + lifetime: ENTITY_LIFETIME + })); + } + } + } + + function despawnEntities () { + print("despawning entities"); + entities.forEach(function (entity) { + entity.destroy(); + }); + entities = []; + } + + var keepAliveTimer = 0.0; + var updateTimer = 0.0; + + // Runs the following entity updates: + // a) refreshes the timeout interval every KEEPALIVE_INTERVAL seconds, and + // b) re-randomizes its position every UPDATE_INTERVAL seconds. + // This should be sufficient to crash the client until the entity tree bug is fixed (and thereafter if it shows up again). + function updateEntities (dt) { + var updateLifetime = ((keepAliveTimer -= dt) < 0.0) ? ((keepAliveTimer = KEEPALIVE_INTERVAL), true) : false; + var updateProperties = ((updateTimer -= dt) < 0.0) ? ((updateTimer = UPDATE_INTERVAL), true) : false; + + if (updateLifetime || updateProperties) { + var center = MyAvatar.position; + center.y -= Y_OFFSET; + + entities.forEach((updateLifetime && updateProperties && function (entity) { + entity.update({ + lifetime: entity.getAge() + ENTITY_LIFETIME, + position: randomPositionXZ(center, RADIUS) + }); + }) || (updateLifetime && function (entity) { + entity.update({ + lifetime: entity.getAge() + ENTITY_LIFETIME + }); + }) || (updateProperties && function (entity) { + entity.update({ + position: randomPositionXZ(center, RADIUS) + }); + }) || null, this); + } + } + + function init () { + Script.update.disconnect(init); + clear(); + createEntities(); + Script.update.connect(updateEntities); + Script.scriptEnding.connect(despawnEntities); + } + Script.update.connect(init); +})(); \ No newline at end of file diff --git a/examples/utilities/tests/entityPerfTest.js b/scripts/developer/utilities/tests/entityPerfTest.js similarity index 100% rename from examples/utilities/tests/entityPerfTest.js rename to scripts/developer/utilities/tests/entityPerfTest.js diff --git a/examples/utilities/tests/forLoopPerfTest.js b/scripts/developer/utilities/tests/forLoopPerfTest.js similarity index 100% rename from examples/utilities/tests/forLoopPerfTest.js rename to scripts/developer/utilities/tests/forLoopPerfTest.js diff --git a/examples/utilities/tests/mathPerfTest.js b/scripts/developer/utilities/tests/mathPerfTest.js similarity index 100% rename from examples/utilities/tests/mathPerfTest.js rename to scripts/developer/utilities/tests/mathPerfTest.js diff --git a/examples/utilities/tests/perfTest.js b/scripts/developer/utilities/tests/perfTest.js similarity index 100% rename from examples/utilities/tests/perfTest.js rename to scripts/developer/utilities/tests/perfTest.js diff --git a/examples/utilities/tools/MonoHMD.js b/scripts/developer/utilities/tools/MonoHMD.js similarity index 100% rename from examples/utilities/tools/MonoHMD.js rename to scripts/developer/utilities/tools/MonoHMD.js diff --git a/examples/utilities/tools/currentAPI.js b/scripts/developer/utilities/tools/currentAPI.js similarity index 100% rename from examples/utilities/tools/currentAPI.js rename to scripts/developer/utilities/tools/currentAPI.js diff --git a/examples/utilities/tools/developerMenuItems.js b/scripts/developer/utilities/tools/developerMenuItems.js similarity index 100% rename from examples/utilities/tools/developerMenuItems.js rename to scripts/developer/utilities/tools/developerMenuItems.js diff --git a/examples/disableAvatarAnimations.js b/scripts/developer/utilities/tools/disableAvatarAnimations.js similarity index 100% rename from examples/disableAvatarAnimations.js rename to scripts/developer/utilities/tools/disableAvatarAnimations.js diff --git a/examples/utilities/tools/reverbTest.js b/scripts/developer/utilities/tools/reverbTest.js similarity index 100% rename from examples/utilities/tools/reverbTest.js rename to scripts/developer/utilities/tools/reverbTest.js diff --git a/scripts/system/assets/images/Overlay-Viz-blank.png b/scripts/system/assets/images/Overlay-Viz-blank.png new file mode 100644 index 0000000000..76f535b6e6 Binary files /dev/null and b/scripts/system/assets/images/Overlay-Viz-blank.png differ diff --git a/scripts/system/assets/images/Particle-Sprite-Smoke-1.png b/scripts/system/assets/images/Particle-Sprite-Smoke-1.png new file mode 100644 index 0000000000..78c9b3da4a Binary files /dev/null and b/scripts/system/assets/images/Particle-Sprite-Smoke-1.png differ diff --git a/scripts/system/assets/images/close-small-light.svg b/scripts/system/assets/images/close-small-light.svg new file mode 100644 index 0000000000..f9edf95fca --- /dev/null +++ b/scripts/system/assets/images/close-small-light.svg @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/scripts/system/assets/images/grabsprite-3.png b/scripts/system/assets/images/grabsprite-3.png new file mode 100644 index 0000000000..4ecc772a41 Binary files /dev/null and b/scripts/system/assets/images/grabsprite-3.png differ diff --git a/scripts/system/assets/images/hourglass.svg b/scripts/system/assets/images/hourglass.svg new file mode 100644 index 0000000000..5c5055b755 --- /dev/null +++ b/scripts/system/assets/images/hourglass.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + diff --git a/scripts/system/assets/images/min-max-toggle.svg b/scripts/system/assets/images/min-max-toggle.svg new file mode 100644 index 0000000000..1699cc705d --- /dev/null +++ b/scripts/system/assets/images/min-max-toggle.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/progress-bar-background.svg b/scripts/system/assets/images/progress-bar-background.svg new file mode 100644 index 0000000000..732acd05ad --- /dev/null +++ b/scripts/system/assets/images/progress-bar-background.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/scripts/system/assets/images/progress-bar.svg b/scripts/system/assets/images/progress-bar.svg new file mode 100644 index 0000000000..0df6f98686 --- /dev/null +++ b/scripts/system/assets/images/progress-bar.svg @@ -0,0 +1,7 @@ + + + + + + diff --git a/scripts/system/assets/images/textures/dirt.jpeg b/scripts/system/assets/images/textures/dirt.jpeg new file mode 100644 index 0000000000..694e4f3c9a Binary files /dev/null and b/scripts/system/assets/images/textures/dirt.jpeg differ diff --git a/scripts/system/assets/images/textures/grass.png b/scripts/system/assets/images/textures/grass.png new file mode 100644 index 0000000000..d51fe0cf28 Binary files /dev/null and b/scripts/system/assets/images/textures/grass.png differ diff --git a/scripts/system/assets/images/tools/add-remove-friends.svg b/scripts/system/assets/images/tools/add-remove-friends.svg new file mode 100644 index 0000000000..6ee9ce842d --- /dev/null +++ b/scripts/system/assets/images/tools/add-remove-friends.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/cube-01.svg b/scripts/system/assets/images/tools/cube-01.svg new file mode 100644 index 0000000000..f8cf96e4f2 --- /dev/null +++ b/scripts/system/assets/images/tools/cube-01.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/directory-01.svg b/scripts/system/assets/images/tools/directory-01.svg new file mode 100644 index 0000000000..d038611d69 --- /dev/null +++ b/scripts/system/assets/images/tools/directory-01.svg @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/edit-01.svg b/scripts/system/assets/images/tools/edit-01.svg new file mode 100644 index 0000000000..c661c6f678 --- /dev/null +++ b/scripts/system/assets/images/tools/edit-01.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/examples-01.svg b/scripts/system/assets/images/tools/examples-01.svg new file mode 100644 index 0000000000..ec4758dcde --- /dev/null +++ b/scripts/system/assets/images/tools/examples-01.svg @@ -0,0 +1,306 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/light-01.svg b/scripts/system/assets/images/tools/light-01.svg new file mode 100644 index 0000000000..4573c7d636 --- /dev/null +++ b/scripts/system/assets/images/tools/light-01.svg @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/min-max-toggle.svg b/scripts/system/assets/images/tools/min-max-toggle.svg new file mode 100644 index 0000000000..1699cc705d --- /dev/null +++ b/scripts/system/assets/images/tools/min-max-toggle.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/model-01.svg b/scripts/system/assets/images/tools/model-01.svg new file mode 100644 index 0000000000..e760d74d5c --- /dev/null +++ b/scripts/system/assets/images/tools/model-01.svg @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/particle-01.svg b/scripts/system/assets/images/tools/particle-01.svg new file mode 100644 index 0000000000..cfcfb0ea7f --- /dev/null +++ b/scripts/system/assets/images/tools/particle-01.svg @@ -0,0 +1,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/polyvox.svg b/scripts/system/assets/images/tools/polyvox.svg new file mode 100644 index 0000000000..69f1e978ff --- /dev/null +++ b/scripts/system/assets/images/tools/polyvox.svg @@ -0,0 +1,39 @@ + + + + +polyvox + + + +voxels + + diff --git a/scripts/system/assets/images/tools/sphere-01.svg b/scripts/system/assets/images/tools/sphere-01.svg new file mode 100644 index 0000000000..975199c8da --- /dev/null +++ b/scripts/system/assets/images/tools/sphere-01.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/sphere-add.svg b/scripts/system/assets/images/tools/sphere-add.svg new file mode 100644 index 0000000000..59ca489b5f --- /dev/null +++ b/scripts/system/assets/images/tools/sphere-add.svg @@ -0,0 +1,77 @@ + + + +image/svg+xmladd + \ No newline at end of file diff --git a/scripts/system/assets/images/tools/sphere-delete.svg b/scripts/system/assets/images/tools/sphere-delete.svg new file mode 100644 index 0000000000..6997654500 --- /dev/null +++ b/scripts/system/assets/images/tools/sphere-delete.svg @@ -0,0 +1,76 @@ + + + +image/svg+xmldelete + \ No newline at end of file diff --git a/scripts/system/assets/images/tools/text-01.svg b/scripts/system/assets/images/tools/text-01.svg new file mode 100644 index 0000000000..d33d66d4a5 --- /dev/null +++ b/scripts/system/assets/images/tools/text-01.svg @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/upload-01.svg b/scripts/system/assets/images/tools/upload-01.svg new file mode 100644 index 0000000000..149b10f3bc --- /dev/null +++ b/scripts/system/assets/images/tools/upload-01.svg @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/voxel-add.svg b/scripts/system/assets/images/tools/voxel-add.svg new file mode 100644 index 0000000000..8e6e2c5b35 --- /dev/null +++ b/scripts/system/assets/images/tools/voxel-add.svg @@ -0,0 +1,104 @@ + + + +image/svg+xmladd + \ No newline at end of file diff --git a/scripts/system/assets/images/tools/voxel-delete.svg b/scripts/system/assets/images/tools/voxel-delete.svg new file mode 100644 index 0000000000..0b0d0b9787 --- /dev/null +++ b/scripts/system/assets/images/tools/voxel-delete.svg @@ -0,0 +1,103 @@ + + + +image/svg+xmldelete + \ No newline at end of file diff --git a/scripts/system/assets/images/tools/voxel-terrain.svg b/scripts/system/assets/images/tools/voxel-terrain.svg new file mode 100644 index 0000000000..e5ed16dbcd --- /dev/null +++ b/scripts/system/assets/images/tools/voxel-terrain.svg @@ -0,0 +1,101 @@ + + + +image/svg+xmlterrain + \ No newline at end of file diff --git a/scripts/system/assets/images/tools/voxels.svg b/scripts/system/assets/images/tools/voxels.svg new file mode 100644 index 0000000000..a0dbd63d45 --- /dev/null +++ b/scripts/system/assets/images/tools/voxels.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/web-01.svg b/scripts/system/assets/images/tools/web-01.svg new file mode 100644 index 0000000000..903b3ac819 --- /dev/null +++ b/scripts/system/assets/images/tools/web-01.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/images/tools/zone-01.svg b/scripts/system/assets/images/tools/zone-01.svg new file mode 100644 index 0000000000..29d17e5187 --- /dev/null +++ b/scripts/system/assets/images/tools/zone-01.svg @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/system/assets/sounds/goodbye.wav b/scripts/system/assets/sounds/goodbye.wav new file mode 100644 index 0000000000..bd6c51a5c0 Binary files /dev/null and b/scripts/system/assets/sounds/goodbye.wav differ diff --git a/scripts/system/assets/sounds/hello.wav b/scripts/system/assets/sounds/hello.wav new file mode 100644 index 0000000000..6269dab5db Binary files /dev/null and b/scripts/system/assets/sounds/hello.wav differ diff --git a/scripts/system/assets/sounds/notification-general1.raw b/scripts/system/assets/sounds/notification-general1.raw new file mode 100644 index 0000000000..be81fa15c5 Binary files /dev/null and b/scripts/system/assets/sounds/notification-general1.raw differ diff --git a/scripts/system/assets/sounds/notification-general2.raw b/scripts/system/assets/sounds/notification-general2.raw new file mode 100644 index 0000000000..58f0bac19c Binary files /dev/null and b/scripts/system/assets/sounds/notification-general2.raw differ diff --git a/scripts/system/assets/sounds/short1.wav b/scripts/system/assets/sounds/short1.wav new file mode 100644 index 0000000000..fb03f5dd49 Binary files /dev/null and b/scripts/system/assets/sounds/short1.wav differ diff --git a/scripts/system/assets/sounds/snap.wav b/scripts/system/assets/sounds/snap.wav new file mode 100644 index 0000000000..bb562e1db9 Binary files /dev/null and b/scripts/system/assets/sounds/snap.wav differ diff --git a/examples/attachedEntitiesManager.js b/scripts/system/attachedEntitiesManager.js similarity index 99% rename from examples/attachedEntitiesManager.js rename to scripts/system/attachedEntitiesManager.js index ef85f8cb98..9ddb040297 100644 --- a/examples/attachedEntitiesManager.js +++ b/scripts/system/attachedEntitiesManager.js @@ -27,7 +27,6 @@ var SHOW_TOOL_BAR = false; // tool bar if (SHOW_TOOL_BAR) { - HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; var BUTTON_SIZE = 32; var PADDING = 3; Script.include(["libraries/toolBars.js"]); diff --git a/examples/away.js b/scripts/system/away.js similarity index 99% rename from examples/away.js rename to scripts/system/away.js index 9c5aed98fa..687345a5e1 100644 --- a/examples/away.js +++ b/scripts/system/away.js @@ -196,6 +196,7 @@ function goActive() { } MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting. stopAwayAnimation(); + MyAvatar.reset(true); hideOverlay(); // restore overlays state to what it was when we went "away" @@ -269,4 +270,4 @@ Script.scriptEnding.connect(function () { Controller.disableMapping(eventMappingName); Controller.mousePressEvent.disconnect(goActive); Controller.keyPressEvent.disconnect(maybeGoActive); -}); +}); \ No newline at end of file diff --git a/examples/grab.js b/scripts/system/controllers/grab.js similarity index 99% rename from examples/grab.js rename to scripts/system/controllers/grab.js index 2134616f89..a7e08451bc 100644 --- a/examples/grab.js +++ b/scripts/system/controllers/grab.js @@ -11,7 +11,7 @@ // /*global print, Mouse, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt, pointInExtents, vec3equal, setEntityCustomData, getEntityCustomData */ -Script.include("libraries/utils.js"); +Script.include("../libraries/utils.js"); // objects that appear smaller than this can't be grabbed var MAX_SOLID_ANGLE = 0.01; diff --git a/examples/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js similarity index 99% rename from examples/controllers/handControllerGrab.js rename to scripts/system/controllers/handControllerGrab.js index 8a7399abc2..2ac07e5c3d 100644 --- a/examples/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -12,7 +12,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /*global print, MyAvatar, Entities, AnimationCache, SoundCache, Scene, Camera, Overlays, Audio, HMD, AvatarList, AvatarManager, Controller, UndoStack, Window, Account, GlobalServices, Script, ScriptDiscoveryService, LODManager, Menu, Vec3, Quat, AudioDevice, Paths, Clipboard, Settings, XMLHttpRequest, randFloat, randInt, pointInExtents, vec3equal, setEntityCustomData, getEntityCustomData */ -Script.include("/~/libraries/utils.js"); +Script.include("../libraries/utils.js"); // diff --git a/examples/controllers/handControllerMouse.js b/scripts/system/controllers/handControllerMouse.js similarity index 100% rename from examples/controllers/handControllerMouse.js rename to scripts/system/controllers/handControllerMouse.js diff --git a/examples/controllers/squeezeHands.js b/scripts/system/controllers/squeezeHands.js similarity index 100% rename from examples/controllers/squeezeHands.js rename to scripts/system/controllers/squeezeHands.js diff --git a/examples/depthReticle.js b/scripts/system/depthReticle.js similarity index 100% rename from examples/depthReticle.js rename to scripts/system/depthReticle.js diff --git a/examples/dialTone.js b/scripts/system/dialTone.js similarity index 75% rename from examples/dialTone.js rename to scripts/system/dialTone.js index eb1fc5ec1c..64ef62d61a 100644 --- a/examples/dialTone.js +++ b/scripts/system/dialTone.js @@ -11,9 +11,11 @@ // // setup the local sound we're going to use -var connectSound = SoundCache.getSound("file:///" + Paths.resources + "sounds/hello.wav"); -var disconnectSound = SoundCache.getSound("file:///" + Paths.resources + "sounds/goodbye.wav"); -var micMutedSound = SoundCache.getSound("file:///" + Paths.resources + "sounds/goodbye.wav"); + + +var connectSound = SoundCache.getSound(Script.resolvePath("assets/sounds/hello.wav")); +var disconnectSound = SoundCache.getSound(Script.resolvePath("assets/sounds/goodbye.wav")); +var micMutedSound = SoundCache.getSound(Script.resolvePath("assets/sounds/goodbye.wav")); // setup the options needed for that sound var soundOptions = { diff --git a/examples/directory.js b/scripts/system/directory.js similarity index 87% rename from examples/directory.js rename to scripts/system/directory.js index 243811c8d4..881b25b771 100644 --- a/examples/directory.js +++ b/scripts/system/directory.js @@ -13,8 +13,7 @@ Script.include([ "libraries/toolBars.js", ]); -HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; -var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; +var toolIconUrl = Script.resolvePath("assets/images/tools/"); var DIRECTORY_WINDOW_URL = "https://metaverse.highfidelity.com/directory"; var directoryWindow = new OverlayWebWindow({ @@ -27,6 +26,7 @@ var directoryWindow = new OverlayWebWindow({ var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; function showDirectory() { @@ -53,11 +53,14 @@ var toolBar = (function() { browseDirectoryButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: 50 + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: -2 * toolWidth, + y: -TOOLBAR_MARGIN_Y - toolHeight }); browseDirectoryButton = toolBar.addTool({ imageURL: toolIconUrl + "directory-01.svg", diff --git a/examples/edit.js b/scripts/system/edit.js similarity index 97% rename from examples/edit.js rename to scripts/system/edit.js index f03915f5ad..a8774db228 100644 --- a/examples/edit.js +++ b/scripts/system/edit.js @@ -48,11 +48,12 @@ var entityListTool = EntityListTool(); selectionManager.addEventListener(function() { selectionDisplay.updateHandles(); lightOverlayManager.updatePositions(); -}); +}); -var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; +var toolIconUrl = Script.resolvePath("assets/images/tools/"); var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; @@ -105,7 +106,7 @@ IMPORTING_SVO_OVERLAY_HEIGHT = 30; IMPORTING_SVO_OVERLAY_MARGIN = 5; IMPORTING_SVO_OVERLAY_LEFT_MARGIN = 34; var importingSVOImageOverlay = Overlays.addOverlay("image", { - imageURL: HIFI_PUBLIC_BUCKET + "images/hourglass.svg", + imageURL: Script.resolvePath("assets") + "/images/hourglass.svg", width: 20, height: 20, alpha: 1.0, @@ -179,11 +180,14 @@ var toolBar = (function() { newParticleButton function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: (windowDimensions.y - toolbar.height) / 2 + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: toolWidth, + y: -TOOLBAR_MARGIN_Y - toolHeight }); activeButton = toolBar.addTool({ @@ -332,7 +336,9 @@ var toolBar = (function() { if (active && !Entities.canAdjustLocks()) { Window.alert(INSUFFICIENT_PERMISSIONS_ERROR_MSG); } else { - Messages.sendLocalMessage("edit-events", JSON.stringify({enabled: active})); + Messages.sendLocalMessage("edit-events", JSON.stringify({ + enabled: active + })); isActive = active; if (!isActive) { entityListTool.setVisible(false); @@ -545,8 +551,16 @@ var toolBar = (function() { type: "ParticleEffect", isEmitting: true, particleRadius: 0.1, - emitAcceleration: {x: 0, y: -1, z: 0}, - accelerationSpread: {x: 5, y: 0, z: 5}, + emitAcceleration: { + x: 0, + y: -1, + z: 0 + }, + accelerationSpread: { + x: 5, + y: 0, + z: 5 + }, emitSpeed: 1, lifespan: 1, particleRadius: 0.025, @@ -559,7 +573,7 @@ var toolBar = (function() { return false; }; - that.mouseReleaseEvent = function (event) { + that.mouseReleaseEvent = function(event) { return false; } @@ -600,7 +614,7 @@ var intersection; var SCALE_FACTOR = 200.0; -function rayPlaneIntersection(pickRay, point, normal) { // +function rayPlaneIntersection(pickRay, point, normal) { // // // This version of the test returns the intersection of a line with a plane // @@ -1203,7 +1217,9 @@ function toggleSelectedEntitiesLocked() { var locked = !Entities.getEntityProperties(SelectionManager.selections[0], ["locked"]).locked; for (var i = 0; i < selectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - Entities.editEntity(entityID, { locked: locked }); + Entities.editEntity(entityID, { + locked: locked + }); } entityListTool.sendUpdate(); selectionManager._update(); @@ -1215,7 +1231,9 @@ function toggleSelectedEntitiesVisible() { var visible = !Entities.getEntityProperties(SelectionManager.selections[0], ["visible"]).visible; for (var i = 0; i < selectionManager.selections.length; i++) { var entityID = SelectionManager.selections[i]; - Entities.editEntity(entityID, { visible: visible }); + Entities.editEntity(entityID, { + visible: visible + }); } entityListTool.sendUpdate(); selectionManager._update(); @@ -1550,8 +1568,7 @@ PropertiesTool = function(opts) { data.properties.keyLight.direction.x * DEGREES_TO_RADIANS, data.properties.keyLight.direction.y * DEGREES_TO_RADIANS); } Entities.editEntity(selectionManager.selections[0], data.properties); - if (data.properties.name !== undefined || data.properties.modelURL !== undefined - || data.properties.visible !== undefined || data.properties.locked !== undefined) { + if (data.properties.name !== undefined || data.properties.modelURL !== undefined || data.properties.visible !== undefined || data.properties.locked !== undefined) { entityListTool.sendUpdate(); } } @@ -1831,15 +1848,15 @@ entityListTool.webView.webEventReceived.connect(function(data) { var data = JSON.parse(data); if (data.type == "selectionUpdate") { var ids = data.entityIds; - if(ids.length === 1) { - if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect" ) { + if (ids.length === 1) { + if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) { // This particle entity is already selected, so return return; } // Destroy the old particles web view first - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); + particleExplorerTool.destroyWebView(); + particleExplorerTool.createWebView(); var properties = Entities.getEntityProperties(ids[0]); var particleData = { messageType: "particle_settings", @@ -1851,7 +1868,7 @@ entityListTool.webView.webEventReceived.connect(function(data) { particleExplorerTool.webView.webEventReceived.connect(function(data) { var data = JSON.parse(data); if (data.messageType === "page_loaded") { - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); } }); } else { @@ -1860,4 +1877,4 @@ entityListTool.webView.webEventReceived.connect(function(data) { } } } -}); +}); \ No newline at end of file diff --git a/examples/examples.js b/scripts/system/examples.js similarity index 86% rename from examples/examples.js rename to scripts/system/examples.js index bfa85473de..9d33e473af 100644 --- a/examples/examples.js +++ b/scripts/system/examples.js @@ -13,8 +13,7 @@ Script.include([ "libraries/toolBars.js", ]); -HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; -var toolIconUrl = HIFI_PUBLIC_BUCKET + "images/tools/"; +var toolIconUrl = Script.resolvePath("assets/images/tools/"); var EXAMPLES_URL = "https://metaverse.highfidelity.com/examples"; var examplesWindow = new OverlayWebWindow({ @@ -27,6 +26,7 @@ var examplesWindow = new OverlayWebWindow({ var toolHeight = 50; var toolWidth = 50; +var TOOLBAR_MARGIN_Y = 0; function showExamples(marketplaceID) { @@ -58,11 +58,14 @@ var toolBar = (function() { browseExamplesButton; function initialize() { - toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { + toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { return { - x: windowDimensions.x - 8 - toolbar.width, - y: 135 + x: windowDimensions.x / 2, + y: windowDimensions.y }; + }, { + x: -toolWidth / 2, + y: -TOOLBAR_MARGIN_Y - toolHeight }); browseExamplesButton = toolBar.addTool({ imageURL: toolIconUrl + "examples-01.svg", @@ -132,4 +135,4 @@ var toolBar = (function() { }()); Controller.mousePressEvent.connect(toolBar.mousePressEvent) -Script.scriptEnding.connect(toolBar.cleanup); +Script.scriptEnding.connect(toolBar.cleanup); \ No newline at end of file diff --git a/examples/html/colpick.js b/scripts/system/html/colpick.js similarity index 100% rename from examples/html/colpick.js rename to scripts/system/html/colpick.js diff --git a/examples/html/css/colpick.css b/scripts/system/html/css/colpick.css similarity index 100% rename from examples/html/css/colpick.css rename to scripts/system/html/css/colpick.css diff --git a/examples/html/edit-style.css b/scripts/system/html/edit-style.css similarity index 94% rename from examples/html/edit-style.css rename to scripts/system/html/edit-style.css index de6f6a670d..5eaa3c6497 100644 --- a/examples/html/edit-style.css +++ b/scripts/system/html/edit-style.css @@ -10,51 +10,51 @@ @font-face { font-family: Raleway-Regular; - src: url(../../resources/fonts/Raleway-Regular.ttf), /* Windows production */ - url(../../fonts/Raleway-Regular.ttf), /* OSX production */ - url(../../interface/resources/fonts/Raleway-Regular.ttf); /* Development, running script in /HiFi/examples */ + src: url(../../../resources/fonts/Raleway-Regular.ttf), /* Windows production */ + url(../../../fonts/Raleway-Regular.ttf), /* OSX production */ + url(../../../interface/resources/fonts/Raleway-Regular.ttf); /* Development, running script in /HiFi/examples */ } @font-face { font-family: Raleway-Light; - src: url(../../resources/fonts/Raleway-Light.ttf), - url(../../fonts/Raleway-Light.ttf), - url(../../interface/resources/fonts/Raleway-Light.ttf); + src: url(../../../resources/fonts/Raleway-Light.ttf), + url(../../../fonts/Raleway-Light.ttf), + url(../../../interface/resources/fonts/Raleway-Light.ttf); } @font-face { font-family: Raleway-Bold; - src: url(../../resources/fonts/Raleway-Bold.ttf), - url(../../fonts/Raleway-Bold.ttf), - url(../../interface/resources/fonts/Raleway-Bold.ttf); + src: url(../../../resources/fonts/Raleway-Bold.ttf), + url(../../../fonts/Raleway-Bold.ttf), + url(../../../interface/resources/fonts/Raleway-Bold.ttf); } @font-face { font-family: Raleway-SemiBold; - src: url(../../resources/fonts/Raleway-SemiBold.ttf), - url(../../fonts/Raleway-SemiBold.ttf), - url(../../interface/resources/fonts/Raleway-SemiBold.ttf); + src: url(../../../resources/fonts/Raleway-SemiBold.ttf), + url(../../../fonts/Raleway-SemiBold.ttf), + url(../../../interface/resources/fonts/Raleway-SemiBold.ttf); } @font-face { font-family: FiraSans-SemiBold; - src: url(../../resources/fonts/FiraSans-SemiBold.ttf), - url(../../fonts/FiraSans-SemiBold.ttf), - url(../../interface/resources/fonts/FiraSans-SemiBold.ttf); + src: url(../../../resources/fonts/FiraSans-SemiBold.ttf), + url(../../../fonts/FiraSans-SemiBold.ttf), + url(../../../interface/resources/fonts/FiraSans-SemiBold.ttf); } @font-face { font-family: AnonymousPro-Regular; - src: url(../../resources/fonts/AnonymousPro-Regular.ttf), - url(../../fonts/AnonymousPro-Regular.ttf), - url(../../interface/resources/fonts/AnonymousPro-Regular.ttf); + src: url(../../../resources/fonts/AnonymousPro-Regular.ttf), + url(../../../fonts/AnonymousPro-Regular.ttf), + url(../../../interface/resources/fonts/AnonymousPro-Regular.ttf); } @font-face { font-family: HiFi-Glyphs; - src: url(../../resources/fonts/hifi-glyphs.ttf), - url(../../fonts/hifi-glyphs.ttf), - url(../../interface/resources/fonts/hifi-glyphs.ttf); + src: url(../../../resources/fonts/hifi-glyphs.ttf), + url(../../../fonts/hifi-glyphs.ttf), + url(../../../interface/resources/fonts/hifi-glyphs.ttf); } * { diff --git a/examples/html/entityList.html b/scripts/system/html/entityList.html similarity index 99% rename from examples/html/entityList.html rename to scripts/system/html/entityList.html index e5fa2ce839..dbc224e9fb 100644 --- a/examples/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -378,4 +378,4 @@ - + \ No newline at end of file diff --git a/examples/html/entityProperties.html b/scripts/system/html/entityProperties.html similarity index 100% rename from examples/html/entityProperties.html rename to scripts/system/html/entityProperties.html diff --git a/examples/html/eventBridgeLoader.js b/scripts/system/html/eventBridgeLoader.js similarity index 100% rename from examples/html/eventBridgeLoader.js rename to scripts/system/html/eventBridgeLoader.js diff --git a/examples/html/gridControls.html b/scripts/system/html/gridControls.html similarity index 100% rename from examples/html/gridControls.html rename to scripts/system/html/gridControls.html diff --git a/examples/html/jquery-2.1.4.min.js b/scripts/system/html/jquery-2.1.4.min.js similarity index 100% rename from examples/html/jquery-2.1.4.min.js rename to scripts/system/html/jquery-2.1.4.min.js diff --git a/examples/html/list.min.js b/scripts/system/html/list.min.js similarity index 100% rename from examples/html/list.min.js rename to scripts/system/html/list.min.js diff --git a/scripts/system/html/spinButtons.js b/scripts/system/html/spinButtons.js new file mode 100644 index 0000000000..fa2d18552f --- /dev/null +++ b/scripts/system/html/spinButtons.js @@ -0,0 +1,51 @@ +// +// spinButtons.js +// +// Created by David Rowe on 20 Apr 2016 +// Copyright 2016 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +function hoverSpinButtons(event) { + var input = event.target, + x = event.offsetX, + y = event.offsetY, + width = input.offsetWidth, + height = input.offsetHeight, + SPIN_WIDTH = 11, + SPIN_MARGIN = 2, + maxX = width - SPIN_MARGIN, + minX = maxX - SPIN_WIDTH; + + if (minX <= x && x <= maxX) { + if (y < height / 2) { + input.classList.remove("hover-down"); + input.classList.add("hover-up"); + } else { + input.classList.remove("hover-up"); + input.classList.add("hover-down"); + } + } else { + input.classList.remove("hover-up"); + input.classList.remove("hover-down"); + } +} + +function unhoverSpinButtons(event) { + event.target.classList.remove("hover-up"); + event.target.classList.remove("hover-down"); +} + +function augmentSpinButtons() { + var inputs, i, length; + + inputs = document.getElementsByTagName("INPUT"); + for (i = 0, length = inputs.length; i < length; i += 1) { + if (inputs[i].type === "number") { + inputs[i].addEventListener("mousemove", hoverSpinButtons); + inputs[i].addEventListener("mouseout", unhoverSpinButtons); + } + } +} diff --git a/examples/libraries/ToolTip.js b/scripts/system/libraries/ToolTip.js similarity index 100% rename from examples/libraries/ToolTip.js rename to scripts/system/libraries/ToolTip.js diff --git a/examples/libraries/dataViewHelpers.js b/scripts/system/libraries/dataViewHelpers.js similarity index 100% rename from examples/libraries/dataViewHelpers.js rename to scripts/system/libraries/dataViewHelpers.js diff --git a/examples/libraries/entityCameraTool.js b/scripts/system/libraries/entityCameraTool.js similarity index 100% rename from examples/libraries/entityCameraTool.js rename to scripts/system/libraries/entityCameraTool.js diff --git a/examples/libraries/entityList.js b/scripts/system/libraries/entityList.js similarity index 99% rename from examples/libraries/entityList.js rename to scripts/system/libraries/entityList.js index 78a8aa5a6a..e9baeac86c 100644 --- a/examples/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -118,4 +118,4 @@ EntityListTool = function(opts) { }); return that; -}; +}; \ No newline at end of file diff --git a/examples/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js similarity index 100% rename from examples/libraries/entitySelectionTool.js rename to scripts/system/libraries/entitySelectionTool.js diff --git a/examples/libraries/globals.js b/scripts/system/libraries/globals.js similarity index 100% rename from examples/libraries/globals.js rename to scripts/system/libraries/globals.js diff --git a/examples/libraries/gridTool.js b/scripts/system/libraries/gridTool.js similarity index 92% rename from examples/libraries/gridTool.js rename to scripts/system/libraries/gridTool.js index bebad84e1e..c002aec3b1 100644 --- a/examples/libraries/gridTool.js +++ b/scripts/system/libraries/gridTool.js @@ -3,7 +3,14 @@ var GRID_CONTROLS_HTML_URL = Script.resolvePath('../html/gridControls.html'); Grid = function(opts) { var that = {}; - var gridColor = { red: 255, green: 255, blue: 255 }; + var colors = [ + { red: 0, green: 0, blue: 0 }, + { red: 255, green: 255, blue: 255 }, + { red: 255, green: 0, blue: 0 }, + { red: 0, green: 255, blue: 0 }, + { red: 0, green: 0, blue: 255 }, + ]; + var colorIndex = 0; var gridAlpha = 0.6; var origin = { x: 0, y: +MyAvatar.getJointPosition('LeftToeBase').y.toFixed(1) + 0.1, z: 0 }; var scale = 500; @@ -21,7 +28,7 @@ Grid = function(opts) { position: origin, visible: false, drawInFront: false, - color: gridColor, + color: colors[0], alpha: gridAlpha, minorGridEvery: minorGridEvery, majorGridEvery: majorGridEvery, @@ -45,6 +52,12 @@ Grid = function(opts) { updateGrid(); }; + that.getColorIndex = function() { return colorIndex; }; + that.setColorIndex = function(value) { + colorIndex = value; + updateGrid(); + }; + that.getSnapToGrid = function() { return snapToGrid; }; that.setSnapToGrid = function(value) { snapToGrid = value; @@ -162,8 +175,8 @@ Grid = function(opts) { majorGridEvery = data.majorGridEvery; } - if (data.gridColor !== undefined) { - gridColor = data.gridColor; + if (data.colorIndex !== undefined) { + colorIndex = data.colorIndex; } if (data.gridSize) { @@ -183,7 +196,7 @@ Grid = function(opts) { visible: that.visible && that.enabled, minorGridEvery: minorGridEvery, majorGridEvery: majorGridEvery, - color: gridColor, + color: colors[colorIndex], alpha: gridAlpha, }); diff --git a/examples/libraries/lightOverlayManager.js b/scripts/system/libraries/lightOverlayManager.js similarity index 100% rename from examples/libraries/lightOverlayManager.js rename to scripts/system/libraries/lightOverlayManager.js diff --git a/examples/libraries/overlayUtils.js b/scripts/system/libraries/overlayUtils.js similarity index 100% rename from examples/libraries/overlayUtils.js rename to scripts/system/libraries/overlayUtils.js diff --git a/examples/libraries/progressDialog.js b/scripts/system/libraries/progressDialog.js similarity index 100% rename from examples/libraries/progressDialog.js rename to scripts/system/libraries/progressDialog.js diff --git a/examples/libraries/soundArray.js b/scripts/system/libraries/soundArray.js similarity index 100% rename from examples/libraries/soundArray.js rename to scripts/system/libraries/soundArray.js diff --git a/examples/libraries/stringHelpers.js b/scripts/system/libraries/stringHelpers.js similarity index 100% rename from examples/libraries/stringHelpers.js rename to scripts/system/libraries/stringHelpers.js diff --git a/examples/libraries/toolBars.js b/scripts/system/libraries/toolBars.js similarity index 93% rename from examples/libraries/toolBars.js rename to scripts/system/libraries/toolBars.js index 6e54c0276c..d97575d349 100644 --- a/examples/libraries/toolBars.js +++ b/scripts/system/libraries/toolBars.js @@ -139,12 +139,13 @@ Tool.prototype = new Overlay2D; Tool.IMAGE_HEIGHT = 50; Tool.IMAGE_WIDTH = 50; -ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPositionFunction) { +ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPositionFunction, optionalOffset) { this.tools = new Array(); this.x = x; this.y = y; + this.offset = optionalOffset ? optionalOffset : { x: 0, y: 0 }; this.width = 0; - this.height = 0 + this.height = 0; this.backAlpha = 1.0; this.back = Overlays.addOverlay("rectangle", { color: { red: 255, green: 255, blue: 255 }, @@ -237,7 +238,7 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit } } - this.move = function(x, y) { + this.move = function (x, y) { var dx = x - this.x; var dy = y - this.y; this.x = x; @@ -370,24 +371,27 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit that.onResizeViewport = function (newSize) { // Can be overridden or extended by clients. var recommendedRect = Controller.getRecommendedOverlayRect(); var recommendedDimmensions = { x: recommendedRect.width, y: recommendedRect.height }; - var originRelativeX = (that.x - that.origin.x); - var originRelativeY = (that.y - that.origin.y); + var originRelativeX = (that.x - that.origin.x - that.offset.x); + var originRelativeY = (that.y - that.origin.y - that.offset.y); var fractionX = clamp(originRelativeX / that.windowDimensions.x, 0, 1); var fractionY = clamp(originRelativeY / that.windowDimensions.y, 0, 1); that.windowDimensions = newSize || recommendedDimmensions; that.origin = { x: recommendedRect.x, y: recommendedRect.y }; - var newX = (fractionX * that.windowDimensions.x) + recommendedRect.x; - var newY = (fractionY * that.windowDimensions.y) + recommendedRect.y; + var newX = (fractionX * that.windowDimensions.x) + recommendedRect.x + that.offset.x; + var newY = (fractionY * that.windowDimensions.y) + recommendedRect.y + that.offset.y; that.move(newX, newY); }; if (optionalPersistenceKey) { this.fractionKey = optionalPersistenceKey + '.fraction'; + // FIXME: New default position in RC8 is bottom center of screen instead of right. Can remove this key and associated + // code once the new toolbar position is well established with users. + this.isNewPositionKey = optionalPersistenceKey + '.isNewPosition'; this.save = function () { var recommendedRect = Controller.getRecommendedOverlayRect(); var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; if (screenSize.x > 0 && screenSize.y > 0) { // Guard against invalid screen size that can occur at shut-down. - var fraction = {x: that.x / screenSize.x, y: that.y / screenSize.y}; + var fraction = {x: (that.x - that.offset.x) / screenSize.x, y: (that.y - that.offset.y) / screenSize.y}; Settings.setValue(this.fractionKey, JSON.stringify(fraction)); } } @@ -451,12 +455,15 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit return id; } if (this.fractionKey || optionalInitialPositionFunction) { - var savedFraction = JSON.parse(Settings.getValue(this.fractionKey) || '0'); // getValue can answer empty string + var isNewPosition = Settings.getValue(this.isNewPositionKey); + var savedFraction = isNewPosition ? JSON.parse(Settings.getValue(this.fractionKey) || "0") : 0; + Settings.setValue(this.isNewPositionKey, true); + var recommendedRect = Controller.getRecommendedOverlayRect(); var screenSize = { x: recommendedRect.width, y: recommendedRect.height }; if (savedFraction) { // If we have saved data, keep the toolbar at the same proportion of the screen width/height. - that.move(savedFraction.x * screenSize.x, savedFraction.y * screenSize.y); + that.move(savedFraction.x * screenSize.x + that.offset.x, savedFraction.y * screenSize.y + that.offset.y); } else if (!optionalInitialPositionFunction) { print("No initPosition(screenSize, intializedToolbar) specified for ToolBar"); } else { @@ -464,11 +471,11 @@ ToolBar = function(x, y, direction, optionalPersistenceKey, optionalInitialPosit var that = this; Script.setTimeout(function () { var position = optionalInitialPositionFunction(screenSize, that); - that.move(position.x, position.y); + that.move(position.x + that.offset.x, position.y + that.offset.y); }, 0); } } } ToolBar.SPACING = 6; ToolBar.VERTICAL = 0; -ToolBar.HORIZONTAL = 1; +ToolBar.HORIZONTAL = 1; \ No newline at end of file diff --git a/scripts/system/libraries/utils.js b/scripts/system/libraries/utils.js new file mode 100644 index 0000000000..f39f4d7913 --- /dev/null +++ b/scripts/system/libraries/utils.js @@ -0,0 +1,313 @@ +// +// Created by Bradley Austin Davis on 2015/08/29 +// Copyright 2015 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +vec3toStr = function(v, digits) { + if (!digits) { digits = 3; } + return "{ " + v.x.toFixed(digits) + ", " + v.y.toFixed(digits) + ", " + v.z.toFixed(digits)+ " }"; +} + +quatToStr = function(q, digits) { + if (!digits) { digits = 3; } + return "{ " + q.w.toFixed(digits) + ", " + q.x.toFixed(digits) + ", " + + q.y.toFixed(digits) + ", " + q.z.toFixed(digits)+ " }"; +} + +vec3equal = function(v0, v1) { + return (v0.x == v1.x) && (v0.y == v1.y) && (v0.z == v1.z); +} + +colorMix = function(colorA, colorB, mix) { + var result = {}; + for (var key in colorA) { + result[key] = (colorA[key] * (1 - mix)) + (colorB[key] * mix); + } + return result; +} +scaleLine = function (start, end, scale) { + var v = Vec3.subtract(end, start); + var length = Vec3.length(v); + v = Vec3.multiply(scale, v); + return Vec3.sum(start, v); +} + +findAction = function(name) { + return Controller.findAction(name); +} + +addLine = function(origin, vector, color) { + if (!color) { + color = COLORS.WHITE + } + return Entities.addEntity(mergeObjects(LINE_PROTOTYPE, { + position: origin, + linePoints: [ + ZERO_VECTOR, + vector, + ], + color: color + })); +} + +// FIXME fetch from a subkey of user data to support non-destructive modifications +setEntityUserData = function(id, data) { + var json = JSON.stringify(data) + Entities.editEntity(id, { userData: json }); +} + +// FIXME do non-destructive modification of the existing user data +getEntityUserData = function(id) { + var results = null; + var properties = Entities.getEntityProperties(id, "userData"); + if (properties.userData) { + try { + results = JSON.parse(properties.userData); + } catch(err) { + logDebug(err); + logDebug(properties.userData); + } + } + return results ? results : {}; +} + + +// Non-destructively modify the user data of an entity. +setEntityCustomData = function(customKey, id, data) { + var userData = getEntityUserData(id); + if (data == null) { + delete userData[customKey]; + } else { + userData[customKey] = data; + } + setEntityUserData(id, userData); +} + +getEntityCustomData = function(customKey, id, defaultValue) { + var userData = getEntityUserData(id); + if (undefined != userData[customKey]) { + return userData[customKey]; + } else { + return defaultValue; + } +} + +mergeObjects = function(proto, custom) { + var result = {}; + for (var attrname in proto) { + result[attrname] = proto[attrname]; + } + for (var attrname in custom) { + result[attrname] = custom[attrname]; + } + return result; +} + +LOG_WARN = 1; + +logWarn = function(str) { + if (LOG_WARN) { + print(str); + } +} + +LOG_ERROR = 1; + +logError = function(str) { + if (LOG_ERROR) { + print(str); + } +} + +LOG_INFO = 1; + +logInfo = function(str) { + if (LOG_INFO) { + print(str); + } +} + +LOG_DEBUG = 0; + +logDebug = function(str) { + if (LOG_DEBUG) { + print(str); + } +} + +LOG_TRACE = 0; + +logTrace = function(str) { + if (LOG_TRACE) { + print(str); + } +} + +// Computes the penetration between a point and a sphere (centered at the origin) +// if point is inside sphere: returns true and stores the result in 'penetration' +// (the vector that would move the point outside the sphere) +// otherwise returns false +findSphereHit = function(point, sphereRadius) { + var EPSILON = 0.000001; //smallish positive number - used as margin of error for some computations + var vectorLength = Vec3.length(point); + if (vectorLength < EPSILON) { + return true; + } + var distance = vectorLength - sphereRadius; + if (distance < 0.0) { + return true; + } + return false; +} + +findSpherePointHit = function(sphereCenter, sphereRadius, point) { + return findSphereHit(Vec3.subtract(point,sphereCenter), sphereRadius); +} + +findSphereSphereHit = function(firstCenter, firstRadius, secondCenter, secondRadius) { + return findSpherePointHit(firstCenter, firstRadius + secondRadius, secondCenter); +} + +// Given a vec3 v, return a vec3 that is the same vector relative to the avatars +// DEFAULT eye position, rotated into the avatars reference frame. +getEyeRelativePosition = function(v) { + return Vec3.sum(MyAvatar.getDefaultEyePosition(), Vec3.multiplyQbyV(MyAvatar.orientation, v)); +} + +getAvatarRelativeRotation = function(q) { + return Quat.multiply(MyAvatar.orientation, q); +} + +pointInExtents = function(point, minPoint, maxPoint) { + return (point.x >= minPoint.x && point.x <= maxPoint.x) && + (point.y >= minPoint.y && point.y <= maxPoint.y) && + (point.z >= minPoint.z && point.z <= maxPoint.z); +} + +/** + * Converts an HSL color value to RGB. Conversion formula + * adapted from http://en.wikipedia.org/wiki/HSL_color_space. + * Assumes h, s, and l are contained in the set [0, 1] and + * returns r, g, and b in the set [0, 255]. + * + * @param Number h The hue + * @param Number s The saturation + * @param Number l The lightness + * @return Array The RGB representation + */ +hslToRgb = function(hsl) { + var r, g, b; + if (hsl.s == 0) { + r = g = b = hsl.l; // achromatic + } else { + var hue2rgb = function hue2rgb(p, q, t) { + if (t < 0) t += 1; + if (t > 1) t -= 1; + if (t < 1 / 6) return p + (q - p) * 6 * t; + if (t < 1 / 2) return q; + if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; + return p; + } + + var q = hsl.l < 0.5 ? hsl.l * (1 + hsl.s) : hsl.l + hsl.s - hsl.l * hsl.s; + var p = 2 * hsl.l - q; + r = hue2rgb(p, q, hsl.h + 1 / 3); + g = hue2rgb(p, q, hsl.h); + b = hue2rgb(p, q, hsl.h - 1 / 3); + } + + return { + red: Math.round(r * 255), + green: Math.round(g * 255), + blue: Math.round(b * 255) + }; +} + +map = function(value, min1, max1, min2, max2) { + return min2 + (max2 - min2) * ((value - min1) / (max1 - min1)); +} + +orientationOf = function(vector) { + var Y_AXIS = { + x: 0, + y: 1, + z: 0 + }; + var X_AXIS = { + x: 1, + y: 0, + z: 0 + }; + + var theta = 0.0; + + var RAD_TO_DEG = 180.0 / Math.PI; + var direction, yaw, pitch; + direction = Vec3.normalize(vector); + yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * RAD_TO_DEG, Y_AXIS); + pitch = Quat.angleAxis(Math.asin(-direction.y) * RAD_TO_DEG, X_AXIS); + return Quat.multiply(yaw, pitch); +} + +randFloat = function(low, high) { + return low + Math.random() * (high - low); +} + + +randInt = function(low, high) { + return Math.floor(randFloat(low, high)); +} + + +randomColor = function() { + return { + red: randInt(0, 255), + green: randInt(0, 255), + blue: randInt(0, 255) + } +} + + +hexToRgb = function(hex) { + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + return result ? { + red: parseInt(result[1], 16), + green: parseInt(result[2], 16), + blue: parseInt(result[3], 16) + } : null; +} + +calculateHandSizeRatio = function() { + // Get the ratio of the current avatar's hand to Owen's hand + + var standardCenterHandPoint = 0.11288; + var jointNames = MyAvatar.getJointNames(); + //get distance from handJoint up to leftHandIndex3 as a proxy for center of hand + var wristToFingertipDistance = 0;; + for (var i = 0; i < jointNames.length; i++) { + var jointName = jointNames[i]; + print(jointName) + if (jointName.indexOf("LeftHandIndex") !== -1) { + // translations are relative to parent joint, so simply add them together + // joints face down the y-axis + var translation = MyAvatar.getDefaultJointTranslation(i).y; + wristToFingertipDistance += translation; + } + } + // Right now units are in cm, so convert to meters + wristToFingertipDistance /= 100; + + var centerHandPoint = wristToFingertipDistance/2; + + // Compare against standard hand (Owen) + var handSizeRatio = centerHandPoint/standardCenterHandPoint; + return handSizeRatio; +} + +clamp = function(val, min, max){ + return Math.max(min, Math.min(max, val)) + } + diff --git a/examples/notifications.js b/scripts/system/notifications.js similarity index 98% rename from examples/notifications.js rename to scripts/system/notifications.js index 63d94fbd92..7d97470b8a 100644 --- a/examples/notifications.js +++ b/scripts/system/notifications.js @@ -55,7 +55,7 @@ // createNotification(noteString, NotificationType.SNAPSHOT); // } // } -Script.include("./libraries/globals.js"); + Script.include("./libraries/soundArray.js"); var width = 340.0; //width of notification overlay @@ -120,7 +120,8 @@ var NotificationType = { var randomSounds = new SoundArray({ localOnly: true }, true); var numberOfSounds = 2; for (var i = 1; i <= numberOfSounds; i++) { - randomSounds.addSound(HIFI_PUBLIC_BUCKET + "sounds/UI/notification-general" + i + ".raw"); + + randomSounds.addSound(Script.resolvePath("assets/sounds/notification-general"+ i + ".raw")); } var notifications = []; @@ -328,7 +329,7 @@ function createNotification(text, notificationType) { width: 10.0, height: 10.0, subImage: { x: 0, y: 0, width: 10, height: 10 }, - imageURL: "http://hifi-public.s3.amazonaws.com/images/close-small-light.svg", + imageURL: Script.resolvePath("assets/images/close-small-light.svg"), color: { red: 255, green: 255, blue: 255}, visible: true, alpha: backgroundAlpha diff --git a/examples/particle_explorer/dat.gui.min.js b/scripts/system/particle_explorer/dat.gui.min.js similarity index 100% rename from examples/particle_explorer/dat.gui.min.js rename to scripts/system/particle_explorer/dat.gui.min.js diff --git a/examples/particle_explorer/particleExplorer.html b/scripts/system/particle_explorer/particleExplorer.html similarity index 96% rename from examples/particle_explorer/particleExplorer.html rename to scripts/system/particle_explorer/particleExplorer.html index 2ab89c98ca..1de176214c 100644 --- a/examples/particle_explorer/particleExplorer.html +++ b/scripts/system/particle_explorer/particleExplorer.html @@ -18,7 +18,7 @@ - +