Minor fix to strange Cube problem.

0 views
Skip to first unread message

Greg209

unread,
Jan 29, 2010, 6:50:27 AM1/29/10
to Away3D.dev
I came across an issue when using Cube with a map6 material, compiled
through the Flex 3.2 sdk (other versions/circumstances may have the
same issue) which was reported on the group in this thread :-

http://groups.google.com/group/away3d-dev/browse_thread/thread/e3e48b6c3714e77d/812318f2637406ee?lnk=gst&q=map6#812318f2637406ee

Basically, the problem is that the UV is all messed up when using map6
material mapping. Tracking it through, it seems to be a strange bug in
flex.

Simply changing the declaration of .....

private var _offset:Number = 1/3;

to

private var _offset:Number = 1/3.0;

.... seems to make the calculation work. Previously it was coming out
as zero, hence
the UVs were all messed up.

I've updated the trunk for both fp9 and fp10 versions of Cube.as.
Hopefully things should work now.

Greg

Joshua Granick

unread,
Jan 29, 2010, 7:12:38 AM1/29/10
to away3...@googlegroups.com
That is weird. Maybe it got confused and thought it was a string, somehow?

Number ("1/3");

Jensa

unread,
Jan 29, 2010, 7:45:49 AM1/29/10
to Away3D.dev
The Map6 material has been broken for more than a year - no matter the
IDE. If this fixes it, I'd love to test it!

J

Fabrice3D

unread,
Jan 29, 2010, 8:10:23 AM1/29/10
to away3...@googlegroups.com
Looks like Its one of the cases where you must add nothing. But if you don't the class does nothing.
So cudos to Greg for adding nothing :))

Fabrice

Greg209

unread,
Jan 29, 2010, 9:20:04 AM1/29/10
to Away3D.dev
Thanx. It makes me feel proud to contribute nothing to the project. ;)

Fabrice3D

unread,
Jan 29, 2010, 9:45:50 AM1/29/10
to away3...@googlegroups.com
lol

delfeld

unread,
Jan 29, 2010, 3:47:36 PM1/29/10
to Away3D.dev
Since this results in (probably) an int, rather than a Number, it
might be a good idea to go throughout the Away3D code and force the
numbers to be Numbers.

I am not sure if it is because the numerator is an int, or the
denominator, or what; but Away3D has a hundred or so instances where
it is initializing a Number with an int, and a few places where there
is a similar "int/int" initialization.

BTW, I have experienced this problem in a very large project, and it
took two days to track down that the Number was not initializing
correctly. This was not using the Flex method of programming, but
using Flash directly with an external class structure. So I think the
problem is more pervasive than just in Flex.

Looking at AS3 c++ code, Numbers are checked for whether they are
initialized as "int" before they are checked for if they are "double",
since initializing as int is much more common. I could not track down
the actual way this works and test it - not enough hours in the day -
but it may be worth the time to find the actual error.


On Jan 29, 5:50 am, Greg209 <caldwel...@googlemail.com> wrote:
> I came across an issue when using Cube with a map6 material, compiled
> through the Flex 3.2 sdk (other versions/circumstances may have the
> same issue) which was reported on the group in this thread :-
>

> http://groups.google.com/group/away3d-dev/browse_thread/thread/e3e48b...

Fabrice3D

unread,
Jan 29, 2010, 4:12:33 PM1/29/10
to away3...@googlegroups.com
> Since this results in (probably) an int, rather than a Number,
Yes that's probably the case. Indeed something to take in account for future updates.

Fabrice

Amarnaman

unread,
Jan 30, 2010, 5:31:30 PM1/30/10
to Away3D.dev
I've seen this can of error many times over the years I've been coding
and teaching programming and warn my students to be careful of int/int
calculations due to the truncation of the answer back to an int. You'd
think this sort of thing would get flagged by the compiler but
nope....

Yvan.

Reply all
Reply to author
Forward
0 new messages