woodedlawn / jsc3d

Automatically exported from code.google.com/p/jsc3d
0 stars 0 forks source link

Not able to change colour of the object #60

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Pls check thatzit.com/3d/loading2.html
2. Click on Yellow button or Red button at bottom 

What is the expected output? What do you see instead?
The colour should change.
The object becomes black

What version of the product are you using? On what operating system?
OS - Windows 7 and Linux

Please provide any additional information below.

Original issue reported on code.google.com by poo...@thatzit.com on 12 Feb 2014 at 7:32

GoogleCodeExporter commented 9 years ago
Your issue looks rather similar to this one: 
http://code.google.com/p/jsc3d/issues/detail?id=58.

The problem is the color you passed in to construct a new material should be a 
number rather than a string.

By the way, you might have noticed that the shading on the cube is a little 
strange. It is caused by excessive averaging when computing vertex normals from 
face normals. Jsc3d provides a solution to deal with this: tell the viewer a 
appropriate crease angle to preserve sharp edges and remove the unpleasant 
shading. It requires just an additional line in the initialization phase:

  viewer.setParameter('CreaseAngle', 30);

More details of the parameter 'CreaseAngle' can be found in this document: 
http://code.google.com/p/jsc3d/wiki/StartupParameters.

Original comment by Humu2...@gmail.com on 12 Feb 2014 at 3:33

GoogleCodeExporter commented 9 years ago
Thanks a lot for the prompt reply. Really appreciate it
Have converted the color string to number and the code now works.

For newbies - to convert colour string to number
color = color.slice(1);  //where color is defined as "#FF0000"
colorNum= parseInt(color, 16);

POONAM BATHIJA
Programming Head

Perfection. Our only endeavour. Thatzit
www.thatzit.com

Original comment by poo...@thatzit.com on 12 Feb 2014 at 4:48

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Also, need to know how to save the same object with the new selected color.

POONAM BATHIJA
Programming Head

Perfection. Our only endeavour. Thatzit
www.thatzit.com

Original comment by poo...@thatzit.com on 12 Feb 2014 at 5:05

GoogleCodeExporter commented 9 years ago
Thanks for posting your code snippet! I'm using this to do the conversion:

  parseInt('0x' + colorString.substring(1));

It outputs the same result :-)

Saving is NOT supported, though it can be implemented with HTML5 File API. It's 
not in my plan.

Original comment by Humu2...@gmail.com on 13 Feb 2014 at 5:53

GoogleCodeExporter commented 9 years ago
Can you help me in writing the code for exporting/saving the new colour
changed object to .obj or .fbx file. as I am not able to do it.

POONAM BATHIJA
Programming Head

Perfection. Our only endeavour. Thatzit
www.thatzit.com

Original comment by poo...@thatzit.com on 14 Feb 2014 at 9:54

GoogleCodeExporter commented 9 years ago
I'll send you a message though email. Please check it there.

Original comment by Humu2...@gmail.com on 14 Feb 2014 at 11:37