[SOLVED] Outline is not correct when I switch to portrait mode

Hello eveyone,
I got an issue. When I open at browser at landscape mode, the red light can overlap with tube correctly. However, when I open at browser with portrait, the red line will be in wrong position. Could anyone knows how to fix it?

I use the outline code in this project.

I changed the code of line 25 - 49 of apply-outline.js from

this.app.on('Ermis:objectOutline:add', function(entity){

        if( entity && entity.model && entity.model.layers.indexOf(this.outlineLayer.id) === -1 ){
            
            var layers = entity.model.layers.slice();
            layers.push(this.outlineLayer.id);
            
            entity.model.layers = layers;
        }
        
    }, this);
    
    this.app.on('Ermis:objectOutline:remove', function(entity){
        
        var index = entity.model.layers.indexOf(this.outlineLayer.id);
        
        if( entity && entity.model && index > -1 ){
            
            var layers = entity.model.layers.slice();
            layers.splice(index, 1);
            
            entity.model.layers = layers;
        }        
        
    }, this);

Changed to (“model” is replaced by “render”):

this.app.on('Ermis:objectOutline:add', function(entity){

        if( entity && entity.render && entity.render.layers.indexOf(this.outlineLayer.id) === -1 ){
            
            var layers = entity.render.layers.slice();
            layers.push(this.outlineLayer.id);
            
            entity.render.layers = layers;
        }
        
    }, this);
    
    this.app.on('Ermis:objectOutline:remove', function(entity){
        
        
        if( entity && entity.render){
            var index = entity.render.layers.indexOf(this.outlineLayer.id);
            if(index > -1){
                var layers = entity.render.layers.slice();
                layers.splice(index, 1);
            
                entity.render.layers = layers;
            }
            
        }        
        
    }, this);

I trigger the event by:


StateMachine.prototype.addOutline = function(){
    //add outline
    gameObject = this.app.root.findByName(deviceName);
    this.app.fire('Ermis:objectOutline:add', gameObject);
}

StateMachine.prototype.removeOutline = function(){
    //remove outline  
    gameObject = this.app.root.findByName(deviceName);
    this.app.fire('Ermis:objectOutline:remove', gameObject);
}

Hi @HongKong_Simfusion!

I had a similar problem in the past so I’m sharing the post below as it might be helpful here too.

Hi @Albertos,

That’s work for me, thank you.

1 Like