[SOLVED] Problems possibly caused by update

Good afternoon guys.

Has there been a recent update to the Playcanvas engine? From yesterday to today two features of my system simply started to give problem without changing anything. I even have an old build with the same code to run those features that keeps running.

Basically I have a 3D tour system with skyboxes and since today, their texture only loads after I load it 2 times.

The other problem is in the layers. I have a piece of code that manually sets the layer of certain objects and now has time that works and time that does not

Hey! Is your project private? Would you mind linking it?

Yes, there was a deployment of engine v1.8.0 yesterday. Please post a link that illustrates the problem.

Yes, it is private and from my company, so i can’t share

You can access the the application running here:

https://playcanv.as/p/VbQ6HlsS/?teleport=6

There are two problems that have arisen on last update:

  • 1: When you click at on blue circle, the application loads a texture and bind it to a skybox. Now at the first click, the texture doesn’t load and the screen came black.The strange thing is that the second skybox clicked works.


    The code that insert this texture is below:
asset.ready( function(assetLoaded){
       console.log(skyboxNew, assetLoaded.resource);
       skyboxNew.setParameter('texture_diffuseMap', assetLoaded.resource);
} );
this.app.assets.load(asset);
  • 2: You can open the object menu by

    • Clicking with right mouse button;
    • Clicking on plus sign;
    • Add objects by draging and dropping on 3d view.

    When in FirstPerson view (click on any blue circle to enter), the added objects must be setted to another layer and each one have a script attached that do it, but this code is only working at the 2th to 3th addition.
    The code attached to set layer manually is:

var SetLayer = pc.createScript('setLayer');

// initialize code called once per entity
SetLayer.prototype.initialize = function() {
    var meshInstances = this.entity.model.meshInstances;
    
    for(var i = 0; i < meshInstances.length;i++){
        // enable depth order rendering
        var instance = meshInstances[i];
        var mat = instance.material;
        mat.blendType = pc.BLEND_NORMAL; // render sphere also after all opaque objects
        instance.layer -= 2; // but force it to be rendered always after occluders
    }
};

The video below shows both problems:

https://drive.google.com/file/d/1ntCugzzcJ-3BVTXHZ8DnDpL7yzXtCkQc/view?usp=sharing

https://drive.google.com/file/d/17uCpVUdB2RgWGhwr03sELKCvH3ISxEsl/view?usp=sharing

I can’t see the full context of why you’re doing:

skyboxNew.setParameter('texture_diffuseMap', assetLoaded.resource);

Why aren’t you doing:

skyboxNew.diffuseMap = assetLoaded.resource;
skyboxNew.update();

You shouldn’t call setParameter on a pc.StandardMaterial yourself. This is done internally in response to updating a material’s public properties.

1 Like

Maybe the best thing to do to examine point 2 is add me (username: will) to your project so I can take a closer look.

I was hired four months ago to continue the development of this software and it worked that way. If i change to your code, tthe software start to run correctly again, but causes some glitch that blinks screens with the new texture.

Now you can view/write (if necessary to do some tests) the project
https://playcanvas.com/project/573114/overview/iteleport-webplayer-15

Note!: When launch the application, add “?teleport=6” at the final of URL to select which aparment you will visualize

I have updated skybox-load.js and I believe it works now (I also had to change your other calls to setParameter in the script). Can you let me know if the app is now working correctly.

1 Like

Great!! The app is working fine, but the objects that i can add dynamically still not visible until add 2 of them. Let me explain: When you add an object, it became invisible at the FirstPerson view camera. Only when you add two they became visible beyond the skybox. I’ll try to fix this later, but if you can look at this will be a great help

I tried a lot of things but the problem persists. I don’t know why the player only set the right layer to a new object when I add a second one. Made this, the first and second objects added become visible together. Is there a function that i’m missing to call? Maybe a recalculate layers or draw order?

The addition code is located in editor-3d.js at Editor3d.prototype.addObject

I have reproduced the problem. The next step for me is to determine the exact commit that caused this. I shall do that in the morning.

1 Like

OK, so I have stepped back to engine v1.0.0 (20th April 2018) and the problem still occurs:

https://launch.playcanvas.com/637787?use_local_engine=https://code.playcanvas.com/playcanvas-1.0.0.js&teleport=6

Are you sure this ever worked correctly?

To be honest, this doesn’t look right:

        instance.layer -= 2; // but force it to be rendered always after occluders

The layer property is not public API for pc.MeshInstance:

https://developer.playcanvas.com/en/api/pc.MeshInstance.html

If you want to control the layers that a model is in, set the layers property on a pc.ModelComponent:

https://developer.playcanvas.com/en/api/pc.ModelComponent.html#layers

1 Like

The addition of objects worked before yes, I don’t know why it broked.

As I said, I got the system development in the middle of the way and the layers were already made that way, but your tip already solved the problem! I changed the way I set the layers to the pc.ModelComponent and it worked!!

Thank you very much for your attention and help!

Oh, excellent! I will mark this thread as resolved then. :smile:

1 Like