Jump to content

Sometimes error with skybox on iOS


ozRocker
 Share

Recommended Posts

I sometimes get a javascript error on my site http://www.punkoffice.com/webiverse while the skybox is loading at the first page.  It only happens on my iPhone, but like 1 out of 7 times.  When the error happens the skybox fails to load and the sky is just black.

I'm loading my scene.  When it loads I'll add a light, camera, ground then skybox, one after the other.  Everything else comes out fine.  At this stage there's no asynchronous calls going on so this shouldn't be caused by a race condition in my code.

The error I get is:

TypeError: undefined is not an object (evaluating 't[c].width')
(anonymous function) babylon.2.4.js:3:29698
a babylon.2.4.js:2:26402
onload babylon.2.4.js:2:6865

My skybox code is:

    private static setupSkyBox() {
        var skybox = BABYLON.Mesh.CreateBox("skyBox", 700.0, this.scene);
        var skyboxMaterial = new BABYLON.StandardMaterial("skyBox", this.scene);
        skyboxMaterial.backFaceCulling = false;
        skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture("images/skybox/plainsky", this.scene);
        skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
        skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
        skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
        skybox.material = skyboxMaterial;
        Tools.debug(1,"Skybox");
    }

 

Link to comment
Share on other sites

19 hours ago, Deltakosh said:

do you mind doing the same test with babylon.max.js?

ok, here is the error in reference to the babylon.max.js file:

TypeError: undefined is not an object (evaluating 'imgs[index].width')  babylon.2.4.max.js:7063:88
(anonymous function) babylon.2.4.max.js:7062:87
onload babylon.2.4.max.js:5536
onload babylon.2.4.max.js:4491

possibly a race condition in there which only gets triggered on mobile devices?  cos it looks like the imgs haven't loaded yet.

Link to comment
Share on other sites

Its in Engine.prototype.createCubeTexture

this code here:

for (var index = 0; index < faces.length; index++) {
   _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
   gl.texImage2D(faces[index], 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, _this._workingCanvas);
}

The error happens when it first tries to access imgs[index].width because imgs is undefined at that time.  Note that this problem doesn't happen all the time.  Maybe 1 out of 10 times on mobile devices.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...