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

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

About Shader and Texture

william_shih
7-Bedrock

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?

ACCEPTED SOLUTION

Accepted Solutions
pandersson
14-Alexandrite
(To:william_shih)

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

 

pandersson
14-Alexandrite
(To:william_shih)

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.

Announcements

Top Tags