From 1ad8aeb7c198ede201d7dc03a0de84d9270f0f9f Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 14 Sep 2017 15:49:09 -0700 Subject: [PATCH 1/7] Fixes for lasers on 2d HUD --- interface/src/Application.cpp | 13 ++----------- .../src/display-plugins/hmd/HmdDisplayPlugin.cpp | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index de1269c3ae..93b915d7b3 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2635,17 +2635,8 @@ void Application::paintGL() { PerformanceTimer perfTimer("postComposite"); renderArgs._batch = &postCompositeBatch; renderArgs._batch->setViewportTransform(ivec4(0, 0, finalFramebufferSize.width(), finalFramebufferSize.height())); - for_each_eye([&](Eye eye) { - - // apply eye offset and IPD scale to the view matrix - mat4 eyeToHead = displayPlugin->getEyeToHeadTransform(eye); - vec3 eyeOffset = glm::vec3(eyeToHead[3]); - mat4 eyeOffsetTransform = glm::translate(mat4(), eyeOffset * -1.0f * ipdScale); - renderArgs._batch->setViewTransform(renderArgs.getViewFrustum().getView() * eyeOffsetTransform); - - renderArgs._batch->setProjectionTransform(eyeProjections[eye]); - _overlays.render3DHUDOverlays(&renderArgs); - }); + renderArgs._batch->setViewTransform(renderArgs.getViewFrustum().getView()); + _overlays.render3DHUDOverlays(&renderArgs); } auto frame = _gpuContext->endFrame(); diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp index caeba37839..88ec94eefb 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp @@ -441,7 +441,7 @@ void HmdDisplayPlugin::OverlayRenderer::updatePipeline() { this->uniformsLocation = program->getUniformBuffers().findLocation("overlayBuffer"); gpu::StatePointer state = gpu::StatePointer(new gpu::State()); - state->setDepthTest(gpu::State::DepthTest(true, true, gpu::LESS_EQUAL)); + state->setDepthTest(gpu::State::DepthTest(false, false, gpu::LESS_EQUAL)); state->setBlendFunction(true, gpu::State::SRC_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::INV_SRC_ALPHA, gpu::State::FACTOR_ALPHA, gpu::State::BLEND_OP_ADD, gpu::State::ONE); From 591c688d79454d61b2d98dea48d54d33a4d908f8 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Thu, 14 Sep 2017 17:09:10 -0700 Subject: [PATCH 2/7] code review feedback --- interface/src/Application.cpp | 2 +- scripts/system/notifications.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 93b915d7b3..3e69852e6b 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -6658,7 +6658,7 @@ void Application::addAssetToWorldCheckModelSize() { if (dimensions != DEFAULT_DIMENSIONS) { // Scale model so that its maximum is exactly specific size. - const float MAXIMUM_DIMENSION = 1.0f * getMyAvatar()->getSensorToWorldScale(); + const float MAXIMUM_DIMENSION = getMyAvatar()->getSensorToWorldScale(); auto previousDimensions = dimensions; auto scale = std::min(MAXIMUM_DIMENSION / dimensions.x, std::min(MAXIMUM_DIMENSION / dimensions.y, MAXIMUM_DIMENSION / dimensions.z)); diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index 53cffa18d8..ffe93d13e8 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -249,7 +249,7 @@ noticeWidth = notice.width * NOTIFICATION_3D_SCALE + NOTIFICATION_3D_BUTTON_WIDTH; noticeHeight = notice.height * NOTIFICATION_3D_SCALE; - notice.size = { x: noticeWidth, y: noticeHeight}; + notice.size = { x: noticeWidth, y: noticeHeight }; positions = calculate3DOverlayPositions(noticeWidth, noticeHeight, notice.y); From da648927af94d08f40c9581e69674a859aca8c84 Mon Sep 17 00:00:00 2001 From: Daniela Date: Fri, 15 Sep 2017 12:41:15 +0100 Subject: [PATCH 3/7] Add Edit.js Entities spawn up according to the orientation of the avatar. --- scripts/system/edit.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 8b61226235..b686a900d5 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -247,9 +247,12 @@ var toolBar = (function () { direction = MyAvatar.orientation; } direction = Vec3.multiplyQbyV(direction, Vec3.UNIT_Z); - + // Align entity with Avatar orientation. + properties.rotation = MyAvatar.orientation; + var PRE_ADJUST_ENTITY_TYPES = ["Box", "Sphere", "Shape", "Text", "Web"]; if (PRE_ADJUST_ENTITY_TYPES.indexOf(properties.type) !== -1) { + // Adjust position of entity per bounding box prior to creating it. var registration = properties.registration; if (registration === undefined) { @@ -259,7 +262,14 @@ var toolBar = (function () { var orientation = properties.orientation; if (orientation === undefined) { - var DEFAULT_ORIENTATION = Quat.fromPitchYawRollDegrees(0, 0, 0); + properties.orientation = MyAvatar.orientation; + var DEFAULT_ORIENTATION = properties.orientation; + orientation = DEFAULT_ORIENTATION; + } else { + // If the orientation is already defined, we perform the corresponding rotation assuming that + // our start referential is the avatar referential. + properties.orientation = Quat.multiply(MyAvatar.orientation, properties.orientation); + var DEFAULT_ORIENTATION = properties.orientation; orientation = DEFAULT_ORIENTATION; } From a260aaaae898df5453ac7465e53af741cad46215 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Fri, 15 Sep 2017 16:17:41 -0700 Subject: [PATCH 4/7] Fix for lighting as IPD scale changes. --- interface/src/Application.cpp | 18 ++++++++++-------- interface/src/ui/overlays/Base3DOverlay.h | 3 --- .../src/display-plugins/hmd/HmdDisplayPlugin.h | 2 +- plugins/oculus/src/OculusBaseDisplayPlugin.cpp | 14 ++++++++++++++ plugins/oculus/src/OculusBaseDisplayPlugin.h | 1 + plugins/openvr/src/OpenVrDisplayPlugin.cpp | 13 +++++++++++++ plugins/openvr/src/OpenVrDisplayPlugin.h | 1 + 7 files changed, 40 insertions(+), 12 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3e69852e6b..dab15cfa2a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2413,10 +2413,18 @@ void Application::paintGL() { auto lodManager = DependencyManager::get(); RenderArgs renderArgs; + + float sensorToWorldScale = getMyAvatar()->getSensorToWorldScale(); { PROFILE_RANGE(render, "/buildFrustrumAndArgs"); { QMutexLocker viewLocker(&_viewMutex); + // adjust near clip plane to account for sensor scaling. + auto adjustedProjection = glm::perspective(_viewFrustum.getFieldOfView(), + _viewFrustum.getAspectRatio(), + DEFAULT_NEAR_CLIP * sensorToWorldScale, + _viewFrustum.getFarClip()); + _viewFrustum.setProjection(adjustedProjection); _viewFrustum.calculate(); } renderArgs = RenderArgs(_gpuContext, lodManager->getOctreeSizeScale(), @@ -2570,7 +2578,6 @@ void Application::paintGL() { float ipdScale = hmdInterface->getIPDScale(); // scale IPD by sensorToWorldScale, to make the world seem larger or smaller accordingly. - float sensorToWorldScale = getMyAvatar()->getSensorToWorldScale(); ipdScale *= sensorToWorldScale; mat4 eyeProjections[2]; @@ -2582,6 +2589,7 @@ void Application::paintGL() { // in the overlay render? // Viewport is assigned to the size of the framebuffer renderArgs._viewport = ivec4(0, 0, finalFramebufferSize.width(), finalFramebufferSize.height()); + auto baseProjection = renderArgs.getViewFrustum().getProjection(); if (displayPlugin->isStereo()) { // Stereo modes will typically have a larger projection matrix overall, // so we ask for the 'mono' projection matrix, which for stereo and HMD @@ -2592,17 +2600,11 @@ void Application::paintGL() { // just relying on the left FOV in each case and hoping that the // overall culling margin of error doesn't cause popping in the // right eye. There are FIXMEs in the relevant plugins - _myCamera.setProjection(displayPlugin->getCullingProjection(_myCamera.getProjection())); + _myCamera.setProjection(displayPlugin->getCullingProjection(baseProjection)); renderArgs._context->enableStereo(true); mat4 eyeOffsets[2]; mat4 eyeProjections[2]; - // adjust near clip plane by sensorToWorldScale - auto baseProjection = glm::perspective(renderArgs.getViewFrustum().getFieldOfView(), - renderArgs.getViewFrustum().getAspectRatio(), - renderArgs.getViewFrustum().getNearClip() * sensorToWorldScale, - renderArgs.getViewFrustum().getFarClip()); - // FIXME we probably don't need to set the projection matrix every frame, // only when the display plugin changes (or in non-HMD modes when the user // changes the FOV manually, which right now I don't think they can. diff --git a/interface/src/ui/overlays/Base3DOverlay.h b/interface/src/ui/overlays/Base3DOverlay.h index cc46fecfa5..6377b46d7d 100644 --- a/interface/src/ui/overlays/Base3DOverlay.h +++ b/interface/src/ui/overlays/Base3DOverlay.h @@ -16,9 +16,6 @@ #include "Overlay.h" -// AJT: keep or remove this. -// #define USE_SN_SCALE - class Base3DOverlay : public Overlay, public SpatiallyNestable { Q_OBJECT diff --git a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h index bcf2b16ac6..db4e0ff7a1 100644 --- a/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h +++ b/libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.h @@ -28,7 +28,7 @@ public: float getIPD() const override final { return _ipd; } glm::mat4 getEyeToHeadTransform(Eye eye) const override final { return _eyeOffsets[eye]; } glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override { return _eyeProjections[eye]; } - glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override final { return _cullingProjection; } + glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override { return _cullingProjection; } glm::uvec2 getRecommendedUiSize() const override final; glm::uvec2 getRecommendedRenderSize() const override final { return _renderTargetSize; } bool isDisplayVisible() const override { return isHmdMounted(); } diff --git a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp index aa39353b94..ea0af0d5f5 100644 --- a/plugins/oculus/src/OculusBaseDisplayPlugin.cpp +++ b/plugins/oculus/src/OculusBaseDisplayPlugin.cpp @@ -76,6 +76,20 @@ glm::mat4 OculusBaseDisplayPlugin::getEyeProjection(Eye eye, const glm::mat4& ba } } +glm::mat4 OculusBaseDisplayPlugin::getCullingProjection(const glm::mat4& baseProjection) const { + if (_session) { + ViewFrustum baseFrustum; + baseFrustum.setProjection(baseProjection); + float baseNearClip = baseFrustum.getNearClip(); + float baseFarClip = baseFrustum.getFarClip(); + auto combinedFov = _eyeFovs[0]; + combinedFov.LeftTan = combinedFov.RightTan = std::max(combinedFov.LeftTan, combinedFov.RightTan); + return toGlm(ovrMatrix4f_Projection(combinedFov, DEFAULT_NEAR_CLIP, DEFAULT_FAR_CLIP, ovrProjection_ClipRangeOpenGL)); + } else { + return baseProjection; + } +} + // DLL based display plugins MUST initialize GLEW inside the DLL code. void OculusBaseDisplayPlugin::customizeContext() { glewExperimental = true; diff --git a/plugins/oculus/src/OculusBaseDisplayPlugin.h b/plugins/oculus/src/OculusBaseDisplayPlugin.h index 4d14223618..b3b99c0ad1 100644 --- a/plugins/oculus/src/OculusBaseDisplayPlugin.h +++ b/plugins/oculus/src/OculusBaseDisplayPlugin.h @@ -20,6 +20,7 @@ public: bool isSupported() const override; glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override; + glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override; bool hasAsyncReprojection() const override { return true; } diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.cpp b/plugins/openvr/src/OpenVrDisplayPlugin.cpp index 25c85737fe..96ad19f46b 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.cpp +++ b/plugins/openvr/src/OpenVrDisplayPlugin.cpp @@ -370,6 +370,19 @@ glm::mat4 OpenVrDisplayPlugin::getEyeProjection(Eye eye, const glm::mat4& basePr } } +glm::mat4 OpenVrDisplayPlugin::getCullingProjection(const glm::mat4& baseProjection) const { + if (_system) { + ViewFrustum baseFrustum; + baseFrustum.setProjection(baseProjection); + float baseNearClip = baseFrustum.getNearClip(); + float baseFarClip = baseFrustum.getFarClip(); + // FIXME Calculate the proper combined projection by using GetProjectionRaw values from both eyes + return toGlm(_system->GetProjectionMatrix((vr::EVREye)0, baseNearClip, baseFarClip)); + } else { + return baseProjection; + } +} + float OpenVrDisplayPlugin::getTargetFrameRate() const { if (forceInterleavedReprojection && !_asyncReprojectionActive) { return TARGET_RATE_OpenVr / 2.0f; diff --git a/plugins/openvr/src/OpenVrDisplayPlugin.h b/plugins/openvr/src/OpenVrDisplayPlugin.h index 062345943a..6aea6ef575 100644 --- a/plugins/openvr/src/OpenVrDisplayPlugin.h +++ b/plugins/openvr/src/OpenVrDisplayPlugin.h @@ -39,6 +39,7 @@ public: const QString getName() const override { return NAME; } glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override; + glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override; void init() override; From 30a5f4b746c72c4ddf4144621fd1840418310ae5 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Mon, 18 Sep 2017 13:30:34 -0700 Subject: [PATCH 5/7] remove USE_N_SCALE preprocessor check --- interface/src/ui/overlays/ModelOverlay.cpp | 2 -- interface/src/ui/overlays/Sphere3DOverlay.cpp | 2 -- interface/src/ui/overlays/Volume3DOverlay.cpp | 2 -- 3 files changed, 6 deletions(-) diff --git a/interface/src/ui/overlays/ModelOverlay.cpp b/interface/src/ui/overlays/ModelOverlay.cpp index e2a7df7ae6..8ab44faaf9 100644 --- a/interface/src/ui/overlays/ModelOverlay.cpp +++ b/interface/src/ui/overlays/ModelOverlay.cpp @@ -47,9 +47,7 @@ void ModelOverlay::update(float deltatime) { _updateModel = false; _model->setSnapModelToCenter(true); Transform transform = getTransform(); -#ifndef USE_SN_SCALE transform.setScale(1.0f); // disable inherited scale -#endif if (_scaleToFit) { _model->setScaleToFit(true, transform.getScale() * getDimensions()); } else { diff --git a/interface/src/ui/overlays/Sphere3DOverlay.cpp b/interface/src/ui/overlays/Sphere3DOverlay.cpp index 83dc4b0e2b..3b3fe9d2bc 100644 --- a/interface/src/ui/overlays/Sphere3DOverlay.cpp +++ b/interface/src/ui/overlays/Sphere3DOverlay.cpp @@ -41,9 +41,7 @@ void Sphere3DOverlay::render(RenderArgs* args) { if (batch) { // FIXME Start using the _renderTransform instead of calling for Transform and Dimensions from here, do the custom things needed in evalRenderTransform() Transform transform = getTransform(); -#ifndef USE_SN_SCALE transform.setScale(1.0f); // ignore inherited scale from SpatiallyNestable -#endif transform.postScale(getDimensions() * SPHERE_OVERLAY_SCALE); batch->setModelTransform(transform); diff --git a/interface/src/ui/overlays/Volume3DOverlay.cpp b/interface/src/ui/overlays/Volume3DOverlay.cpp index 5e3e4ccee7..3f94c1fa7b 100644 --- a/interface/src/ui/overlays/Volume3DOverlay.cpp +++ b/interface/src/ui/overlays/Volume3DOverlay.cpp @@ -57,9 +57,7 @@ bool Volume3DOverlay::findRayIntersection(const glm::vec3& origin, const glm::ve // extents is the entity relative, scaled, centered extents of the entity glm::mat4 worldToEntityMatrix; Transform transform = getTransform(); -#ifndef USE_SN_SCALE transform.setScale(1.0f); // ignore any inherited scale from SpatiallyNestable -#endif transform.getInverseMatrix(worldToEntityMatrix); glm::vec3 overlayFrameOrigin = glm::vec3(worldToEntityMatrix * glm::vec4(origin, 1.0f)); From 13eb7db462e760b45d9fc345b05e0c3cc00a9434 Mon Sep 17 00:00:00 2001 From: Daniela Date: Thu, 28 Sep 2017 16:12:20 +0100 Subject: [PATCH 6/7] Change teleport.js to update render state more frequently. --- .../controllers/controllerModules/teleport.js | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/scripts/system/controllers/controllerModules/teleport.js b/scripts/system/controllers/controllerModules/teleport.js index 548179761c..0f40ccb22a 100644 --- a/scripts/system/controllers/controllerModules/teleport.js +++ b/scripts/system/controllers/controllerModules/teleport.js @@ -235,7 +235,35 @@ function Teleporter(hand) { this.hand === RIGHT_HAND ? ["rightHand"] : ["leftHand"], [], 100); + + this.updatePadDimensions = function() { + // pad scale with avatar size + var AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS = Vec3.multiply(MyAvatar.sensorToWorldScale, TARGET_MODEL_DIMENSIONS); + + cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; + teleportEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; + seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; + teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, + {name: "teleport", path: teleportPath, end: teleportEnd}, + {name: "seat", path: seatPath, end: seatEnd}]; + + LaserPointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]); + LaserPointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]); + LaserPointers.editRenderState(this.teleportRayHeadVisible, "cancel", teleportRenderStates[0]); + LaserPointers.editRenderState(this.teleportRayHeadInvisible, "cancel", teleportRenderStates[0]); + + LaserPointers.editRenderState(this.teleportRayHandVisible, "teleport", teleportRenderStates[1]); + LaserPointers.editRenderState(this.teleportRayHandInvisible, "teleport", teleportRenderStates[1]); + LaserPointers.editRenderState(this.teleportRayHeadVisible, "teleport", teleportRenderStates[1]); + LaserPointers.editRenderState(this.teleportRayHeadInvisible, "teleport", teleportRenderStates[1]); + + LaserPointers.editRenderState(this.teleportRayHandVisible, "seat", teleportRenderStates[2]); + LaserPointers.editRenderState(this.teleportRayHandInvisible, "seat", teleportRenderStates[2]); + LaserPointers.editRenderState(this.teleportRayHeadVisible, "seat", teleportRenderStates[2]); + LaserPointers.editRenderState(this.teleportRayHeadInvisible, "seat", teleportRenderStates[2]); + } + this.enterTeleport = function() { if (coolInTimeout !== null) { Script.clearTimeout(coolInTimeout); @@ -248,33 +276,7 @@ function Teleporter(hand) { } }, COOL_IN_DURATION); - // pad scale with avatar size - var AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS = Vec3.multiply(MyAvatar.sensorToWorldScale, TARGET_MODEL_DIMENSIONS); - - if (!Vec3.equal(AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS, cancelEnd.dimensions)) { - cancelEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; - teleportEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; - seatEnd.dimensions = AVATAR_PROPORTIONAL_TARGET_MODEL_DIMENSIONS; - - teleportRenderStates = [{name: "cancel", path: cancelPath, end: cancelEnd}, - {name: "teleport", path: teleportPath, end: teleportEnd}, - {name: "seat", path: seatPath, end: seatEnd}]; - - LaserPointers.editRenderState(this.teleportRayHandVisible, "cancel", teleportRenderStates[0]); - LaserPointers.editRenderState(this.teleportRayHandInvisible, "cancel", teleportRenderStates[0]); - LaserPointers.editRenderState(this.teleportRayHeadVisible, "cancel", teleportRenderStates[0]); - LaserPointers.editRenderState(this.teleportRayHeadInvisible, "cancel", teleportRenderStates[0]); - - LaserPointers.editRenderState(this.teleportRayHandVisible, "teleport", teleportRenderStates[1]); - LaserPointers.editRenderState(this.teleportRayHandInvisible, "teleport", teleportRenderStates[1]); - LaserPointers.editRenderState(this.teleportRayHeadVisible, "teleport", teleportRenderStates[1]); - LaserPointers.editRenderState(this.teleportRayHeadInvisible, "teleport", teleportRenderStates[1]); - - LaserPointers.editRenderState(this.teleportRayHandVisible, "seat", teleportRenderStates[2]); - LaserPointers.editRenderState(this.teleportRayHandInvisible, "seat", teleportRenderStates[2]); - LaserPointers.editRenderState(this.teleportRayHeadVisible, "seat", teleportRenderStates[2]); - LaserPointers.editRenderState(this.teleportRayHeadInvisible, "seat", teleportRenderStates[2]); - } + this.updatePadDimensions(); }; this.isReady = function(controllerData, deltaTime) { From 4a1dd975a92ef3bd8723db0f4566db86d5040494 Mon Sep 17 00:00:00 2001 From: Daniela Date: Thu, 28 Sep 2017 17:05:06 +0100 Subject: [PATCH 7/7] Fix bubble scale issue for IPD Secondary Task List: bubble.js Scale. --- scripts/system/bubble.js | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/scripts/system/bubble.js b/scripts/system/bubble.js index c3d240f9a5..4ea684ff06 100644 --- a/scripts/system/bubble.js +++ b/scripts/system/bubble.js @@ -25,10 +25,10 @@ // The bubble model itself var bubbleOverlay = Overlays.addOverlay("model", { url: Script.resolvePath("assets/models/Bubble-v14.fbx"), // If you'd like to change the model, modify this line (and the dimensions below) - dimensions: { x: 1.0, y: 0.75, z: 1.0 }, + dimensions: { x: MyAvatar.sensorToWorldScale, y: 0.75 * MyAvatar.sensorToWorldScale, z: MyAvatar.sensorToWorldScale }, position: { x: MyAvatar.position.x, y: -MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, z: MyAvatar.position.z }, rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), - scale: { x: 2 * MyAvatar.sensorToWorldScale, y: MyAvatar.scale * 0.5 + 0.2 * MyAvatar.sensorToWorldScale, z: 2 * MyAvatar.sensorToWorldScale }, + scale: { x: 2 , y: MyAvatar.scale * 0.5 + 0.5, z: 2 }, visible: false, ignoreRayIntersection: true }); @@ -62,6 +62,11 @@ } Overlays.editOverlay(bubbleOverlay, { + dimensions: { + x: MyAvatar.sensorToWorldScale, + y: 0.75 * MyAvatar.sensorToWorldScale, + z: MyAvatar.sensorToWorldScale + }, position: { x: MyAvatar.position.x, y: -MyAvatar.scale * 2 + MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, @@ -69,9 +74,9 @@ }, rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), scale: { - x: 2 * MyAvatar.sensorToWorldScale, - y: MyAvatar.scale * 0.5 + 0.2 * MyAvatar.sensorToWorldScale, - z: 2 * MyAvatar.sensorToWorldScale + x: 2 , + y: MyAvatar.scale * 0.5 + 0.5 , + z: 2 }, visible: true }); @@ -107,6 +112,11 @@ if (delay < BUBBLE_RAISE_ANIMATION_DURATION_MS) { Overlays.editOverlay(bubbleOverlay, { + dimensions: { + x: MyAvatar.sensorToWorldScale, + y: 0.75 * MyAvatar.sensorToWorldScale, + z: MyAvatar.sensorToWorldScale + }, // Quickly raise the bubble from the ground up position: { x: MyAvatar.position.x, @@ -115,14 +125,19 @@ }, rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), scale: { - x: 2 * MyAvatar.sensorToWorldScale, - y: ((1 - ((BUBBLE_RAISE_ANIMATION_DURATION_MS - delay) / BUBBLE_RAISE_ANIMATION_DURATION_MS)) * MyAvatar.scale * 0.5 + 0.2 * MyAvatar.sensorToWorldScale), - z: 2 * MyAvatar.sensorToWorldScale + x: 2 , + y: ((1 - ((BUBBLE_RAISE_ANIMATION_DURATION_MS - delay) / BUBBLE_RAISE_ANIMATION_DURATION_MS)) * MyAvatar.scale * 0.5 + 0.5), + z: 2 } }); } else { // Keep the bubble in place for a couple seconds Overlays.editOverlay(bubbleOverlay, { + dimensions: { + x: MyAvatar.sensorToWorldScale, + y: 0.75 * MyAvatar.sensorToWorldScale, + z: MyAvatar.sensorToWorldScale + }, position: { x: MyAvatar.position.x, y: MyAvatar.position.y + MyAvatar.scale * BUBBLE_HEIGHT_SCALE, @@ -130,9 +145,9 @@ }, rotation: Quat.multiply(MyAvatar.orientation, Quat.fromVec3Degrees({x: 0.0, y: 180.0, z: 0.0})), scale: { - x: 2 * MyAvatar.sensorToWorldScale, - y: MyAvatar.scale * 0.5 + 0.2 * MyAvatar.sensorToWorldScale, - z: 2 * MyAvatar.sensorToWorldScale + x: 2, + y: MyAvatar.scale * 0.5 + 0.5 , + z: 2 } }); }