three.js - ThreeJS - Simple Extrusion Issue -


i struggling should quite easy do, have been unable find example addresses scenario. want extrude simple profile along rectangular path:

(as new here cannot post images, these can viewed on forum explain should getting , generating. original question on threejs forum)

i appreciate if @ code below , tell me doing wrong:

'----------------------------------------------------------------------------------------------------------------

<script>          var container;          var camera, scene, renderer, controls;          init();         animate();          function init() {             //scene setup             renderer = new three.webglrenderer();             renderer.setpixelratio( window.devicepixelratio );             renderer.setsize( window.innerwidth, window.innerheight );             document.body.appendchild( renderer.domelement );              scene = new three.scene();             scene.background = new three.color( 0x222222 );              camera = new three.perspectivecamera( 45, window.innerwidth / window.innerheight, 1, 1000 );             camera.position.set( -250, 150, 200 );             camera.lookat(new three.vector3(0, -50, 0))             controls = new three.trackballcontrols( camera, renderer.domelement );             controls.mindistance = 200;             controls.maxdistance = 500;              scene.add( new three.ambientlight( 0x222222 ) );              var light = new three.pointlight( 0xffffff );             light.position.copy( camera.position );             scene.add( light );               //profile shape             var spts = [];             spts.push(new three.vector2(0, 0));             spts.push(new three.vector2(10, 0));             spts.push(new three.vector2(10, 25));             spts.push(new three.vector2(-5, 25));             spts.push(new three.vector2(-5, 20));             spts.push(new three.vector2(0, 20));               //path points             var ppth = []             ppth.push(new three.vector3(0,0,10));             ppth.push(new three.vector3(100, 0,10));             ppth.push(new three.vector3(100, 200,10));             ppth.push(new three.vector3(0, 200,10));              //-----------------------------------------------extrusion path curvepath              var cpth = new three.curvepath()              //the following statement apears create no new curves             //cpth.creategeometry(ppth)              //add curves explicitely             var v1 = new three.linecurve(new three.vector3(0,0,0), new three.vector3(100,0,0));             var v2 = new three.linecurve(new three.vector3(100,0,0), new three.vector3(100,200,0));             var v3 = new three.linecurve(new three.vector3(100, 200, 0), new three.vector3(0, 200, 0));             var v4 = new three.linecurve(new three.vector3(0, 200, 0), new three.vector3(0, 0, 0));              cpth.add(v1);             cpth.add(v2);             cpth.add(v3);             cpth.add(v4);             cpth.autoclose = true;             //cpth.update;              //set extrusion path curvepath              expth = cpth              //extrusion settings             var extrudesettings = {                 steps: 200,                 bevelenabled: false,                 extrudepath: expth             };              // generate scene geometry             var shape = new three.shape( spts );              var geometry = new three.extrudegeometry(shape, extrudesettings);               var material2 = new three.meshlambertmaterial( { color: 0xff8000, wireframe: false } );              var mesh = new three.mesh( geometry, material2 );             mesh.position.x = -50;             mesh.position.y = -100;              scene.add( mesh );         }  </script> 


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -