mirror of
https://github.com/overte-org/overte.git
synced 2025-06-18 22:01:52 +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)) {
|
if (newWebButton === toolBar.clicked(clickedOverlay)) {
|
||||||
print("Web");
|
|
||||||
var position = getPositionToCreateEntity();
|
var position = getPositionToCreateEntity();
|
||||||
|
|
||||||
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
if (position.x > 0 && position.y > 0 && position.z > 0) {
|
||||||
placingEntityID = Entities.addEntity({
|
placingEntityID = Entities.addEntity({
|
||||||
type: "Web",
|
type: "Web",
|
||||||
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
position: grid.snapToSurface(grid.snapToGrid(position, false, DEFAULT_DIMENSIONS), DEFAULT_DIMENSIONS),
|
||||||
dimensions: { x: 0.65, y: 0.3, z: 0.01 },
|
dimensions: { x: 1.6, y: 0.9, z: 0.01 },
|
||||||
source: "http://www.slashdot.org",
|
sourceUrl: "https://highfidelity.com/",
|
||||||
});
|
});
|
||||||
} else {
|
} 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,7 +283,6 @@
|
||||||
allSections.push(elModelSections);
|
allSections.push(elModelSections);
|
||||||
var elWebSourceURL = document.getElementById("property-web-source-url");
|
var elWebSourceURL = document.getElementById("property-web-source-url");
|
||||||
|
|
||||||
|
|
||||||
var elTextSections = document.querySelectorAll(".text-section");
|
var elTextSections = document.querySelectorAll(".text-section");
|
||||||
allSections.push(elTextSections);
|
allSections.push(elTextSections);
|
||||||
var elTextText = document.getElementById("property-text-text");
|
var elTextText = document.getElementById("property-text-text");
|
||||||
|
@ -1039,7 +1038,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="model-section property">
|
<div class="model-section property">
|
||||||
<div class="label">Model URL</div>
|
<div class="label">Model URL</div>
|
||||||
<div class="value">
|
<div class="value">
|
||||||
|
|
|
@ -2,44 +2,9 @@ import QtQuick 2.3
|
||||||
import QtQuick.Controls 1.2
|
import QtQuick.Controls 1.2
|
||||||
import QtWebKit 3.0
|
import QtWebKit 3.0
|
||||||
|
|
||||||
Item {
|
|
||||||
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 {
|
WebView {
|
||||||
id: webview
|
id: root
|
||||||
objectName: "webview"
|
objectName: "webview"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
url: "about:blank"
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3102,7 +3102,7 @@ ViewFrustum* Application::getViewFrustum() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (QThread::currentThread() == activeRenderingThread) {
|
if (QThread::currentThread() == activeRenderingThread) {
|
||||||
// FIXME, should this be an assert?
|
// 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
|
#endif
|
||||||
return &_viewFrustum;
|
return &_viewFrustum;
|
||||||
|
@ -3112,7 +3112,7 @@ const ViewFrustum* Application::getViewFrustum() const {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (QThread::currentThread() == activeRenderingThread) {
|
if (QThread::currentThread() == activeRenderingThread) {
|
||||||
// FIXME, should this be an assert?
|
// 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
|
#endif
|
||||||
return &_viewFrustum;
|
return &_viewFrustum;
|
||||||
|
@ -3122,7 +3122,7 @@ ViewFrustum* Application::getDisplayViewFrustum() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (QThread::currentThread() != activeRenderingThread) {
|
if (QThread::currentThread() != activeRenderingThread) {
|
||||||
// FIXME, should this be an assert?
|
// 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
|
#endif
|
||||||
return &_displayViewFrustum;
|
return &_displayViewFrustum;
|
||||||
|
@ -4688,3 +4688,7 @@ void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
||||||
int Application::getMaxOctreePacketsPerSecond() {
|
int Application::getMaxOctreePacketsPerSecond() {
|
||||||
return _maxOctreePPS;
|
return _maxOctreePPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AbstractViewStateInterface* AbstractViewStateInterface::instance() {
|
||||||
|
return qApp;
|
||||||
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <PerfStat.h>
|
#include <PerfStat.h>
|
||||||
#include <TextRenderer.h>
|
#include <TextRenderer.h>
|
||||||
#include <OffscreenQmlSurface.h>
|
#include <OffscreenQmlSurface.h>
|
||||||
|
#include <AbstractViewStateInterface.h>
|
||||||
#include <GLMHelpers.h>
|
#include <GLMHelpers.h>
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
#include <TextureCache.h>
|
#include <TextureCache.h>
|
||||||
|
@ -34,23 +35,43 @@ RenderableWebEntityItem::RenderableWebEntityItem(const EntityItemID& entityItemI
|
||||||
WebEntityItem(entityItemID, properties) {
|
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) {
|
void RenderableWebEntityItem::render(RenderArgs* args) {
|
||||||
QOpenGLContext * currentContext = QOpenGLContext::currentContext();
|
QOpenGLContext * currentContext = QOpenGLContext::currentContext();
|
||||||
QSurface * currentSurface = currentContext->surface();
|
QSurface * currentSurface = currentContext->surface();
|
||||||
if (!_webSurface) {
|
if (!_webSurface) {
|
||||||
_webSurface = new OffscreenQmlSurface();
|
_webSurface = QSharedPointer<OffscreenQmlSurface>(new OffscreenQmlSurface());
|
||||||
_webSurface->create(currentContext);
|
_webSurface->create(currentContext);
|
||||||
_webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
_webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||||
_webSurface->load("WebEntity.qml");
|
_webSurface->load("WebEntity.qml");
|
||||||
_webSurface->resume();
|
_webSurface->resume();
|
||||||
updateQmlSourceUrl();
|
updateQmlSourceUrl();
|
||||||
QObject::connect(_webSurface, &OffscreenQmlSurface::textureUpdated, [&](GLuint textureId) {
|
_connection = QObject::connect(_webSurface.data(), &OffscreenQmlSurface::textureUpdated, [&](GLuint textureId) {
|
||||||
_webSurface->lockTexture(textureId);
|
_webSurface->lockTexture(textureId);
|
||||||
assert(!glGetError());
|
assert(!glGetError());
|
||||||
std::swap(_texture, textureId);
|
std::swap(_texture, textureId);
|
||||||
if (textureId) {
|
if (textureId) {
|
||||||
_webSurface->releaseTexture(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);
|
glm::vec3 axis = glm::axis(rotation);
|
||||||
glRotatef(glm::degrees(glm::angle(rotation)), axis.x, axis.y, axis.z);
|
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 texMin(0);
|
||||||
static const glm::vec2 texMax(1);
|
static const glm::vec2 texMax(1);
|
||||||
glm::vec2 topLeft(-halfDimensions.x, -halfDimensions.y);
|
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_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
}
|
}
|
||||||
|
DependencyManager::get<GeometryCache>()->renderQuad(
|
||||||
|
topLeft, bottomRight, texMin, texMax, glm::vec4(1));
|
||||||
// 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));
|
|
||||||
|
|
||||||
if (_texture) {
|
if (_texture) {
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
@ -106,8 +122,10 @@ void RenderableWebEntityItem::render(RenderArgs* args) {
|
||||||
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
|
void RenderableWebEntityItem::setSourceUrl(const QString& value) {
|
||||||
if (_sourceUrl != value) {
|
if (_sourceUrl != value) {
|
||||||
_sourceUrl = value;
|
_sourceUrl = value;
|
||||||
|
AbstractViewStateInterface::instance()->postLambdaEvent([this] {
|
||||||
// Update the offscreen display
|
// Update the offscreen display
|
||||||
updateQmlSourceUrl();
|
updateQmlSourceUrl();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +133,7 @@ void RenderableWebEntityItem::updateQmlSourceUrl() {
|
||||||
if (!_webSurface) {
|
if (!_webSurface) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto webView = _webSurface->getRootItem()->findChild<QQuickItem*>("webview");
|
auto webView = _webSurface->getRootItem();
|
||||||
if (!webView) {
|
if (!webView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#ifndef hifi_RenderableWebEntityItem_h
|
#ifndef hifi_RenderableWebEntityItem_h
|
||||||
#define hifi_RenderableWebEntityItem_h
|
#define hifi_RenderableWebEntityItem_h
|
||||||
|
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
#include <WebEntityItem.h>
|
#include <WebEntityItem.h>
|
||||||
|
|
||||||
class OffscreenQmlSurface;
|
class OffscreenQmlSurface;
|
||||||
|
@ -18,14 +20,16 @@ public:
|
||||||
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
static EntityItem* factory(const EntityItemID& entityID, const EntityItemProperties& properties);
|
||||||
|
|
||||||
RenderableWebEntityItem(const EntityItemID& entityItemID, 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);
|
virtual void setSourceUrl(const QString& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateQmlSourceUrl();
|
void updateQmlSourceUrl();
|
||||||
|
|
||||||
OffscreenQmlSurface* _webSurface{ nullptr };
|
QSharedPointer<OffscreenQmlSurface> _webSurface;
|
||||||
|
QMetaObject::Connection _connection;
|
||||||
uint32_t _texture{ 0 };
|
uint32_t _texture{ 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -142,7 +142,6 @@ public:
|
||||||
DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup);
|
DEFINE_PROPERTY_GROUP(Skybox, skybox, SkyboxPropertyGroup);
|
||||||
DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString);
|
DEFINE_PROPERTY_REF(PROP_SOURCE_URL, SourceUrl, sourceUrl, QString);
|
||||||
|
|
||||||
|
|
||||||
static QString getBackgroundModeString(BackgroundMode mode);
|
static QString getBackgroundModeString(BackgroundMode mode);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,16 +30,16 @@ class EntityTypes {
|
||||||
public:
|
public:
|
||||||
typedef enum EntityType_t {
|
typedef enum EntityType_t {
|
||||||
Unknown,
|
Unknown,
|
||||||
Box,
|
|
||||||
Light,
|
|
||||||
Line,
|
|
||||||
Model,
|
Model,
|
||||||
ParticleEffect,
|
Box,
|
||||||
Sphere,
|
Sphere,
|
||||||
|
Light,
|
||||||
Text,
|
Text,
|
||||||
Web,
|
ParticleEffect,
|
||||||
Zone,
|
Zone,
|
||||||
LAST = Zone
|
Web,
|
||||||
|
Line,
|
||||||
|
LAST = Line
|
||||||
} EntityType;
|
} EntityType;
|
||||||
|
|
||||||
static const QString& getEntityTypeName(EntityType entityType);
|
static const QString& getEntityTypeName(EntityType entityType);
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define hifi_AbstractViewStateInterface_h
|
#define hifi_AbstractViewStateInterface_h
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
class Transform;
|
class Transform;
|
||||||
class QThread;
|
class QThread;
|
||||||
|
@ -53,6 +54,10 @@ public:
|
||||||
virtual PickRay computePickRay(float x, float y) const = 0;
|
virtual PickRay computePickRay(float x, float y) const = 0;
|
||||||
|
|
||||||
virtual const glm::vec3& getAvatarPosition() 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
|
// Created by Bradley Austin Davis on 2015-05-13
|
||||||
// interface/src/render-utils
|
|
||||||
//
|
|
||||||
// Created by Bradley Austin Davis on 2015-04-04
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
|
Loading…
Reference in a new issue