cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

About Shader and Texture

william_shih
6-Contributor

About Shader and Texture

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?

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

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

 

//Per

View solution in original post

4 REPLIES 4

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);

 

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);

 

Hello,

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

 

//Per

Hi Pandersson,

 

Yes, you are right.

I use the model and it is mistake.

Need to use Model Item to apply texture and shader.

 

Thank you so much.

Top Tags