0

How to set a different geometry Three.ShapeGeometry for one particular face in a CubeGeometry?

I tried this

    var rectLength = 120, rectWidth = 40;

            var rectShape = new THREE.Shape();
            rectShape.moveTo( 0,0 );
            rectShape.lineTo( 0, rectWidth );
            rectShape.lineTo( rectLength, rectWidth );
            rectShape.lineTo( rectLength, 0 );
            rectShape.lineTo( 0, 0 );

var geom = new THREE.ShapeGeometry( rectShape );
var geometry = new THREE.CubeGeometry( 256, 100, 256 );
geometry.faces[0] = geom;
geometry.faces[0].needsUpdate = true;
rkm
  • 892
  • 2
  • 16
  • 32
  • What was the result? How was it not what you hoped for / intended? – Floris Feb 26 '13 at 05:15
  • ypeError: material is undefined [Break On This Error] ...ap || material.bumpMap || material.normalMap || material.specularMap || material... three.js (line 18648) TypeError: material is undefined [Break On This Error] ...ap || material.bumpMap || material.normalMap || material.specularMap || material... three.js (line 18648) TypeError: material is undefined [Break On This Error] ...ap || material.bumpMap || material.normalMap || material.specularMap || material... – rkm Feb 26 '13 at 05:28
  • i need to see a polyline on one of the faces of cubegeometry but all I am getting is the error said in above comment. – rkm Feb 26 '13 at 06:09

1 Answers1

1

A face is not a geometry and you cannot assign a geometry into it because it is an entirely different type of object and concept.

A face is a series of vertices, not a shape, that are referred to by index number. You create the vertices then tell the face the index number of the vertices that make the face. A Face3 would have 3 indices and make a triangle, a Face4 would have 4 indices and form a 4 sided polygon.

If you look at the link I've provided below my answer should be more clear.

Look here

BTW - You could not use a shape as a face for one obvious reason. A shape has an arbitrary number of vertices that could easily be outside the range for a face (3 or 4) meaning you can have a shape with 2 points or a shape with 100 points.

Community
  • 1
  • 1
John McKnight
  • 684
  • 4
  • 9
  • current what I want is basically a 3D cube but each face (side ones) need to have different shapes/geomtries. Can we make 6 mesh and then combine them in such a way that it look it a 3d cube. For start I can consider 6 mesh with planegeometry and put theses meshes together. Is that possible at all? – rkm Feb 27 '13 at 07:08
  • I'm not sure why you want different geometries on what would be a cube. If all you want to do is have different textures on each face you can do what is shown in this question. http://stackoverflow.com/questions/13795354/verification-of-using-multiple-textures-with-three-js-cubes – John McKnight Feb 27 '13 at 17:47