mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 05:30:41 +02:00
Working on web entities
This commit is contained in:
parent
e9b83e1c02
commit
a8d343bbf1
10 changed files with 64 additions and 75 deletions
|
@ -438,18 +438,17 @@ var toolBar = (function () {
|
|||
}
|
||||
|
||||
if (newWebButton === toolBar.clicked(clickedOverlay)) {
|
||||
print("Web");
|
||||
var position = getPositionToCreateEntity();
|
||||
|
||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||
placingEntityID = Entities.addEntity({
|
||||
type: "Web",
|
||||
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
||||
dimensions: { x: 0.65, y: 0.3, z: 0.01 },
|
||||
source: "http://www.slashdot.org",
|
||||
dimensions: { x: 1.6, y: 0.9, z: 0.01 },
|
||||
sourceUrl: "https://highfidelity.com/",
|
||||
});
|
||||
} else {
|
||||
print("Can't create box: Text would be out of bounds.");
|
||||
print("Can't create Web Entity: would be out of bounds.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -283,7 +283,6 @@
|
|||
allSections.push(elModelSections);
|
||||
var elWebSourceURL = document.getElementById("property-web-source-url");
|
||||
|
||||
|
||||
var elTextSections = document.querySelectorAll(".text-section");
|
||||
allSections.push(elTextSections);
|
||||
var elTextText = document.getElementById("property-text-text");
|
||||
|
@ -1039,7 +1038,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="model-section property">
|
||||
<div class="label">Model URL</div>
|
||||
<div class="value">
|
||||
|
|
|
@ -2,44 +2,9 @@ import QtQuick 2.3
|
|||
import QtQuick.Controls 1.2
|
||||
import QtWebKit 3.0
|
||||
|
||||
Item {
|
||||
WebView {
|
||||
id: root
|
||||
implicitHeight: 600
|
||||
implicitWidth: 800
|
||||
Rectangle {
|
||||
anchors.margins: 120
|
||||
color: "#7f0000ff"
|
||||
anchors.right: parent.horizontalCenter
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.rightMargin: 10
|
||||
anchors.leftMargin: 10
|
||||
anchors.bottomMargin: 10
|
||||
anchors.topMargin: 10
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "#7Fff0000"
|
||||
anchors.left: parent.horizontalCenter
|
||||
anchors.leftMargin: 10
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 120
|
||||
anchors.right: parent.right
|
||||
anchors.topMargin: 10
|
||||
anchors.bottomMargin: 10
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.rightMargin: 10
|
||||
/*
|
||||
ScrollView {
|
||||
id: scrollView
|
||||
anchors.fill: parent
|
||||
WebView {
|
||||
id: webview
|
||||
objectName: "webview"
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
objectName: "webview"
|
||||
anchors.fill: parent
|
||||
url: "about:blank"
|
||||
}
|
||||
|
|
|
@ -3102,7 +3102,7 @@ ViewFrustum* Application::getViewFrustum() {
|
|||
#ifdef DEBUG
|
||||
if (QThread::currentThread() == activeRenderingThread) {
|
||||
// FIXME, should this be an assert?
|
||||
// qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
|
||||
qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
|
||||
}
|
||||
#endif
|
||||
return &_viewFrustum;
|
||||
|
@ -3112,7 +3112,7 @@ const ViewFrustum* Application::getViewFrustum() const {
|
|||
#ifdef DEBUG
|
||||
if (QThread::currentThread() == activeRenderingThread) {
|
||||
// FIXME, should this be an assert?
|
||||
// qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
|
||||
qWarning() << "Calling Application::getViewFrustum() from the active rendering thread, did you mean Application::getDisplayViewFrustum()?";
|
||||
}
|
||||
#endif
|
||||
return &_viewFrustum;
|
||||
|
@ -3122,7 +3122,7 @@ ViewFrustum* Application::getDisplayViewFrustum() {
|
|||
#ifdef DEBUG
|
||||
if (QThread::currentThread() != activeRenderingThread) {
|
||||
// FIXME, should this be an assert?
|
||||
// qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
|
||||
qWarning() << "Calling Application::getDisplayViewFrustum() from outside the active rendering thread or outside rendering, did you mean Application::getViewFrustum()?";
|
||||
}
|
||||
#endif
|
||||
return &_displayViewFrustum;
|
||||
|
@ -4688,3 +4688,7 @@ void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
|||
int Application::getMaxOctreePacketsPerSecond() {
|
||||
return _maxOctreePPS;
|
||||
}
|
||||
|
||||
AbstractViewStateInterface* AbstractViewStateInterface::instance() {
|
||||
return qApp;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <PerfStat.h>
|
||||
#include <TextRenderer.h>
|
||||
#include <OffscreenQmlSurface.h>
|
||||
#include <AbstractViewStateInterface.h>
|
||||
#include <GLMHelpers.h>
|
||||
#include <PathUtils.h>
|
||||
#include <TextureCache.h>
|
||||
|
@ -34,23 +35,43 @@ RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemI
|
|||
WebEntityItem(entityItemID, properties) {
|
||||
}
|
||||
|
||||
RenderableWebEntityItem::~RenderableWebEntityItem() {
|
||||
if (_webSurface) {
|
||||
_webSurface->pause();
|
||||
_webSurface->disconnect(_connection);
|
||||
if (_texture) {
|
||||
_webSurface->releaseTexture(_texture);
|
||||
_texture = 0;
|
||||
}
|
||||
_webSurface.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void RenderableWebEntityItem::render(RenderArgs* args) {
|
||||
QOpenGLContext * currentContext = QOpenGLContext::currentContext();
|
||||
QSurface * currentSurface = currentContext->surface();
|
||||
if (!_webSurface) {
|
||||
_webSurface = new OffscreenQmlSurface();
|
||||
_webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface());
|
||||
_webSurface->create(currentContext);
|
||||
_webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||
_webSurface->load("WebEntity.qml");
|
||||
_webSurface->resume();
|
||||
updateQmlSourceUrl();
|
||||
QObject::connect(_webSurface, &OffscreenQmlSurface::textureUpdated, [&](GLuint textureId) {
|
||||
_connection = QObject::connect(_webSurface.data(), &OffscreenQmlSurface::textureUpdated, [&](GLuint textureId) {
|
||||
_webSurface->lockTexture(textureId);
|
||||
assert(!glGetError());
|
||||
std::swap(_texture, textureId);
|
||||
if (textureId) {
|
||||
_webSurface->releaseTexture(textureId);
|
||||
}
|
||||
if (_texture) {
|
||||
_webSurface->makeCurrent();
|
||||
glBindTexture(GL_TEXTURE_2D, _texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
_webSurface->doneCurrent();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -77,7 +98,7 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
glm::vec3 axis = glm::axis(rotation);
|
||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
||||
|
||||
float alpha = 1.0f; //getBackgroundAlpha();
|
||||
float alpha = 1.0f;
|
||||
static const glm::vec2 texMin(0);
|
||||
static const glm::vec2 texMax(1);
|
||||
glm::vec2 topLeft(-halfDimensions.x, -halfDimensions.y);
|
||||
|
@ -88,13 +109,8 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
}
|
||||
|
||||
|
||||
// TODO: Determine if we want these entities to have the deferred lighting effect? I think we do, so that the color
|
||||
// used for a sphere, or box have the same look as those used on a text entity.
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(topLeft, bottomRight,
|
||||
texMin, texMax, glm::vec4(1));
|
||||
|
||||
DependencyManager::get<GeometryCache>()->renderQuad(
|
||||
topLeft, bottomRight, texMin, texMax, glm::vec4(1));
|
||||
if (_texture) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
@ -106,8 +122,10 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
|||
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
|
||||
if (_sourceUrl != value) {
|
||||
_sourceUrl = value;
|
||||
// Update the offscreen display
|
||||
updateQmlSourceUrl();
|
||||
AbstractViewStateInterface::instance()->postLambdaEvent([this] {
|
||||
// Update the offscreen display
|
||||
updateQmlSourceUrl();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +133,7 @@ void RenderableWebEntityItem::updateQmlSourceUrl() {
|
|||
if (!_webSurface) {
|
||||
return;
|
||||
}
|
||||
auto webView = _webSurface->getRootItem()->findChild<QQuickItem*>("webview");
|
||||
auto webView = _webSurface->getRootItem();
|
||||
if (!webView) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef hifi_RenderableWebEntityItem_h
|
||||
#define hifi_RenderableWebEntityItem_h
|
||||
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include <WebEntityItem.h>
|
||||
|
||||
class OffscreenQmlSurface;
|
||||
|
@ -18,14 +20,16 @@ public:
|
|||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||
|
||||
RenderableWebEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties);
|
||||
virtual void render(RenderArgs* args);
|
||||
~RenderableWebEntityItem();
|
||||
|
||||
virtual void render(RenderArgs* args);
|
||||
virtual void setSourceUrl(const QString& value);
|
||||
|
||||
private:
|
||||
void updateQmlSourceUrl();
|
||||
|
||||
OffscreenQmlSurface* _webSurface{ nullptr };
|
||||
QSharedPointer<OffscreenQmlSurface> _webSurface;
|
||||
QMetaObject::Connection _connection;
|
||||
uint32_t _texture{ 0 };
|
||||
};
|
||||
|
||||
|
|
|
@ -141,7 +141,6 @@ public:
|
|||
DEFINE_PROPERTY_GROUP(Atmosphere, atmosphere, AtmospherePropertyGroup);
|
||||
DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup);
|
||||
DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString);
|
||||
|
||||
|
||||
static QString getBackgroundModeString(BackgroundMode mode);
|
||||
|
||||
|
|
|
@ -30,16 +30,16 @@ class EntityTypes {
|
|||
public:
|
||||
typedef enum EntityType_t {
|
||||
Unknown,
|
||||
Box,
|
||||
Light,
|
||||
Line,
|
||||
Model,
|
||||
ParticleEffect,
|
||||
Box,
|
||||
Sphere,
|
||||
Light,
|
||||
Text,
|
||||
Web,
|
||||
ParticleEffect,
|
||||
Zone,
|
||||
LAST = Zone
|
||||
Web,
|
||||
Line,
|
||||
LAST = Line
|
||||
} EntityType;
|
||||
|
||||
static const QString& getEntityTypeName(EntityType entityType);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define hifi_AbstractViewStateInterface_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <functional>
|
||||
|
||||
class Transform;
|
||||
class QThread;
|
||||
|
@ -37,7 +38,7 @@ public:
|
|||
/// overrides environment data
|
||||
virtual void overrideEnvironmentData(const EnvironmentData& newData) = 0;
|
||||
virtual void endOverrideEnvironmentData() = 0;
|
||||
|
||||
|
||||
/// gets the shadow view frustum for rendering the view state
|
||||
virtual ViewFrustum* getShadowViewFrustum() = 0;
|
||||
|
||||
|
@ -53,6 +54,10 @@ public:
|
|||
virtual PickRay computePickRay(float x, float y) const = 0;
|
||||
|
||||
virtual const glm::vec3& getAvatarPosition() const = 0;
|
||||
|
||||
virtual void postLambdaEvent(std::function<void()> f) = 0;
|
||||
|
||||
static AbstractViewStateInterface* instance();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
//
|
||||
// OffscreenUi.cpp
|
||||
// interface/src/render-utils
|
||||
//
|
||||
// Created by Bradley Austin Davis on 2015-04-04
|
||||
// Created by Bradley Austin Davis on 2015-05-13
|
||||
// Copyright 2015 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
|
|
Loading…
Reference in a new issue