diff --git a/README.md b/README.md old mode 100644 new mode 100755 index def1cd83..d587b70d --- a/README.md +++ b/README.md @@ -71,9 +71,9 @@ Basic Example - + @@ -163,11 +163,11 @@ Completely removing `a-scene` from your page will also handle cleanly disconnect ```html - + diff --git a/dist/networked-aframe.js b/dist/networked-aframe.js index 5ff114fe..661d2cf3 100644 --- a/dist/networked-aframe.js +++ b/dist/networked-aframe.js @@ -178,7 +178,7 @@ eval("\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance insta /***/ (function(module, exports, __webpack_require__) { "use strict"; -eval("\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\n/* global NAF */\nvar Schemas =\n/*#__PURE__*/\nfunction () {\n function Schemas() {\n _classCallCheck(this, Schemas);\n\n this.schemaDict = {};\n this.templateCache = {};\n }\n\n _createClass(Schemas, [{\n key: \"createDefaultSchema\",\n value: function createDefaultSchema(name) {\n return {\n template: name,\n components: ['position', 'rotation']\n };\n }\n }, {\n key: \"add\",\n value: function add(schema) {\n if (this.validateSchema(schema)) {\n this.schemaDict[schema.template] = schema;\n var templateEl = document.querySelector(schema.template);\n\n if (!templateEl) {\n NAF.log.error(\"Template el not found for \".concat(schema.template, \", make sure NAF.schemas.add is called after is defined.\"));\n return;\n }\n\n if (!this.validateTemplate(schema, templateEl)) {\n return;\n }\n\n this.templateCache[schema.template] = document.importNode(templateEl.content, true);\n } else {\n NAF.log.error('Schema not valid: ', schema);\n NAF.log.error('See https://github.com/haydenjameslee/networked-aframe#syncing-custom-components');\n }\n }\n }, {\n key: \"getCachedTemplate\",\n value: function getCachedTemplate(template) {\n if (!this.templateIsCached(template)) {\n if (this.templateExistsInScene(template)) {\n this.add(this.createDefaultSchema(template));\n } else {\n NAF.log.error(\"Template el for \".concat(template, \" is not in the scene, add the template to and register with NAF.schemas.add.\"));\n }\n }\n\n return this.templateCache[template].firstElementChild.cloneNode(true);\n }\n }, {\n key: \"templateIsCached\",\n value: function templateIsCached(template) {\n return !!this.templateCache[template];\n }\n }, {\n key: \"getComponents\",\n value: function getComponents(template) {\n var components = ['position', 'rotation'];\n\n if (this.hasTemplate(template)) {\n components = this.schemaDict[template].components;\n }\n\n return components;\n }\n }, {\n key: \"hasTemplate\",\n value: function hasTemplate(template) {\n return !!this.schemaDict[template];\n }\n }, {\n key: \"templateExistsInScene\",\n value: function templateExistsInScene(templateSelector) {\n var el = document.querySelector(templateSelector);\n return el && this.isTemplateTag(el);\n }\n }, {\n key: \"validateSchema\",\n value: function validateSchema(schema) {\n return !!(schema['template'] && schema['components']);\n }\n }, {\n key: \"validateTemplate\",\n value: function validateTemplate(schema, el) {\n if (!this.isTemplateTag(el)) {\n NAF.log.error(\"Template for \".concat(schema.template, \" is not a