r3-v2/dist/r3.js

1791 lines
159 KiB
JavaScript
Raw Normal View History

2020-02-27 17:07:46 +01:00
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "./src/r3/index.js");
2020-02-27 17:07:46 +01:00
/******/ })
/************************************************************************/
/******/ ({
/***/ "./src/r3/index.js":
/*!*************************!*\
!*** ./src/r3/index.js ***!
\*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
var R3 = __webpack_require__(/*! ./r3.js */ "./src/r3/r3.js");
2020-02-27 17:07:46 +01:00
R3.System.Linking.start();
2020-04-23 15:26:54 +02:00
R3.System.Socket.start();
module.exports = R3;
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
/***/ }),
/***/ "./src/r3/r3-event.js":
/*!****************************!*\
!*** ./src/r3/r3-event.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var Utils = __webpack_require__(/*! ./r3-utils */ "./src/r3/r3-utils.js");
var Event = /*#__PURE__*/function () {
2021-06-19 11:27:32 +02:00
function Event(options) {
2021-06-18 02:10:32 +02:00
_classCallCheck(this, Event);
console.log('Event created');
}
/**
* Some nice Events handling
* @type {{}}
*/
_createClass(Event, [{
key: "subscribe",
value:
/**
* Subscribe to some events
* @param eventName
* @param callback
*/
function subscribe(eventName, callback) {
return Event.Subscribe(eventName, callback.bind(this));
}
}, {
key: "emit",
value: function emit(eventName, data, clientCallback, clientErrorCallback) {
return Event.Emit(eventName, data, clientCallback, clientErrorCallback);
}
/**
* Execute the functions which subscribe to this event, but don't process the client callback - the subscription function
* should execute the client callback
* @param eventId
* @param data
* @param clientCallback
* @param clientErrorCallback
* @returns {number}
* @constructor
*/
}], [{
key: "Subscribe",
value: function Subscribe(eventName, fn) {
/**
* Todo - maybe eventually store a boolean which indicates if the function has been executed
*/
var subscriptionId = Utils.RandomId(10);
if (Event.Subscriptions.hasOwnProperty(eventName)) {
if (Event.Subscriptions[eventName][subscriptionId]) {
throw new Error('A component can only subscribe to a particular event ID once');
}
Event.Subscriptions[eventName][subscriptionId] = fn;
} else {
Event.Subscriptions[eventName] = {};
Event.Subscriptions[eventName][subscriptionId] = fn;
}
/**
* Return a handle to the caller to allow us to unsubscribe to this event
*/
return {
fn: fn,
remove: function (eventId, subscriptionId) {
return function () {
/**
* Stop listening for this event from this component
*/
delete Event.Subscriptions[eventId][subscriptionId];
/**
* If the length of listeners is 0, stop referencing this event
* @type {string[]}
*/
var listeners = Object.keys(Event.Subscriptions[eventId]);
if (listeners.length === 0) {
delete Event.Subscriptions[eventId];
}
};
}(eventName, subscriptionId),
subscriptionId: subscriptionId
};
}
}, {
key: "Emit",
value:
/**
* Static Synchronous Event - Calls clientCallback directly after the event result is obtained
* @param eventId
* @param data
* @param clientCallback is executed ideally when the event completed
* @param clientErrorCallback
* @returns {number} of callbacks executed
* @constructor
*/
function Emit(eventId, data, clientCallback, clientErrorCallback) {
if (Event.Subscriptions.hasOwnProperty(eventId)) {
var subscriptionIds = Object.keys(Event.Subscriptions[eventId]);
subscriptionIds.map(function (subscriptionId) {
try {
var result = Event.Subscriptions[eventId][subscriptionId](data);
if (clientCallback) {
clientCallback(result);
}
} catch (error) {
if (clientErrorCallback) {
clientErrorCallback(error);
} else {
console.error(error);
throw error;
}
}
});
}
}
}, {
key: "Async",
value: function Async(eventId, data, clientCallback, clientErrorCallback) {
if (Event.Subscriptions.hasOwnProperty(eventId)) {
var subscriptionIds = Object.keys(Event.Subscriptions[eventId]);
subscriptionIds.map(function (subscriptionId) {
try {
Event.Subscriptions[eventId][subscriptionId](data, clientCallback, clientErrorCallback);
} catch (error) {
if (clientErrorCallback) {
clientErrorCallback(error);
} else {
console.error(error);
throw error;
}
}
});
}
}
}]);
return Event;
2021-06-18 13:54:08 +02:00
}(); //EVENT_GENERATED_START
2021-06-18 02:10:32 +02:00
_defineProperty(Event, "Subscriptions", {});
2021-06-18 14:29:33 +02:00
Event.CREATE_INSTANCE = 0x1;
2021-06-19 11:27:32 +02:00
Event.DISPOSE_INSTANCE = 0x2;
Event.DISPOSE_OBJECT = 0x3;
Event.GET_RUNTIME = 0x4;
Event.GET_WINDOW_SIZE = 0x5;
Event.INSTANCE_CREATED = 0x6;
Event.INSTANCE_DISPOSED = 0x7;
Event.OBJECT_CREATED = 0x8;
Event.OBJECT_DISPOSED = 0x9;
Event.OBJECT_INITIALIZED = 0xa;
Event.PAUSE = 0xb;
Event.RESTART = 0xc;
Event.START = 0xd;
Event.UPDATE_FROM_INSTANCE_AFTER = 0xe;
Event.UPDATE_FROM_INSTANCE_BEFORE = 0xf;
Event.UPDATE_INSTANCE_AFTER = 0x10;
Event.UPDATE_INSTANCE_BEFORE = 0x11;
Event.MAX_EVENTS = 0x12;
2021-06-18 14:29:33 +02:00
Event.GetEventName = function (eventId) {
switch (eventId) {
case 0x1:
return 'create_instance';
case 0x2:
2021-06-19 11:27:32 +02:00
return 'dispose_instance';
2021-06-18 14:29:33 +02:00
case 0x3:
2021-06-19 11:27:32 +02:00
return 'dispose_object';
2021-06-18 14:29:33 +02:00
case 0x4:
2021-06-19 11:27:32 +02:00
return 'get_runtime';
2021-06-18 14:29:33 +02:00
case 0x5:
2021-06-19 11:27:32 +02:00
return 'get_window_size';
2021-06-18 14:29:33 +02:00
case 0x6:
2021-06-19 11:27:32 +02:00
return 'instance_created';
2021-06-18 14:29:33 +02:00
case 0x7:
2021-06-19 11:27:32 +02:00
return 'instance_disposed';
2021-06-18 14:29:33 +02:00
case 0x8:
2021-06-19 11:27:32 +02:00
return 'object_created';
2021-06-18 14:29:33 +02:00
case 0x9:
2021-06-19 11:27:32 +02:00
return 'object_disposed';
case 0xa:
return 'object_initialized';
case 0xb:
return 'pause';
case 0xc:
return 'restart';
case 0xd:
2021-06-18 14:29:33 +02:00
return 'start';
2021-06-19 11:27:32 +02:00
case 0xe:
return 'update_from_instance_after';
case 0xf:
return 'update_from_instance_before';
case 0x10:
return 'update_instance_after';
case 0x11:
return 'update_instance_before';
2021-06-18 14:29:33 +02:00
default:
throw new Error('Event type not defined : ' + eventId);
}
}; //EVENT_GENERATED_END
2021-06-18 13:54:08 +02:00
2021-06-18 02:10:32 +02:00
module.exports = Event;
2020-02-27 17:07:46 +01:00
2020-04-21 11:54:13 +02:00
/***/ }),
2021-06-18 13:54:08 +02:00
/***/ "./src/r3/r3-r3-object.js":
/*!********************************!*\
!*** ./src/r3/r3-r3-object.js ***!
\********************************/
2020-04-21 11:54:13 +02:00
/*! no static exports found */
2021-06-18 02:10:32 +02:00
/***/ (function(module, exports, __webpack_require__) {
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var Event = __webpack_require__(/*! ./r3-event */ "./src/r3/r3-event.js");
2021-06-18 13:54:08 +02:00
var R3Object = /*#__PURE__*/function (_Event) {
_inherits(R3Object, _Event);
2021-06-18 02:10:32 +02:00
2021-06-18 13:54:08 +02:00
var _super = _createSuper(R3Object);
2021-06-18 02:10:32 +02:00
2021-06-19 11:27:32 +02:00
function R3Object(options) {
2021-06-18 02:10:32 +02:00
var _this;
2021-06-18 13:54:08 +02:00
_classCallCheck(this, R3Object);
2021-06-18 02:10:32 +02:00
2021-06-19 11:27:32 +02:00
_this = _super.call(this, options);
2021-06-18 02:10:32 +02:00
console.log('Object created');
_this.emit(Event.OBJECT_CREATED);
return _this;
}
2020-04-21 11:54:13 +02:00
2021-06-18 13:54:08 +02:00
return R3Object;
2021-06-18 02:10:32 +02:00
}(Event);
2020-04-21 11:54:13 +02:00
2021-06-18 13:54:08 +02:00
module.exports = R3Object;
2020-04-21 11:54:13 +02:00
2021-06-18 02:10:32 +02:00
/***/ }),
/***/ "./src/r3/r3-system/index.js":
/*!***********************************!*\
!*** ./src/r3/r3-system/index.js ***!
\***********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
2021-06-19 11:27:32 +02:00
var System = __webpack_require__(/*! ./r3-system.js */ "./src/r3/r3-system/r3-system.js");
2021-06-18 02:10:32 +02:00
2021-06-19 11:27:32 +02:00
var SystemLinking = __webpack_require__(/*! ./r3-system-linking.js */ "./src/r3/r3-system/r3-system-linking.js");
2020-04-21 11:54:13 +02:00
2021-06-19 11:27:32 +02:00
var SystemSocket = __webpack_require__(/*! ./r3-system-socket.js */ "./src/r3/r3-system/r3-system-socket.js");
2021-06-18 02:10:32 +02:00
module.exports = {
System: System,
SystemLinking: SystemLinking,
SystemSocket: SystemSocket
};
2020-04-21 11:54:13 +02:00
2020-02-27 17:07:46 +01:00
/***/ }),
2021-06-18 02:10:32 +02:00
/***/ "./src/r3/r3-system/r3-system-linking.js":
/*!***********************************************!*\
!*** ./src/r3/r3-system/r3-system-linking.js ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2021-06-18 02:10:32 +02:00
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var System = __webpack_require__(/*! ./r3-system */ "./src/r3/r3-system/r3-system.js");
2020-02-27 17:07:46 +01:00
2021-06-18 13:54:08 +02:00
var R3Object = __webpack_require__(/*! ../r3-r3-object */ "./src/r3/r3-r3-object.js");
2021-06-18 02:10:32 +02:00
var Event = __webpack_require__(/*! ../r3-event */ "./src/r3/r3-event.js");
var LinkingSystem = /*#__PURE__*/function (_System) {
_inherits(LinkingSystem, _System);
var _super = _createSuper(LinkingSystem);
function LinkingSystem() {
_classCallCheck(this, LinkingSystem);
return _super.apply(this, arguments);
}
_createClass(LinkingSystem, null, [{
key: "start",
value: function start() {
_get(_getPrototypeOf(LinkingSystem), "start", this).call(this);
console.log('starting linking system');
Event.Subscribe(Event.OBJECT_CREATED, function () {
console.log('linking system discovered an object');
});
2021-06-18 13:54:08 +02:00
var object = new R3Object();
2021-06-18 02:10:32 +02:00
return true;
}
}]);
return LinkingSystem;
}(System);
module.exports = LinkingSystem;
2020-02-27 17:07:46 +01:00
2020-04-23 15:26:54 +02:00
/***/ }),
2021-06-18 02:10:32 +02:00
/***/ "./src/r3/r3-system/r3-system-socket.js":
/*!**********************************************!*\
!*** ./src/r3/r3-system/r3-system-socket.js ***!
\**********************************************/
2020-04-23 15:26:54 +02:00
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
2021-06-18 02:10:32 +02:00
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
2020-04-23 15:26:54 +02:00
2021-06-18 02:10:32 +02:00
var System = __webpack_require__(/*! ./r3-system.js */ "./src/r3/r3-system/r3-system.js");
var SocketSystem = /*#__PURE__*/function (_System) {
_inherits(SocketSystem, _System);
var _super = _createSuper(SocketSystem);
function SocketSystem() {
_classCallCheck(this, SocketSystem);
return _super.apply(this, arguments);
}
_createClass(SocketSystem, null, [{
key: "start",
value: function start() {
_get(_getPrototypeOf(SocketSystem), "start", this).call(this);
console.log('starting socket system');
return true;
}
}]);
return SocketSystem;
}(System);
module.exports = SocketSystem;
2020-04-23 15:26:54 +02:00
2020-02-27 17:07:46 +01:00
/***/ }),
2021-06-18 02:10:32 +02:00
/***/ "./src/r3/r3-system/r3-system.js":
/*!***************************************!*\
!*** ./src/r3/r3-system/r3-system.js ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports) {
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
var System = /*#__PURE__*/function () {
function System() {
_classCallCheck(this, System);
}
_createClass(System, null, [{
key: "start",
value: function start() {
console.log('starting a system');
}
}]);
return System;
}();
2020-02-27 17:07:46 +01:00
module.exports = System;
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
/***/ }),
/***/ "./src/r3/r3-utils.js":
/*!****************************!*\
!*** ./src/r3/r3-utils.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2021-06-18 13:54:08 +02:00
var Utils = /*#__PURE__*/function () {
2021-06-18 02:10:32 +02:00
function Utils() {
_classCallCheck(this, Utils);
}
/**
* Gets the first parent of the object which is an instance of constructor
* @param object
* @param constructor
* @returns {*}
* @constructor
*/
_createClass(Utils, null, [{
key: "GetFirstParent",
value: function GetFirstParent(object, constructor) {
if (Utils.UndefinedOrNull(constructor)) {
throw new Error('You need to specify a constructor');
}
if (object.parent === null) {
return null;
}
if (object.parent instanceof constructor) {
return object.parent;
} else {
return Utils.GetFirstParent(object.parent, constructor);
}
}
}, {
key: "SyntaxHighlight",
value: function SyntaxHighlight(json) {
if (typeof json != 'string') {
json = JSON.stringify(json, undefined, 2);
}
json = json.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
var cls = 'number';
if (/^"/.test(match)) {
if (/:$/.test(match)) {
cls = 'key';
} else {
cls = 'string';
}
} else if (/true|false/.test(match)) {
cls = 'boolean';
} else if (/null/.test(match)) {
cls = 'null';
}
return '<span class="' + cls + '">' + match + '</span>';
});
}
}, {
key: "GetParentProject",
value: function GetParentProject(component) {
if (Utils.UndefinedOrNull(component.parent)) {
throw new Error('Parent not found');
}
if (component.parent instanceof R3.Project) {
return component.parent;
}
return Utils.GetParentProject(component.parent);
}
}, {
key: "GetParents",
value: function GetParents(component, parents) {
if (Utils.UndefinedOrNull(parents)) {
parents = [];
}
if (Utils.UndefinedOrNull(component.parent)) {
return parents;
}
parents.push(component.parent);
return Utils.GetParents(component.parent, parents);
}
}, {
key: "Instance",
value:
/**
* @return {boolean}
*/
function Instance(component) {
return Utils.Defined(component) && Utils.Defined(component.instance);
}
}, {
key: "RemoveFromSelect",
value:
/**
* Utils.RemoveFromSelect
* @param select
* @param id
* @returns {boolean}
* @constructor
*/
function RemoveFromSelect(select, id) {
var i;
for (i = 0; i < select.options.length; i++) {
if (select.options[i].value === id) {
select.remove(i);
return true;
}
}
return false;
}
}, {
key: "SetSelectIndex",
value:
/**
* Utils.GetSelectIndex
*
* Get the select index of given id
*
* @param select
* @param id
* @returns boolean true if successful
*
* @constructor
*/
function SetSelectIndex(select, id) {
for (var _i = 0; _i < select.options.length; _i++) {
if (select.options[_i].value === id) {
select.selectedIndex = _i;
return true;
}
}
return false;
}
}, {
key: "SortSelect",
value: function SortSelect(select) {
var tmp = [];
var i;
for (i = 1; i < select.options.length; i++) {
tmp[i - 1] = [];
tmp[i - 1][0] = select.options[i].text;
tmp[i - 1][1] = select.options[i].value;
}
tmp.sort();
select.options = [select.options[0]];
for (i = 0; i < tmp.length; i++) {
select.options[i + 1] = new Option(tmp[i][0], tmp[i][1]);
}
return;
}
}, {
key: "GetParent",
value:
/**
* Gets the parent of object whith property of optional type constructor. If index is specified, get the parent of the
* object with property[index] - which means the property should be an array
* @param object
* @param property
* @param index
* @param constructor
* @returns {*}
* @constructor
*/
function GetParent(object, property, index, constructor) {
if (Utils.UndefinedOrNull(constructor)) {
constructor = null;
}
if (Utils.UndefinedOrNull(index)) {
index = null;
}
if (object.parent) {
/**
* Parent defined
*/
if (object.parent.hasOwnProperty(property)) {
if (constructor) {
if (index) {
if (object.parent[property][index] instanceof constructor) {
return object.parent[property][index];
} else {
if (typeof object.parent.getParent === 'function') {
return object.parent.getParent(property, index, constructor);
} else {
console.warn('getParent not defined on API object : ' + object.parent + ' - you should avoid having these messsages');
return null;
}
}
} else {
if (object.parent[property] instanceof constructor) {
return object.parent[property];
} else {
if (typeof object.parent.getParent === 'function') {
return object.parent.getParent(property, index, constructor);
} else {
console.warn('getParent not defined on API object : ' + object.parent + ' - you should avoid having these messsages');
return null;
}
}
}
} else {
if (index) {
return object.parent[property][index];
} else {
return object.parent[property];
}
}
} else {
/**
* This parent does not have the property - go a level higher
*/
if (typeof object.parent.getParent === 'function') {
return object.parent.getParent(property, index, constructor);
} else {
console.warn('getParent not defined on API object : ' + object.parent + ' - you should avoid having these messsages');
return null;
}
}
} else {
/**
* No parent defined
*/
console.warn('property : ' + property + ' of type ' + constructor + ' was not found in the parent chain');
return null;
}
}
}, {
key: "StripImageExtension",
value:
/**
* Strips image extension from given path
* @param imagePath
* @constructor
*/
function StripImageExtension(imagePath) {
return imagePath.replace(/(\.png$|\.gif$|\.jpeg$|\.jpg$)/, '');
}
}, {
key: "Unloaded",
value:
/**
* Returns true if unloaded
* @param component
* @returns {boolean}
* @constructor
*/
function Unloaded(component) {
if (Utils.UndefinedOrNull(component) || Utils.UndefinedOrNull(component.instance)) {
return true;
}
return false;
}
}, {
key: "Loaded",
value:
/**
*
* @param component
* @returns {boolean}
* @constructor
*/
function Loaded(component) {
if (component && component.instance) {
return true;
}
return false;
}
}, {
key: "BuildVectorSource",
value: function BuildVectorSource(result, name, dimension) {
if (dimension === 2) {
result[name] = {};
result[name].x = false;
result[name].y = false;
return;
}
if (dimension === 3) {
result[name] = {};
result[name].x = false;
result[name].y = false;
result[name].y = false;
return;
}
if (dimension === 4) {
result[name] = {};
result[name].x = false;
result[name].y = false;
result[name].z = false;
result[name].w = false;
return;
}
console.warn('unknown dimension : ' + dimension);
}
}, {
key: "GetArrayInstances",
value:
/**
* Returns all 'instances' of the array, or null if an 'instance' is undefined
* @constructor
* @param array
*/
function GetArrayInstances(array) {
return array.reduce(function (result, object) {
if (result === null) {
return result;
}
if (Utils.UndefinedOrNull(object.instance)) {
result = null;
} else {
result.push(object.instance);
}
return result;
}, []);
}
}, {
key: "SortFacesByMaterialIndex",
value: function SortFacesByMaterialIndex(faces) {
/**
* Sorts faces according to material index because later we will create
* groups for each vertice group
*/
faces.sort(function (a, b) {
if (a.materialIndex < b.materialIndex) {
return -1;
}
if (a.materialIndex > b.materialIndex) {
return 1;
}
return 0;
});
return faces;
}
}, {
key: "BuildQuaternionSource",
value: function BuildQuaternionSource(result, name) {
result[name] = {};
result[name].axis = {};
result[name].axis.x = false;
result[name].axis.y = false;
result[name].axis.z = false;
result[name].angle = false;
result[name].x = false;
result[name].y = false;
result[name].z = false;
result[name].w = false;
}
}, {
key: "ObjectPropertiesAsBoolean",
value: function ObjectPropertiesAsBoolean(object) {
return Object.keys(object).reduce(function (result, propertyId) {
if (typeof object[propertyId] === 'function') {
return result;
}
result[propertyId] = false; // if (object[propertyId] instanceof R3.Vector2) {
// Utils.BuildVectorSource(result, propertyId, 2);
// }
//
// if (object[propertyId] instanceof R3.Vector3) {
// Utils.BuildVectorSource(result, propertyId, 3);
// }
//
// if (object[propertyId] instanceof R3.Vector4) {
// Utils.BuildVectorSource(result, propertyId, 4);
// }
//
// if (object[propertyId] instanceof R3.Quaternion) {
// Utils.BuildQuaternionSource(result, propertyId);
// }
return result;
}.bind(this), {});
}
}, {
key: "GetRuntime",
value: function GetRuntime() {
var result = null;
R3.Event.Emit(R3.Event.GET_RUNTIME, null, function (runtime) {
result = runtime;
});
return result;
}
}, {
key: "GetWindowSize",
value:
/**
* Returns the window size or null
* @returns {*}
* @constructor
*/
function GetWindowSize() {
var size = null;
R3.Event.Emit(R3.Event.GET_WINDOW_SIZE, null, function (data) {
size = data;
}.bind(this));
return size;
}
}, {
key: "UpdateWindowSize",
value:
/**
* Convenience function to update object width and height members with window size
* @param object
* @constructor
*/
function UpdateWindowSize(object) {
var size = Utils.GetWindowSize();
object.width = size.width;
object.height = size.height;
}
}, {
key: "ObjectIdWithNameInArray",
value:
/**
* Returns id of object with the name if it exists in the array, otherwise null
* @param name
* @param array
* @returns {*}
* @constructor
*/
function ObjectIdWithNameInArray(name, array) {
return array.reduce(function (result, object) {
if (result) {
return result;
}
if (name === object.name) {
return object.id;
}
return null;
}, null);
}
}, {
key: "LoadIdsFromArrayToIdObject",
value: function LoadIdsFromArrayToIdObject(array, idToObject) {}
}, {
key: "LoadIdsFromObjectToIdObject",
value: function LoadIdsFromObjectToIdObject(object, idToObject) {}
}, {
key: "GetRandomInt",
value:
/**
* Gets random int exclusive of maximum but inclusive of minimum
* @param min
* @param max
* @returns {*}
* @constructor
*/
function GetRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
}
}, {
key: "GetRandomIntInclusive",
value:
/**
* Gets random int inclusive of minimum and maximum
* @param min
* @param max
* @returns {*}
* @constructor
*/
function GetRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //The maximum is inclusive and the minimum is inclusive
}
}, {
key: "InterpolateArray",
value: function InterpolateArray(data, fitCount) {
var linearInterpolate = function linearInterpolate(before, after, atPoint) {
return before + (after - before) * atPoint;
};
var newData = [];
var springFactor = Number((data.length - 1) / (fitCount - 1));
newData[0] = data[0]; // for new allocation
for (var _i2 = 1; _i2 < fitCount - 1; _i2++) {
var tmp = _i2 * springFactor;
var before = Number(Math.floor(tmp)).toFixed();
var after = Number(Math.ceil(tmp)).toFixed();
var atPoint = tmp - before;
newData[_i2] = linearInterpolate(data[before], data[after], atPoint);
}
newData[fitCount - 1] = data[data.length - 1]; // for new allocation
return newData;
}
}, {
key: "UndefinedOrNull",
value:
/**
* Undefined or null check
* @param variable
* @returns {boolean}
* @constructor
*/
function UndefinedOrNull(variable) {
return typeof variable === 'undefined' || variable === null;
}
}, {
key: "Defined",
value:
/**
* The variable is not undefined and not null
* @param variable
* @returns {boolean}
* @constructor
*/
function Defined(variable) {
return typeof variable !== 'undefined' && variable !== null;
}
}, {
key: "GetParameters",
value:
/**
* Gets function parameters
* @param fn
* @constructor
*/
function GetParameters(fn) {
var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(_?)(.+?)\1\s*$/;
var STRIP_COMMENTS = /(\/\/.*$)|(\/\*[\s\S]*?\*\/)|(\s*=[^,\)]*(('(?:\\'|[^'\r\n])*')|("(?:\\"|[^"\r\n])*"))|(\s*=[^,\)]*))/mg;
var parameters, fnText, argDecl;
if (typeof fn !== 'function') {
parameters = [];
fnText = fn.toString().replace(STRIP_COMMENTS, '');
argDecl = fnText.match(FN_ARGS);
argDecl[1].split(FN_ARG_SPLIT).forEach(function (arg) {
arg.replace(FN_ARG, function (all, underscore, name) {
parameters.push(name);
});
});
} else {
throw Error("not a function");
}
return parameters;
}
}, {
key: "IdOrNull",
value:
/**
* Returns either an ID of the object or Null
* @param object
* @returns {null}
* @constructor
*/
function IdOrNull(object) {
if (Utils.UndefinedOrNull(object)) {
return null;
} else {
if (Utils.UndefinedOrNull(object.id)) {
console.warn('saving an object reference with no ID : ', object);
return null;
}
return object.id;
}
}
}, {
key: "LimitToPI",
value:
/**
* Limit a property to values between -pi and +pi
* @param property
* @param objectProperty
* @returns {{configurable?: boolean, enumerable?: boolean, value?, writable?: boolean, get?: Function, set?: Function}}
* @constructor
*/
function LimitToPI(property, objectProperty) {
var store = objectProperty;
return {
get: function get() {
return store;
},
set: function set(value) {
while (value > Math.PI) {
value -= Math.PI * 2;
}
while (value < -Math.PI) {
value += Math.PI * 2;
}
store = value;
}
};
}
}, {
key: "IdArrayOrEmptyArray",
value:
/**
* Returns an array of IDs representing the objects
* @param array
* @returns []
* @constructor
*/
function IdArrayOrEmptyArray(array) {
if (Utils.UndefinedOrNull(array)) {
return [];
} else {
return array.map(function (item) {
if (Utils.UndefinedOrNull(item.id)) {
throw new Error('No ID found while trying to store IDs to array');
}
return item.id;
});
}
}
}, {
key: "Link",
value:
/**
* Links an object to its parent through idToObject array
* @param propertyString
* @param idToObject
* @param parentObject
* @param id
* @constructor
*/
function Link(propertyString, idToObject, parentObject, id) {
if (!Utils.UndefinedOrNull(parentObject[propertyString])) {
if (!idToObject.hasOwnProperty(id)) {
console.warn('Linking failed for object:' + parentObject.name);
}
parentObject[propertyString] = idToObject[id];
}
}
}, {
key: "RandomId",
value:
/**
* Generates a random ID
* @returns {string}
* @constructor
*/
function RandomId(length) {
if (Utils.UndefinedOrNull(length)) {
length = 10;
}
return Math.random().toString(36).substr(2, length);
}
}, {
key: "InvertWindingOrder",
value: function InvertWindingOrder(triangles) {
for (var _i3 = 0; _i3 < triangles.length; _i3++) {
var v1 = triangles[_i3].v1;
triangles[_i3].v1 = triangles[_i3].v2;
triangles[_i3].v2 = v1;
var backupUV = triangles[_i3].triangle.v1uv;
triangles[_i3].triangle.v1uv = triangles[_i3].triangle.v2uv;
triangles[_i3].triangle.v2uv = backupUV;
}
return triangles;
}
}, {
key: "InvertMeshWindingOrder",
value:
/**
* Inverts a mesh winding order (and its instance)
* @param mesh R3.D3.Mesh
* @returns {*}
* @constructor
*/
function InvertMeshWindingOrder(mesh) {
mesh.faces.forEach(function (face) {
var tmpV1 = face.v1;
face.v1 = face.v2;
face.v2 = tmpV1;
var tmpV1uv = face.v1uv;
face.v1uv = face.v2uv;
face.v2uv = tmpV1uv;
}.bind(this)); //mesh.computeNormals = true;
//mesh.createInstance();
}
}, {
key: "ResetWindingOrder",
value:
/**
* This function resets a the winding order of a mesh from a reference point V (the average center of the mesh)
*/
function ResetWindingOrder(faces, vertices) {
var vertexList = new R3.API.Vector3.Points();
for (var v = 0; v < vertices.length; v++) {
vertexList.add(new R3.API.Vector3(vertices[v].position.x, vertices[v].position.y, vertices[v].position.z));
}
var V = vertexList.average();
var triangles = [];
for (var s = 0; s < faces.length; s += 3) {
var v0 = faces[s];
var v1 = faces[s + 1];
var v2 = faces[s + 2];
triangles.push({
v0: v0,
v1: v1,
v2: v2,
edges: [{
v0: v0,
v1: v1
}, {
v0: v1,
v1: v2
}, {
v0: v2,
v1: v0
}],
winding: 0,
edgeIndex: -1,
processed: false
});
}
for (var _i4 = 0; _i4 < triangles.length; _i4++) {
if (R3.API.Vector3.clockwise(vertices[triangles[_i4].v0].position, vertices[triangles[_i4].v1].position, vertices[triangles[_i4].v2].position, V)) {
console.log('clockwise');
var bv1 = triangles[_i4].v1;
triangles[_i4].v1 = triangles[_i4].v2;
triangles[_i4].v2 = bv1;
} else {
console.log('not clockwise');
}
}
return triangles;
}
}, {
key: "FixWindingOrder",
value:
/**
* This function resets the winding order for triangles in faces, given an initial triangle and orientation edge
* used pseudocode from
* http://stackoverflow.com/questions/17036970/how-to-correct-winding-of-triangles-to-counter-clockwise-direction-of-a-3d-mesh
* We need to use a graph traversal algorithm,
* lets assume we have method that returns neighbor of triangle on given edge
*
* neighbor_on_egde( next_tria, edge )
*
* to_process = set of pairs triangle and orientation edge, initial state is one good oriented triangle with any edge on it
* processed = set of processed triangles; initial empty
*
* while to_process is not empty:
* next_tria, orientation_edge = to_process.pop()
* add next_tria in processed
* if next_tria is not opposite oriented than orientation_edge:
* change next_tria (ABC) orientation (B<->C)
* for each edge (AB) in next_tria:
* neighbor_tria = neighbor_on_egde( next_tria, edge )
* if neighbor_tria exists and neighbor_tria not in processed:
* to_process add (neighbor_tria, edge opposite oriented (BA))
* @param faces R3.D3.Face[]
* @param orientationEdge R3.API.Vector2
* @returns {Array}
*/
function FixWindingOrder(faces, orientationEdge) {
/**
* Checks if a Face belonging to a TriangleEdge has already been processed
* @param processed TriangleEdge[]
* @param triangle Face
* @returns {boolean}
*/
function inProcessed(processed, triangle) {
for (var _i5 = 0; _i5 < processed.length; _i5++) {
if (processed[_i5].triangle.equals(triangle)) {
return true;
}
}
return false;
}
/**
* Returns a neighbouring triangle on a specific edge - preserving the edge orientation
* @param edge R3.API.Vector2
* @param faces R3.D3.Face[]
* @param currentTriangle
* @returns {*}
*/
function neighbourOnEdge(edge, faces, currentTriangle) {
for (var _i6 = 0; _i6 < faces.length; _i6++) {
if (faces[_i6].v0 === edge.x && faces[_i6].v1 === edge.y || faces[_i6].v1 === edge.x && faces[_i6].v2 === edge.y || faces[_i6].v2 === edge.x && faces[_i6].v0 === edge.y || faces[_i6].v0 === edge.y && faces[_i6].v1 === edge.x || faces[_i6].v1 === edge.y && faces[_i6].v2 === edge.x || faces[_i6].v2 === edge.y && faces[_i6].v0 === edge.x) {
var triangle = new R3.D3.API.Face(null, null, faces[_i6].v0index, faces[_i6].v1index, faces[_i6].v2index, faces[_i6].materialIndex, faces[_i6].uvs);
if (triangle.equals(currentTriangle)) {
continue;
}
return new R3.D3.TriangleEdge(triangle, edge);
}
}
return null;
}
var toProcess = [new R3.D3.TriangleEdge(new R3.D3.API.Face(null, null, faces[0].v0index, faces[0].v1index, faces[0].v2index, faces[0].materialIndex, faces[0].uvs), orientationEdge)];
var processed = [];
while (toProcess.length > 0) {
var triangleEdge = toProcess.pop();
/**
* If edge is the same orientation (i.e. the edge order is the same as the given triangle edge) it needs to be reversed
* to have the same winding order)
*/
if (triangleEdge.triangle.v0index === triangleEdge.edge.x && triangleEdge.triangle.v1index === triangleEdge.edge.y || triangleEdge.triangle.v1index === triangleEdge.edge.x && triangleEdge.triangle.v2index === triangleEdge.edge.y || triangleEdge.triangle.v2index === triangleEdge.edge.x && triangleEdge.triangle.v0index === triangleEdge.edge.y) {
var backupV = triangleEdge.triangle.v1index;
triangleEdge.triangle.v1index = triangleEdge.triangle.v2index;
triangleEdge.triangle.v2index = backupV; // let backupUV = triangleEdge.triangle.v1uv;
// triangleEdge.triangle.v1uv = triangleEdge.triangle.v2uv;
// triangleEdge.triangle.v2uv = backupUV;
//
var backupUV = triangleEdge.triangle.uvs[0][1];
triangleEdge.triangle.uvs[0][1] = triangleEdge.triangle.uvs[0][2];
triangleEdge.triangle.uvs[0][2] = backupUV;
}
processed.push(triangleEdge);
var edges = [new R3.API.Vector2(triangleEdge.triangle.v0index, triangleEdge.triangle.v1index), new R3.API.Vector2(triangleEdge.triangle.v1index, triangleEdge.triangle.v2index), new R3.API.Vector2(triangleEdge.triangle.v2index, triangleEdge.triangle.v0index)];
for (var j = 0; j < edges.length; j++) {
var neighbour = neighbourOnEdge(edges[j], faces, triangleEdge.triangle);
if (neighbour && !inProcessed(processed, neighbour.triangle)) {
toProcess.push(neighbour);
}
}
}
/**
* In processed - we will have some duplicates - only add the unique ones
* @type {Array}
*/
var triangles = [];
for (var _i7 = 0; _i7 < processed.length; _i7++) {
var found = false;
for (var k = 0; k < triangles.length; k++) {
if (triangles[k].equals(processed[_i7].triangle)) {
found = true;
break;
}
}
if (!found) {
triangles.push(processed[_i7].triangle);
}
}
return triangles;
}
}, {
key: "FixPolyZPlane",
value:
/**
* This is a work-around function to fix polys which don't triangulate because
* they could lie on Z-plane (XZ or YZ)) - we translate the poly to the origin, systematically rotate the poly around
* Z then Y axis
* @param verticesFlat []
* @param grain is the amount to systematically rotate the poly by - a finer grain means a more accurate maximum XY
* @return []
*/
function FixPolyZPlane(verticesFlat, grain) {
if (verticesFlat.length % 3 !== 0 && !(verticesFlat.length > 9)) {
console.log("The vertices are not in the right length : " + verticesFlat.length);
}
var vertices = [];
var points = new R3.API.Quaternion.Points();
for (var _i8 = 0; _i8 < verticesFlat.length; _i8 += 3) {
points.add(new R3.API.Vector3(verticesFlat[_i8], verticesFlat[_i8 + 1], verticesFlat[_i8 + 2]));
}
points.toOrigin();
points.maximizeXDistance(grain);
points.maximizeYDistance(grain);
for (i = 0; i < points.vectors.length; i++) {
vertices.push([points.vectors[i].x, points.vectors[i].y]);
}
return vertices;
}
}, {
key: "MovingAverage",
value: function MovingAverage(period) {
var nums = [];
return function (num) {
nums.push(num);
if (nums.length > period) nums.splice(0, 1); // remove the first element of the array
var sum = 0;
for (var _i9 in nums) {
sum += nums[_i9];
}
var n = period;
if (nums.length < period) n = nums.length;
return sum / n;
};
}
}, {
key: "Intersect",
value: function Intersect(a, b) {
var t;
/**
* Loop over shortest array
*/
if (b.length > a.length) {
t = b;
b = a;
a = t;
}
return a.filter(
/**
* Check if exists
* @param e
* @returns {boolean}
*/
function (e) {
return b.indexOf(e) > -1;
}).filter(
/**
* Remove Duplicates
* @param e
* @param i
* @param c
* @returns {boolean}
*/
function (e, i, c) {
return c.indexOf(e) === i;
});
}
}, {
key: "Difference",
value: function Difference(a, b) {
var t;
/**
* Loop over shortest array
*/
if (b.length > a.length) {
t = b;
b = a;
a = t;
}
return a.filter(
/**
* Check if exists
* @param e
* @returns {boolean}
*/
function (e) {
return b.indexOf(e) === -1;
}).filter(
/**
* Remove Duplicates
* @param e
* @param i
* @param c
* @returns {boolean}
*/
function (e, i, c) {
return c.indexOf(e) === i;
});
}
}, {
key: "PushUnique",
value:
/**
* Push only if not in there already
* @param array
* @param object
* @constructor
*/
function PushUnique(array, object) {
if (array.indexOf(object) === -1) {
array.push(object);
}
}
}, {
key: "IsEmpty",
value:
/**
* Checks whether or not the object is empty
* @param obj
* @returns {boolean}
* @constructor
*/
function IsEmpty(obj) {
return Object.keys(obj).length === 0 && obj.constructor === Object;
}
}, {
key: "IsString",
value: function IsString(member) {
return typeof member === 'string';
}
}, {
key: "IsBoolean",
value: function IsBoolean(member) {
return member === true || member === false;
}
}, {
key: "IsColor",
value: function IsColor(member) {
return member instanceof R3.Color;
}
}, {
key: "IsNumber",
value: function IsNumber(member) {
return typeof member === 'number';
}
}, {
key: "IsVector2",
value: function IsVector2(member) {
return member instanceof R3.API.Vector2 || member instanceof R3.Vector2;
}
}, {
key: "IsVector3",
value: function IsVector3(member) {
return member instanceof R3.API.Vector3 || member instanceof R3.Vector3;
}
}, {
key: "IsVector4",
value: function IsVector4(member) {
return member instanceof R3.API.Vector4 || member instanceof R3.Vector4 || member instanceof R3.API.Quaternion || member instanceof R3.Quaternion;
}
}, {
key: "IsObject",
value: function IsObject(member) {
var type = _typeof(member);
return type === 'function' || type === 'object' && !!member;
}
}, {
key: "LowerUnderscore",
value:
/**
* @return {string}
*/
function LowerUnderscore(name) {
var string = name.toLowerCase().replace(/\s+/g, '_');
string = string.replace(/-/g, '_');
string = string.replace(/\_+/g, '_');
return string;
}
}, {
key: "UpperCaseWordsSpaces",
value: function UpperCaseWordsSpaces(input) {
var word = input.replace(/[-_]/g, ' ');
word = word.replace(/\s+/, ' ');
var words = word.split(' ');
return words.reduce(function (result, word) {
result += word[0].toUpperCase() + word.substr(1);
return result + ' ';
}, '').trim();
}
}, {
key: "UpperCaseUnderscore",
value:
/**
* @return {string}
*/
function UpperCaseUnderscore(word) {
var str = '';
word.split('').map(function (letter) {
if (letter == letter.toUpperCase()) {
str += '_' + letter;
} else {
str += letter.toUpperCase();
}
});
str = str.replace(new RegExp('^_'), '');
return str;
}
}, {
key: "PaddedText",
value:
/**
* Returns Left Padded Text - ex. length 5, padchar 0, string abc = '00abc'
* @param length
* @param padChar
* @param string
* @returns {string}
* @constructor
*/
function PaddedText(length, padChar, string) {
var pad = "";
for (var x = 0; x < length; x++) {
pad += padChar;
}
return pad.substring(0, pad.length - string.length) + string;
}
}]);
return Utils;
}();
2020-02-27 17:07:46 +01:00
2021-06-18 13:54:08 +02:00
module.exports = Utils;
2020-02-27 17:07:46 +01:00
/***/ }),
/***/ "./src/r3/r3.js":
/*!**********************!*\
!*** ./src/r3/r3.js ***!
\**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
var _require = __webpack_require__(/*! ./r3-system */ "./src/r3/r3-system/index.js"),
System = _require.System,
SystemLinking = _require.SystemLinking,
SystemSocket = _require.SystemSocket;
2021-06-18 13:54:08 +02:00
var R3Object = __webpack_require__(/*! ./r3-r3-object */ "./src/r3/r3-r3-object.js");
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
var R3 = /*#__PURE__*/function () {
function R3() {
_classCallCheck(this, R3);
}
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
_createClass(R3, null, [{
key: "version",
value: function version() {
2021-06-20 08:13:06 +02:00
return 'Sun Jun 20 2021 06:12:04 GMT+0000 (Coordinated Universal Time)';
2021-06-18 02:10:32 +02:00
}
}]);
2020-02-27 17:07:46 +01:00
2021-06-18 02:10:32 +02:00
return R3;
}();
2020-02-27 17:07:46 +01:00
2021-06-18 13:54:08 +02:00
R3.R3Object = R3Object;
2021-06-18 02:10:32 +02:00
R3.System = System;
R3.System.Linking = SystemLinking;
R3.System.Socket = SystemSocket;
module.exports = R3;
2020-02-27 17:07:46 +01:00
/***/ })
/******/ });
2021-06-19 11:27:32 +02:00
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInd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