diff --git a/VERSION b/VERSION index c2b4f17e1ab..b850a2eef84 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.191.0-dev +0.192.0-dev diff --git a/build/build.js b/build/build.js index a5df979e7e3..1fd631ae415 100644 --- a/build/build.js +++ b/build/build.js @@ -124,7 +124,7 @@ var getVersion = function (callback) { var loadDependencies = function (fullpath, callback) { fs.readFile(fullpath, function (err, data) { if (err) callback(err); - callback(data.toString().trim().split(os.EOL)) + callback(data.toString().trim().split(new RegExp("[\\r\\n]+", 'g'))); }); }; @@ -144,7 +144,7 @@ var concatentateShaders = function (callback) { if (ext) { var fullpath = dir + file; - var content = replaceAll(fs.readFileSync(fullpath).toString(), os.EOL, "\\n"); + var content = replaceAll(fs.readFileSync(fullpath).toString(), "[\\r\\n]+", "\\n"); var name = file.split(".")[0] + ext; var data = util.format('pc.shaderChunks.%s = "%s";\n', name, content); fs.writeSync(fd, data); diff --git a/examples/portal/index.html b/examples/portal/index.html new file mode 100644 index 00000000000..81698885b20 --- /dev/null +++ b/examples/portal/index.html @@ -0,0 +1,203 @@ + + + + + + + + + + + + + + + diff --git a/src/asset/asset-registry.js b/src/asset/asset-registry.js index c7a7f9223ab..7dc7da469cb 100644 --- a/src/asset/asset-registry.js +++ b/src/asset/asset-registry.js @@ -306,7 +306,7 @@ pc.extend(pc, function () { var url = asset.file.url; // apply prefix if present - if (self.prefix) { + if (self.prefix && !self._isAbsoluteUrl(url)) { if (url.startsWith('/')) { url = url.slice(1); } @@ -689,6 +689,22 @@ pc.extend(pc, function () { getAssetById: function (id) { console.warn("DEPRECATED: getAssetById() use get() instead"); return this.get(id); + }, + + // check if url is absolute (e.g. begins with 'http://', 'https://', 'ftp://', '//') + _isAbsoluteUrl: function (url) { + var pattern = new RegExp( + '^' + // beginning of the url + '\\s*' + // ignore leading spaces (some browsers trim the url automatically, but we can't assume that) + '(?:' + // beginning of protocol scheme (non-captured regex group) + '[a-z]+[a-z0-9\\-\\+\\.]*' + // protocol scheme must (RFC 3986) consist of "a letter and followed by any combination of letters, digits, plus ("+"), period ("."), or hyphen ("-")." + ':' + // protocol scheme must end with colon character + ')?' + // end of optional scheme group, the group is optional since the string may be a protocol-relative absolute URL + '//', // a absolute url must always begin with two forward slash characters (ignoring any leading spaces and protocol scheme) + 'i' // non case-sensitive flag + ); + + return pattern.test(url); } }; diff --git a/src/graphics/device.js b/src/graphics/device.js index 2c6a0e43afc..a11534fd160 100644 --- a/src/graphics/device.js +++ b/src/graphics/device.js @@ -29,6 +29,8 @@ pc.extend(pc, function () { var _createContext = function (canvas, options) { var names = ["webgl", "experimental-webgl"]; var context = null; + options = options || {}; + options.stencil = true; for (var i = 0; i < names.length; i++) { try { context = canvas.getContext(names[i], options); @@ -219,7 +221,6 @@ pc.extend(pc, function () { // Retrieve the WebGL context if (canvas) { - options.stencil = true; this.gl = _createContext(canvas, options); } @@ -1744,8 +1745,7 @@ pc.extend(pc, function () { /** * @function * @name pc.GraphicsDevice#setStencilOperation - * @description Configures how stencil buffer values should be modified based on the result of depth/stencil tests. - * @description Works for both front and back faces. + * @description Configures how stencil buffer values should be modified based on the result of depth/stencil tests. Works for both front and back faces. * @param {Number} fail Action to take if stencil test is failed * @param {Number} zfail Action to take if depth test is failed * @param {Number} zpass Action to take if both depth and stencil test are passed