Skip to content

Commit

Permalink
Merge pull request #1 from TrevorDev/textureTransformBugTrevor
Browse files Browse the repository at this point in the history
playground async working
  • Loading branch information
kcoley committed Sep 7, 2018
2 parents 1e1d570 + c4f4624 commit b16ce27
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 11 deletions.
25 changes: 17 additions & 8 deletions Playground/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ function showError(errorMessage, errorEvent) {
document.getElementById("errorZone").innerHTML = "";
document.getElementById("statusBar").innerHTML = "Loading assets...Please wait";
var checkCamera = true;
var checkSceneCount = true;
var wrappedEval = false;
var createEngineFunction = "createDefaultEngine";
var createSceneFunction;
Expand Down Expand Up @@ -595,7 +596,11 @@ function showError(errorMessage, errorEvent) {

//create scene
eval("scene = " + createSceneFunction + "()");

// if scene returns a promise avoid checks
if(scene.then){
checkCamera = false
checkSceneCount = false
}
if (!scene) {
showError(createSceneFunction + " function must return a scene.", null);
return;
Expand Down Expand Up @@ -631,20 +636,24 @@ function showError(errorMessage, errorEvent) {
fpsLabel.innerHTML = engine.getFps().toFixed() + " fps";
});

if (engine.scenes.length === 0) {
if (checkSceneCount && engine.scenes.length === 0) {
showError("You must at least create a scene.", null);
return;
}

if (checkCamera && engine.scenes[0].activeCamera == null) {
showError("You must at least create a camera.", null);
return;
}

engine.scenes[0].executeWhenReady(function () {
document.getElementById("statusBar").innerHTML = "";
});

}else if(scene.then){
scene.then(function (){
document.getElementById("statusBar").innerHTML = "";
});
}else{
engine.scenes[0].executeWhenReady(function () {
document.getElementById("statusBar").innerHTML = "";
});
}

if (scene) {
if (showInspector) {
scene.debugLayer.show({ initialTab: initialTabIndex });
Expand Down
11 changes: 9 additions & 2 deletions serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,15 @@ module BABYLON.GLTF2.Exporter.Extensions {
proceduralTexture.setTexture("textureSampler", babylonTexture);
proceduralTexture.setMatrix("textureTransformMat", babylonTexture.getTextureMatrix());

proceduralTexture.onGenerated = () => {
resolve(proceduralTexture);
// isReady trigger creation of effect if it doesnt exist yet
if(proceduralTexture.isReady()){
proceduralTexture.render();
resolve(proceduralTexture)
}else{
(proceduralTexture as any)._effect.onCompileObservable.add(() => {
proceduralTexture.render();
resolve(proceduralTexture);
});
}
});
}
Expand Down
15 changes: 14 additions & 1 deletion tests/validation/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,20 @@ function runTest(index, done) {
code = code.replace(/\/scenes\//g, pgRoot + "/scenes/");
code = code.replace(/"scenes\//g, "\"" + pgRoot + "/scenes/");
currentScene = eval(code + "\r\ncreateScene(engine)");
processCurrentScene(test, resultCanvas, result, renderImage, index, waitRing, done);

if(currentScene.then){
// Handle if createScene returns a promise
currentScene.then(function(scene){
currentScene = scene;
processCurrentScene(test, resultCanvas, result, renderImage, index, waitRing, done);
}).catch(function(e){
console.error(e);
onError();
})
}else{
// Handle if createScene returns a scene
processCurrentScene(test, resultCanvas, result, renderImage, index, waitRing, done);
}
}
catch (e) {
console.error(e);
Expand Down

0 comments on commit b16ce27

Please sign in to comment.