viewDirFragmentReg is protected by arcane now?

Software: Away3D 4.x

mmix7, Newbie
Posted: 09 July 2012 06:22 AM   Total Posts: 9

This is in reference to : https://github.com/away3d/away3d-examples-fp11/blob/dev/src/Intermediate_Globe.as

As seen here: http://www.infiniteturtles.co.uk/blog/away3d-with-flash-11-2-mouse-locking-all-over-the-world


It’s a great example of using custom shaders on diffuse bitmaps for sphereGeometry.
However, while using the LATEST dev git checkout, I have encountered 1 problem. To my understanding the upcoming GOLD 4.0 release will derive from the dev branch. So that is why I’m using it, as well as for testing purposes.

Line #365 in the example:

var viewDirFragmentReg:ShaderRegisterElement atmosphereDiffuseMethod.viewDirFragmentReg

As you can see it’s a variable declaration that is assigned the ‘viewDirFragmentReg’. This is apparently now PROTECTED by arcane.

override arcane function get viewDirFragmentReg() : ShaderRegisterElement
  {
   
return _viewDirFragmentReg;
  

So it’s impossible to get the example running without modifying the materials.methods.CompositeDiffuseMethod with custom getter to return it (as well as the normalFragmentReg). Not difficult, but surely doing such is not intended by away3d?


I was wondering what the reason for protecting this by arcane might be, and also what is the PROPER way to resolve this issue? Clearly it was protected by arcane for a reason, like many internals to the engine itself. ?

   

Richard Olsson, Administrator
Posted: 10 July 2012 06:31 AM   Total Posts: 1192   [ # 1 ]

I think you might be misunderstanding the purpose of the arcane namespace (and ActionScript namespaces in general.)

If something is in the “arcane” namespace that doesn’t mean you can’t access it from outside. In fact, it’s in that namespace for that very reason, so that code running in instances of other classes can access that property, and is a way for the internal engine classes to communicate with each other through a channel that’s faster than getters/setters and method calls.

The arcane namespace just means that you probably shouldn’t be accessing a property directly unless you know what you’re doing. If you do know what you’re doing works, then there’s nothing stopping you from continuing to access that property.

Namespaces are an ActionScript feature that not many people know about, but as long as you make sure to import the away3d.arcane namespace, you can access arcane properties like so:

import away3d.arcane;

someInstance.arcane::myArcaneProperty 5

Note though that the above type of access, using the namespace qualifier and the double-colon syntax, is slow compared to normal instance field access. To be able to get fast access, you have to insert a “use namespace” statement in the scope in which you want to use the namespace, most often at the top of the class (see examples in several core classes of Away3D.)

import away3d.arcane;

use namespace 
arcane;

someInstance.myArcaneProperty 5

Hope this helps!

By the way, the branch called “release” is where the 4.0 release is being prepared. That branch will be merged into master in time for the release. The “dev” branch is used for further-future development (e.g. anything that happens in preparation of 4.1 and onward at this point).

   

mmix7, Newbie
Posted: 10 July 2012 09:10 AM   Total Posts: 9   [ # 2 ]

Wow thank you very much Mr. Olsson, I could not possible have asked for a better or more informative reply. This has definitely helped me.
I’m new to AS3 , coming from a c++ background. I should’ve known better, in retrospect. lol.


And very good to know on the 4.0 release branch; not sure why I thought otherwise. Thanks again, it all makes much more sense now smile

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X