Set same BitmapMaterial to Sprite3D

Software: Away3D 4.x

Meis, Newbie
Posted: 27 June 2011 10:04 AM   Total Posts: 3

Hi.I really love this amazing API and try to play it.

I created two Sprite3Ds and set the same BitmapMaterial to both.
Then I got folllowing Error.

RangeError: Error #1125: The index 0 is out of range 0.
at away3d.entities::Entity/get zIndex()
at away3d.core.sort::RenderableSorter/blendedSortFunction()
at Vector.<*>$/_sort()
at Vector$object/http://adobe.com/AS3/2006/builtin::sort()
at away3d.core.sort::RenderableSorter/sort()
at away3d.core.render::RendererBase/render()
at away3d.core.render::DefaultRenderer/render()
at away3d.containers::View3D/render()

Did I make a mistake in any ways ?

I want to create many Sprite3Ds that appearance?are the same.
So I think it is a waste that I create 100 BitmapMaterials and transport it to GPU for 100 Sprite3Ds.

Once I transported BtmapData to GPU, I can create a number of BitmapMaterials using one, I search for such way.

Thanks.

   

Avatar
Choons, Sr. Member
Posted: 29 June 2011 02:52 AM   Total Posts: 281   [ # 1 ]

that error happens when a Vector hasn’t been initialized properly. Are you using a Vector to step through your Sprite3D’s? If not, then the devs musta have changed something that is causing it

   

Meis, Newbie
Posted: 29 June 2011 01:56 PM   Total Posts: 3   [ # 2 ]

Thanks for your reply.
I used Vector, but I reproduce the same Error without using Vector in short code.

playerglobal.swc provided with Flash Player Incubator 11.0.1.3
Away3D 4.0.0 Alpha

package {
import away3d.cameras.Camera3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.entities.Sprite3D;
import away3d.materials.ColorMaterial;
import flash.display.Sprite;
import flash.events.Event;

public class Main extends Sprite {
  public var viewport:View3D;
  public var camera:Camera3D;
  public var scene:Scene3D;

  public function Main(){
  viewport = new View3D();
  addChild(viewport);
  camera = viewport.camera;
  scene = viewport.scene;
  //
  var material:ColorMaterial = new ColorMaterial(0xff0000);
  var sp1:Sprite3D = new Sprite3D(material, 100, 100);
  sp1.x = 200;
  scene.addChild(sp1);
  var sp2:Sprite3D = new Sprite3D(material, 100, 100);
  sp2.x = -200;
  scene.addChild(sp2);
  //
  addEventListener(Event.ENTER_FRAME, _render);
  }

  private function _render(e:Event):void {
  viewport.render();
  }

}

}

In my Enviroment, it causes Run Time Error.
Please try this code to confirm if this causes the Error.

Thanks.

   

Avatar
Choons, Sr. Member
Posted: 29 June 2011 04:47 PM   Total Posts: 281   [ # 3 ]

seems like you have some extraneous code in there. Unlike 3.6 you don’t have to explicitly assign the scene and camera. This code worked for me:

package 
{
 
 import away3d
.containers.View3D;
 
import away3d.entities.Sprite3D;
 
import away3d.materials.ColorMaterial;
 
 
import flash.display.Sprite;
 
import flash.events.Event
 
 public class 
Main extends Sprite 
 {
  
  
private var view:View3D;
  
  public function 
Main():void 
  {
   
if (stageinit();
   else 
addEventListener(Event.ADDED_TO_STAGEinit);
  
}
  
  
private function init(e:Event null):void 
  {
   removeEventListener
(Event.ADDED_TO_STAGEinit);
   
   
view = new View3D();
   
addChild(view);
   
   var 
material:ColorMaterial = new ColorMaterial(0xff0000);
   var 
sp1:Sprite3D = new Sprite3D(material100100);
   
sp1.200;
   
view.scene.addChild(sp1);
   var 
sp2:Sprite3D = new Sprite3D(material100100);
   
sp2.= -200;
   
view.scene.addChild(sp2);
   
//
   
addEventListener(Event.ENTER_FRAME_render);  
  
}
  
  
private function _render(e:Event):void {
   view
.render();   
  
}
 }
 
   

Meis, Newbie
Posted: 30 June 2011 04:36 AM   Total Posts: 3   [ # 4 ]

Thanks for your reply.

I explicitly assigned scene and camera to operate 3D root container and camera easily, but it seems not to be necessary in Away3D 4.0, thanks.

I tried your code, but got the same Error.
And I set the following code comment out, it works correctly.
//view.scene.addChild(sp2);

...Is my environment something wrong?

   

Avatar
Choons, Sr. Member
Posted: 30 June 2011 04:56 AM   Total Posts: 281   [ # 5 ]

which environment are you using? I use FlashDevelop and have to set -swf-version=13 and custom path to Flex 4.5.1 in compiler options, output to the browser molehill player, and use the playerglobal.swc that works with molehill

   

Meis, Newbie
Posted: 03 July 2011 02:42 AM   Total Posts: 3   [ # 6 ]

I use Flash CS5
Because to display one Sprite3D works correct, I think I build my environment correctly.

ummm…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X