actionscript-3away3d

Away3d transparent bitmap Sprite3d


I'm adding some circles to away3d as sprite3ds, but for some reason they all have white backgrounds that I can't seem to remove. Anyone know what I'm missing:

        var hotspot:Hotspot = e.target as Hotspot;

        var spBoard:Sprite = new Sprite();
        spBoard.x = circleX;
        spBoard.y = circleY;


        var shCircle:Shape = new Shape();
        shCircle.graphics.lineStyle(2,0x000000);
        shCircle.graphics.drawCircle(0,0,circleR);
        shCircle.x = 0;
        shCircle.y = 0;

        var shFill:Shape = new Shape();
        shFill.graphics.lineStyle(1,0x000000);
        shFill.graphics.moveTo(0,0);
        shFill.graphics.lineTo(circleR,0);
        shFill.x = 0;
        shFill.y = 0;

        var shAngle:Shape = new Shape();

        var shArrow:Shape = new Shape();
        shArrow.graphics.lineStyle();
        shArrow.graphics.beginFill(0x000000);
        shArrow.graphics.moveTo(angleR,1);
        shArrow.graphics.lineTo(angleR-5,8);
        shArrow.graphics.lineTo(angleR+5,8);
        shArrow.graphics.lineTo(angleR,1);
        shArrow.graphics.endFill();

        spBoard.addChild(shFill);
        spBoard.addChild(shAngle);
        spBoard.addChild(shArrow);
        spBoard.addChild(shCircle);


        var hotspotTimer:MovieClip = new MovieClip();
        hotspotTimer.addChild(spBoard);

        var bounds:Rectangle = hotspotTimer.getBounds(hotspotTimer);

        var bitmapData : BitmapData = new BitmapData(512, 512);
            bitmapData.draw(hotspotTimer);

        var bitmapPointsTexture:BitmapTexture = new BitmapTexture(bitmapData);
        var _pointsMaterial:TextureMaterial = new TextureMaterial(bitmapPointsTexture);
        var inworldHotspotTimer:Sprite3D = new Sprite3D(_pointsMaterial,bitmapData.width,bitmapData.height);
        inworldHotspotTimer.x = hotspot.x;
        inworldHotspotTimer.y = hotspot.y;
        inworldHotspotTimer.z = hotspot.z;
        scene.addChild(inworldHotspotTimer);    

    }

I've seen in blog posts such as this http://www.allforthecode.co.uk/aftc/forum/user/modules/forum/article.php?index=6&subindex=4&aid=315

On how they do it, but they're using an older version with the BitmapMaterial removed.


Solution

  • Change the line that declares the bitmapdata to this:

    var bitmapData : BitmapData = new BitmapData(512, 512, true, 0x00808080);
    

    If you don't fill the bitmap with a color that has alpha of 0, you'll get the borders in the texture.