One sided plane

Software: Away3D 4.x

Fossor, Newbie
Posted: 12 September 2012 03:19 PM   Total Posts: 21

Simple question:
How do I make one sided textured plane?
I tried to set TextureMaterial bothSides to false, in this example:

https://github.com/away3d/away3d-examples-fp11/blob/master/src/Basic_View.as

but it does nothing.

P.S. If I set doubleSided = true in PlaneGeometry I get this error:

RangeError: Error #3669: Bad input size.
at flash.display3D::VertexBuffer3D/uploadFromVector()
at away3d.core.base::SubGeometry/getUVBuffer()
at away3d.core.base::SubMesh/getUVBuffer()
at away3d.materials.passes::DefaultScreenPass/render()
at away3d.materials::MaterialBase/renderPass()
at away3d.core.render::DefaultRenderer/drawRenderables()
at away3d.core.render::DefaultRenderer/draw()
at away3d.core.render::RendererBase/executeRender()
at away3d.core.render::DefaultRenderer/executeRender()
at away3d.core.render::RendererBase/render()
at away3d.containers::View3D/render()
at Basic_View/_onEnterFrame()

   

John Wilson, Member
Posted: 13 September 2012 06:48 AM   Total Posts: 62   [ # 1 ]

Is the bitmap you use for the texture the correct size? It must be “power of 2 and not exceeding 2048”.  So 256 x 256 is fine, but 320 x 240 would not be.

   

Fossor, Newbie
Posted: 13 September 2012 07:49 AM   Total Posts: 21   [ # 2 ]

It is 512x512 - all from the example, nothing changed

   

John Wilson, Member
Posted: 13 September 2012 09:36 AM   Total Posts: 62   [ # 3 ]

That’s odd.  By default a plane will have bothSides set to false, but I tried the following in Basic_View.as and it worked with no problem:

_plane = new Mesh(new PlaneGeometry(700700), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse)));
   
_plane.material.bothSides true;
   
_view.scene.addChild(_plane); 
   

Fossor, Newbie
Posted: 13 September 2012 11:19 AM   Total Posts: 21   [ # 4 ]

Thanx for the reply, John.
But I need it set to false, so I don’t see the other side when rotated on X axis in the example.

   

John Wilson, Member
Posted: 13 September 2012 11:31 AM   Total Posts: 62   [ # 5 ]

I wonder if you are using the latest GitHub versions of the Away3D and/or the Away3D examples.

If I set the botthSides property to false:

plane = new Mesh(new PlaneGeometry(700700), new TextureMaterial(Cast.bitmapTexture(FloorDiffuse)));
_plane.material.bothSides false;
_view.scene.addChild(_plane); 

Then add align to _onEnterFrame:

[quote]private function _onEnterFrame(e:Event):void
{
 _plane
.rotationY += 1;
 
_plane.rotationX += 1;
   
 
_view.render();
}[/quote] 

. . . everything is fine.  The back of the plane becomes invisible when it has rotated far enough in the X axis.

   

Fossor, Newbie
Posted: 13 September 2012 04:15 PM   Total Posts: 21   [ # 6 ]

John, sorry for being stupid and wasting your time.
I actually added some more code to that example, which is responsible for the plane to be two sided:

var geometry:PlaneGeometry = new PlaneGeometry(7003501515true);
var 
indices:Vector.<uint> = geometry.subGeometries[0].indexData.slice();
var 
sil:uint indices.length;
for (var 
i:int 0sil+= 3){
    indices
.push(indices[i 2]indices[i 1]indices[i]);
}
geometry
.subGeometries[0].updateIndexData(indices); 


And then:

_plane = new Mesh(geometry, new TextureMaterial(Cast.bitmapTexture(FloorDiffuse)) );
_plane.material.bothSides false
_view
.scene.addChild(_plane); 

I need it for the Bend modifier from another library
Any thoughts?


Edit: Never mind, the code is not needed.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X