mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 16:18:19 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into commerce_extendedCerts_1
This commit is contained in:
commit
90f05f4db7
58 changed files with 802 additions and 475 deletions
|
@ -75,8 +75,6 @@ Item {
|
||||||
// TODO: Fix this unlikely bug
|
// TODO: Fix this unlikely bug
|
||||||
onVisibleChanged: {
|
onVisibleChanged: {
|
||||||
if (visible) {
|
if (visible) {
|
||||||
passphraseField.error = false;
|
|
||||||
passphraseField.focus = true;
|
|
||||||
sendSignalToParent({method: 'disableHmdPreview'});
|
sendSignalToParent({method: 'disableHmdPreview'});
|
||||||
} else {
|
} else {
|
||||||
sendSignalToParent({method: 'maybeEnableHmdPreview'});
|
sendSignalToParent({method: 'maybeEnableHmdPreview'});
|
||||||
|
@ -206,6 +204,14 @@ Item {
|
||||||
placeholderText: "passphrase";
|
placeholderText: "passphrase";
|
||||||
activeFocusOnPress: true;
|
activeFocusOnPress: true;
|
||||||
activeFocusOnTab: true;
|
activeFocusOnTab: true;
|
||||||
|
|
||||||
|
onVisibleChanged: {
|
||||||
|
if (visible) {
|
||||||
|
error = false;
|
||||||
|
focus = true;
|
||||||
|
forceActiveFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
root.keyboardRaised = focus;
|
root.keyboardRaised = focus;
|
||||||
|
|
|
@ -923,7 +923,7 @@ Item {
|
||||||
anchors.leftMargin: 20;
|
anchors.leftMargin: 20;
|
||||||
anchors.right: parent.right;
|
anchors.right: parent.right;
|
||||||
anchors.rightMargin: 20;
|
anchors.rightMargin: 20;
|
||||||
height: 140;
|
height: 95;
|
||||||
|
|
||||||
FontLoader { id: firaSansSemiBold; source: "../../../../../fonts/FiraSans-SemiBold.ttf"; }
|
FontLoader { id: firaSansSemiBold; source: "../../../../../fonts/FiraSans-SemiBold.ttf"; }
|
||||||
TextArea {
|
TextArea {
|
||||||
|
@ -947,8 +947,14 @@ Item {
|
||||||
wrapMode: TextEdit.Wrap;
|
wrapMode: TextEdit.Wrap;
|
||||||
activeFocusOnPress: true;
|
activeFocusOnPress: true;
|
||||||
activeFocusOnTab: true;
|
activeFocusOnTab: true;
|
||||||
// Workaround for no max length on TextAreas
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
// Don't allow tabs or newlines
|
||||||
|
if ((/[\n\r\t]/g).test(text)) {
|
||||||
|
var cursor = cursorPosition;
|
||||||
|
text = text.replace(/[\n\r\t]/g, '');
|
||||||
|
cursorPosition = cursor-1;
|
||||||
|
}
|
||||||
|
// Workaround for no max length on TextAreas
|
||||||
if (text.length > maximumLength) {
|
if (text.length > maximumLength) {
|
||||||
var cursor = cursorPosition;
|
var cursor = cursorPosition;
|
||||||
text = previousText;
|
text = previousText;
|
||||||
|
|
|
@ -131,7 +131,7 @@ Rectangle {
|
||||||
spacing: 5
|
spacing: 5
|
||||||
|
|
||||||
anchors.horizontalCenter: column3.horizontalCenter
|
anchors.horizontalCenter: column3.horizontalCenter
|
||||||
anchors.horizontalCenterOffset: -20
|
anchors.horizontalCenterOffset: 0
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
id: button1
|
id: button1
|
||||||
|
|
|
@ -130,6 +130,7 @@ Item {
|
||||||
flickableDirection: Flickable.AutoFlickIfNeeded
|
flickableDirection: Flickable.AutoFlickIfNeeded
|
||||||
keyNavigationEnabled: false
|
keyNavigationEnabled: false
|
||||||
highlightFollowsCurrentItem: false
|
highlightFollowsCurrentItem: false
|
||||||
|
interactive: false
|
||||||
|
|
||||||
property int previousGridIndex: -1
|
property int previousGridIndex: -1
|
||||||
|
|
||||||
|
|
|
@ -4829,7 +4829,6 @@ void Application::setKeyboardFocusHighlight(const glm::vec3& position, const glm
|
||||||
if (_keyboardFocusHighlightID == UNKNOWN_OVERLAY_ID || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) {
|
if (_keyboardFocusHighlightID == UNKNOWN_OVERLAY_ID || !getOverlays().isAddedOverlay(_keyboardFocusHighlightID)) {
|
||||||
_keyboardFocusHighlight = std::make_shared<Cube3DOverlay>();
|
_keyboardFocusHighlight = std::make_shared<Cube3DOverlay>();
|
||||||
_keyboardFocusHighlight->setAlpha(1.0f);
|
_keyboardFocusHighlight->setAlpha(1.0f);
|
||||||
_keyboardFocusHighlight->setBorderSize(1.0f);
|
|
||||||
_keyboardFocusHighlight->setColor({ 0xFF, 0xEF, 0x00 });
|
_keyboardFocusHighlight->setColor({ 0xFF, 0xEF, 0x00 });
|
||||||
_keyboardFocusHighlight->setIsSolid(false);
|
_keyboardFocusHighlight->setIsSolid(false);
|
||||||
_keyboardFocusHighlight->setPulseMin(0.5);
|
_keyboardFocusHighlight->setPulseMin(0.5);
|
||||||
|
@ -5969,7 +5968,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe
|
||||||
DependencyManager::get<TabletScriptingInterface>().data()->setToolbarScriptingInterface(toolbarScriptingInterface);
|
DependencyManager::get<TabletScriptingInterface>().data()->setToolbarScriptingInterface(toolbarScriptingInterface);
|
||||||
|
|
||||||
scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
scriptEngine->registerGlobalObject("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
||||||
qScriptRegisterMetaType(scriptEngine.data(), CustomPromptResultToScriptValue, CustomPromptResultFromScriptValue);
|
|
||||||
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
|
||||||
LocationScriptingInterface::locationSetter, "Window");
|
LocationScriptingInterface::locationSetter, "Window");
|
||||||
// register `location` on the global object.
|
// register `location` on the global object.
|
||||||
|
|
|
@ -210,6 +210,7 @@ Menu::Menu() {
|
||||||
auto avatarEntitiesBookmarks = DependencyManager::get<AvatarEntitiesBookmarks>();
|
auto avatarEntitiesBookmarks = DependencyManager::get<AvatarEntitiesBookmarks>();
|
||||||
avatarEntitiesBookmarks->setupMenus(this, avatarMenu);
|
avatarEntitiesBookmarks->setupMenus(this, avatarMenu);
|
||||||
|
|
||||||
|
|
||||||
// Display menu ----------------------------------
|
// Display menu ----------------------------------
|
||||||
// FIXME - this is not yet matching Alan's spec because it doesn't have
|
// FIXME - this is not yet matching Alan's spec because it doesn't have
|
||||||
// menus for "2D"/"3D" - we need to add support for detecting the appropriate
|
// menus for "2D"/"3D" - we need to add support for detecting the appropriate
|
||||||
|
|
|
@ -94,22 +94,6 @@ bool MenuScriptingInterface::menuItemExists(const QString& menu, const QString&
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuScriptingInterface::addActionGroup(const QString& groupName, const QStringList& actionList,
|
|
||||||
const QString& selected) {
|
|
||||||
static const char* slot = SLOT(menuItemTriggered());
|
|
||||||
QMetaObject::invokeMethod(Menu::getInstance(), "addActionGroup",
|
|
||||||
Q_ARG(const QString&, groupName),
|
|
||||||
Q_ARG(const QStringList&, actionList),
|
|
||||||
Q_ARG(const QString&, selected),
|
|
||||||
Q_ARG(QObject*, this),
|
|
||||||
Q_ARG(const char*, slot));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MenuScriptingInterface::removeActionGroup(const QString& groupName) {
|
|
||||||
QMetaObject::invokeMethod(Menu::getInstance(), "removeActionGroup",
|
|
||||||
Q_ARG(const QString&, groupName));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MenuScriptingInterface::isOptionChecked(const QString& menuOption) {
|
bool MenuScriptingInterface::isOptionChecked(const QString& menuOption) {
|
||||||
if (QThread::currentThread() == qApp->thread()) {
|
if (QThread::currentThread() == qApp->thread()) {
|
||||||
return Menu::getInstance()->isOptionChecked(menuOption);
|
return Menu::getInstance()->isOptionChecked(menuOption);
|
||||||
|
@ -147,19 +131,3 @@ void MenuScriptingInterface::setMenuEnabled(const QString& menuOption, bool isCh
|
||||||
void MenuScriptingInterface::triggerOption(const QString& menuOption) {
|
void MenuScriptingInterface::triggerOption(const QString& menuOption) {
|
||||||
QMetaObject::invokeMethod(Menu::getInstance(), "triggerOption", Q_ARG(const QString&, menuOption));
|
QMetaObject::invokeMethod(Menu::getInstance(), "triggerOption", Q_ARG(const QString&, menuOption));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuScriptingInterface::closeInfoView(const QString& path) {
|
|
||||||
QMetaObject::invokeMethod(Menu::getInstance(), "closeInfoView", Q_ARG(const QString&, path));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MenuScriptingInterface::isInfoViewVisible(const QString& path) {
|
|
||||||
if (QThread::currentThread() == qApp->thread()) {
|
|
||||||
return Menu::getInstance()->isInfoViewVisible(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool result;
|
|
||||||
BLOCKING_INVOKE_METHOD(Menu::getInstance(), "isInfoViewVisible",
|
|
||||||
Q_RETURN_ARG(bool, result), Q_ARG(const QString&, path));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -163,13 +163,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
bool menuItemExists(const QString& menuName, const QString& menuitem);
|
bool menuItemExists(const QString& menuName, const QString& menuitem);
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Not working; don't document until fixed.
|
|
||||||
*/
|
|
||||||
void addActionGroup(const QString& groupName, const QStringList& actionList,
|
|
||||||
const QString& selected = QString());
|
|
||||||
void removeActionGroup(const QString& groupName);
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Check whether a checkable menu item is checked.
|
* Check whether a checkable menu item is checked.
|
||||||
* @function Menu.isOptionChecked
|
* @function Menu.isOptionChecked
|
||||||
|
@ -222,12 +215,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Not used or useful; will not document until used.
|
|
||||||
*/
|
|
||||||
void closeInfoView(const QString& path);
|
|
||||||
bool isInfoViewVisible(const QString& path);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Triggered when a menu item is clicked (or triggered by {@link Menu.triggerOption}).
|
* Triggered when a menu item is clicked (or triggered by {@link Menu.triggerOption}).
|
||||||
|
|
|
@ -32,20 +32,6 @@ static const QString LAST_BROWSE_LOCATION_SETTING = "LastBrowseLocation";
|
||||||
static const QString LAST_BROWSE_ASSETS_LOCATION_SETTING = "LastBrowseAssetsLocation";
|
static const QString LAST_BROWSE_ASSETS_LOCATION_SETTING = "LastBrowseAssetsLocation";
|
||||||
|
|
||||||
|
|
||||||
QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result) {
|
|
||||||
if (!result.value.isValid()) {
|
|
||||||
return QScriptValue::UndefinedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(result.value.userType() == qMetaTypeId<QVariantMap>());
|
|
||||||
return engine->toScriptValue(result.value.toMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result) {
|
|
||||||
result.value = object.toVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WindowScriptingInterface::WindowScriptingInterface() {
|
WindowScriptingInterface::WindowScriptingInterface() {
|
||||||
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
const DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||||
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
connect(&domainHandler, &DomainHandler::connectedToDomain, this, &WindowScriptingInterface::domainChanged);
|
||||||
|
@ -143,14 +129,6 @@ void WindowScriptingInterface::disconnectedFromDomain() {
|
||||||
emit domainChanged("");
|
emit domainChanged("");
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) {
|
|
||||||
CustomPromptResult result;
|
|
||||||
bool ok = false;
|
|
||||||
auto configMap = config.toMap();
|
|
||||||
result.value = OffscreenUi::getCustomInfo(OffscreenUi::ICON_NONE, "", configMap, &ok);
|
|
||||||
return ok ? result : CustomPromptResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString fixupPathForMac(const QString& directory) {
|
QString fixupPathForMac(const QString& directory) {
|
||||||
// On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
|
// On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus
|
||||||
// filename if the directory is valid.
|
// filename if the directory is valid.
|
||||||
|
|
|
@ -22,17 +22,6 @@
|
||||||
|
|
||||||
#include <DependencyManager.h>
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
class CustomPromptResult {
|
|
||||||
public:
|
|
||||||
QVariant value;
|
|
||||||
};
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(CustomPromptResult);
|
|
||||||
|
|
||||||
QScriptValue CustomPromptResultToScriptValue(QScriptEngine* engine, const CustomPromptResult& result);
|
|
||||||
void CustomPromptResultFromScriptValue(const QScriptValue& object, CustomPromptResult& result);
|
|
||||||
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* The Window API provides various facilities not covered elsewhere: window dimensions, window focus, normal or entity camera
|
* The Window API provides various facilities not covered elsewhere: window dimensions, window focus, normal or entity camera
|
||||||
* view, clipboard, announcements, user connections, common dialog boxes, snapshots, file import, domain changes, domain
|
* view, clipboard, announcements, user connections, common dialog boxes, snapshots, file import, domain changes, domain
|
||||||
|
@ -142,15 +131,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void promptAsync(const QString& message = "", const QString& defaultText = "");
|
void promptAsync(const QString& message = "", const QString& defaultText = "");
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Prompt the user for input in a custom, modal dialog.
|
|
||||||
* @deprecated This function is deprecated and will soon be removed.
|
|
||||||
* @function Window.customPrompt
|
|
||||||
* @param {object} config - Configures the modal dialog.
|
|
||||||
* @returns {object} The user's response.
|
|
||||||
*/
|
|
||||||
CustomPromptResult customPrompt(const QVariant& config);
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Prompt the user to choose a directory. Displays a modal dialog that navigates the directory tree.
|
* Prompt the user to choose a directory. Displays a modal dialog that navigates the directory tree.
|
||||||
* @function Window.browseDir
|
* @function Window.browseDir
|
||||||
|
|
|
@ -42,8 +42,6 @@ private:
|
||||||
int _domainStatusBorder;
|
int _domainStatusBorder;
|
||||||
int _magnifierBorder;
|
int _magnifierBorder;
|
||||||
|
|
||||||
ivec2 _previousBorderSize{ -1 };
|
|
||||||
|
|
||||||
gpu::TexturePointer _uiTexture;
|
gpu::TexturePointer _uiTexture;
|
||||||
gpu::TexturePointer _overlayDepthTexture;
|
gpu::TexturePointer _overlayDepthTexture;
|
||||||
gpu::TexturePointer _overlayColorTexture;
|
gpu::TexturePointer _overlayColorTexture;
|
||||||
|
|
|
@ -125,13 +125,6 @@ Cube3DOverlay* Cube3DOverlay::createClone() const {
|
||||||
|
|
||||||
void Cube3DOverlay::setProperties(const QVariantMap& properties) {
|
void Cube3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
Volume3DOverlay::setProperties(properties);
|
Volume3DOverlay::setProperties(properties);
|
||||||
|
|
||||||
auto borderSize = properties["borderSize"];
|
|
||||||
|
|
||||||
if (borderSize.isValid()) {
|
|
||||||
float value = borderSize.toFloat();
|
|
||||||
setBorderSize(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -177,14 +170,8 @@ void Cube3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
* <code>parentID</code> is an avatar skeleton. A value of <code>65535</code> means "no joint".
|
* <code>parentID</code> is an avatar skeleton. A value of <code>65535</code> means "no joint".
|
||||||
*
|
*
|
||||||
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
|
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
|
||||||
*
|
|
||||||
* @property {number} borderSize - Not used.
|
|
||||||
*/
|
*/
|
||||||
QVariant Cube3DOverlay::getProperty(const QString& property) {
|
QVariant Cube3DOverlay::getProperty(const QString& property) {
|
||||||
if (property == "borderSize") {
|
|
||||||
return _borderSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Volume3DOverlay::getProperty(property);
|
return Volume3DOverlay::getProperty(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,10 +29,6 @@ public:
|
||||||
|
|
||||||
virtual Cube3DOverlay* createClone() const override;
|
virtual Cube3DOverlay* createClone() const override;
|
||||||
|
|
||||||
float getBorderSize() const { return _borderSize; }
|
|
||||||
|
|
||||||
void setBorderSize(float value) { _borderSize = value; }
|
|
||||||
|
|
||||||
void setProperties(const QVariantMap& properties) override;
|
void setProperties(const QVariantMap& properties) override;
|
||||||
QVariant getProperty(const QString& property) override;
|
QVariant getProperty(const QString& property) override;
|
||||||
|
|
||||||
|
@ -40,7 +36,6 @@ protected:
|
||||||
Transform evalRenderTransform() override;
|
Transform evalRenderTransform() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _borderSize;
|
|
||||||
// edges on a cube
|
// edges on a cube
|
||||||
std::array<int, 12> _geometryIds;
|
std::array<int, 12> _geometryIds;
|
||||||
};
|
};
|
||||||
|
|
|
@ -388,21 +388,6 @@ QString Overlays::getOverlayType(OverlayID overlayId) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject* Overlays::getOverlayObject(OverlayID id) {
|
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
QObject* result;
|
|
||||||
PROFILE_RANGE(script, __FUNCTION__);
|
|
||||||
BLOCKING_INVOKE_METHOD(this, "getOverlayObject", Q_RETURN_ARG(QObject*, result), Q_ARG(OverlayID, id));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
Overlay::Pointer thisOverlay = getOverlay(id);
|
|
||||||
if (thisOverlay) {
|
|
||||||
return qobject_cast<QObject*>(&(*thisOverlay));
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
return UNKNOWN_OVERLAY_ID;
|
return UNKNOWN_OVERLAY_ID;
|
||||||
|
|
|
@ -98,6 +98,11 @@ public:
|
||||||
OverlayID addOverlay(Overlay* overlay) { return addOverlay(Overlay::Pointer(overlay)); }
|
OverlayID addOverlay(Overlay* overlay) { return addOverlay(Overlay::Pointer(overlay)); }
|
||||||
OverlayID addOverlay(const Overlay::Pointer& overlay);
|
OverlayID addOverlay(const Overlay::Pointer& overlay);
|
||||||
|
|
||||||
|
RayToOverlayIntersectionResult findRayIntersectionVector(const PickRay& ray, bool precisionPicking,
|
||||||
|
const QVector<OverlayID>& overlaysToInclude,
|
||||||
|
const QVector<OverlayID>& overlaysToDiscard,
|
||||||
|
bool visibleOnly = false, bool collidableOnly = false);
|
||||||
|
|
||||||
bool mousePressEvent(QMouseEvent* event);
|
bool mousePressEvent(QMouseEvent* event);
|
||||||
bool mouseDoublePressEvent(QMouseEvent* event);
|
bool mouseDoublePressEvent(QMouseEvent* event);
|
||||||
bool mouseReleaseEvent(QMouseEvent* event);
|
bool mouseReleaseEvent(QMouseEvent* event);
|
||||||
|
@ -227,15 +232,6 @@ public slots:
|
||||||
*/
|
*/
|
||||||
QString getOverlayType(OverlayID overlayId);
|
QString getOverlayType(OverlayID overlayId);
|
||||||
|
|
||||||
/**jsdoc
|
|
||||||
* Get the overlay script object.
|
|
||||||
* @function Overlays.getOverlayObject
|
|
||||||
* @deprecated This function is deprecated and will soon be removed.
|
|
||||||
* @param {Uuid} overlayID - The ID of the overlay to get the script object of.
|
|
||||||
* @returns {object} The script object for the overlay if found.
|
|
||||||
*/
|
|
||||||
QObject* getOverlayObject(OverlayID id);
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Get the ID of the 2D overlay at a particular point on the screen or HUD.
|
* Get the ID of the 2D overlay at a particular point on the screen or HUD.
|
||||||
* @function Overlays.getOverlayAtPoint
|
* @function Overlays.getOverlayAtPoint
|
||||||
|
@ -356,28 +352,6 @@ public slots:
|
||||||
bool visibleOnly = false,
|
bool visibleOnly = false,
|
||||||
bool collidableOnly = false);
|
bool collidableOnly = false);
|
||||||
|
|
||||||
// TODO: Apart from the name, this function signature on JavaScript is identical to that of findRayIntersection() and should
|
|
||||||
// probably be removed from the JavaScript API so as not to cause confusion.
|
|
||||||
/**jsdoc
|
|
||||||
* Find the closest 3D overlay intersected by a {@link PickRay}.
|
|
||||||
* @function Overlays.findRayIntersectionVector
|
|
||||||
* @deprecated Use {@link Overlays.findRayIntersection} instead; it has identical parameters and results.
|
|
||||||
* @param {PickRay} pickRay - The PickRay to use for finding overlays.
|
|
||||||
* @param {boolean} [precisionPicking=false] - <em>Unused</em>; exists to match Entity API.
|
|
||||||
* @param {Array.<Uuid>} [overlayIDsToInclude=[]] - Whitelist for intersection test. If empty then the result isn't limited
|
|
||||||
* to overlays in the list.
|
|
||||||
* @param {Array.<Uuid>} [overlayIDsToExclude=[]] - Blacklist for intersection test. If empty then the result doesn't
|
|
||||||
* exclude overlays in the list.
|
|
||||||
* @param {boolean} [visibleOnly=false] - <em>Unused</em>; exists to match Entity API.
|
|
||||||
* @param {boolean} [collidableOnly=false] - <em>Unused</em>; exists to match Entity API.
|
|
||||||
* @returns {Overlays.RayToOverlayIntersectionResult} The closest 3D overlay intersected by <code>pickRay</code>, taking
|
|
||||||
* into account <code>overlayIDsToInclude</code> and <code>overlayIDsToExclude</code> if they're not empty.
|
|
||||||
*/
|
|
||||||
RayToOverlayIntersectionResult findRayIntersectionVector(const PickRay& ray, bool precisionPicking,
|
|
||||||
const QVector<OverlayID>& overlaysToInclude,
|
|
||||||
const QVector<OverlayID>& overlaysToDiscard,
|
|
||||||
bool visibleOnly = false, bool collidableOnly = false);
|
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Return a list of 3D overlays with bounding boxes that touch a search sphere.
|
* Return a list of 3D overlays with bounding boxes that touch a search sphere.
|
||||||
* @function Overlays.findOverlays
|
* @function Overlays.findOverlays
|
||||||
|
|
|
@ -99,13 +99,6 @@ void Shape3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto borderSize = properties["borderSize"];
|
|
||||||
|
|
||||||
if (borderSize.isValid()) {
|
|
||||||
float value = borderSize.toFloat();
|
|
||||||
setBorderSize(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -153,13 +146,8 @@ void Shape3DOverlay::setProperties(const QVariantMap& properties) {
|
||||||
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
|
* @property {Vec3} dimensions - The dimensions of the overlay. Synonyms: <code>scale</code>, <code>size</code>.
|
||||||
*
|
*
|
||||||
* @property {Shape} shape=Hexagon - The geometrical shape of the overlay.
|
* @property {Shape} shape=Hexagon - The geometrical shape of the overlay.
|
||||||
* @property {number} borderSize - Not used.
|
|
||||||
*/
|
*/
|
||||||
QVariant Shape3DOverlay::getProperty(const QString& property) {
|
QVariant Shape3DOverlay::getProperty(const QString& property) {
|
||||||
if (property == "borderSize") {
|
|
||||||
return _borderSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (property == "shape") {
|
if (property == "shape") {
|
||||||
return shapeStrings[_shape];
|
return shapeStrings[_shape];
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,6 @@ public:
|
||||||
|
|
||||||
virtual Shape3DOverlay* createClone() const override;
|
virtual Shape3DOverlay* createClone() const override;
|
||||||
|
|
||||||
float getBorderSize() const { return _borderSize; }
|
|
||||||
|
|
||||||
void setBorderSize(float value) { _borderSize = value; }
|
|
||||||
|
|
||||||
void setProperties(const QVariantMap& properties) override;
|
void setProperties(const QVariantMap& properties) override;
|
||||||
QVariant getProperty(const QString& property) override;
|
QVariant getProperty(const QString& property) override;
|
||||||
|
|
||||||
|
@ -41,7 +37,6 @@ protected:
|
||||||
Transform evalRenderTransform() override;
|
Transform evalRenderTransform() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
float _borderSize;
|
|
||||||
GeometryCache::Shape _shape { GeometryCache::Hexagon };
|
GeometryCache::Shape _shape { GeometryCache::Hexagon };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -434,9 +434,13 @@ void Rig::setJointRotation(int index, bool valid, const glm::quat& rotation, flo
|
||||||
|
|
||||||
bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const {
|
bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const {
|
||||||
bool success { false };
|
bool success { false };
|
||||||
if (QThread::currentThread() == thread()) {
|
glm::vec3 originalPosition = position;
|
||||||
|
bool onOwnerThread = (QThread::currentThread() == thread());
|
||||||
|
glm::vec3 poseSetTrans;
|
||||||
|
if (onOwnerThread) {
|
||||||
if (isIndexValid(jointIndex)) {
|
if (isIndexValid(jointIndex)) {
|
||||||
position = (rotation * _internalPoseSet._absolutePoses[jointIndex].trans()) + translation;
|
poseSetTrans = _internalPoseSet._absolutePoses[jointIndex].trans();
|
||||||
|
position = (rotation * poseSetTrans) + translation;
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -444,7 +448,8 @@ bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm:
|
||||||
} else {
|
} else {
|
||||||
QReadLocker readLock(&_externalPoseSetLock);
|
QReadLocker readLock(&_externalPoseSetLock);
|
||||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
||||||
position = (rotation * _externalPoseSet._absolutePoses[jointIndex].trans()) + translation;
|
poseSetTrans = _externalPoseSet._absolutePoses[jointIndex].trans();
|
||||||
|
position = (rotation * poseSetTrans) + translation;
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
success = false;
|
success = false;
|
||||||
|
@ -452,7 +457,14 @@ bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNaN(position)) {
|
if (isNaN(position)) {
|
||||||
qCWarning(animation) << "Rig::getJointPositionInWorldFrame produces NaN";
|
qCWarning(animation) << "Rig::getJointPositionInWorldFrame produced NaN."
|
||||||
|
<< " is owner thread = " << onOwnerThread
|
||||||
|
<< " position = " << originalPosition
|
||||||
|
<< " translation = " << translation
|
||||||
|
<< " rotation = " << rotation
|
||||||
|
<< " poseSetTrans = " << poseSetTrans
|
||||||
|
<< " success = " << success
|
||||||
|
<< " jointIndex = " << jointIndex;
|
||||||
success = false;
|
success = false;
|
||||||
position = glm::vec3(0.0f);
|
position = glm::vec3(0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ QList<EntityItemID> EntityEditFilters::getZonesByPosition(glm::vec3& position) {
|
||||||
return zones;
|
return zones;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged,
|
bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut,
|
||||||
EntityTree::FilterType filterType, EntityItemID& itemID) {
|
bool& wasChanged, EntityTree::FilterType filterType, EntityItemID& itemID, EntityItemPointer& existingEntity) {
|
||||||
|
|
||||||
// get the ids of all the zones (plus the global entity edit filter) that the position
|
// get the ids of all the zones (plus the global entity edit filter) that the position
|
||||||
// lies within
|
// lies within
|
||||||
|
@ -61,6 +61,17 @@ bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& proper
|
||||||
if (filterData.rejectAll) {
|
if (filterData.rejectAll) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check to see if this filter wants to filter this message type
|
||||||
|
if ((!filterData.wantsToFilterEdit && filterType == EntityTree::FilterType::Edit) ||
|
||||||
|
(!filterData.wantsToFilterPhysics && filterType == EntityTree::FilterType::Physics) ||
|
||||||
|
(!filterData.wantsToFilterDelete && filterType == EntityTree::FilterType::Delete) ||
|
||||||
|
(!filterData.wantsToFilterAdd && filterType == EntityTree::FilterType::Add)) {
|
||||||
|
|
||||||
|
wasChanged = false;
|
||||||
|
return true; // accept the message
|
||||||
|
}
|
||||||
|
|
||||||
auto oldProperties = propertiesIn.getDesiredProperties();
|
auto oldProperties = propertiesIn.getDesiredProperties();
|
||||||
auto specifiedProperties = propertiesIn.getChangedProperties();
|
auto specifiedProperties = propertiesIn.getChangedProperties();
|
||||||
propertiesIn.setDesiredProperties(specifiedProperties);
|
propertiesIn.setDesiredProperties(specifiedProperties);
|
||||||
|
@ -68,16 +79,62 @@ bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& proper
|
||||||
propertiesIn.setDesiredProperties(oldProperties);
|
propertiesIn.setDesiredProperties(oldProperties);
|
||||||
|
|
||||||
auto in = QJsonValue::fromVariant(inputValues.toVariant()); // grab json copy now, because the inputValues might be side effected by the filter.
|
auto in = QJsonValue::fromVariant(inputValues.toVariant()); // grab json copy now, because the inputValues might be side effected by the filter.
|
||||||
|
|
||||||
QScriptValueList args;
|
QScriptValueList args;
|
||||||
args << inputValues;
|
args << inputValues;
|
||||||
args << filterType;
|
args << filterType;
|
||||||
|
|
||||||
|
// get the current properties for then entity and include them for the filter call
|
||||||
|
if (existingEntity && filterData.wantsOriginalProperties) {
|
||||||
|
auto currentProperties = existingEntity->getProperties(filterData.includedOriginalProperties);
|
||||||
|
QScriptValue currentValues = currentProperties.copyToScriptValue(filterData.engine, false, true, true);
|
||||||
|
args << currentValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// get the zone properties
|
||||||
|
if (filterData.wantsZoneProperties) {
|
||||||
|
auto zoneEntity = _tree->findEntityByEntityItemID(id);
|
||||||
|
if (zoneEntity) {
|
||||||
|
auto zoneProperties = zoneEntity->getProperties(filterData.includedZoneProperties);
|
||||||
|
QScriptValue zoneValues = zoneProperties.copyToScriptValue(filterData.engine, false, true, true);
|
||||||
|
|
||||||
|
if (filterData.wantsZoneBoundingBox) {
|
||||||
|
bool success = true;
|
||||||
|
AABox aaBox = zoneEntity->getAABox(success);
|
||||||
|
if (success) {
|
||||||
|
QScriptValue boundingBox = filterData.engine->newObject();
|
||||||
|
QScriptValue bottomRightNear = vec3toScriptValue(filterData.engine, aaBox.getCorner());
|
||||||
|
QScriptValue topFarLeft = vec3toScriptValue(filterData.engine, aaBox.calcTopFarLeft());
|
||||||
|
QScriptValue center = vec3toScriptValue(filterData.engine, aaBox.calcCenter());
|
||||||
|
QScriptValue boundingBoxDimensions = vec3toScriptValue(filterData.engine, aaBox.getDimensions());
|
||||||
|
boundingBox.setProperty("brn", bottomRightNear);
|
||||||
|
boundingBox.setProperty("tfl", topFarLeft);
|
||||||
|
boundingBox.setProperty("center", center);
|
||||||
|
boundingBox.setProperty("dimensions", boundingBoxDimensions);
|
||||||
|
zoneValues.setProperty("boundingBox", boundingBox);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this is an add or delete, or original properties weren't requested
|
||||||
|
// there won't be original properties in the args, but zone properties need
|
||||||
|
// to be the fourth parameter, so we need to pad the args accordingly
|
||||||
|
int EXPECTED_ARGS = 3;
|
||||||
|
if (args.length() < EXPECTED_ARGS) {
|
||||||
|
args << QScriptValue();
|
||||||
|
}
|
||||||
|
assert(args.length() == EXPECTED_ARGS); // we MUST have 3 args by now!
|
||||||
|
args << zoneValues;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QScriptValue result = filterData.filterFn.call(_nullObjectForFilter, args);
|
QScriptValue result = filterData.filterFn.call(_nullObjectForFilter, args);
|
||||||
|
|
||||||
if (filterData.uncaughtExceptions()) {
|
if (filterData.uncaughtExceptions()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isObject()){
|
if (result.isObject()) {
|
||||||
// make propertiesIn reflect the changes, for next filter...
|
// make propertiesIn reflect the changes, for next filter...
|
||||||
propertiesIn.copyFromScriptValue(result, false);
|
propertiesIn.copyFromScriptValue(result, false);
|
||||||
|
|
||||||
|
@ -86,6 +143,17 @@ bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& proper
|
||||||
// Javascript objects are == only if they are the same object. To compare arbitrary values, we need to use JSON.
|
// Javascript objects are == only if they are the same object. To compare arbitrary values, we need to use JSON.
|
||||||
auto out = QJsonValue::fromVariant(result.toVariant());
|
auto out = QJsonValue::fromVariant(result.toVariant());
|
||||||
wasChanged |= (in != out);
|
wasChanged |= (in != out);
|
||||||
|
} else if (result.isBool()) {
|
||||||
|
|
||||||
|
// if the filter returned false, then it's authoritative
|
||||||
|
if (!result.toBool()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise, assume it wants to pass all properties
|
||||||
|
propertiesOut = propertiesIn;
|
||||||
|
wasChanged = false;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -182,8 +250,8 @@ static bool hadUncaughtExceptions(QScriptEngine& engine, const QString& fileName
|
||||||
void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
|
void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
|
||||||
qDebug() << "script request completed for entity " << entityID;
|
qDebug() << "script request completed for entity " << entityID;
|
||||||
auto scriptRequest = qobject_cast<ResourceRequest*>(sender());
|
auto scriptRequest = qobject_cast<ResourceRequest*>(sender());
|
||||||
const QString urlString = scriptRequest->getUrl().toString();
|
|
||||||
if (scriptRequest && scriptRequest->getResult() == ResourceRequest::Success) {
|
if (scriptRequest && scriptRequest->getResult() == ResourceRequest::Success) {
|
||||||
|
const QString urlString = scriptRequest->getUrl().toString();
|
||||||
auto scriptContents = scriptRequest->getData();
|
auto scriptContents = scriptRequest->getData();
|
||||||
qInfo() << "Downloaded script:" << scriptContents;
|
qInfo() << "Downloaded script:" << scriptContents;
|
||||||
QScriptProgram program(scriptContents, urlString);
|
QScriptProgram program(scriptContents, urlString);
|
||||||
|
@ -207,6 +275,7 @@ void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
|
||||||
entitiesObject.setProperty("ADD_FILTER_TYPE", EntityTree::FilterType::Add);
|
entitiesObject.setProperty("ADD_FILTER_TYPE", EntityTree::FilterType::Add);
|
||||||
entitiesObject.setProperty("EDIT_FILTER_TYPE", EntityTree::FilterType::Edit);
|
entitiesObject.setProperty("EDIT_FILTER_TYPE", EntityTree::FilterType::Edit);
|
||||||
entitiesObject.setProperty("PHYSICS_FILTER_TYPE", EntityTree::FilterType::Physics);
|
entitiesObject.setProperty("PHYSICS_FILTER_TYPE", EntityTree::FilterType::Physics);
|
||||||
|
entitiesObject.setProperty("DELETE_FILTER_TYPE", EntityTree::FilterType::Delete);
|
||||||
global.setProperty("Entities", entitiesObject);
|
global.setProperty("Entities", entitiesObject);
|
||||||
filterData.filterFn = global.property("filter");
|
filterData.filterFn = global.property("filter");
|
||||||
if (!filterData.filterFn.isFunction()) {
|
if (!filterData.filterFn.isFunction()) {
|
||||||
|
@ -214,8 +283,86 @@ void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
|
||||||
delete engine;
|
delete engine;
|
||||||
filterData.rejectAll=true;
|
filterData.rejectAll=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if the wantsToFilterEdit is a boolean evaluate as a boolean, otherwise assume true
|
||||||
|
QScriptValue wantsToFilterAddValue = filterData.filterFn.property("wantsToFilterAdd");
|
||||||
|
filterData.wantsToFilterAdd = wantsToFilterAddValue.isBool() ? wantsToFilterAddValue.toBool() : true;
|
||||||
|
|
||||||
|
// if the wantsToFilterEdit is a boolean evaluate as a boolean, otherwise assume true
|
||||||
|
QScriptValue wantsToFilterEditValue = filterData.filterFn.property("wantsToFilterEdit");
|
||||||
|
filterData.wantsToFilterEdit = wantsToFilterEditValue.isBool() ? wantsToFilterEditValue.toBool() : true;
|
||||||
|
|
||||||
|
// if the wantsToFilterPhysics is a boolean evaluate as a boolean, otherwise assume true
|
||||||
|
QScriptValue wantsToFilterPhysicsValue = filterData.filterFn.property("wantsToFilterPhysics");
|
||||||
|
filterData.wantsToFilterPhysics = wantsToFilterPhysicsValue.isBool() ? wantsToFilterPhysicsValue.toBool() : true;
|
||||||
|
|
||||||
|
// if the wantsToFilterDelete is a boolean evaluate as a boolean, otherwise assume false
|
||||||
|
QScriptValue wantsToFilterDeleteValue = filterData.filterFn.property("wantsToFilterDelete");
|
||||||
|
filterData.wantsToFilterDelete = wantsToFilterDeleteValue.isBool() ? wantsToFilterDeleteValue.toBool() : false;
|
||||||
|
|
||||||
|
// check to see if the filterFn has properties asking for Original props
|
||||||
|
QScriptValue wantsOriginalPropertiesValue = filterData.filterFn.property("wantsOriginalProperties");
|
||||||
|
// if the wantsOriginalProperties is a boolean, or a string, or list of strings, then evaluate as follows:
|
||||||
|
// - boolean - true - include all original properties
|
||||||
|
// false - no properties at all
|
||||||
|
// - string - empty - no properties at all
|
||||||
|
// any valid property - include just that property in the Original properties
|
||||||
|
// - list of strings - include only those properties in the Original properties
|
||||||
|
if (wantsOriginalPropertiesValue.isBool()) {
|
||||||
|
filterData.wantsOriginalProperties = wantsOriginalPropertiesValue.toBool();
|
||||||
|
} else if (wantsOriginalPropertiesValue.isString()) {
|
||||||
|
auto stringValue = wantsOriginalPropertiesValue.toString();
|
||||||
|
filterData.wantsOriginalProperties = !stringValue.isEmpty();
|
||||||
|
if (filterData.wantsOriginalProperties) {
|
||||||
|
EntityPropertyFlagsFromScriptValue(wantsOriginalPropertiesValue, filterData.includedOriginalProperties);
|
||||||
|
}
|
||||||
|
} else if (wantsOriginalPropertiesValue.isArray()) {
|
||||||
|
EntityPropertyFlagsFromScriptValue(wantsOriginalPropertiesValue, filterData.includedOriginalProperties);
|
||||||
|
filterData.wantsOriginalProperties = !filterData.includedOriginalProperties.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// check to see if the filterFn has properties asking for Zone props
|
||||||
|
QScriptValue wantsZonePropertiesValue = filterData.filterFn.property("wantsZoneProperties");
|
||||||
|
// if the wantsZoneProperties is a boolean, or a string, or list of strings, then evaluate as follows:
|
||||||
|
// - boolean - true - include all Zone properties
|
||||||
|
// false - no properties at all
|
||||||
|
// - string - empty - no properties at all
|
||||||
|
// any valid property - include just that property in the Zone properties
|
||||||
|
// - list of strings - include only those properties in the Zone properties
|
||||||
|
if (wantsZonePropertiesValue.isBool()) {
|
||||||
|
filterData.wantsZoneProperties = wantsZonePropertiesValue.toBool();
|
||||||
|
filterData.wantsZoneBoundingBox = filterData.wantsZoneProperties; // include this too
|
||||||
|
} else if (wantsZonePropertiesValue.isString()) {
|
||||||
|
auto stringValue = wantsZonePropertiesValue.toString();
|
||||||
|
filterData.wantsZoneProperties = !stringValue.isEmpty();
|
||||||
|
if (filterData.wantsZoneProperties) {
|
||||||
|
if (stringValue == "boundingBox") {
|
||||||
|
filterData.wantsZoneBoundingBox = true;
|
||||||
|
} else {
|
||||||
|
EntityPropertyFlagsFromScriptValue(wantsZonePropertiesValue, filterData.includedZoneProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (wantsZonePropertiesValue.isArray()) {
|
||||||
|
auto length = wantsZonePropertiesValue.property("length").toInteger();
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
auto stringValue = wantsZonePropertiesValue.property(i).toString();
|
||||||
|
if (!stringValue.isEmpty()) {
|
||||||
|
filterData.wantsZoneProperties = true;
|
||||||
|
|
||||||
|
// boundingBox is a special case since it's not a true EntityPropertyFlag, so we
|
||||||
|
// need to detect it here.
|
||||||
|
if (stringValue == "boundingBox") {
|
||||||
|
filterData.wantsZoneBoundingBox = true;
|
||||||
|
break; // we can break here, since there are no other special cases
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (filterData.wantsZoneProperties) {
|
||||||
|
EntityPropertyFlagsFromScriptValue(wantsZonePropertiesValue, filterData.includedZoneProperties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_lock.lockForWrite();
|
_lock.lockForWrite();
|
||||||
_filterDataMap.insert(entityID, filterData);
|
_filterDataMap.insert(entityID, filterData);
|
||||||
_lock.unlock();
|
_lock.unlock();
|
||||||
|
@ -227,6 +374,7 @@ void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (scriptRequest) {
|
} else if (scriptRequest) {
|
||||||
|
const QString urlString = scriptRequest->getUrl().toString();
|
||||||
qCritical() << "Failed to download script at" << urlString;
|
qCritical() << "Failed to download script at" << urlString;
|
||||||
// See HTTPResourceRequest::onRequestFinished for interpretation of codes. For example, a 404 is code 6 and 403 is 3. A timeout is 2. Go figure.
|
// See HTTPResourceRequest::onRequestFinished for interpretation of codes. For example, a 404 is code 6 and 403 is 3. A timeout is 2. Go figure.
|
||||||
qCritical() << "ResourceRequest error was" << scriptRequest->getResult();
|
qCritical() << "ResourceRequest error was" << scriptRequest->getResult();
|
||||||
|
|
|
@ -28,6 +28,18 @@ class EntityEditFilters : public QObject, public Dependency {
|
||||||
public:
|
public:
|
||||||
struct FilterData {
|
struct FilterData {
|
||||||
QScriptValue filterFn;
|
QScriptValue filterFn;
|
||||||
|
bool wantsOriginalProperties { false };
|
||||||
|
bool wantsZoneProperties { false };
|
||||||
|
|
||||||
|
bool wantsToFilterAdd { true };
|
||||||
|
bool wantsToFilterEdit { true };
|
||||||
|
bool wantsToFilterPhysics { true };
|
||||||
|
bool wantsToFilterDelete { true };
|
||||||
|
|
||||||
|
EntityPropertyFlags includedOriginalProperties;
|
||||||
|
EntityPropertyFlags includedZoneProperties;
|
||||||
|
bool wantsZoneBoundingBox { false };
|
||||||
|
|
||||||
std::function<bool()> uncaughtExceptions;
|
std::function<bool()> uncaughtExceptions;
|
||||||
QScriptEngine* engine;
|
QScriptEngine* engine;
|
||||||
bool rejectAll;
|
bool rejectAll;
|
||||||
|
@ -43,7 +55,7 @@ public:
|
||||||
void removeFilter(EntityItemID entityID);
|
void removeFilter(EntityItemID entityID);
|
||||||
|
|
||||||
bool filter(glm::vec3& position, EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged,
|
bool filter(glm::vec3& position, EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged,
|
||||||
EntityTree::FilterType filterType, EntityItemID& entityID);
|
EntityTree::FilterType filterType, EntityItemID& entityID, EntityItemPointer& existingEntity);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void filterAdded(EntityItemID id, bool success);
|
void filterAdded(EntityItemID id, bool success);
|
||||||
|
|
|
@ -593,7 +593,10 @@ void EntityScriptingInterface::deleteEntity(QUuid id) {
|
||||||
if (entity->getLocked()) {
|
if (entity->getLocked()) {
|
||||||
shouldDelete = false;
|
shouldDelete = false;
|
||||||
} else {
|
} else {
|
||||||
_entityTree->deleteEntity(entityID);
|
// only delete local entities, server entities will round trip through the server filters
|
||||||
|
if (entity->getClientOnly()) {
|
||||||
|
_entityTree->deleteEntity(entityID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1105,7 +1105,7 @@ bool EntityTree::filterProperties(EntityItemPointer& existingEntity, EntityItemP
|
||||||
if (entityEditFilters) {
|
if (entityEditFilters) {
|
||||||
auto position = existingEntity ? existingEntity->getWorldPosition() : propertiesIn.getPosition();
|
auto position = existingEntity ? existingEntity->getWorldPosition() : propertiesIn.getPosition();
|
||||||
auto entityID = existingEntity ? existingEntity->getEntityItemID() : EntityItemID();
|
auto entityID = existingEntity ? existingEntity->getEntityItemID() : EntityItemID();
|
||||||
accepted = entityEditFilters->filter(position, propertiesIn, propertiesOut, wasChanged, filterType, entityID);
|
accepted = entityEditFilters->filter(position, propertiesIn, propertiesOut, wasChanged, filterType, entityID, existingEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
return accepted;
|
return accepted;
|
||||||
|
@ -1868,6 +1868,36 @@ void EntityTree::forgetEntitiesDeletedBefore(quint64 sinceTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool EntityTree::shouldEraseEntity(EntityItemID entityID, const SharedNodePointer& sourceNode) {
|
||||||
|
EntityItemPointer existingEntity;
|
||||||
|
|
||||||
|
auto startLookup = usecTimestampNow();
|
||||||
|
existingEntity = findEntityByEntityItemID(entityID);
|
||||||
|
auto endLookup = usecTimestampNow();
|
||||||
|
_totalLookupTime += endLookup - startLookup;
|
||||||
|
|
||||||
|
auto startFilter = usecTimestampNow();
|
||||||
|
FilterType filterType = FilterType::Delete;
|
||||||
|
EntityItemProperties dummyProperties;
|
||||||
|
bool wasChanged = false;
|
||||||
|
|
||||||
|
bool allowed = (sourceNode->isAllowedEditor()) || filterProperties(existingEntity, dummyProperties, dummyProperties, wasChanged, filterType);
|
||||||
|
auto endFilter = usecTimestampNow();
|
||||||
|
|
||||||
|
_totalFilterTime += endFilter - startFilter;
|
||||||
|
|
||||||
|
if (allowed) {
|
||||||
|
if (wantEditLogging() || wantTerseEditLogging()) {
|
||||||
|
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityID;
|
||||||
|
}
|
||||||
|
} else if (wantEditLogging() || wantTerseEditLogging()) {
|
||||||
|
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] attempted to deleteentity. ID:" << entityID << " Filter rejected erase.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: consider consolidating processEraseMessageDetails() and processEraseMessage()
|
// TODO: consider consolidating processEraseMessageDetails() and processEraseMessage()
|
||||||
int EntityTree::processEraseMessage(ReceivedMessage& message, const SharedNodePointer& sourceNode) {
|
int EntityTree::processEraseMessage(ReceivedMessage& message, const SharedNodePointer& sourceNode) {
|
||||||
#ifdef EXTRA_ERASE_DEBUGGING
|
#ifdef EXTRA_ERASE_DEBUGGING
|
||||||
|
@ -1895,12 +1925,10 @@ int EntityTree::processEraseMessage(ReceivedMessage& message, const SharedNodePo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EntityItemID entityItemID(entityID);
|
EntityItemID entityItemID(entityID);
|
||||||
entityItemIDsToDelete << entityItemID;
|
|
||||||
|
|
||||||
if (wantEditLogging() || wantTerseEditLogging()) {
|
if (shouldEraseEntity(entityID, sourceNode)) {
|
||||||
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityItemID;
|
entityItemIDsToDelete << entityItemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
deleteEntities(entityItemIDsToDelete, true, true);
|
deleteEntities(entityItemIDsToDelete, true, true);
|
||||||
}
|
}
|
||||||
|
@ -1946,10 +1974,9 @@ int EntityTree::processEraseMessageDetails(const QByteArray& dataByteArray, cons
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EntityItemID entityItemID(entityID);
|
EntityItemID entityItemID(entityID);
|
||||||
entityItemIDsToDelete << entityItemID;
|
|
||||||
|
|
||||||
if (wantEditLogging() || wantTerseEditLogging()) {
|
if (shouldEraseEntity(entityID, sourceNode)) {
|
||||||
qCDebug(entities) << "User [" << sourceNode->getUUID() << "] deleting entity. ID:" << entityItemID;
|
entityItemIDsToDelete << entityItemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ public:
|
||||||
enum FilterType {
|
enum FilterType {
|
||||||
Add,
|
Add,
|
||||||
Edit,
|
Edit,
|
||||||
Physics
|
Physics,
|
||||||
|
Delete
|
||||||
};
|
};
|
||||||
EntityTree(bool shouldReaverage = false);
|
EntityTree(bool shouldReaverage = false);
|
||||||
virtual ~EntityTree();
|
virtual ~EntityTree();
|
||||||
|
@ -193,6 +194,8 @@ public:
|
||||||
|
|
||||||
int processEraseMessage(ReceivedMessage& message, const SharedNodePointer& sourceNode);
|
int processEraseMessage(ReceivedMessage& message, const SharedNodePointer& sourceNode);
|
||||||
int processEraseMessageDetails(const QByteArray& buffer, const SharedNodePointer& sourceNode);
|
int processEraseMessageDetails(const QByteArray& buffer, const SharedNodePointer& sourceNode);
|
||||||
|
bool shouldEraseEntity(EntityItemID entityID, const SharedNodePointer& sourceNode);
|
||||||
|
|
||||||
|
|
||||||
EntityTreeElementPointer getContainingElement(const EntityItemID& entityItemID) /*const*/;
|
EntityTreeElementPointer getContainingElement(const EntityItemID& entityItemID) /*const*/;
|
||||||
void addEntityMapEntry(EntityItemPointer entity);
|
void addEntityMapEntry(EntityItemPointer entity);
|
||||||
|
|
|
@ -331,9 +331,9 @@ void OffscreenSurface::finishQmlLoad(QQmlComponent* qmlComponent,
|
||||||
qmlComponent->deleteLater();
|
qmlComponent->deleteLater();
|
||||||
|
|
||||||
onItemCreated(qmlContext, newItem);
|
onItemCreated(qmlContext, newItem);
|
||||||
connect(newItem, SIGNAL(sendToScript(QVariant)), this, SIGNAL(fromQml(QVariant)));
|
|
||||||
|
|
||||||
if (!rootCreated) {
|
if (!rootCreated) {
|
||||||
|
connect(newItem, SIGNAL(sendToScript(QVariant)), this, SIGNAL(fromQml(QVariant)));
|
||||||
onRootCreated();
|
onRootCreated();
|
||||||
emit rootItemCreated(newItem);
|
emit rootItemCreated(newItem);
|
||||||
// Call this callback after rootitem is set, otherwise VrMenu wont work
|
// Call this callback after rootitem is set, otherwise VrMenu wont work
|
||||||
|
|
|
@ -389,19 +389,6 @@ QString OffscreenUi::getItem(const Icon icon, const QString& title, const QStrin
|
||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant OffscreenUi::getCustomInfo(const Icon icon, const QString& title, const QVariantMap& config, bool* ok) {
|
|
||||||
if (ok) {
|
|
||||||
*ok = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant result = DependencyManager::get<OffscreenUi>()->customInputDialog(icon, title, config);
|
|
||||||
if (ok && result.isValid()) {
|
|
||||||
*ok = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModalDialogListener* OffscreenUi::getTextAsync(const Icon icon, const QString& title, const QString& label, const QString& text) {
|
ModalDialogListener* OffscreenUi::getTextAsync(const Icon icon, const QString& title, const QString& label, const QString& text) {
|
||||||
return DependencyManager::get<OffscreenUi>()->inputDialogAsync(icon, title, label, text);
|
return DependencyManager::get<OffscreenUi>()->inputDialogAsync(icon, title, label, text);
|
||||||
}
|
}
|
||||||
|
@ -423,10 +410,6 @@ ModalDialogListener* OffscreenUi::getItemAsync(const Icon icon, const QString& t
|
||||||
return inputDialogListener;
|
return inputDialogListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModalDialogListener* OffscreenUi::getCustomInfoAsync(const Icon icon, const QString& title, const QVariantMap& config) {
|
|
||||||
return DependencyManager::get<OffscreenUi>()->customInputDialogAsync(icon, title, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant OffscreenUi::inputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current) {
|
QVariant OffscreenUi::inputDialog(const Icon icon, const QString& title, const QString& label, const QVariant& current) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
QVariant result;
|
QVariant result;
|
||||||
|
|
|
@ -230,10 +230,8 @@ public:
|
||||||
|
|
||||||
static QString getText(const Icon icon, const QString & title, const QString & label, const QString & text = QString(), bool * ok = 0);
|
static QString getText(const Icon icon, const QString & title, const QString & label, const QString & text = QString(), bool * ok = 0);
|
||||||
static QString getItem(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true, bool * ok = 0);
|
static QString getItem(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true, bool * ok = 0);
|
||||||
static QVariant getCustomInfo(const Icon icon, const QString& title, const QVariantMap& config, bool* ok = 0);
|
|
||||||
static ModalDialogListener* getTextAsync(const Icon icon, const QString & title, const QString & label, const QString & text = QString());
|
static ModalDialogListener* getTextAsync(const Icon icon, const QString & title, const QString & label, const QString & text = QString());
|
||||||
static ModalDialogListener* getItemAsync(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true);
|
static ModalDialogListener* getItemAsync(const Icon icon, const QString & title, const QString & label, const QStringList & items, int current = 0, bool editable = true);
|
||||||
static ModalDialogListener* getCustomInfoAsync(const Icon icon, const QString& title, const QVariantMap& config);
|
|
||||||
|
|
||||||
unsigned int getMenuUserDataId() const;
|
unsigned int getMenuUserDataId() const;
|
||||||
QList<QObject *> &getModalDialogListeners();
|
QList<QObject *> &getModalDialogListeners();
|
||||||
|
|
|
@ -268,16 +268,6 @@ bool Menu::isOptionChecked(const QString& menuOption) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::closeInfoView(const QString& path) {
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
offscreenUi->hide(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Menu::isInfoViewVisible(const QString& path) {
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
return offscreenUi->isVisible(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::triggerOption(const QString& menuOption) {
|
void Menu::triggerOption(const QString& menuOption) {
|
||||||
QAction* action = _actionHash.value(menuOption);
|
QAction* action = _actionHash.value(menuOption);
|
||||||
if (action) {
|
if (action) {
|
||||||
|
@ -538,24 +528,6 @@ void Menu::setGroupingIsVisible(const QString& grouping, bool isVisible) {
|
||||||
QMenuBar::repaint();
|
QMenuBar::repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::addActionGroup(const QString& groupName, const QStringList& actionList, const QString& selected, QObject* receiver, const char* slot) {
|
|
||||||
auto menu = addMenu(groupName);
|
|
||||||
|
|
||||||
QActionGroup* actionGroup = new QActionGroup(menu);
|
|
||||||
actionGroup->setExclusive(true);
|
|
||||||
|
|
||||||
for (auto action : actionList) {
|
|
||||||
auto item = addCheckableActionToQMenuAndActionHash(menu, action, 0, action == selected, receiver, slot);
|
|
||||||
actionGroup->addAction(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
QMenuBar::repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Menu::removeActionGroup(const QString& groupName) {
|
|
||||||
removeMenu(groupName);
|
|
||||||
}
|
|
||||||
|
|
||||||
MenuWrapper::MenuWrapper(ui::Menu& rootMenu, QMenu* menu) : _rootMenu(rootMenu), _realMenu(menu) {
|
MenuWrapper::MenuWrapper(ui::Menu& rootMenu, QMenu* menu) : _rootMenu(rootMenu), _realMenu(menu) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
|
offscreenUi->addMenuInitializer([=](VrMenu* vrMenu) {
|
||||||
|
|
|
@ -110,9 +110,6 @@ public slots:
|
||||||
void removeSeparator(const QString& menuName, const QString& separatorName);
|
void removeSeparator(const QString& menuName, const QString& separatorName);
|
||||||
void removeMenuItem(const QString& menuName, const QString& menuitem);
|
void removeMenuItem(const QString& menuName, const QString& menuitem);
|
||||||
bool menuItemExists(const QString& menuName, const QString& menuitem);
|
bool menuItemExists(const QString& menuName, const QString& menuitem);
|
||||||
void addActionGroup(const QString& groupName, const QStringList& actionList, const QString& selected = QString(),
|
|
||||||
QObject* receiver = nullptr, const char* slot = nullptr);
|
|
||||||
void removeActionGroup(const QString& groupName);
|
|
||||||
bool isOptionChecked(const QString& menuOption) const;
|
bool isOptionChecked(const QString& menuOption) const;
|
||||||
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
||||||
|
|
||||||
|
@ -125,9 +122,6 @@ public slots:
|
||||||
void toggleDeveloperMenus();
|
void toggleDeveloperMenus();
|
||||||
void toggleAdvancedMenus();
|
void toggleAdvancedMenus();
|
||||||
|
|
||||||
bool isInfoViewVisible(const QString& path);
|
|
||||||
void closeInfoView(const QString& path);
|
|
||||||
|
|
||||||
void triggerOption(const QString& menuOption);
|
void triggerOption(const QString& menuOption);
|
||||||
|
|
||||||
static bool isSomeSubmenuShown() { return _isSomeSubmenuShown; }
|
static bool isSomeSubmenuShown() { return _isSomeSubmenuShown; }
|
||||||
|
|
|
@ -305,7 +305,6 @@ void OffscreenQmlSurface::onItemCreated(QQmlContext* qmlContext, QQuickItem* new
|
||||||
qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(eventBridge, qmlContext));
|
qmlContext->setContextProperty("eventBridgeWrapper", new EventBridgeWrapper(eventBridge, qmlContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(newItem, SIGNAL(sendToScript(QVariant)), this, SIGNAL(fromQml(QVariant)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlSurface::onRootCreated() {
|
void OffscreenQmlSurface::onRootCreated() {
|
||||||
|
|
|
@ -40,7 +40,6 @@ function updateOverlay(entityID, queryAACube) {
|
||||||
blue: 255
|
blue: 255
|
||||||
},
|
},
|
||||||
alpha: 1,
|
alpha: 1,
|
||||||
// borderSize: ...,
|
|
||||||
solid: false
|
solid: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,9 @@ function onClicked() {
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
var entity = HMD.tabletID;
|
if (HMD.tabletID) {
|
||||||
Entities.editEntity(entity, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
|
Entities.editEntity(HMD.tabletID, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
|
||||||
|
}
|
||||||
tablet.loadQMLSource(AUDIO_QML_SOURCE);
|
tablet.loadQMLSource(AUDIO_QML_SOURCE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setIgnorePointerItems = function() {
|
this.setIgnorePointerItems = function() {
|
||||||
if (HMD.tabletID !== this.tabletID) {
|
if (HMD.tabletID && HMD.tabletID !== this.tabletID) {
|
||||||
this.tabletID = HMD.tabletID;
|
this.tabletID = HMD.tabletID;
|
||||||
Pointers.setIgnoreItems(_this.leftPointer, _this.blacklist);
|
Pointers.setIgnoreItems(_this.leftPointer, _this.blacklist);
|
||||||
Pointers.setIgnoreItems(_this.rightPointer, _this.blacklist);
|
Pointers.setIgnoreItems(_this.rightPointer, _this.blacklist);
|
||||||
|
@ -479,7 +479,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function mouseReleaseOnOverlay(overlayID, event) {
|
function mouseReleaseOnOverlay(overlayID, event) {
|
||||||
if (overlayID === HMD.homeButtonID && event.button === "Primary") {
|
if (HMD.homeButtonID && overlayID === HMD.homeButtonID && event.button === "Primary") {
|
||||||
Messages.sendLocalMessage("home", overlayID);
|
Messages.sendLocalMessage("home", overlayID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
|
|
||||||
this.nearTablet = function(overlays) {
|
this.nearTablet = function(overlays) {
|
||||||
for (var i = 0; i < overlays.length; i++) {
|
for (var i = 0; i < overlays.length; i++) {
|
||||||
if (overlays[i] === HMD.tabletID) {
|
if (HMD.tabletID && overlays[i] === HMD.tabletID) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,8 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.pointingAtTablet = function(objectID) {
|
this.pointingAtTablet = function(objectID) {
|
||||||
return objectID === HMD.tabletScreenID || objectID === HMD.homeButtonID;
|
return (HMD.tabletScreenID && objectID === HMD.tabletScreenID)
|
||||||
|
|| (HMD.homeButtonID && objectID === HMD.homeButtonID);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.sendPickData = function(controllerData) {
|
this.sendPickData = function(controllerData) {
|
||||||
|
@ -106,7 +107,7 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
if (nearOverlay) {
|
if (nearOverlay) {
|
||||||
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
||||||
|
|
||||||
if (nearOverlayReady.active && nearOverlay.grabbedThingID === HMD.tabletID) {
|
if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) {
|
||||||
return this.exitModule();
|
return this.exitModule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
);
|
);
|
||||||
|
|
||||||
this.pointingAtTablet = function (objectID) {
|
this.pointingAtTablet = function (objectID) {
|
||||||
return objectID === HMD.tabletScreenID || objectID === HMD.homeButtonID;
|
return (HMD.tabletScreenID && objectID === HMD.tabletScreenID)
|
||||||
|
|| (HMD.homeButtonID && objectID === HMD.homeButtonID);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.isReady = function (controllerData) {
|
this.isReady = function (controllerData) {
|
||||||
|
@ -76,7 +77,7 @@ Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||||
: "LeftNearParentingGrabOverlay");
|
: "LeftNearParentingGrabOverlay");
|
||||||
if (nearOverlay) {
|
if (nearOverlay) {
|
||||||
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
var nearOverlayReady = nearOverlay.isReady(controllerData);
|
||||||
if (nearOverlayReady.active && nearOverlay.grabbedThingID === HMD.tabletID) {
|
if (nearOverlayReady.active && HMD.tabletID && nearOverlay.grabbedThingID === HMD.tabletID) {
|
||||||
return makeRunningValues(false, [], []);
|
return makeRunningValues(false, [], []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
Overlays.editOverlay(this.grabbedThingID, reparentProps);
|
Overlays.editOverlay(this.grabbedThingID, reparentProps);
|
||||||
|
|
||||||
// resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
// resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
||||||
if (this.grabbedThingID === HMD.tabletID) {
|
if (HMD.tabletID && this.grabbedThingID === HMD.tabletID) {
|
||||||
resizeTablet(getTabletWidthFromSettings(), reparentProps.parentJointIndex);
|
resizeTablet(getTabletWidthFromSettings(), reparentProps.parentJointIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ Script.include("/~/system/libraries/utils.js");
|
||||||
});
|
});
|
||||||
|
|
||||||
// resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
// resizeTablet to counter adjust offsets to account for change of scale from sensorToWorldMatrix
|
||||||
if (this.grabbedThingID === HMD.tabletID) {
|
if (HMD.tabletID && this.grabbedThingID === HMD.tabletID) {
|
||||||
resizeTablet(getTabletWidthFromSettings(), this.previousParentJointIndex[this.grabbedThingID]);
|
resizeTablet(getTabletWidthFromSettings(), this.previousParentJointIndex[this.grabbedThingID]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
var stylusTargetIDs = [];
|
var stylusTargetIDs = [];
|
||||||
for (var index = 0; index < stylusTargets.length; index++) {
|
for (var index = 0; index < stylusTargets.length; index++) {
|
||||||
var stylusTarget = stylusTargets[index];
|
var stylusTarget = stylusTargets[index];
|
||||||
if (stylusTarget.distance <= maxNormalDistance && stylusTarget.id !== HMD.tabletID) {
|
if (stylusTarget.distance <= maxNormalDistance && !(HMD.tabletID && stylusTarget.id === HMD.tabletID)) {
|
||||||
stylusTargetIDs.push(stylusTarget.id);
|
stylusTargetIDs.push(stylusTarget.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ Script.include("/~/system/libraries/controllers.js");
|
||||||
var i, stylusTarget;
|
var i, stylusTarget;
|
||||||
|
|
||||||
for (i = 0; i < candidateOverlays.length; i++) {
|
for (i = 0; i < candidateOverlays.length; i++) {
|
||||||
if (candidateOverlays[i] !== HMD.tabletID &&
|
if (!(HMD.tabletID && candidateOverlays[i] === HMD.tabletID) &&
|
||||||
Overlays.getProperty(candidateOverlays[i], "visible")) {
|
Overlays.getProperty(candidateOverlays[i], "visible")) {
|
||||||
stylusTarget = getOverlayDistance(controllerPosition, candidateOverlays[i]);
|
stylusTarget = getOverlayDistance(controllerPosition, candidateOverlays[i]);
|
||||||
if (stylusTarget) {
|
if (stylusTarget) {
|
||||||
|
|
|
@ -263,7 +263,10 @@ function Grabber() {
|
||||||
filter: Picks.PICK_OVERLAYS,
|
filter: Picks.PICK_OVERLAYS,
|
||||||
enabled: true
|
enabled: true
|
||||||
});
|
});
|
||||||
RayPick.setIncludeItems(this.mouseRayOverlays, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]);
|
var tabletItems = getMainTabletIDs();
|
||||||
|
if (tabletItems.length > 0) {
|
||||||
|
RayPick.setIncludeItems(this.mouseRayOverlays, tabletItems);
|
||||||
|
}
|
||||||
var renderStates = [{name: "grabbed", end: beacon}];
|
var renderStates = [{name: "grabbed", end: beacon}];
|
||||||
this.mouseRayEntities = Pointers.createPointer(PickType.Ray, {
|
this.mouseRayEntities = Pointers.createPointer(PickType.Ray, {
|
||||||
joint: "Mouse",
|
joint: "Mouse",
|
||||||
|
|
|
@ -31,6 +31,7 @@ Script.include([
|
||||||
"libraries/entityCameraTool.js",
|
"libraries/entityCameraTool.js",
|
||||||
"libraries/gridTool.js",
|
"libraries/gridTool.js",
|
||||||
"libraries/entityList.js",
|
"libraries/entityList.js",
|
||||||
|
"libraries/utils.js",
|
||||||
"particle_explorer/particleExplorerTool.js",
|
"particle_explorer/particleExplorerTool.js",
|
||||||
"libraries/entityIconOverlayManager.js"
|
"libraries/entityIconOverlayManager.js"
|
||||||
]);
|
]);
|
||||||
|
@ -775,8 +776,7 @@ function findClickedEntity(event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||||
|
var overlayResult = Overlays.findRayIntersection(pickRay, true, getMainTabletIDs());
|
||||||
var overlayResult = Overlays.findRayIntersection(pickRay, true, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]);
|
|
||||||
if (overlayResult.intersects) {
|
if (overlayResult.intersects) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -964,7 +964,7 @@ function mouseReleaseEvent(event) {
|
||||||
|
|
||||||
function wasTabletClicked(event) {
|
function wasTabletClicked(event) {
|
||||||
var rayPick = Camera.computePickRay(event.x, event.y);
|
var rayPick = Camera.computePickRay(event.x, event.y);
|
||||||
var result = Overlays.findRayIntersection(rayPick, true, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]);
|
var result = Overlays.findRayIntersection(rayPick, true, getMainTabletIDs());
|
||||||
return result.intersects;
|
return result.intersects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -987,7 +987,7 @@ function mouseClickEvent(event) {
|
||||||
toolBar.setActive(true);
|
toolBar.setActive(true);
|
||||||
var pickRay = result.pickRay;
|
var pickRay = result.pickRay;
|
||||||
var foundEntity = result.entityID;
|
var foundEntity = result.entityID;
|
||||||
if (foundEntity === HMD.tabletID) {
|
if (HMD.tabletID && foundEntity === HMD.tabletID) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
properties = Entities.getEntityProperties(foundEntity);
|
properties = Entities.getEntityProperties(foundEntity);
|
||||||
|
|
|
@ -30,9 +30,8 @@
|
||||||
if (onHelpScreen) {
|
if (onHelpScreen) {
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
var tabletEntity = HMD.tabletID;
|
if (HMD.tabletID) {
|
||||||
if (tabletEntity) {
|
Entities.editEntity(HMD.tabletID, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
||||||
Entities.editEntity(tabletEntity, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
|
||||||
}
|
}
|
||||||
Menu.triggerOption('Help...');
|
Menu.triggerOption('Help...');
|
||||||
onHelpScreen = true;
|
onHelpScreen = true;
|
||||||
|
@ -47,22 +46,12 @@
|
||||||
button.clicked.connect(onClicked);
|
button.clicked.connect(onClicked);
|
||||||
tablet.screenChanged.connect(onScreenChanged);
|
tablet.screenChanged.connect(onScreenChanged);
|
||||||
|
|
||||||
var POLL_RATE = 500;
|
|
||||||
var interval = Script.setInterval(function () {
|
|
||||||
var visible = Menu.isInfoViewVisible('InfoView_html/help.html');
|
|
||||||
if (visible !== enabled) {
|
|
||||||
enabled = visible;
|
|
||||||
button.editProperties({isActive: enabled});
|
|
||||||
}
|
|
||||||
}, POLL_RATE);
|
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
if (onHelpScreen) {
|
if (onHelpScreen) {
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
}
|
}
|
||||||
button.clicked.disconnect(onClicked);
|
button.clicked.disconnect(onClicked);
|
||||||
tablet.screenChanged.disconnect(onScreenChanged);
|
tablet.screenChanged.disconnect(onScreenChanged);
|
||||||
Script.clearInterval(interval);
|
|
||||||
if (tablet) {
|
if (tablet) {
|
||||||
tablet.removeButton(button);
|
tablet.removeButton(button);
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,7 +279,7 @@ colpick Color Picker / colpick.com
|
||||||
}
|
}
|
||||||
|
|
||||||
/*full layout with no submit button*/
|
/*full layout with no submit button*/
|
||||||
.colpick_full_ns .colpick_submit, .colpick_full_ns .colpick_current_color{
|
.colpick_full_ns .colpick_submit {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
.colpick_full_ns .colpick_new_color {
|
.colpick_full_ns .colpick_new_color {
|
||||||
|
@ -320,11 +320,11 @@ colpick Color Picker / colpick.com
|
||||||
}
|
}
|
||||||
|
|
||||||
/*rgbhex layout, no submit button*/
|
/*rgbhex layout, no submit button*/
|
||||||
.colpick_rgbhex_ns .colpick_submit, .colpick_rgbhex_ns .colpick_current_color{
|
.colpick_rgbhex_ns .colpick_submit {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
.colpick_rgbhex_ns .colpick_new_color{
|
.colpick_rgbhex_ns .colpick_new_color{
|
||||||
width:68px;
|
width:34px;
|
||||||
border: 1px solid #8f8f8f;
|
border: 1px solid #8f8f8f;
|
||||||
}
|
}
|
||||||
.colpick_rgbhex_ns .colpick_rgb_r {
|
.colpick_rgbhex_ns .colpick_rgb_r {
|
||||||
|
@ -379,7 +379,7 @@ colpick Color Picker / colpick.com
|
||||||
}
|
}
|
||||||
|
|
||||||
/*hex layout, no submit button*/
|
/*hex layout, no submit button*/
|
||||||
.colpick_hex_ns .colpick_submit, .colpick_hex_ns .colpick_current_color {
|
.colpick_hex_ns .colpick_submit {
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
.colpick_hex_ns .colpick_hex_field {
|
.colpick_hex_ns .colpick_hex_field {
|
||||||
|
|
|
@ -1,14 +1,41 @@
|
||||||
/*
|
/*
|
||||||
colpick Color Picker
|
colpick Color Picker
|
||||||
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
|
Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed
|
||||||
|
under the MIT and GPL licenses
|
||||||
|
|
||||||
For usage and examples: colpick.com/plugin
|
For usage and examples: colpick.com/plugin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* global console, document, Element, EventBridge, jQuery, navigator, window, _ $ */
|
||||||
|
|
||||||
(function ($) {
|
(function ($) {
|
||||||
var colpick = function () {
|
var colpick = function () {
|
||||||
var
|
var
|
||||||
tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
|
tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1">' +
|
||||||
|
'<div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner">' +
|
||||||
|
'</div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs">' +
|
||||||
|
'<div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div>' +
|
||||||
|
'<div class="colpick_new_color"></div><div class="colpick_current_color"></div>' +
|
||||||
|
'<div class="colpick_hex_field"><div class="colpick_field_letter">#</div>' +
|
||||||
|
'<input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field">' +
|
||||||
|
'<div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" />' +
|
||||||
|
'<div class="colpick_field_arrs"><div class="colpick_field_uarr"></div>' +
|
||||||
|
'<div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field">' +
|
||||||
|
'<div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" />' +
|
||||||
|
'<div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div>' +
|
||||||
|
'</div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div>' +
|
||||||
|
'<input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs">' +
|
||||||
|
'<div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div>' +
|
||||||
|
'<div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div>' +
|
||||||
|
'<input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs">' +
|
||||||
|
'<div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div>' +
|
||||||
|
'<div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div>' +
|
||||||
|
'<input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs">' +
|
||||||
|
'<div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div>' +
|
||||||
|
'<div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div>' +
|
||||||
|
'<input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs">' +
|
||||||
|
'<div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div>' +
|
||||||
|
'<div class="colpick_submit"></div></div>',
|
||||||
defaults = {
|
defaults = {
|
||||||
showEvent: 'click',
|
showEvent: 'click',
|
||||||
onShow: function () {},
|
onShow: function () {},
|
||||||
|
@ -25,15 +52,15 @@ For usage and examples: colpick.com/plugin
|
||||||
submitText: 'OK',
|
submitText: 'OK',
|
||||||
height: 156
|
height: 156
|
||||||
},
|
},
|
||||||
//Fill the inputs of the plugin
|
// Fill the inputs of the plugin
|
||||||
fillRGBFields = function (hsb, cal) {
|
fillRGBFields = function (hsb, cal) {
|
||||||
var rgb = hsbToRgb(hsb);
|
var rgb = hsbToRgb(hsb);
|
||||||
$(cal).data('colpick').fields
|
$(cal).data('colpick').fields
|
||||||
.eq(1).val(rgb.r).end()
|
.eq(1).val(rgb.r).end()
|
||||||
.eq(2).val(rgb.g).end()
|
.eq(2).val(rgb.g).end()
|
||||||
.eq(3).val(rgb.b).end();
|
.eq(3).val(rgb.b).end();
|
||||||
},
|
},
|
||||||
fillHSBFields = function (hsb, cal) {
|
fillHSBFields = function (hsb, cal) {
|
||||||
$(cal).data('colpick').fields
|
$(cal).data('colpick').fields
|
||||||
.eq(4).val(Math.round(hsb.h)).end()
|
.eq(4).val(Math.round(hsb.h)).end()
|
||||||
.eq(5).val(Math.round(hsb.s)).end()
|
.eq(5).val(Math.round(hsb.s)).end()
|
||||||
|
@ -42,7 +69,7 @@ For usage and examples: colpick.com/plugin
|
||||||
fillHexFields = function (hsb, cal) {
|
fillHexFields = function (hsb, cal) {
|
||||||
$(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
|
$(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
|
||||||
},
|
},
|
||||||
//Set the round selector position
|
// Set the round selector position
|
||||||
setSelector = function (hsb, cal) {
|
setSelector = function (hsb, cal) {
|
||||||
$(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
|
$(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
|
||||||
$(cal).data('colpick').selectorIndic.css({
|
$(cal).data('colpick').selectorIndic.css({
|
||||||
|
@ -50,18 +77,19 @@ For usage and examples: colpick.com/plugin
|
||||||
top: parseInt($(cal).data('colpick').height * (100-hsb.b)/100, 10)
|
top: parseInt($(cal).data('colpick').height * (100-hsb.b)/100, 10)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//Set the hue selector position
|
// Set the hue selector position
|
||||||
setHue = function (hsb, cal) {
|
setHue = function (hsb, cal) {
|
||||||
$(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h/360, 10));
|
$(cal).data('colpick').hue.css('top',
|
||||||
|
parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
|
||||||
},
|
},
|
||||||
//Set current and new colors
|
// Set current and new colors
|
||||||
setCurrentColor = function (hsb, cal) {
|
setCurrentColor = function (hsb, cal) {
|
||||||
$(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
$(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
||||||
},
|
},
|
||||||
setNewColor = function (hsb, cal) {
|
setNewColor = function (hsb, cal) {
|
||||||
$(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
$(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
|
||||||
},
|
},
|
||||||
//Called when the new color is changed
|
// Called when the new color is changed
|
||||||
change = function (ev) {
|
change = function (ev) {
|
||||||
var cal = $(this).parent().parent(), col;
|
var cal = $(this).parent().parent(), col;
|
||||||
if (this.parentNode.className.indexOf('_hex') > 0) {
|
if (this.parentNode.className.indexOf('_hex') > 0) {
|
||||||
|
@ -91,9 +119,10 @@ For usage and examples: colpick.com/plugin
|
||||||
setSelector(col, cal.get(0));
|
setSelector(col, cal.get(0));
|
||||||
setHue(col, cal.get(0));
|
setHue(col, cal.get(0));
|
||||||
setNewColor(col, cal.get(0));
|
setNewColor(col, cal.get(0));
|
||||||
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
|
cal.data('colpick').onChange.apply(cal.parent(),
|
||||||
|
[col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
|
||||||
},
|
},
|
||||||
//Change style on blur and on focus of inputs
|
// Change style on blur and on focus of inputs
|
||||||
blur = function (ev) {
|
blur = function (ev) {
|
||||||
$(this).parent().removeClass('colpick_focus');
|
$(this).parent().removeClass('colpick_focus');
|
||||||
},
|
},
|
||||||
|
@ -101,13 +130,14 @@ For usage and examples: colpick.com/plugin
|
||||||
$(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
|
$(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
|
||||||
$(this).parent().addClass('colpick_focus');
|
$(this).parent().addClass('colpick_focus');
|
||||||
},
|
},
|
||||||
//Increment/decrement arrows functions
|
// Increment/decrement arrows functions
|
||||||
downIncrement = function (ev) {
|
downIncrement = function (ev) {
|
||||||
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
||||||
var field = $(this).parent().find('input').focus();
|
var field = $(this).parent().find('input').focus();
|
||||||
var current = {
|
var current = {
|
||||||
el: $(this).parent().addClass('colpick_slider'),
|
el: $(this).parent().addClass('colpick_slider'),
|
||||||
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 :
|
||||||
|
(this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
|
||||||
y: ev.pageY,
|
y: ev.pageY,
|
||||||
field: field,
|
field: field,
|
||||||
val: parseInt(field.val(), 10),
|
val: parseInt(field.val(), 10),
|
||||||
|
@ -130,7 +160,7 @@ For usage and examples: colpick.com/plugin
|
||||||
$(document).off('mousemove', moveIncrement);
|
$(document).off('mousemove', moveIncrement);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
//Hue slider functions
|
// Hue slider functions
|
||||||
downHue = function (ev) {
|
downHue = function (ev) {
|
||||||
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
||||||
var current = {
|
var current = {
|
||||||
|
@ -140,20 +170,23 @@ For usage and examples: colpick.com/plugin
|
||||||
$(document).on('mouseup touchend',current,upHue);
|
$(document).on('mouseup touchend',current,upHue);
|
||||||
$(document).on('mousemove touchmove',current,moveHue);
|
$(document).on('mousemove touchmove',current,moveHue);
|
||||||
|
|
||||||
var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY );
|
var pageY = ((ev.type === 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY );
|
||||||
change.apply(
|
change.apply(
|
||||||
current.cal.data('colpick')
|
current.cal.data('colpick')
|
||||||
.fields.eq(4).val(parseInt(360*(current.cal.data('colpick').height - (pageY - current.y))/current.cal.data('colpick').height, 10))
|
.fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height -
|
||||||
|
(pageY - current.y)) / current.cal.data('colpick').height, 10))
|
||||||
.get(0),
|
.get(0),
|
||||||
[current.cal.data('colpick').livePreview]
|
[current.cal.data('colpick').livePreview]
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
moveHue = function (ev) {
|
moveHue = function (ev) {
|
||||||
var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY );
|
var pageY = ((ev.type === 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY );
|
||||||
change.apply(
|
change.apply(
|
||||||
ev.data.cal.data('colpick')
|
ev.data.cal.data('colpick')
|
||||||
.fields.eq(4).val(parseInt(360*(ev.data.cal.data('colpick').height - Math.max(0,Math.min(ev.data.cal.data('colpick').height,(pageY - ev.data.y))))/ev.data.cal.data('colpick').height, 10))
|
.fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height -
|
||||||
|
Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) /
|
||||||
|
ev.data.cal.data('colpick').height, 10))
|
||||||
.get(0),
|
.get(0),
|
||||||
[ev.data.preview]
|
[ev.data.preview]
|
||||||
);
|
);
|
||||||
|
@ -166,7 +199,7 @@ For usage and examples: colpick.com/plugin
|
||||||
$(document).off('mousemove touchmove',moveHue);
|
$(document).off('mousemove touchmove',moveHue);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
//Color selector functions
|
// Color selector functions
|
||||||
downSelector = function (ev) {
|
downSelector = function (ev) {
|
||||||
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
|
||||||
var current = {
|
var current = {
|
||||||
|
@ -178,8 +211,8 @@ For usage and examples: colpick.com/plugin
|
||||||
$(document).on('mouseup touchend',current,upSelector);
|
$(document).on('mouseup touchend',current,upSelector);
|
||||||
$(document).on('mousemove touchmove',current,moveSelector);
|
$(document).on('mousemove touchmove',current,moveSelector);
|
||||||
|
|
||||||
var payeX,pageY;
|
var pageX,pageY;
|
||||||
if(ev.type == 'touchstart') {
|
if (ev.type === 'touchstart') {
|
||||||
pageX = ev.originalEvent.changedTouches[0].pageX,
|
pageX = ev.originalEvent.changedTouches[0].pageX,
|
||||||
pageY = ev.originalEvent.changedTouches[0].pageY;
|
pageY = ev.originalEvent.changedTouches[0].pageY;
|
||||||
} else {
|
} else {
|
||||||
|
@ -189,16 +222,17 @@ For usage and examples: colpick.com/plugin
|
||||||
|
|
||||||
change.apply(
|
change.apply(
|
||||||
current.cal.data('colpick').fields
|
current.cal.data('colpick').fields
|
||||||
.eq(6).val(parseInt(100*(current.cal.data('colpick').height - (pageY - current.pos.top))/current.cal.data('colpick').height, 10)).end()
|
.eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) /
|
||||||
.eq(5).val(parseInt(100*(pageX - current.pos.left)/current.cal.data('colpick').height, 10))
|
current.cal.data('colpick').height, 10)).end()
|
||||||
.get(0),
|
.eq(5).val(parseInt(100*(pageX - current.pos.left)/current.cal.data('colpick').height, 10))
|
||||||
|
.get(0),
|
||||||
[current.preview]
|
[current.preview]
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
moveSelector = function (ev) {
|
moveSelector = function (ev) {
|
||||||
var payeX,pageY;
|
var pageX,pageY;
|
||||||
if(ev.type == 'touchmove') {
|
if (ev.type === 'touchmove') {
|
||||||
pageX = ev.originalEvent.changedTouches[0].pageX,
|
pageX = ev.originalEvent.changedTouches[0].pageX,
|
||||||
pageY = ev.originalEvent.changedTouches[0].pageY;
|
pageY = ev.originalEvent.changedTouches[0].pageY;
|
||||||
} else {
|
} else {
|
||||||
|
@ -208,9 +242,12 @@ For usage and examples: colpick.com/plugin
|
||||||
|
|
||||||
change.apply(
|
change.apply(
|
||||||
ev.data.cal.data('colpick').fields
|
ev.data.cal.data('colpick').fields
|
||||||
.eq(6).val(parseInt(100*(ev.data.cal.data('colpick').height - Math.max(0,Math.min(ev.data.cal.data('colpick').height,(pageY - ev.data.pos.top))))/ev.data.cal.data('colpick').height, 10)).end()
|
.eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height -
|
||||||
.eq(5).val(parseInt(100*(Math.max(0,Math.min(ev.data.cal.data('colpick').height,(pageX - ev.data.pos.left))))/ev.data.cal.data('colpick').height, 10))
|
Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) /
|
||||||
.get(0),
|
ev.data.cal.data('colpick').height, 10)).end()
|
||||||
|
.eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height,
|
||||||
|
(pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
|
||||||
|
.get(0),
|
||||||
[ev.data.preview]
|
[ev.data.preview]
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
@ -222,7 +259,7 @@ For usage and examples: colpick.com/plugin
|
||||||
$(document).off('mousemove touchmove',moveSelector);
|
$(document).off('mousemove touchmove',moveSelector);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
//Submit button
|
// Submit button
|
||||||
clickSubmit = function (ev) {
|
clickSubmit = function (ev) {
|
||||||
var cal = $(this).parent();
|
var cal = $(this).parent();
|
||||||
var col = cal.data('colpick').color;
|
var col = cal.data('colpick').color;
|
||||||
|
@ -230,7 +267,7 @@ For usage and examples: colpick.com/plugin
|
||||||
setCurrentColor(col, cal.get(0));
|
setCurrentColor(col, cal.get(0));
|
||||||
cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
|
cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
|
||||||
},
|
},
|
||||||
//Show/hide the color picker
|
// Show/hide the color picker
|
||||||
show = function (ev) {
|
show = function (ev) {
|
||||||
// Prevent the trigger of any direct parent
|
// Prevent the trigger of any direct parent
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
|
@ -245,27 +282,29 @@ For usage and examples: colpick.com/plugin
|
||||||
left -= calW;
|
left -= calW;
|
||||||
}
|
}
|
||||||
cal.css({left: left + 'px', top: top + 'px'});
|
cal.css({left: left + 'px', top: top + 'px'});
|
||||||
if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
|
if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) !== false) {
|
||||||
cal.show();
|
cal.show();
|
||||||
}
|
}
|
||||||
//Hide when user clicks outside
|
// Hide when user clicks outside
|
||||||
$('html').mousedown({cal:cal}, hide);
|
$('html').mousedown({cal:cal}, hide);
|
||||||
cal.mousedown(function(ev){ev.stopPropagation();})
|
cal.mousedown(function(ev){
|
||||||
|
ev.stopPropagation();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
hide = function (ev) {
|
hide = function (ev) {
|
||||||
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) !== false) {
|
||||||
ev.data.cal.hide();
|
ev.data.cal.hide();
|
||||||
}
|
}
|
||||||
$('html').off('mousedown', hide);
|
$('html').off('mousedown', hide);
|
||||||
},
|
},
|
||||||
getViewport = function () {
|
getViewport = function () {
|
||||||
var m = document.compatMode == 'CSS1Compat';
|
var m = document.compatMode === 'CSS1Compat';
|
||||||
return {
|
return {
|
||||||
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
||||||
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
|
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
//Fix the values if the user enters a negative or high value
|
// Fix the values if the user enters a negative or high value
|
||||||
fixHSB = function (hsb) {
|
fixHSB = function (hsb) {
|
||||||
return {
|
return {
|
||||||
h: Math.min(360, Math.max(0, hsb.h)),
|
h: Math.min(360, Math.max(0, hsb.h)),
|
||||||
|
@ -302,70 +341,85 @@ For usage and examples: colpick.com/plugin
|
||||||
setSelector(col, cal.get(0));
|
setSelector(col, cal.get(0));
|
||||||
setHue(col, cal.get(0));
|
setHue(col, cal.get(0));
|
||||||
setNewColor(col, cal.get(0));
|
setNewColor(col, cal.get(0));
|
||||||
|
// If the user triggered this behavior, then any prior color change should be negated.
|
||||||
|
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col),
|
||||||
|
hsbToRgb(col), cal.data('colpick').el, 0]);
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
init: function (opt) {
|
init: function (opt) {
|
||||||
opt = $.extend({}, defaults, opt||{});
|
opt = $.extend({}, defaults, opt||{});
|
||||||
//Set color
|
// Set color
|
||||||
if (typeof opt.color == 'string') {
|
if (typeof opt.color === 'string') {
|
||||||
opt.color = hexToHsb(opt.color);
|
opt.color = hexToHsb(opt.color);
|
||||||
} else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
|
} else if (opt.color.r !== undefined && opt.color.g !== undefined && opt.color.b !== undefined) {
|
||||||
opt.color = rgbToHsb(opt.color);
|
opt.color = rgbToHsb(opt.color);
|
||||||
} else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
|
} else if (opt.color.h !== undefined && opt.color.s !== undefined && opt.color.b !== undefined) {
|
||||||
opt.color = fixHSB(opt.color);
|
opt.color = fixHSB(opt.color);
|
||||||
} else {
|
} else {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//For each selected DOM element
|
// For each selected DOM element
|
||||||
return this.each(function () {
|
return this.each(function () {
|
||||||
//If the element does not have an ID
|
// If the element does not have an ID
|
||||||
if (!$(this).data('colpickId')) {
|
if (!$(this).data('colpickId')) {
|
||||||
var options = $.extend({}, opt);
|
var options = $.extend({}, opt);
|
||||||
options.origColor = opt.color;
|
options.origColor = opt.color;
|
||||||
//Generate and assign a random ID
|
// Generate and assign a random ID
|
||||||
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
var id = 'collorpicker_' + parseInt(Math.random() * 1000);
|
||||||
$(this).data('colpickId', id);
|
$(this).data('colpickId', id);
|
||||||
//Set the tpl's ID and get the HTML
|
// Set the tpl's ID and get the HTML
|
||||||
var cal = $(tpl).attr('id', id);
|
var cal = $(tpl).attr('id', id);
|
||||||
//Add class according to layout
|
// Add class according to layout
|
||||||
cal.addClass('colpick_'+options.layout+(options.submit?'':' colpick_'+options.layout+'_ns'));
|
cal.addClass('colpick_'+options.layout+(options.submit?'':' colpick_'+options.layout+'_ns'));
|
||||||
//Add class if the color scheme is not default
|
// Add class if the color scheme is not default
|
||||||
if(options.colorScheme != 'light') {
|
if (options.colorScheme !== 'light') {
|
||||||
cal.addClass('colpick_'+options.colorScheme);
|
cal.addClass('colpick_'+options.colorScheme);
|
||||||
}
|
}
|
||||||
//Setup submit button
|
// Setup submit button
|
||||||
cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
|
cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
|
||||||
//Setup input fields
|
// Setup input fields
|
||||||
options.fields = cal.find('input').change(change).blur(blur).focus(focus);
|
options.fields = cal.find('input').change(change).blur(blur).focus(focus);
|
||||||
cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
|
cal.find('div.colpick_field_arrs').mousedown(downIncrement);
|
||||||
//Setup hue selector
|
cal.find('div.colpick_current_color').click(restoreOriginal);
|
||||||
|
// Setup hue selector
|
||||||
options.selector = cal.find('div.colpick_color').on('mousedown touchstart',downSelector);
|
options.selector = cal.find('div.colpick_color').on('mousedown touchstart',downSelector);
|
||||||
options.selectorIndic = options.selector.find('div.colpick_selector_outer');
|
options.selectorIndic = options.selector.find('div.colpick_selector_outer');
|
||||||
//Store parts of the plugin
|
// Store parts of the plugin
|
||||||
options.el = this;
|
options.el = this;
|
||||||
options.hue = cal.find('div.colpick_hue_arrs');
|
options.hue = cal.find('div.colpick_hue_arrs');
|
||||||
huebar = options.hue.parent();
|
var huebar = options.hue.parent();
|
||||||
//Paint the hue bar
|
// Paint the hue bar
|
||||||
var UA = navigator.userAgent.toLowerCase();
|
var UA = navigator.userAgent.toLowerCase();
|
||||||
var isIE = navigator.appName === 'Microsoft Internet Explorer';
|
var isIE = navigator.appName === 'Microsoft Internet Explorer';
|
||||||
var IEver = isIE ? parseFloat( UA.match( /msie ([0-9]{1,}[\.0-9]{0,})/ )[1] ) : 0;
|
var IEver = isIE ? parseFloat( UA.match( /msie ([0-9]{1,}[.0-9]{0,})/ )[1] ) : 0;
|
||||||
var ngIE = ( isIE && IEver < 10 );
|
var ngIE = ( isIE && IEver < 10 );
|
||||||
var stops = ['#ff0000','#ff0080','#ff00ff','#8000ff','#0000ff','#0080ff','#00ffff','#00ff80','#00ff00','#80ff00','#ffff00','#ff8000','#ff0000'];
|
var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80',
|
||||||
if(ngIE) {
|
'#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
|
||||||
|
if (ngIE) {
|
||||||
var i, div;
|
var i, div;
|
||||||
for(i=0; i<=11; i++) {
|
for (i=0; i<=11; i++) {
|
||||||
div = $('<div></div>').attr('style','height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='+stops[i]+', endColorstr='+stops[i+1]+'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='+stops[i]+', endColorstr='+stops[i+1]+')";');
|
div = $('<div></div>').attr('style',
|
||||||
|
'height:8.333333%; filter:progid:' +
|
||||||
|
'DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] +
|
||||||
|
', endColorstr=' + stops[i + 1] +
|
||||||
|
'); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' +
|
||||||
|
stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
|
||||||
huebar.append(div);
|
huebar.append(div);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
stopList = stops.join(',');
|
var stopList = stops.join(',');
|
||||||
huebar.attr('style','background:-webkit-linear-gradient(top,'+stopList+'); background: -o-linear-gradient(top,'+stopList+'); background: -ms-linear-gradient(top,'+stopList+'); background:-moz-linear-gradient(top,'+stopList+'); -webkit-linear-gradient(top,'+stopList+'); background:linear-gradient(to bottom,'+stopList+'); ');
|
huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList +
|
||||||
|
'); background: -o-linear-gradient(top,' + stopList +
|
||||||
|
'); background: -ms-linear-gradient(top,' + stopList +
|
||||||
|
'); background:-moz-linear-gradient(top,' + stopList +
|
||||||
|
'); -webkit-linear-gradient(top,' + stopList +
|
||||||
|
'); background:linear-gradient(to bottom,' + stopList + '); ');
|
||||||
}
|
}
|
||||||
cal.find('div.colpick_hue').on('mousedown touchstart',downHue);
|
cal.find('div.colpick_hue').on('mousedown touchstart',downHue);
|
||||||
options.newColor = cal.find('div.colpick_new_color');
|
options.newColor = cal.find('div.colpick_new_color');
|
||||||
options.currentColor = cal.find('div.colpick_current_color');
|
options.currentColor = cal.find('div.colpick_current_color');
|
||||||
//Store options and fill with default color
|
// Store options and fill with default color
|
||||||
cal.data('colpick', options);
|
cal.data('colpick', options);
|
||||||
fillRGBFields(options.color, cal.get(0));
|
fillRGBFields(options.color, cal.get(0));
|
||||||
fillHSBFields(options.color, cal.get(0));
|
fillHSBFields(options.color, cal.get(0));
|
||||||
|
@ -374,7 +428,7 @@ For usage and examples: colpick.com/plugin
|
||||||
setSelector(options.color, cal.get(0));
|
setSelector(options.color, cal.get(0));
|
||||||
setCurrentColor(options.color, cal.get(0));
|
setCurrentColor(options.color, cal.get(0));
|
||||||
setNewColor(options.color, cal.get(0));
|
setNewColor(options.color, cal.get(0));
|
||||||
//Append to body if flat=false, else show in place
|
// Append to body if flat=false, else show in place
|
||||||
if (options.flat) {
|
if (options.flat) {
|
||||||
cal.appendTo(this).show();
|
cal.appendTo(this).show();
|
||||||
cal.css({
|
cal.css({
|
||||||
|
@ -391,7 +445,7 @@ For usage and examples: colpick.com/plugin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//Shows the picker
|
// Shows the picker
|
||||||
showPicker: function() {
|
showPicker: function() {
|
||||||
return this.each( function () {
|
return this.each( function () {
|
||||||
if ($(this).data('colpickId')) {
|
if ($(this).data('colpickId')) {
|
||||||
|
@ -399,7 +453,7 @@ For usage and examples: colpick.com/plugin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//Hides the picker
|
// Hides the picker
|
||||||
hidePicker: function() {
|
hidePicker: function() {
|
||||||
return this.each( function () {
|
return this.each( function () {
|
||||||
if ($(this).data('colpickId')) {
|
if ($(this).data('colpickId')) {
|
||||||
|
@ -407,14 +461,14 @@ For usage and examples: colpick.com/plugin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
//Sets a color as new and current (default)
|
// Sets a color as new and current (default)
|
||||||
setColor: function(col, setCurrent) {
|
setColor: function(col, setCurrent) {
|
||||||
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
|
||||||
if (typeof col == 'string') {
|
if (typeof col === 'string') {
|
||||||
col = hexToHsb(col);
|
col = hexToHsb(col);
|
||||||
} else if (col.r != undefined && col.g != undefined && col.b != undefined) {
|
} else if (col.r !== undefined && col.g !== undefined && col.b !== undefined) {
|
||||||
col = rgbToHsb(col);
|
col = rgbToHsb(col);
|
||||||
} else if (col.h != undefined && col.s != undefined && col.b != undefined) {
|
} else if (col.h !== undefined && col.s !== undefined && col.b !== undefined) {
|
||||||
col = fixHSB(col);
|
col = fixHSB(col);
|
||||||
} else {
|
} else {
|
||||||
return this;
|
return this;
|
||||||
|
@ -431,8 +485,9 @@ For usage and examples: colpick.com/plugin
|
||||||
setSelector(col, cal.get(0));
|
setSelector(col, cal.get(0));
|
||||||
|
|
||||||
setNewColor(col, cal.get(0));
|
setNewColor(col, cal.get(0));
|
||||||
cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
|
cal.data('colpick').onChange.apply(cal.parent(),
|
||||||
if(setCurrent) {
|
[col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
|
||||||
|
if (setCurrent) {
|
||||||
setCurrentColor(col, cal.get(0));
|
setCurrentColor(col, cal.get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -440,13 +495,23 @@ For usage and examples: colpick.com/plugin
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}();
|
}();
|
||||||
//Color space convertions
|
// Color space convertions
|
||||||
var hexToRgb = function (hex) {
|
var hexToRgb = function (hexString) {
|
||||||
var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
|
if (typeof hexString !== "string") {
|
||||||
return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
|
print("Error - ColPick.js::hexToRgb expects string object.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hexNumber = parseInt(((hexString.indexOf('#') > -1) ? hexString.substring(1) : hexString), 16);
|
||||||
|
return { r: hexNumber >> 16, g: (hexNumber & 0x00FF00) >> 8, b: (hexNumber & 0x0000FF)};
|
||||||
};
|
};
|
||||||
var hexToHsb = function (hex) {
|
var hexToHsb = function (hexString) {
|
||||||
return rgbToHsb(hexToRgb(hex));
|
if (typeof hexString !== "string") {
|
||||||
|
print("Error - ColPick.js::hexToHsb expects string object.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rgbToHsb(hexToRgb(hexString));
|
||||||
};
|
};
|
||||||
var rgbToHsb = function (rgb) {
|
var rgbToHsb = function (rgb) {
|
||||||
var hsb = {h: 0, s: 0, b: 0};
|
var hsb = {h: 0, s: 0, b: 0};
|
||||||
|
@ -454,14 +519,22 @@ For usage and examples: colpick.com/plugin
|
||||||
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
var max = Math.max(rgb.r, rgb.g, rgb.b);
|
||||||
var delta = max - min;
|
var delta = max - min;
|
||||||
hsb.b = max;
|
hsb.b = max;
|
||||||
hsb.s = max != 0 ? 255 * delta / max : 0;
|
hsb.s = max != 0 ? 255 * delta / max : 0; // eslint-disable-line eqeqeq
|
||||||
if (hsb.s != 0) {
|
if (hsb.s != 0) { // eslint-disable-line eqeqeq
|
||||||
if (rgb.r == max) hsb.h = (rgb.g - rgb.b) / delta;
|
if (rgb.r == max) { // eslint-disable-line eqeqeq
|
||||||
else if (rgb.g == max) hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
hsb.h = (rgb.g - rgb.b) / delta;
|
||||||
else hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
} else if (rgb.g == max) { // eslint-disable-line eqeqeq
|
||||||
} else hsb.h = -1;
|
hsb.h = 2 + (rgb.b - rgb.r) / delta;
|
||||||
|
} else {
|
||||||
|
hsb.h = 4 + (rgb.r - rgb.g) / delta;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hsb.h = -1;
|
||||||
|
}
|
||||||
hsb.h *= 60;
|
hsb.h *= 60;
|
||||||
if (hsb.h < 0) hsb.h += 360;
|
if (hsb.h < 0) {
|
||||||
|
hsb.h += 360;
|
||||||
|
}
|
||||||
hsb.s *= 100/255;
|
hsb.s *= 100/255;
|
||||||
hsb.b *= 100/255;
|
hsb.b *= 100/255;
|
||||||
return hsb;
|
return hsb;
|
||||||
|
@ -471,20 +544,30 @@ For usage and examples: colpick.com/plugin
|
||||||
var h = hsb.h;
|
var h = hsb.h;
|
||||||
var s = hsb.s*255/100;
|
var s = hsb.s*255/100;
|
||||||
var v = hsb.b*255/100;
|
var v = hsb.b*255/100;
|
||||||
if(s == 0) {
|
if (s == 0) { // eslint-disable-line eqeqeq
|
||||||
rgb.r = rgb.g = rgb.b = v;
|
rgb.r = rgb.g = rgb.b = v;
|
||||||
} else {
|
} else {
|
||||||
var t1 = v;
|
var t1 = v;
|
||||||
var t2 = (255-s)*v/255;
|
var t2 = (255-s)*v/255;
|
||||||
var t3 = (t1-t2)*(h%60)/60;
|
var t3 = (t1-t2)*(h%60)/60;
|
||||||
if(h==360) h = 0;
|
if (h==360) { // eslint-disable-line eqeqeq
|
||||||
if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
|
h = 0;
|
||||||
else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
|
}
|
||||||
else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
|
if (h<60) {
|
||||||
else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
|
rgb.r=t1; rgb.b=t2; rgb.g=t2+t3;
|
||||||
else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
|
} else if (h<120) {
|
||||||
else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
|
rgb.g=t1; rgb.b=t2; rgb.r=t1-t3;
|
||||||
else {rgb.r=0; rgb.g=0; rgb.b=0}
|
} else if (h<180) {
|
||||||
|
rgb.g=t1; rgb.r=t2; rgb.b=t2+t3;
|
||||||
|
} else if (h<240) {
|
||||||
|
rgb.b=t1; rgb.r=t2; rgb.g=t1-t3;
|
||||||
|
} else if (h<300) {
|
||||||
|
rgb.b=t1; rgb.g=t2; rgb.r=t2+t3;
|
||||||
|
} else if (h<360) {
|
||||||
|
rgb.r=t1; rgb.g=t2; rgb.b=t1-t3;
|
||||||
|
} else {
|
||||||
|
rgb.r=0; rgb.g=0; rgb.b=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
|
return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
|
||||||
};
|
};
|
||||||
|
@ -495,7 +578,7 @@ For usage and examples: colpick.com/plugin
|
||||||
rgb.b.toString(16)
|
rgb.b.toString(16)
|
||||||
];
|
];
|
||||||
$.each(hex, function (nr, val) {
|
$.each(hex, function (nr, val) {
|
||||||
if (val.length == 1) {
|
if (val.length == 1) { // eslint-disable-line eqeqeq
|
||||||
hex[nr] = '0' + val;
|
hex[nr] = '0' + val;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -521,3 +604,4 @@ For usage and examples: colpick.com/plugin
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ var ICON_FOR_TYPE = {
|
||||||
|
|
||||||
var EDITOR_TIMEOUT_DURATION = 1500;
|
var EDITOR_TIMEOUT_DURATION = 1500;
|
||||||
var KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
var KEY_P = 80; // Key code for letter p used for Parenting hotkey.
|
||||||
var colorPickers = [];
|
var colorPickers = {};
|
||||||
var lastEntityID = null;
|
var lastEntityID = null;
|
||||||
|
|
||||||
var MATERIAL_PREFIX_STRING = "mat::";
|
var MATERIAL_PREFIX_STRING = "mat::";
|
||||||
|
@ -73,8 +73,8 @@ function enableProperties() {
|
||||||
function disableProperties() {
|
function disableProperties() {
|
||||||
disableChildren(document.getElementById("properties-list"), "input, textarea, checkbox, .dropdown dl, .color-picker");
|
disableChildren(document.getElementById("properties-list"), "input, textarea, checkbox, .dropdown dl, .color-picker");
|
||||||
disableChildren(document, ".colpick");
|
disableChildren(document, ".colpick");
|
||||||
for (var i = 0; i < colorPickers.length; i++) {
|
for (var pickKey in colorPickers) {
|
||||||
colorPickers[i].colpickHide();
|
colorPickers[pickKey].colpickHide();
|
||||||
}
|
}
|
||||||
var elLocked = document.getElementById("property-locked");
|
var elLocked = document.getElementById("property-locked");
|
||||||
|
|
||||||
|
@ -86,7 +86,6 @@ function disableProperties() {
|
||||||
function showElements(els, show) {
|
function showElements(els, show) {
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var i = 0; i < els.length; i++) {
|
||||||
els[i].style.display = (show) ? 'table' : 'none';
|
els[i].style.display = (show) ? 'table' : 'none';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,15 +508,6 @@ function unbindAllInputs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearSelection() {
|
|
||||||
if (document.selection && document.selection.empty) {
|
|
||||||
document.selection.empty();
|
|
||||||
} else if (window.getSelection) {
|
|
||||||
var sel = window.getSelection();
|
|
||||||
sel.removeAllRanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function showParentMaterialNameBox(number, elNumber, elString) {
|
function showParentMaterialNameBox(number, elNumber, elString) {
|
||||||
if (number) {
|
if (number) {
|
||||||
$('#property-parent-material-id-number-container').show();
|
$('#property-parent-material-id-number-container').show();
|
||||||
|
@ -827,8 +817,10 @@ function loaded() {
|
||||||
if (lastEntityID !== '"' + properties.id + '"' && lastEntityID !== null && editor !== null) {
|
if (lastEntityID !== '"' + properties.id + '"' && lastEntityID !== null && editor !== null) {
|
||||||
saveJSONUserData(true);
|
saveJSONUserData(true);
|
||||||
}
|
}
|
||||||
// the event bridge and json parsing handle our avatar id string differently.
|
|
||||||
|
|
||||||
|
var doSelectElement = lastEntityID === '"' + properties.id + '"';
|
||||||
|
|
||||||
|
// the event bridge and json parsing handle our avatar id string differently.
|
||||||
lastEntityID = '"' + properties.id + '"';
|
lastEntityID = '"' + properties.id + '"';
|
||||||
elID.value = properties.id;
|
elID.value = properties.id;
|
||||||
|
|
||||||
|
@ -1193,12 +1185,10 @@ function loaded() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeElement = document.activeElement;
|
var activeElement = document.activeElement;
|
||||||
|
if (doSelectElement && typeof activeElement.select !== "undefined") {
|
||||||
if (typeof activeElement.select !== "undefined") {
|
|
||||||
activeElement.select();
|
activeElement.select();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clearSelection();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1381,13 +1371,19 @@ function loaded() {
|
||||||
elColorRed.addEventListener('change', colorChangeFunction);
|
elColorRed.addEventListener('change', colorChangeFunction);
|
||||||
elColorGreen.addEventListener('change', colorChangeFunction);
|
elColorGreen.addEventListener('change', colorChangeFunction);
|
||||||
elColorBlue.addEventListener('change', colorChangeFunction);
|
elColorBlue.addEventListener('change', colorChangeFunction);
|
||||||
colorPickers.push($('#property-color-control2').colpick({
|
colorPickers['#property-color-control2'] = $('#property-color-control2').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-color-control2').attr('active', 'true');
|
$('#property-color-control2').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-color-control2'].colpickSetColor({
|
||||||
|
"r": elColorRed.value,
|
||||||
|
"g": elColorGreen.value,
|
||||||
|
"b": elColorBlue.value});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-color-control2').attr('active', 'false');
|
$('#property-color-control2').attr('active', 'false');
|
||||||
|
@ -1396,7 +1392,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b);
|
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
elLightSpotLight.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isSpotlight'));
|
elLightSpotLight.addEventListener('change', createEmitCheckedPropertyUpdateFunction('isSpotlight'));
|
||||||
|
|
||||||
|
@ -1405,13 +1401,20 @@ function loaded() {
|
||||||
elLightColorRed.addEventListener('change', lightColorChangeFunction);
|
elLightColorRed.addEventListener('change', lightColorChangeFunction);
|
||||||
elLightColorGreen.addEventListener('change', lightColorChangeFunction);
|
elLightColorGreen.addEventListener('change', lightColorChangeFunction);
|
||||||
elLightColorBlue.addEventListener('change', lightColorChangeFunction);
|
elLightColorBlue.addEventListener('change', lightColorChangeFunction);
|
||||||
colorPickers.push($('#property-light-color').colpick({
|
colorPickers['#property-light-color'] = $('#property-light-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-light-color').attr('active', 'true');
|
$('#property-light-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-light-color'].colpickSetColor({
|
||||||
|
"r": elLightColorRed.value,
|
||||||
|
"g": elLightColorGreen.value,
|
||||||
|
"b": elLightColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-light-color').attr('active', 'false');
|
$('#property-light-color').attr('active', 'false');
|
||||||
|
@ -1420,7 +1423,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b);
|
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
elLightIntensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('intensity', 1));
|
elLightIntensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('intensity', 1));
|
||||||
elLightFalloffRadius.addEventListener('change', createEmitNumberPropertyUpdateFunction('falloffRadius', 1));
|
elLightFalloffRadius.addEventListener('change', createEmitNumberPropertyUpdateFunction('falloffRadius', 1));
|
||||||
|
@ -1486,13 +1489,20 @@ function loaded() {
|
||||||
elTextTextColorRed.addEventListener('change', textTextColorChangeFunction);
|
elTextTextColorRed.addEventListener('change', textTextColorChangeFunction);
|
||||||
elTextTextColorGreen.addEventListener('change', textTextColorChangeFunction);
|
elTextTextColorGreen.addEventListener('change', textTextColorChangeFunction);
|
||||||
elTextTextColorBlue.addEventListener('change', textTextColorChangeFunction);
|
elTextTextColorBlue.addEventListener('change', textTextColorChangeFunction);
|
||||||
colorPickers.push($('#property-text-text-color').colpick({
|
colorPickers['#property-text-text-color'] = $('#property-text-text-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-text-text-color').attr('active', 'true');
|
$('#property-text-text-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-text-text-color'].colpickSetColor({
|
||||||
|
"r": elTextTextColorRed.value,
|
||||||
|
"g": elTextTextColorGreen.value,
|
||||||
|
"b": elTextTextColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-text-text-color').attr('active', 'false');
|
$('#property-text-text-color').attr('active', 'false');
|
||||||
|
@ -1502,7 +1512,7 @@ function loaded() {
|
||||||
$(el).attr('active', 'false');
|
$(el).attr('active', 'false');
|
||||||
emitColorPropertyUpdate('textColor', rgb.r, rgb.g, rgb.b);
|
emitColorPropertyUpdate('textColor', rgb.r, rgb.g, rgb.b);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
var textBackgroundColorChangeFunction = createEmitColorPropertyUpdateFunction(
|
var textBackgroundColorChangeFunction = createEmitColorPropertyUpdateFunction(
|
||||||
'backgroundColor', elTextBackgroundColorRed, elTextBackgroundColorGreen, elTextBackgroundColorBlue);
|
'backgroundColor', elTextBackgroundColorRed, elTextBackgroundColorGreen, elTextBackgroundColorBlue);
|
||||||
|
@ -1510,13 +1520,20 @@ function loaded() {
|
||||||
elTextBackgroundColorRed.addEventListener('change', textBackgroundColorChangeFunction);
|
elTextBackgroundColorRed.addEventListener('change', textBackgroundColorChangeFunction);
|
||||||
elTextBackgroundColorGreen.addEventListener('change', textBackgroundColorChangeFunction);
|
elTextBackgroundColorGreen.addEventListener('change', textBackgroundColorChangeFunction);
|
||||||
elTextBackgroundColorBlue.addEventListener('change', textBackgroundColorChangeFunction);
|
elTextBackgroundColorBlue.addEventListener('change', textBackgroundColorChangeFunction);
|
||||||
colorPickers.push($('#property-text-background-color').colpick({
|
colorPickers['#property-text-background-color'] = $('#property-text-background-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-text-background-color').attr('active', 'true');
|
$('#property-text-background-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-text-background-color'].colpickSetColor({
|
||||||
|
"r": elTextBackgroundColorRed.value,
|
||||||
|
"g": elTextBackgroundColorGreen.value,
|
||||||
|
"b": elTextBackgroundColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-text-background-color').attr('active', 'false');
|
$('#property-text-background-color').attr('active', 'false');
|
||||||
|
@ -1525,7 +1542,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('backgroundColor', rgb.r, rgb.g, rgb.b);
|
emitColorPropertyUpdate('backgroundColor', rgb.r, rgb.g, rgb.b);
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
// Key light
|
// Key light
|
||||||
var keyLightModeChanged = createZoneComponentModeChangedFunction('keyLightMode',
|
var keyLightModeChanged = createZoneComponentModeChangedFunction('keyLightMode',
|
||||||
|
@ -1535,13 +1552,20 @@ function loaded() {
|
||||||
elZoneKeyLightModeDisabled.addEventListener('change', keyLightModeChanged);
|
elZoneKeyLightModeDisabled.addEventListener('change', keyLightModeChanged);
|
||||||
elZoneKeyLightModeEnabled.addEventListener('change', keyLightModeChanged);
|
elZoneKeyLightModeEnabled.addEventListener('change', keyLightModeChanged);
|
||||||
|
|
||||||
colorPickers.push($('#property-zone-key-light-color').colpick({
|
colorPickers['#property-zone-key-light-color'] = $('#property-zone-key-light-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-zone-key-light-color').attr('active', 'true');
|
$('#property-zone-key-light-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-zone-key-light-color'].colpickSetColor({
|
||||||
|
"r": elZoneKeyLightColorRed.value,
|
||||||
|
"g": elZoneKeyLightColorGreen.value,
|
||||||
|
"b": elZoneKeyLightColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-zone-key-light-color').attr('active', 'false');
|
$('#property-zone-key-light-color').attr('active', 'false');
|
||||||
|
@ -1550,7 +1574,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'keyLight');
|
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'keyLight');
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
var zoneKeyLightColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('keyLight', 'color',
|
var zoneKeyLightColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('keyLight', 'color',
|
||||||
elZoneKeyLightColorRed, elZoneKeyLightColorGreen, elZoneKeyLightColorBlue);
|
elZoneKeyLightColorRed, elZoneKeyLightColorGreen, elZoneKeyLightColorBlue);
|
||||||
|
|
||||||
|
@ -1604,13 +1628,20 @@ function loaded() {
|
||||||
|
|
||||||
elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange'));
|
elZoneHazeRange.addEventListener('change', createEmitGroupNumberPropertyUpdateFunction('haze', 'hazeRange'));
|
||||||
|
|
||||||
colorPickers.push($('#property-zone-haze-color').colpick({
|
colorPickers['#property-zone-haze-color'] = $('#property-zone-haze-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-zone-haze-color').attr('active', 'true');
|
$('#property-zone-haze-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-zone-haze-color'].colpickSetColor({
|
||||||
|
"r": elZoneHazeColorRed.value,
|
||||||
|
"g": elZoneHazeColorGreen.value,
|
||||||
|
"b": elZoneHazeColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-zone-haze-color').attr('active', 'false');
|
$('#property-zone-haze-color').attr('active', 'false');
|
||||||
|
@ -1619,7 +1650,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('hazeColor', rgb.r, rgb.g, rgb.b, 'haze');
|
emitColorPropertyUpdate('hazeColor', rgb.r, rgb.g, rgb.b, 'haze');
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
var zoneHazeColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeColor',
|
var zoneHazeColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeColor',
|
||||||
elZoneHazeColorRed,
|
elZoneHazeColorRed,
|
||||||
elZoneHazeColorGreen,
|
elZoneHazeColorGreen,
|
||||||
|
@ -1629,13 +1660,20 @@ function loaded() {
|
||||||
elZoneHazeColorGreen.addEventListener('change', zoneHazeColorChangeFunction);
|
elZoneHazeColorGreen.addEventListener('change', zoneHazeColorChangeFunction);
|
||||||
elZoneHazeColorBlue.addEventListener('change', zoneHazeColorChangeFunction);
|
elZoneHazeColorBlue.addEventListener('change', zoneHazeColorChangeFunction);
|
||||||
|
|
||||||
colorPickers.push($('#property-zone-haze-glare-color').colpick({
|
colorPickers['#property-zone-haze-glare-color'] = $('#property-zone-haze-glare-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-zone-haze-glare-color').attr('active', 'true');
|
$('#property-zone-haze-glare-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-zone-haze-glare-color'].colpickSetColor({
|
||||||
|
"r": elZoneHazeGlareColorRed.value,
|
||||||
|
"g": elZoneHazeGlareColorGreen.value,
|
||||||
|
"b": elZoneHazeGlareColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-zone-haze-glare-color').attr('active', 'false');
|
$('#property-zone-haze-glare-color').attr('active', 'false');
|
||||||
|
@ -1644,7 +1682,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('hazeGlareColor', rgb.r, rgb.g, rgb.b, 'haze');
|
emitColorPropertyUpdate('hazeGlareColor', rgb.r, rgb.g, rgb.b, 'haze');
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
var zoneHazeGlareColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeGlareColor',
|
var zoneHazeGlareColorChangeFunction = createEmitGroupColorPropertyUpdateFunction('haze', 'hazeGlareColor',
|
||||||
elZoneHazeGlareColorRed,
|
elZoneHazeGlareColorRed,
|
||||||
elZoneHazeGlareColorGreen,
|
elZoneHazeGlareColorGreen,
|
||||||
|
@ -1671,13 +1709,20 @@ function loaded() {
|
||||||
elZoneSkyboxColorRed.addEventListener('change', zoneSkyboxColorChangeFunction);
|
elZoneSkyboxColorRed.addEventListener('change', zoneSkyboxColorChangeFunction);
|
||||||
elZoneSkyboxColorGreen.addEventListener('change', zoneSkyboxColorChangeFunction);
|
elZoneSkyboxColorGreen.addEventListener('change', zoneSkyboxColorChangeFunction);
|
||||||
elZoneSkyboxColorBlue.addEventListener('change', zoneSkyboxColorChangeFunction);
|
elZoneSkyboxColorBlue.addEventListener('change', zoneSkyboxColorChangeFunction);
|
||||||
colorPickers.push($('#property-zone-skybox-color').colpick({
|
colorPickers['#property-zone-skybox-color'] = $('#property-zone-skybox-color').colpick({
|
||||||
colorScheme: 'dark',
|
colorScheme: 'dark',
|
||||||
layout: 'hex',
|
layout: 'hex',
|
||||||
color: '000000',
|
color: '000000',
|
||||||
submit: false, // We don't want to have a submission button
|
submit: false, // We don't want to have a submission button
|
||||||
onShow: function(colpick) {
|
onShow: function(colpick) {
|
||||||
$('#property-zone-skybox-color').attr('active', 'true');
|
$('#property-zone-skybox-color').attr('active', 'true');
|
||||||
|
// The original color preview within the picker needs to be updated on show because
|
||||||
|
// prior to the picker being shown we don't have access to the selections' starting color.
|
||||||
|
colorPickers['#property-zone-skybox-color'].colpickSetColor({
|
||||||
|
"r": elZoneSkyboxColorRed.value,
|
||||||
|
"g": elZoneSkyboxColorGreen.value,
|
||||||
|
"b": elZoneSkyboxColorBlue.value
|
||||||
|
});
|
||||||
},
|
},
|
||||||
onHide: function(colpick) {
|
onHide: function(colpick) {
|
||||||
$('#property-zone-skybox-color').attr('active', 'false');
|
$('#property-zone-skybox-color').attr('active', 'false');
|
||||||
|
@ -1686,7 +1731,7 @@ function loaded() {
|
||||||
$(el).css('background-color', '#' + hex);
|
$(el).css('background-color', '#' + hex);
|
||||||
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'skybox');
|
emitColorPropertyUpdate('color', rgb.r, rgb.g, rgb.b, 'skybox');
|
||||||
}
|
}
|
||||||
}));
|
});
|
||||||
|
|
||||||
elZoneSkyboxURL.addEventListener('change', createEmitGroupTextPropertyUpdateFunction('skybox', 'url'));
|
elZoneSkyboxURL.addEventListener('change', createEmitGroupTextPropertyUpdateFunction('skybox', 'url'));
|
||||||
|
|
||||||
|
@ -1761,34 +1806,13 @@ function loaded() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// For input and textarea elements, select all of the text on focus
|
// For input and textarea elements, select all of the text on focus
|
||||||
// WebKit-based browsers, such as is used with QWebView, have a quirk
|
|
||||||
// where the mouseup event comes after the focus event, causing the
|
|
||||||
// text to be deselected immediately after selecting all of the text.
|
|
||||||
// To make this work we block the first mouseup event after the elements
|
|
||||||
// received focus. If we block all mouseup events the user will not
|
|
||||||
// be able to click within the selected text.
|
|
||||||
// We also check to see if the value has changed to make sure we aren't
|
|
||||||
// blocking a mouse-up event when clicking on an input spinner.
|
|
||||||
var els = document.querySelectorAll("input, textarea");
|
var els = document.querySelectorAll("input, textarea");
|
||||||
for (var i = 0; i < els.length; i++) {
|
for (var i = 0; i < els.length; i++) {
|
||||||
var clicked = false;
|
els[i].onfocus = function (e) {
|
||||||
var originalText;
|
e.target.select();
|
||||||
// TODO FIXME: (JSHint) Functions declared within loops referencing
|
|
||||||
// an outer scoped variable may lead to confusing semantics.
|
|
||||||
els[i].onfocus = function(e) {
|
|
||||||
originalText = this.value;
|
|
||||||
this.select();
|
|
||||||
clicked = false;
|
|
||||||
};
|
|
||||||
// TODO FIXME: (JSHint) Functions declared within loops referencing
|
|
||||||
// an outer scoped variable may lead to confusing semantics.
|
|
||||||
els[i].onmouseup = function(e) {
|
|
||||||
if (!clicked && originalText === this.value) {
|
|
||||||
e.preventDefault();
|
|
||||||
}
|
|
||||||
clicked = true;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bindAllNonJSONEditorElements();
|
bindAllNonJSONEditorElements();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -306,10 +306,6 @@ WebTablet.prototype.setScriptURL = function (scriptURL) {
|
||||||
Overlays.editOverlay(this.webOverlayID, { scriptURL: scriptURL });
|
Overlays.editOverlay(this.webOverlayID, { scriptURL: scriptURL });
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.getOverlayObject = function () {
|
|
||||||
return Overlays.getOverlayObject(this.webOverlayID);
|
|
||||||
};
|
|
||||||
|
|
||||||
WebTablet.prototype.setWidth = function (width) {
|
WebTablet.prototype.setWidth = function (width) {
|
||||||
// imported from libraries/utils.js
|
// imported from libraries/utils.js
|
||||||
resizeTablet(width);
|
resizeTablet(width);
|
||||||
|
@ -335,7 +331,7 @@ WebTablet.prototype.destroy = function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.geometryChanged = function (geometry) {
|
WebTablet.prototype.geometryChanged = function (geometry) {
|
||||||
if (!HMD.active) {
|
if (!HMD.active && HMD.tabletID) {
|
||||||
var tabletProperties = {};
|
var tabletProperties = {};
|
||||||
// compute position, rotation & parentJointIndex of the tablet
|
// compute position, rotation & parentJointIndex of the tablet
|
||||||
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
|
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
|
||||||
|
@ -463,6 +459,9 @@ WebTablet.prototype.calculateTabletAttachmentProperties = function (hand, useMou
|
||||||
};
|
};
|
||||||
|
|
||||||
WebTablet.prototype.onHmdChanged = function () {
|
WebTablet.prototype.onHmdChanged = function () {
|
||||||
|
if (!HMD.tabletID) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var tabletProperties = {};
|
var tabletProperties = {};
|
||||||
// compute position, rotation & parentJointIndex of the tablet
|
// compute position, rotation & parentJointIndex of the tablet
|
||||||
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
|
this.calculateTabletAttachmentProperties(NO_HANDS, false, tabletProperties);
|
||||||
|
|
|
@ -21,7 +21,10 @@ SPACE_LOCAL = "local";
|
||||||
SPACE_WORLD = "world";
|
SPACE_WORLD = "world";
|
||||||
HIGHLIGHT_LIST_NAME = "editHandleHighlightList";
|
HIGHLIGHT_LIST_NAME = "editHandleHighlightList";
|
||||||
|
|
||||||
Script.include("./controllers.js");
|
Script.include([
|
||||||
|
"./controllers.js",
|
||||||
|
"./utils.js"
|
||||||
|
]);
|
||||||
|
|
||||||
SelectionManager = (function() {
|
SelectionManager = (function() {
|
||||||
var that = {};
|
var that = {};
|
||||||
|
@ -668,7 +671,7 @@ SelectionDisplay = (function() {
|
||||||
|
|
||||||
var pickRay = generalComputePickRay(event.x, event.y);
|
var pickRay = generalComputePickRay(event.x, event.y);
|
||||||
// TODO_Case6491: Move this out to setup just to make it once
|
// TODO_Case6491: Move this out to setup just to make it once
|
||||||
var interactiveOverlays = [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID];
|
var interactiveOverlays = getMainTabletIDs();
|
||||||
for (var key in handleTools) {
|
for (var key in handleTools) {
|
||||||
if (handleTools.hasOwnProperty(key)) {
|
if (handleTools.hasOwnProperty(key)) {
|
||||||
interactiveOverlays.push(key);
|
interactiveOverlays.push(key);
|
||||||
|
@ -681,8 +684,8 @@ SelectionDisplay = (function() {
|
||||||
var results = testRayIntersect(pickRay, interactiveOverlays);
|
var results = testRayIntersect(pickRay, interactiveOverlays);
|
||||||
if (results.intersects) {
|
if (results.intersects) {
|
||||||
var hitOverlayID = results.overlayID;
|
var hitOverlayID = results.overlayID;
|
||||||
if ((hitOverlayID === HMD.tabletID) || (hitOverlayID === HMD.tabletScreenID) ||
|
if ((HMD.tabletID && hitOverlayID === HMD.tabletID) || (HMD.tabletScreenID && hitOverlayID === HMD.tabletScreenID)
|
||||||
(hitOverlayID === HMD.homeButtonID)) {
|
|| (HMD.homeButtonID && hitOverlayID === HMD.homeButtonID)) {
|
||||||
// EARLY EXIT-(mouse clicks on the tablet should override the edit affordances)
|
// EARLY EXIT-(mouse clicks on the tablet should override the edit affordances)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -428,3 +428,17 @@ resizeTablet = function (width, newParentJointIndex, sensorToWorldScaleOverride)
|
||||||
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
|
dimensions: { x: homeButtonDim, y: homeButtonDim, z: homeButtonDim }
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getMainTabletIDs = function () {
|
||||||
|
var tabletIDs = [];
|
||||||
|
if (HMD.tabletID) {
|
||||||
|
tabletIDs.push(HMD.tabletID);
|
||||||
|
}
|
||||||
|
if (HMD.tabletScreenID) {
|
||||||
|
tabletIDs.push(HMD.tabletScreenID);
|
||||||
|
}
|
||||||
|
if (HMD.homeButtonID) {
|
||||||
|
tabletIDs.push(HMD.homeButtonID);
|
||||||
|
}
|
||||||
|
return tabletIDs;
|
||||||
|
};
|
|
@ -104,8 +104,9 @@ var selectionDisplay = null; // for gridTool.js to ignore
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
Wallet.refreshWalletStatus();
|
Wallet.refreshWalletStatus();
|
||||||
var entity = HMD.tabletID;
|
if (HMD.tabletID) {
|
||||||
Entities.editEntity(entity, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
|
Entities.editEntity(HMD.tabletID, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
|
||||||
|
}
|
||||||
showMarketplace();
|
showMarketplace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,9 @@ var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
var entity = HMD.tabletID;
|
if (HMD.tabletID) {
|
||||||
Entities.editEntity(entity, {textures: JSON.stringify({"tex.close": HOME_BUTTON_TEXTURE})});
|
Entities.editEntity(HMD.tabletID, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) });
|
||||||
|
}
|
||||||
tablet.gotoMenuScreen();
|
tablet.gotoMenuScreen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,14 @@
|
||||||
if (!UIWebTablet) {
|
if (!UIWebTablet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Overlays.getProperty(HMD.tabletID, "type") != "model") {
|
if (Overlays.getProperty(HMD.tabletID, "type") !== "model") {
|
||||||
if (debugTablet) {
|
if (debugTablet) {
|
||||||
print("TABLET is invalid due to frame: " + JSON.stringify(Overlays.getProperty(HMD.tabletID, "type")));
|
print("TABLET is invalid due to frame: " + JSON.stringify(Overlays.getProperty(HMD.tabletID, "type")));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Overlays.getProperty(HMD.homeButtonID, "type") != "circle3d" ||
|
if (Overlays.getProperty(HMD.homeButtonID, "type") !== "circle3d" ||
|
||||||
Overlays.getProperty(HMD.tabletScreenID, "type") != "web3d") {
|
Overlays.getProperty(HMD.tabletScreenID, "type") !== "web3d") {
|
||||||
if (debugTablet) {
|
if (debugTablet) {
|
||||||
print("TABLET is invalid due to other");
|
print("TABLET is invalid due to other");
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTabletUI() {
|
function showTabletUI() {
|
||||||
checkTablet()
|
checkTablet();
|
||||||
|
|
||||||
if (!tabletRezzed || !tabletIsValid()) {
|
if (!tabletRezzed || !tabletIsValid()) {
|
||||||
closeTabletUI();
|
closeTabletUI();
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeTabletUI() {
|
function closeTabletUI() {
|
||||||
checkTablet()
|
checkTablet();
|
||||||
gTablet.tabletShown = false;
|
gTablet.tabletShown = false;
|
||||||
if (UIWebTablet) {
|
if (UIWebTablet) {
|
||||||
if (UIWebTablet.onClose) {
|
if (UIWebTablet.onClose) {
|
||||||
|
@ -178,14 +178,14 @@
|
||||||
print("TABLET closeTabletUI, UIWebTablet is null");
|
print("TABLET closeTabletUI, UIWebTablet is null");
|
||||||
}
|
}
|
||||||
tabletRezzed = false;
|
tabletRezzed = false;
|
||||||
gTablet = null
|
gTablet = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateShowTablet() {
|
function updateShowTablet() {
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
|
||||||
checkTablet()
|
checkTablet();
|
||||||
|
|
||||||
// close the WebTablet if it we go into toolbar mode.
|
// close the WebTablet if it we go into toolbar mode.
|
||||||
var tabletShown = gTablet.tabletShown;
|
var tabletShown = gTablet.tabletShown;
|
||||||
|
@ -270,7 +270,7 @@
|
||||||
}
|
}
|
||||||
if (channel === "home") {
|
if (channel === "home") {
|
||||||
if (UIWebTablet) {
|
if (UIWebTablet) {
|
||||||
checkTablet()
|
checkTablet();
|
||||||
gTablet.landscape = false;
|
gTablet.landscape = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,9 +48,8 @@
|
||||||
// for toolbar-mode: go back to home screen, this will close the window.
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
tablet.gotoHomeScreen();
|
tablet.gotoHomeScreen();
|
||||||
} else {
|
} else {
|
||||||
var tabletEntity = HMD.tabletID;
|
if (HMD.tabletID) {
|
||||||
if (tabletEntity) {
|
Entities.editEntity(HMD.tabletID, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
||||||
Entities.editEntity(tabletEntity, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
|
||||||
}
|
}
|
||||||
shouldActivateButton = true;
|
shouldActivateButton = true;
|
||||||
tablet.gotoWebScreen(USERS_URL);
|
tablet.gotoWebScreen(USERS_URL);
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
//
|
||||||
|
// keep-in-zone-example.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub to use Entities on Dec. 15, 2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample entity edit filter script will keep any entity inside the bounding box of the zone this filter is applied to.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function filter(properties, type, originalProperties, zoneProperties) {
|
||||||
|
|
||||||
|
var nearZero = 0.0001 * Math.random() + 0.001;
|
||||||
|
|
||||||
|
/* Clamp position changes to bounding box of zone.*/
|
||||||
|
function clamp(val, min, max) {
|
||||||
|
/* Random near-zero value used as "zero" to prevent two sequential updates from being
|
||||||
|
exactly the same (which would cause them to be ignored) */
|
||||||
|
if (val > max) {
|
||||||
|
val = max - nearZero;
|
||||||
|
} else if (val < min) {
|
||||||
|
val = min + nearZero;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties.position) {
|
||||||
|
properties.position.x = clamp(properties.position.x, zoneProperties.boundingBox.brn.x, zoneProperties.boundingBox.tfl.x);
|
||||||
|
properties.position.y = clamp(properties.position.y, zoneProperties.boundingBox.brn.y, zoneProperties.boundingBox.tfl.y);
|
||||||
|
properties.position.z = clamp(properties.position.z, zoneProperties.boundingBox.brn.z, zoneProperties.boundingBox.tfl.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.wantsOriginalProperties = true;
|
||||||
|
filter.wantsZoneProperties = true;
|
||||||
|
filter;
|
45
scripts/tutorials/entity_edit_filters/position-example.js
Normal file
45
scripts/tutorials/entity_edit_filters/position-example.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
//
|
||||||
|
// position-example.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub to use Entities on Dec. 15, 2017
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample entity edit filter script will only allow position to be changed by no more than 5 meters on any axis.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function filter(properties, type, originalProperties) {
|
||||||
|
|
||||||
|
/* Clamp position changes.*/
|
||||||
|
var maxChange = 5;
|
||||||
|
|
||||||
|
function clamp(val, min, max) {
|
||||||
|
if (val > max) {
|
||||||
|
val = max;
|
||||||
|
} else if (val < min) {
|
||||||
|
val = min;
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (properties.position) {
|
||||||
|
/* Random near-zero value used as "zero" to prevent two sequential updates from being
|
||||||
|
exactly the same (which would cause them to be ignored) */
|
||||||
|
var nearZero = 0.0001 * Math.random() + 0.001;
|
||||||
|
var maxFudgeChange = (maxChange + nearZero);
|
||||||
|
properties.position.x = clamp(properties.position.x, originalProperties.position.x
|
||||||
|
- maxFudgeChange, originalProperties.position.x + maxFudgeChange);
|
||||||
|
properties.position.y = clamp(properties.position.y, originalProperties.position.y
|
||||||
|
- maxFudgeChange, originalProperties.position.y + maxFudgeChange);
|
||||||
|
properties.position.z = clamp(properties.position.z, originalProperties.position.z
|
||||||
|
- maxFudgeChange, originalProperties.position.z + maxFudgeChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
filter.wantsOriginalProperties = "position";
|
||||||
|
filter;
|
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
// prevent-add-delete-or-edit-of-entities-with-name-of-zone.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub to use Entities on Feb. 14, 2018
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample entity edit filter script will get all edits, adds, physcis, and deletes, but will only block
|
||||||
|
// deletes, and will pass through all others.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function filter(properties, type, originalProperties, zoneProperties) {
|
||||||
|
|
||||||
|
// for adds, check the new properties, if the name is the same as the zone, prevent the add
|
||||||
|
// note: this case tests the example where originalProperties will be unknown, since as an
|
||||||
|
// add message, there is no existing entity to get proprties from. But we need to make sure
|
||||||
|
// zoneProperties is still set in the correct 4th parameter.
|
||||||
|
if (type == Entities.ADD_FILTER_TYPE) {
|
||||||
|
if (properties.name == zoneProperties.name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// for edits or deletes, check the "original" property for the entity against the zone's name
|
||||||
|
if (originalProperties.name == zoneProperties.name) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.wantsToFilterAdd = true; // do run on add
|
||||||
|
filter.wantsToFilterEdit = true; // do not run on edit
|
||||||
|
filter.wantsToFilterPhysics = false; // do not run on physics
|
||||||
|
filter.wantsToFilterDelete = true; // do not run on delete
|
||||||
|
filter.wantsOriginalProperties = "name";
|
||||||
|
filter.wantsZoneProperties = "name";
|
||||||
|
filter;
|
|
@ -0,0 +1,26 @@
|
||||||
|
//
|
||||||
|
// prevent-add-of-entities-named-bob-example.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub to use Entities on Jan. 25, 2018
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample entity edit filter script will get all edits, adds, physcis, and deletes, but will only block
|
||||||
|
// deletes, and will pass through all others.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function filter(properties, type) {
|
||||||
|
if (properties.name == "bob") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.wantsToFilterAdd = true; // do run on add
|
||||||
|
filter.wantsToFilterEdit = false; // do not run on edit
|
||||||
|
filter.wantsToFilterPhysics = false; // do not run on physics
|
||||||
|
filter.wantsToFilterDelete = false; // do not run on delete
|
||||||
|
filter;
|
22
scripts/tutorials/entity_edit_filters/prevent-all-deletes.js
Normal file
22
scripts/tutorials/entity_edit_filters/prevent-all-deletes.js
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
//
|
||||||
|
// prevent-all-deletes.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub to use Entities on Jan. 25, 2018
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample entity edit filter script will prevent deletes of any entities.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function filter() {
|
||||||
|
return false; // all deletes are blocked
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.wantsToFilterAdd = false; // don't run on adds
|
||||||
|
filter.wantsToFilterEdit = false; // don't run on edits
|
||||||
|
filter.wantsToFilterPhysics = false; // don't run on physics
|
||||||
|
filter.wantsToFilterDelete = true; // do run on deletes
|
||||||
|
filter;
|
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// prevent-delete-in-zone-example.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Brad Hefta-Gaub to use Entities on Jan. 25, 2018
|
||||||
|
// Copyright 2018 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample entity edit filter script will get all edits, adds, physcis, and deletes, but will only block
|
||||||
|
// deletes, and will pass through all others.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
function filter(properties, type) {
|
||||||
|
|
||||||
|
if (type == Entities.DELETE_FILTER_TYPE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
filter.wantsToFilterDelete = true; // do run on deletes
|
||||||
|
filter;
|
|
@ -252,16 +252,17 @@ function onFinishOnOpenClicked() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function signalBodyLoaded() {
|
function signalBodyLoaded() {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
var EVENTBRIDGE_OPEN_DELAY = 500; // Delay required to ensure EventBridge is ready for use.
|
||||||
type: EVENT_BRIDGE_TYPE,
|
setTimeout(function () {
|
||||||
action: BODY_LOADED_ACTION
|
EventBridge.scriptEventReceived.connect(onScriptEventReceived);
|
||||||
}));
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: EVENT_BRIDGE_TYPE,
|
||||||
|
action: BODY_LOADED_ACTION
|
||||||
|
}));
|
||||||
|
}, EVENTBRIDGE_OPEN_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onBodyLoaded() {
|
function onBodyLoaded() {
|
||||||
|
|
||||||
EventBridge.scriptEventReceived.connect(onScriptEventReceived);
|
|
||||||
|
|
||||||
elRecordings = document.getElementById("recordings");
|
elRecordings = document.getElementById("recordings");
|
||||||
|
|
||||||
elRecordingsTable = document.getElementById("recordings-table");
|
elRecordingsTable = document.getElementById("recordings-table");
|
||||||
|
|
|
@ -139,7 +139,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function setMappingCallback(status) {
|
function setMappingCallback(status) {
|
||||||
if (status !== "") {
|
// FIXME: "" is for RC <= 63, null is for RC > 63. Remove the former when RC63 is no longer used.
|
||||||
|
if (status !== null && status !== "") {
|
||||||
error("Error mapping recording to " + mappingPath + " on Asset Server!", status);
|
error("Error mapping recording to " + mappingPath + " on Asset Server!", status);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -173,8 +173,18 @@ Laser = function (side) {
|
||||||
// Normal laser operation with trigger.
|
// Normal laser operation with trigger.
|
||||||
intersection = Overlays.findRayIntersection(pickRay, PRECISION_PICKING, NO_INCLUDE_IDS, NO_EXCLUDE_IDS,
|
intersection = Overlays.findRayIntersection(pickRay, PRECISION_PICKING, NO_INCLUDE_IDS, NO_EXCLUDE_IDS,
|
||||||
VISIBLE_ONLY);
|
VISIBLE_ONLY);
|
||||||
|
var tabletIDs = [];
|
||||||
|
if (HMD.tabletID) {
|
||||||
|
tabletIDs.push(HMD.tabletID);
|
||||||
|
}
|
||||||
|
if (HMD.tabletScreenID) {
|
||||||
|
tabletIDs.push(HMD.tabletScreenID);
|
||||||
|
}
|
||||||
|
if (HMD.homeButtonID) {
|
||||||
|
tabletIDs.push(HMD.homeButtonID);
|
||||||
|
}
|
||||||
if (Reticle.pointingAtSystemOverlay || (intersection.overlayID
|
if (Reticle.pointingAtSystemOverlay || (intersection.overlayID
|
||||||
&& [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID].indexOf(intersection.overlayID) !== -1)) {
|
&& tabletIDs.indexOf(intersection.overlayID) !== -1)) {
|
||||||
// No laser if pointing at HUD overlay or tablet; system provides lasers for these cases.
|
// No laser if pointing at HUD overlay or tablet; system provides lasers for these cases.
|
||||||
if (isLaserOn) {
|
if (isLaserOn) {
|
||||||
isLaserOn = false;
|
isLaserOn = false;
|
||||||
|
|
Loading…
Reference in a new issue