|
Simon Kendrew, Newbie
Posted: 26 August 2015 08:05 AM Total Posts: 9
I am using Away3D 4 with the IN2AR augmented reality plugin, using the sample code from IN2AR to begin my application.
I can successfully load models from an AWD file, however I cannot seem to load a light from the AWD file, in fact, when I have loaded the AWD file, my actionscript code cannot seem to find any reference to a light within the file.
If I open my AWD file into Away Builder, both the model and the light are present, and the light illuminates the model as required.
I can manually create the lights through actionscript, however, this isn’t ideal as the 3D models and lighting are being created by someone else, and it would be a better and quicker solution to simply load the lights from the AWD file.
Can anyone provide advice on how I can do this?
Many thanks.
|
Fabrice Closier, Administrator
Posted: 26 August 2015 02:07 PM Total Posts: 1265
[ # 1 ]
onAssetEvent, look at asset.type, if type = lightbase—> add to scene, or add to lightpicker (which you also can detect from asset type)
if you replace content, make sure to remove existing pickers/lights from your previously loaded materials/scene.
|
Simon Kendrew, Newbie
Posted: 26 August 2015 04:44 PM Total Posts: 9
[ # 2 ]
Hi Fabrice,
Thank you for your assistance.
I have a function onAssetRetrieved(event:AssetEvent) that processes the assets, such as setting initial rotations, scale, and this is also where I can manually add a lightpicker.
It checks the assetType in this function, such as if (event.asset.assetType == AssetType.MESH) {
However, if I add a statement to check event.asset.assetType == AssetType.LIGHTBASE, I get the following error:
“1119: Access of possibly undefined property LIGHTBASE through a reference with static type Class.”
Looking through the Away3D API docs, it doesn’t appear to have LIGHTBASE as an assetType. Any idea what I’m doing wrong here?
http://away3d.com/livedocs/away3d/4.0/away3d/library/assets/AssetType.html
|
Simon Kendrew, Newbie
Posted: 28 August 2015 11:48 AM Total Posts: 9
[ # 3 ]
Hi Fabrice,
Can you offer any further advice on loading lights into Away3D? When I load my AWD file into Flash, I cannot see any assets of type lightbase, yet the lights are clearly present when I load the models into Away Builder. This has got me really confused.
|
rdoi, Member
Posted: 28 August 2015 02:18 PM Total Posts: 86
[ # 4 ]
Hi there,
LightBase is the “class type” not the asset type, so you should compare with something like (event.asset is LightBase).
The correct light related assets types are strings “light” and “lightPicker” or constants AssetType.LIGHT and AssetType.LIGHT_PICKER.
About the light not appearing in the scene, make sure all elements are correctly linked after the load:
Mesh <- Material <- LightPicker <- Light
|
Simon Kendrew, Newbie
Posted: 01 September 2015 09:04 AM Total Posts: 9
[ # 5 ]
Hi rdoi,
Thank you for the advice. Following your suggestion, I’ve adjusted my onAssetComplete function so that it now traces “event.asset = ” for every asset in the AWD file that is loaded. I can see all the assets within my AWD files being loaded, except the lights!
Assets being loaded are traced as [object Mesh], [object Geometry], [object BitmapTexture], [object TextureMaterial], [object ObjectContainer3D]
What am I doing wrong here? The lights appear and work automatically in Away Builder, but don’t appear to be present when the files are loaded in Flash?
|
Fabrice Closier, Administrator
Posted: 01 September 2015 10:05 AM Total Posts: 1265
[ # 6 ]
well, assuming your code is correct, this says that either the light(s) are not saved within the awd file, but as you suggest that loading the same awd in awaybuilder does show the light(s), then there is a diff in parsers, where the awaybuilder parser does trigger an asset event for this asset type, and the engine version that you use for own project does not.
It should be fairly simple to check and fix.
|
Simon Kendrew, Newbie
Posted: 01 September 2015 10:58 AM Total Posts: 9
[ # 7 ]
Thanks Fabrice,
I can confirm that if I update the Away3D library I am using to 4.1.4 or 4.1.6, then my program can now see the light assets as the AWD files are loaded. It would appear that the Away3D library that is supplied with the IN2AR plugin uses an earlier version of v4.x.
While I can now load lighting directly from my AWD files, the newer versions of Away3D seem to be incompatible with other aspects of the IN2AR plugin, causing new errors to appear.
I may need to revert back to the supplied version of Away3D, and add the lighting through code!
Thanks for your help.
|
Fabrice Closier, Administrator
Posted: 01 September 2015 02:14 PM Total Posts: 1265
[ # 8 ]
Yeah, as I expected… so on top of my head, I think it’s just a matter of adding types to assetType class 4.14, and into the parserbase class in order to fire the events.
|