Weird Mesh Issue

Software: Away3D 4.x

jth133, Newbie
Posted: 27 April 2013 01:27 PM   Total Posts: 5

The code:

function onAssetComplete(e:AssetEvent):void{
   
if (e.asset.assetType == AssetType.MESH){
    
if (e.asset.assetNamespace == "mesh1"){
     mesh1 
e.asset as Mesh;
     
     
createMesh(mesh1);

     
view.scene.addChild(mesh1//works fine
    
}

This first part works fine. Assuming I add mesh1 to the scene after running createMesh() there aren’t any problems. However, I have a timer that executes every 15 seconds roughly. Each execution it should add a new mesh based on mesh1…here’s the code for that:

private function onTimer(e:TimerEvent):void{
var newMesh:Mesh = new Mesh(mesh1.geometry,mesh1.material);

view.scene.addChild(newMesh);

meshArray.push(newMesh);

In this case everything executes as it should; it even adds newMesh to the meshArray (which I know because I have a separate function that loops through meshArray), however newMesh is never actually added to the scene; or if it is it’s not visible. The strangest part is I have another mesh that’s loaded and created the exact same way, and when I create another mesh from it it works without issue. Any ideas what the problem could be?

 

   

CyrilM, Newbie
Posted: 30 April 2013 05:41 PM   Total Posts: 15   [ # 1 ]

You could try cloning the mesh before you add it. I’ve never tried adding the same mesh to a scene more than once.

   

Avatar
Fabrice Closier, Administrator
Posted: 30 April 2013 05:56 PM   Total Posts: 1265   [ # 2 ]

if mesh1 has no transform, adding newMesh will place the new one exactly at same location and even if you add 100, you will see only one.

of course there are other explainations, but without seeing more of the code, its just a series of guesses. The createMesh method is not described here, and makes from its name very little sens as the mesh is already created on onAssetComplete, so what does it do? Is your mesh1 not located beyond far lens value? Is it is supposed to be in viewport, the camera is supposed to see it? etc etc…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X