(data, responseURL)
| 112 | console.log("Failed to retrieve " + url + ".", exception); |
| 113 | }; |
| 114 | var onload = function(data, responseURL) { |
| 115 | if (typeof (data) === "string") { |
| 116 | throw new Error("Decode Image from string data not yet implemented."); |
| 117 | } |
| 118 | |
| 119 | var referenceImage = TestUtils.decodeImage(data); |
| 120 | |
| 121 | if (test.sceneFolder) { |
| 122 | BABYLON.SceneLoader.Load(config.root + test.sceneFolder, test.sceneFilename, engine, function(newScene) { |
| 123 | currentScene = newScene; |
| 124 | processCurrentScene(test, resultCanvas, result, referenceImage, index, waitRing, done); |
| 125 | }, |
| 126 | null, |
| 127 | function(loadedScene, msg) { |
| 128 | console.error(msg); |
| 129 | done(false); |
| 130 | }); |
| 131 | } |
| 132 | else if (test.playgroundId) { |
| 133 | if (test.playgroundId[0] !== "#" || test.playgroundId.indexOf("#", 1) === -1) { |
| 134 | console.error("Invalid playground id"); |
| 135 | done(false); |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | var snippetUrl = "https://snippet.babylonjs.com"; |
| 140 | var pgRoot = "/Playground" |
| 141 | |
| 142 | var retryTime = 500; |
| 143 | var maxRetry = 5; |
| 144 | var retry = 0; |
| 145 | |
| 146 | var onError = function() { |
| 147 | retry++; |
| 148 | if (retry < maxRetry) { |
| 149 | setTimeout(function() { |
| 150 | loadPG(); |
| 151 | }, retryTime); |
| 152 | } |
| 153 | else { |
| 154 | // Skip the test as we can not fetch the source. |
| 155 | done(true); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | var loadPG = function() { |
| 160 | var xmlHttp = new XMLHttpRequest(); |
| 161 | xmlHttp.addEventListener("readystatechange", function() { |
| 162 | if (xmlHttp.readyState === 4) { |
| 163 | try { |
| 164 | xmlHttp.onreadystatechange = null; |
| 165 | var snippet = JSON.parse(xmlHttp.responseText); |
| 166 | var code = JSON.parse(snippet.jsonPayload).code.toString(); |
| 167 | code = code.replace(/\/textures\//g, pgRoot + "/textures/"); |
| 168 | code = code.replace(/"textures\//g, "\"" + pgRoot + "/textures/"); |
| 169 | code = code.replace(/\/scenes\//g, pgRoot + "/scenes/"); |
| 170 | code = code.replace(/"scenes\//g, "\"" + pgRoot + "/scenes/"); |
| 171 | if (test.replace) { |
no test coverage detected