Skip to main content
7-Bedrock
August 4, 2021
Solved

About Shader and Texture

  • August 4, 2021
  • 1 reply
  • 2910 views

Hi,

 

I read this article (here) and try it on my project, but it doesn't work.

Whatever texture changed, it didn't show difference.

 

I uploaded two pictures (sea and forest for test).

william_shih_0-1628062552660.png

 

Then use this script to change texture and shader.

$scope.init = function(){
//$scope.setWidgetProp('model-1', 'texture', 'app/resources/Uploaded/sea.jpg?name=tex0&edge=repeat');
$scope.setWidgetProp('model-1', 'texture', 'app/resources/Uploaded/forest.jpg?name=tex0&edge=repeat');
$scope.setWidgetProp('model-1', 'shader', 'reflect;mixer f 0.5');
};
angular.element(document).ready($scope.init);

In runtime, it look like that.

william_shih_1-1628062761676.png

 

Did I miss something?

Best answer by pandersson

Hello,

I think it must be a model-item you apply a texture on, not a model.

 

//Per

1 reply

16-Pearl
August 4, 2021

Use timeout function

 

//This applies shader to certain model items. Make sure you have a model item defined! 
$timeout(function() {
$scope.view.wdg['wheel']['texture'] = "app/resources/Uploaded/MyImage.jpg?name=tex0&edge=repeat";
$scope.view.wdg['wheel']['shader'] = "reflect;mixer f 0.5";
} ,50);

 

7-Bedrock
August 4, 2021

Hi Suraj_Patil,

 

Thank you for replay,

 

I changed script and try difference timeout value but not work either.

 

Script:

$scope.init = function(){
$timeout(function() {
//$scope.setWidgetProp('model-1', 'texture', 'app/resources/Uploaded/sea.jpg?name=tex0&edge=repeat');
$scope.setWidgetProp('model-1', 'texture', 'app/resources/Uploaded/forest.jpg?name=tex0&edge=repeat');
$scope.setWidgetProp('model-1', 'shader', 'reflect;mixer f 0.5');
} ,500);
console.log($scope.app.view['Home'].wdg['model-1']);
};
angular.element(document).ready($scope.init);

 

14-Alexandrite
August 4, 2021

Hello,

I think it must be a model-item you apply a texture on, not a model.

 

//Per