diff --git a/build/dependencies.txt b/build/dependencies.txt index 318838ebeba..b0c351fb04a 100644 --- a/build/dependencies.txt +++ b/build/dependencies.txt @@ -153,6 +153,8 @@ ../src/resources/resources_script.js ../src/resources/resources_text.js ../src/resources/resources_texture.js +../src/resources/resources_html.js +../src/resources/resources_css.js ../src/resources/resources_scene.js ../src/resources/resources_hierarchy.js ../src/resources/resources_scenesettings.js diff --git a/src/framework/framework_application.js b/src/framework/framework_application.js index 0d54f1bc976..16b9961a5f2 100644 --- a/src/framework/framework_application.js +++ b/src/framework/framework_application.js @@ -82,6 +82,8 @@ pc.extend(pc, function () { this.loader.addHandler("script", new pc.ScriptHandler(this)); this.loader.addHandler("scene", new pc.SceneHandler(this)); this.loader.addHandler("cubemap", new pc.CubemapHandler(this.graphicsDevice, this.assets, this.loader)); + this.loader.addHandler("html", new pc.HtmlHandler()); + this.loader.addHandler("css", new pc.CssHandler()); this.loader.addHandler("hierarchy", new pc.HierarchyHandler(this)); this.loader.addHandler("scenesettings", new pc.SceneSettingsHandler(this)); diff --git a/src/resources/resources_css.js b/src/resources/resources_css.js new file mode 100644 index 00000000000..8aa34403971 --- /dev/null +++ b/src/resources/resources_css.js @@ -0,0 +1,41 @@ +pc.extend(pc, function () { + 'use strict'; + + var CssHandler = function () {}; + + CssHandler.prototype = { + load: function (url, callback) { + pc.net.http.get(url, function (response) { + callback(null, response); + }, { + error: function (status, xhr, e) { + callback(pc.string.format("Error loading css resource: {0} [{1}]", url, status)); + } + }); + }, + + open: function (url, data) { + return data; + }, + + patch: function (asset, assets) { + } + }; + + var createStyle = function (cssString) { + var result = document.createElement('style'); + result.type = 'text/css'; + if (result.styleSheet) { + result.styleSheet.cssText = cssString; + } else { + result.appendChild(document.createTextNode(cssString)); + } + + return result; + }; + + return { + CssHandler: CssHandler, + createStyle: createStyle + }; +}()); diff --git a/src/resources/resources_html.js b/src/resources/resources_html.js new file mode 100644 index 00000000000..6580e4c9c3f --- /dev/null +++ b/src/resources/resources_html.js @@ -0,0 +1,28 @@ +pc.extend(pc, function () { + 'use strict'; + + var HtmlHandler = function () {}; + + HtmlHandler.prototype = { + load: function (url, callback) { + pc.net.http.get(url, function (response) { + callback(null, response); + }, { + error: function (status, xhr, e) { + callback(pc.string.format("Error loading html resource: {0} [{1}]", url, status)); + } + }); + }, + + open: function (url, data) { + return data; + }, + + patch: function (asset, assets) { + } + }; + + return { + HtmlHandler: HtmlHandler + }; +}());