Extruding multiple polygons with multiple holes and texturing the combined shape

后端 未结 1 826
误落风尘
误落风尘 2020-12-10 17:49

This question is related to this question. The answer shows very nice way to extrude polygons that have holes (see the excellent live example). The main learning of the answ

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 18:46

    You can merge geometries as in the following snippet, resulting in just a single mesh. From your prior questions, you already know how to texture a single geometry.

    var geometry1 = new THREE.ExtrudeGeometry( shape1, extrusionSettings );
    var geometry2 = new THREE.ExtrudeGeometry( shape2, extrusionSettings );
    
    geometry1.merge( geometry2 );
    
    . . .
    
    var mesh = new THREE.Mesh( geometry1, material );
    
    scene.add( mesh );
    

    Fiddle: http://jsfiddle.net/pHn2B/88/

    Fiddle: http://jsfiddle.net/C5dga/13/ (with texture)

    EDIT: As an alternative to creating separate geometries and using the merge utility, you can create a single geometry using the following pattern, instead:

    var geometry1 = new THREE.ExtrudeGeometry( [ shape1, shape2 ], extrusionSettings );
    

    EDIT: updated to three.js r.70

    0 讨论(0)
提交回复
热议问题