Merge pull request #605 from kasenvr/feature/transparent-web-entities

Transparent Web Entities
This commit is contained in:
kasenvr 2020-09-26 01:26:09 -04:00 committed by GitHub
commit ac6486052d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 109 additions and 13 deletions

View file

@ -8,7 +8,6 @@ WebView {
id: webview id: webview
url: "https://vircadia.com/" url: "https://vircadia.com/"
profile: FileTypeProfile; profile: FileTypeProfile;
property var parentRoot: null property var parentRoot: null
// Create a global EventBridge object for raiseAndLowerKeyboard. // Create a global EventBridge object for raiseAndLowerKeyboard.

View file

@ -3,6 +3,7 @@
// //
// Created by David Rowe on 16 Dec 2016. // Created by David Rowe on 16 Dec 2016.
// Copyright 2016 High Fidelity, Inc. // Copyright 2016 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -17,22 +18,31 @@ Item {
anchors.fill: parent anchors.fill: parent
property string url: "" property string url: ""
property string scriptUrl: null property string scriptUrl: null
property bool useBackground: true
onUrlChanged: { onUrlChanged: {
load(root.url, root.scriptUrl); load(root.url, root.scriptUrl, root.useBackground);
} }
onScriptUrlChanged: { onScriptUrlChanged: {
if (root.item) { if (root.item) {
root.item.scriptUrl = root.scriptUrl; root.item.scriptUrl = root.scriptUrl;
} else { } else {
load(root.url, root.scriptUrl); load(root.url, root.scriptUrl, root.useBackground);
}
}
onUseBackgroundChanged: {
if (root.item) {
root.item.useBackground = root.useBackground;
} else {
load(root.url, root.scriptUrl, root.useBackground);
} }
} }
property var item: null property var item: null
function load(url, scriptUrl) { function load(url, scriptUrl, useBackground) {
// Ensure we reset any existing item to "about:blank" to ensure web audio stops: DEV-2375 // Ensure we reset any existing item to "about:blank" to ensure web audio stops: DEV-2375
if (root.item != null) { if (root.item != null) {
root.item.url = "about:blank" root.item.url = "about:blank"
@ -43,11 +53,12 @@ Item {
root.item = newItem root.item = newItem
root.item.url = url root.item.url = url
root.item.scriptUrl = scriptUrl root.item.scriptUrl = scriptUrl
root.item.useBackground = useBackground
}) })
} }
Component.onCompleted: { Component.onCompleted: {
load(root.url, root.scriptUrl); load(root.url, root.scriptUrl, root.useBackground);
} }
signal sendToScript(var message); signal sendToScript(var message);

View file

@ -16,6 +16,7 @@ Item {
property alias webViewCoreProfile: webViewCore.profile property alias webViewCoreProfile: webViewCore.profile
property string webViewCoreUserAgent property string webViewCoreUserAgent
property bool useBackground: webViewCore.useBackground
property string userScriptUrl: "" property string userScriptUrl: ""
property string urlTag: "noDownload=false"; property string urlTag: "noDownload=false";
@ -98,6 +99,7 @@ Item {
width: parent.width width: parent.width
height: parent.height height: parent.height
backgroundColor: (flick.useBackground) ? "white" : "transparent"
profile: HFWebEngineProfile; profile: HFWebEngineProfile;
settings.pluginsEnabled: true settings.pluginsEnabled: true

View file

@ -14,6 +14,7 @@ Item {
property alias webViewCoreProfile: webViewCore.profile property alias webViewCoreProfile: webViewCore.profile
property string webViewCoreUserAgent property string webViewCoreUserAgent
property bool useBackground: webViewCore.useBackground
property string userScriptUrl: "" property string userScriptUrl: ""
property string urlTag: "noDownload=false"; property string urlTag: "noDownload=false";

View file

@ -23,6 +23,7 @@ Item {
property bool passwordField: false property bool passwordField: false
property alias flickable: webroot.interactive property alias flickable: webroot.interactive
property alias blurOnCtrlShift: webroot.blurOnCtrlShift property alias blurOnCtrlShift: webroot.blurOnCtrlShift
property alias useBackground: webroot.useBackground
function stop() { function stop() {
webroot.stop(); webroot.stop();

View file

@ -4,6 +4,7 @@
// //
// Created by Mark Peng on 8/16/13. // Created by Mark Peng on 8/16/13.
// Copyright 2012 High Fidelity, Inc. // Copyright 2012 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -51,6 +52,7 @@
#include <RecordingScriptingInterface.h> #include <RecordingScriptingInterface.h>
#include <RenderableModelEntityItem.h> #include <RenderableModelEntityItem.h>
#include <VariantMapToScriptValue.h> #include <VariantMapToScriptValue.h>
#include <NetworkingConstants.h>
#include "MyHead.h" #include "MyHead.h"
#include "MySkeletonModel.h" #include "MySkeletonModel.h"

View file

@ -4,6 +4,7 @@
// //
// Created by Clement on 3/17/14. // Created by Clement on 3/17/14.
// Copyright 2014 High Fidelity, Inc. // Copyright 2014 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -33,7 +34,7 @@
const char* MODEL_TYPE_NAMES[] = { "entities", "heads", "skeletons", "skeletons", "attachments" }; const char* MODEL_TYPE_NAMES[] = { "entities", "heads", "skeletons", "skeletons", "attachments" };
static const QString S3_URL = NetworkingConstants::HF_PUBLIC_CDN_URL; static const QString S3_URL = NetworkingConstants::HF_PUBLIC_CDN_URL;
static const QString PUBLIC_URL = "http://public.highfidelity.io"; // Needs to change to Vircadia...? static const QString PUBLIC_URL = "http://public.vircadia.com"; // Changed to Vircadia but not entirely sure what to do with this yet.
static const QString MODELS_LOCATION = "models/"; static const QString MODELS_LOCATION = "models/";
static const QString PREFIX_PARAMETER_NAME = "prefix"; static const QString PREFIX_PARAMETER_NAME = "prefix";

View file

@ -1,6 +1,7 @@
// //
// Created by Bradley Austin Davis on 2015/05/12 // Created by Bradley Austin Davis on 2015/05/12
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -35,6 +36,9 @@ using namespace render::entities;
const QString WebEntityRenderer::QML = "Web3DSurface.qml"; const QString WebEntityRenderer::QML = "Web3DSurface.qml";
const char* WebEntityRenderer::URL_PROPERTY = "url"; const char* WebEntityRenderer::URL_PROPERTY = "url";
const char* WebEntityRenderer::SCRIPT_URL_PROPERTY = "scriptURL";
const char* WebEntityRenderer::GLOBAL_POSITION_PROPERTY = "globalPosition";
const char* WebEntityRenderer::USE_BACKGROUND_PROPERTY = "useBackground";
std::function<void(QString, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> WebEntityRenderer::_acquireWebSurfaceOperator = nullptr; std::function<void(QString, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> WebEntityRenderer::_acquireWebSurfaceOperator = nullptr;
std::function<void(QSharedPointer<OffscreenQmlSurface>&, bool&, std::vector<QMetaObject::Connection>&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr; std::function<void(QSharedPointer<OffscreenQmlSurface>&, bool&, std::vector<QMetaObject::Connection>&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr;
@ -100,7 +104,7 @@ WebEntityRenderer::~WebEntityRenderer() {
bool WebEntityRenderer::isTransparent() const { bool WebEntityRenderer::isTransparent() const {
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
return fadeRatio < OPAQUE_ALPHA_THRESHOLD || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE; return fadeRatio < OPAQUE_ALPHA_THRESHOLD || _alpha < 1.0f || _pulseProperties.getAlphaMode() != PulseMode::NONE || !_useBackground;
} }
bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const { bool WebEntityRenderer::needsRenderUpdateFromTypedEntity(const TypedEntityPointer& entity) const {
@ -193,11 +197,15 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
if (_webSurface) { if (_webSurface) {
if (_webSurface->getRootItem()) { if (_webSurface->getRootItem()) {
if (_contentType == ContentType::HtmlContent && _sourceURL != newSourceURL) { if (_contentType == ContentType::HtmlContent && _sourceURL != newSourceURL) {
if (localSafeContext) { if (localSafeContext) {
::hifi::scripting::setLocalAccessSafeThread(true); ::hifi::scripting::setLocalAccessSafeThread(true);
} }
_webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL); _webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL);
_webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, _scriptURL);
_webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, _useBackground);
_webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(_contextPosition));
_webSurface->setMaxFps((QUrl(newSourceURL).host().endsWith("youtube.com", Qt::CaseInsensitive)) ? YOUTUBE_MAX_FPS : _maxFPS);
::hifi::scripting::setLocalAccessSafeThread(false); ::hifi::scripting::setLocalAccessSafeThread(false);
_sourceURL = newSourceURL; _sourceURL = newSourceURL;
} else if (_contentType != ContentType::HtmlContent) { } else if (_contentType != ContentType::HtmlContent) {
@ -207,7 +215,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
{ {
auto scriptURL = entity->getScriptURL(); auto scriptURL = entity->getScriptURL();
if (_scriptURL != scriptURL) { if (_scriptURL != scriptURL) {
_webSurface->getRootItem()->setProperty("scriptURL", _scriptURL); _webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, scriptURL);
_scriptURL = scriptURL; _scriptURL = scriptURL;
} }
} }
@ -226,10 +234,18 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
} }
} }
{
auto useBackground = entity->getUseBackground();
if (_useBackground != useBackground) {
_webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, useBackground);
_useBackground = useBackground;
}
}
{ {
auto contextPosition = entity->getWorldPosition(); auto contextPosition = entity->getWorldPosition();
if (_contextPosition != contextPosition) { if (_contextPosition != contextPosition) {
_webSurface->getSurfaceContext()->setContextProperty("globalPosition", vec3toVariant(contextPosition)); _webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(contextPosition));
_contextPosition = contextPosition; _contextPosition = contextPosition;
} }
} }
@ -290,12 +306,14 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
glm::vec4 color; glm::vec4 color;
Transform transform; Transform transform;
bool forward; bool forward;
bool transparent;
withReadLock([&] { withReadLock([&] {
float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f; float fadeRatio = _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) : 1.0f;
color = glm::vec4(toGlm(_color), _alpha * fadeRatio); color = glm::vec4(toGlm(_color), _alpha * fadeRatio);
color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created); color = EntityRenderer::calculatePulseColor(color, _pulseProperties, _created);
transform = _renderTransform; transform = _renderTransform;
forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == render::Args::FORWARD; forward = _renderLayer != RenderLayer::WORLD || args->_renderMethod == render::Args::FORWARD;
transparent = isTransparent();
}); });
if (color.a == 0.0f) { if (color.a == 0.0f) {
@ -309,7 +327,7 @@ void WebEntityRenderer::doRender(RenderArgs* args) {
// Turn off jitter for these entities // Turn off jitter for these entities
batch.pushProjectionJitter(); batch.pushProjectionJitter();
DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, color.a < OPAQUE_ALPHA_THRESHOLD, forward); DependencyManager::get<GeometryCache>()->bindWebBrowserProgram(batch, transparent, forward);
DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId); DependencyManager::get<GeometryCache>()->renderQuad(batch, topLeft, bottomRight, texMin, texMax, color, _geometryId);
batch.popProjectionJitter(); batch.popProjectionJitter();
batch.setResourceTexture(0, nullptr); batch.setResourceTexture(0, nullptr);

View file

@ -1,6 +1,7 @@
// //
// Created by Bradley Austin Davis on 2015/05/12 // Created by Bradley Austin Davis on 2015/05/12
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -32,6 +33,9 @@ public:
static const QString QML; static const QString QML;
static const char* URL_PROPERTY; static const char* URL_PROPERTY;
static const char* SCRIPT_URL_PROPERTY;
static const char* GLOBAL_POSITION_PROPERTY;
static const char* USE_BACKGROUND_PROPERTY;
static void setAcquireWebSurfaceOperator(std::function<void(const QString&, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> acquireWebSurfaceOperator) { _acquireWebSurfaceOperator = acquireWebSurfaceOperator; } static void setAcquireWebSurfaceOperator(std::function<void(const QString&, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> acquireWebSurfaceOperator) { _acquireWebSurfaceOperator = acquireWebSurfaceOperator; }
static void acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) { static void acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
@ -93,6 +97,7 @@ private:
uint16_t _dpi; uint16_t _dpi;
QString _scriptURL; QString _scriptURL;
uint8_t _maxFPS; uint8_t _maxFPS;
bool _useBackground;
WebInputMode _inputMode; WebInputMode _inputMode;
glm::vec3 _contextPosition; glm::vec3 _contextPosition;

View file

@ -602,6 +602,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
CHECK_PROPERTY_CHANGE(PROP_MAX_FPS, maxFPS); CHECK_PROPERTY_CHANGE(PROP_MAX_FPS, maxFPS);
CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode); CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode);
CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight); CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
CHECK_PROPERTY_CHANGE(PROP_WEB_USE_BACKGROUND, useBackground);
// Polyline // Polyline
CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints); CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints);
@ -1383,6 +1384,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
* @property {WebInputMode} inputMode="touch" - The user input mode to use. * @property {WebInputMode} inputMode="touch" - The user input mode to use.
* @property {boolean} showKeyboardFocusHighlight=true - <code>true</code> if the entity is highlighted when it has keyboard * @property {boolean} showKeyboardFocusHighlight=true - <code>true</code> if the entity is highlighted when it has keyboard
* focus, <code>false</code> if it isn't. * focus, <code>false</code> if it isn't.
* @property {boolean} useBackground=true - <code>true</code> if the web entity should have a background,
* <code>false</code> if the web entity's background should be transparent. The webpage must have CSS properties for transparency set
* on the <code>background-color</code> for this property to have an effect.
* @example <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption> * @example <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption>
* var METERS_TO_INCHES = 39.3701; * var METERS_TO_INCHES = 39.3701;
* var entity = Entities.addEntity({ * var entity = Entities.addEntity({
@ -1820,6 +1824,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_FPS, maxFPS); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_MAX_FPS, maxFPS);
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_INPUT_MODE, inputMode, getInputModeAsString()); COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_INPUT_MODE, inputMode, getInputModeAsString());
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_WEB_USE_BACKGROUND, useBackground);
} }
// PolyVoxel only // PolyVoxel only
@ -2201,6 +2206,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
COPY_PROPERTY_FROM_QSCRIPTVALUE(maxFPS, uint8_t, setMaxFPS); COPY_PROPERTY_FROM_QSCRIPTVALUE(maxFPS, uint8_t, setMaxFPS);
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode); COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode);
COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight); COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight);
COPY_PROPERTY_FROM_QSCRIPTVALUE(useBackground, bool, setUseBackground);
// Polyline // Polyline
COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints); COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints);
@ -2492,6 +2498,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
COPY_PROPERTY_IF_CHANGED(maxFPS); COPY_PROPERTY_IF_CHANGED(maxFPS);
COPY_PROPERTY_IF_CHANGED(inputMode); COPY_PROPERTY_IF_CHANGED(inputMode);
COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight); COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight);
COPY_PROPERTY_IF_CHANGED(useBackground);
// Polyline // Polyline
COPY_PROPERTY_IF_CHANGED(linePoints); COPY_PROPERTY_IF_CHANGED(linePoints);
@ -2891,6 +2898,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
ADD_PROPERTY_TO_MAP(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t); ADD_PROPERTY_TO_MAP(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t);
ADD_PROPERTY_TO_MAP(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode); ADD_PROPERTY_TO_MAP(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode);
ADD_PROPERTY_TO_MAP(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool); ADD_PROPERTY_TO_MAP(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool);
ADD_PROPERTY_TO_MAP(PROP_WEB_USE_BACKGROUND, useBackground, useBackground, bool);
// Polyline // Polyline
ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector<vec3>); ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector<vec3>);
@ -3321,6 +3329,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, properties.getMaxFPS()); APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, properties.getMaxFPS());
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode()); APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode());
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, properties.getShowKeyboardFocusHighlight()); APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, properties.getShowKeyboardFocusHighlight());
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, properties.getUseBackground());
} }
if (properties.getType() == EntityTypes::Line) { if (properties.getType() == EntityTypes::Line) {
@ -3796,6 +3805,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_FPS, uint8_t, setMaxFPS); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_MAX_FPS, uint8_t, setMaxFPS);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INPUT_MODE, WebInputMode, setInputMode); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INPUT_MODE, WebInputMode, setInputMode);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight); READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
} }
if (properties.getType() == EntityTypes::Line) { if (properties.getType() == EntityTypes::Line) {
@ -4183,6 +4193,7 @@ void EntityItemProperties::markAllChanged() {
_maxFPSChanged = true; _maxFPSChanged = true;
_inputModeChanged = true; _inputModeChanged = true;
_showKeyboardFocusHighlightChanged = true; _showKeyboardFocusHighlightChanged = true;
_useBackgroundChanged = true;
// Polyline // Polyline
_linePointsChanged = true; _linePointsChanged = true;
@ -4873,6 +4884,9 @@ QList<QString> EntityItemProperties::listChangedProperties() {
if (showKeyboardFocusHighlightChanged()) { if (showKeyboardFocusHighlightChanged()) {
out += "showKeyboardFocusHighlight"; out += "showKeyboardFocusHighlight";
} }
if (useBackgroundChanged()) {
out += "useBackground";
}
// Shape // Shape
if (shapeChanged()) { if (shapeChanged()) {

View file

@ -4,6 +4,7 @@
// //
// Created by Brad Hefta-Gaub on 12/4/13. // Created by Brad Hefta-Gaub on 12/4/13.
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -365,6 +366,7 @@ public:
DEFINE_PROPERTY_REF(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t, WebEntityItem::DEFAULT_MAX_FPS); DEFINE_PROPERTY_REF(PROP_MAX_FPS, MaxFPS, maxFPS, uint8_t, WebEntityItem::DEFAULT_MAX_FPS);
DEFINE_PROPERTY_REF_ENUM(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode, WebInputMode::TOUCH); DEFINE_PROPERTY_REF_ENUM(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode, WebInputMode::TOUCH);
DEFINE_PROPERTY_REF(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool, true); DEFINE_PROPERTY_REF(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool, true);
DEFINE_PROPERTY_REF(PROP_WEB_USE_BACKGROUND, UseBackground, useBackground, bool, true);
// Polyline // Polyline
DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector<glm::vec3>, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC); DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector<glm::vec3>, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC);

View file

@ -4,6 +4,7 @@
// //
// Created by Brad Hefta-Gaub on 12/4/13. // Created by Brad Hefta-Gaub on 12/4/13.
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -317,6 +318,7 @@ enum EntityPropertyList {
PROP_MAX_FPS = PROP_DERIVED_3, PROP_MAX_FPS = PROP_DERIVED_3,
PROP_INPUT_MODE = PROP_DERIVED_4, PROP_INPUT_MODE = PROP_DERIVED_4,
PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5, PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5,
PROP_WEB_USE_BACKGROUND = PROP_DERIVED_6,
// Polyline // Polyline
PROP_LINE_POINTS = PROP_DERIVED_0, PROP_LINE_POINTS = PROP_DERIVED_0,

View file

@ -1,6 +1,7 @@
// //
// Created by Bradley Austin Davis on 2015/05/12 // Created by Bradley Austin Davis on 2015/05/12
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -16,13 +17,14 @@
#include <ByteCountCoding.h> #include <ByteCountCoding.h>
#include <GeometryUtil.h> #include <GeometryUtil.h>
#include <shared/LocalFileAccessGate.h> #include <shared/LocalFileAccessGate.h>
#include <NetworkingConstants.h>
#include "EntitiesLogging.h" #include "EntitiesLogging.h"
#include "EntityItemProperties.h" #include "EntityItemProperties.h"
#include "EntityTree.h" #include "EntityTree.h"
#include "EntityTreeElement.h" #include "EntityTreeElement.h"
const QString WebEntityItem::DEFAULT_SOURCE_URL = "http://www.google.com"; const QString WebEntityItem::DEFAULT_SOURCE_URL = NetworkingConstants::WEB_ENTITY_DEFAULT_SOURCE_URL;
const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10; const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10;
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) { EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
@ -60,6 +62,7 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des
COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxFPS, getMaxFPS); COPY_ENTITY_PROPERTY_TO_PROPERTIES(maxFPS, getMaxFPS);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode); COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight); COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight);
COPY_ENTITY_PROPERTY_TO_PROPERTIES(useBackground, getUseBackground);
return properties; return properties;
} }
@ -81,6 +84,7 @@ bool WebEntityItem::setSubClassProperties(const EntityItemProperties& properties
SET_ENTITY_PROPERTY_FROM_PROPERTIES(maxFPS, setMaxFPS); SET_ENTITY_PROPERTY_FROM_PROPERTIES(maxFPS, setMaxFPS);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode); SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight); SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight);
SET_ENTITY_PROPERTY_FROM_PROPERTIES(useBackground, setUseBackground);
return somethingChanged; return somethingChanged;
} }
@ -110,6 +114,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
READ_ENTITY_PROPERTY(PROP_MAX_FPS, uint8_t, setMaxFPS); READ_ENTITY_PROPERTY(PROP_MAX_FPS, uint8_t, setMaxFPS);
READ_ENTITY_PROPERTY(PROP_INPUT_MODE, WebInputMode, setInputMode); READ_ENTITY_PROPERTY(PROP_INPUT_MODE, WebInputMode, setInputMode);
READ_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight); READ_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
READ_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
return bytesRead; return bytesRead;
} }
@ -127,6 +132,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa
requestedProperties += PROP_MAX_FPS; requestedProperties += PROP_MAX_FPS;
requestedProperties += PROP_INPUT_MODE; requestedProperties += PROP_INPUT_MODE;
requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT; requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT;
requestedProperties += PROP_WEB_USE_BACKGROUND;
return requestedProperties; return requestedProperties;
} }
@ -153,6 +159,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, getMaxFPS()); APPEND_ENTITY_PROPERTY(PROP_MAX_FPS, getMaxFPS());
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)getInputMode()); APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)getInputMode());
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, getShowKeyboardFocusHighlight()); APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, getShowKeyboardFocusHighlight());
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, getUseBackground());
} }
glm::vec3 WebEntityItem::getRaycastDimensions() const { glm::vec3 WebEntityItem::getRaycastDimensions() const {
@ -295,7 +302,7 @@ void WebEntityItem::setScriptURL(const QString& value) {
auto newURL = QUrl::fromUserInput(value); auto newURL = QUrl::fromUserInput(value);
if (!newURL.isValid()) { if (!newURL.isValid()) {
qCDebug(entities) << "Not setting web entity script URL since" << value << "cannot be parsed to a valid URL."; qCDebug(entities) << "Not setting web entity script URL since" << value << "cannot be parsed to a valid URL.";
return; return;
} }
@ -347,6 +354,17 @@ bool WebEntityItem::getShowKeyboardFocusHighlight() const {
return _showKeyboardFocusHighlight; return _showKeyboardFocusHighlight;
} }
void WebEntityItem::setUseBackground(bool value) {
withWriteLock([&] {
_needsRenderUpdate |= _useBackground != value;
_useBackground = value;
});
}
bool WebEntityItem::getUseBackground() const {
return resultWithReadLock<bool>([&] { return _useBackground; });
}
PulsePropertyGroup WebEntityItem::getPulseProperties() const { PulsePropertyGroup WebEntityItem::getPulseProperties() const {
return resultWithReadLock<PulsePropertyGroup>([&] { return resultWithReadLock<PulsePropertyGroup>([&] {
return _pulseProperties; return _pulseProperties;

View file

@ -1,6 +1,7 @@
// //
// Created by Bradley Austin Davis on 2015/05/12 // Created by Bradley Austin Davis on 2015/05/12
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -85,6 +86,9 @@ public:
bool getShowKeyboardFocusHighlight() const; bool getShowKeyboardFocusHighlight() const;
void setShowKeyboardFocusHighlight(bool value); void setShowKeyboardFocusHighlight(bool value);
bool getUseBackground() const;
void setUseBackground(bool value);
PulsePropertyGroup getPulseProperties() const; PulsePropertyGroup getPulseProperties() const;
@ -100,6 +104,7 @@ protected:
uint8_t _maxFPS; uint8_t _maxFPS;
WebInputMode _inputMode; WebInputMode _inputMode;
bool _showKeyboardFocusHighlight; bool _showKeyboardFocusHighlight;
bool _useBackground;
bool _localSafeContext { false }; bool _localSafeContext { false };
}; };

View file

@ -43,6 +43,11 @@ namespace NetworkingConstants {
const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml"); const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml");
const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml"); const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml");
// WebEntity Defaults
const QString WEB_ENTITY_DEFAULT_SOURCE_URL = "https://vircadia.com/";
const QString DEFAULT_AVATAR_COLLISION_SOUND_URL = "https://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/Body_Hits_Impact.wav";
// CDN URLs // CDN URLs
const QString HF_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-content/"; const QString HF_CONTENT_CDN_URL = "https://cdn-1.vircadia.com/eu-c-1/vircadia-content/";

View file

@ -4,6 +4,7 @@
// //
// Created by Stephen Birarda on 4/8/13. // Created by Stephen Birarda on 4/8/13.
// Copyright 2013 High Fidelity, Inc. // Copyright 2013 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -281,6 +282,7 @@ enum class EntityVersion : PacketVersion {
ScreenshareZone, ScreenshareZone,
ZoneOcclusion, ZoneOcclusion,
ModelBlendshapes, ModelBlendshapes,
TransparentWeb,
// Add new versions above here // Add new versions above here
NUM_PACKET_TYPE, NUM_PACKET_TYPE,

View file

@ -607,6 +607,9 @@
"webAlpha": { "webAlpha": {
"tooltip": "The opacity of the web entity between 0.0 fully transparent and 1.0 completely opaque." "tooltip": "The opacity of the web entity between 0.0 fully transparent and 1.0 completely opaque."
}, },
"useBackground": {
"tooltip": "If disabled, this web entity will support a transparent background for the webpage and its elements if the CSS property of 'background-color' on the 'body' is set with transparency."
},
"maxFPS": { "maxFPS": {
"tooltip": "The FPS at which to render the web entity. Higher values will have a performance impact." "tooltip": "The FPS at which to render the web entity. Higher values will have a performance impact."
}, },

View file

@ -762,6 +762,11 @@ const GROUPS = [
min: 0, min: 0,
max: 1, max: 1,
}, },
{
label: "Use Background",
type: "bool",
propertyID: "useBackground",
},
{ {
label: "Max FPS", label: "Max FPS",
type: "number-draggable", type: "number-draggable",