I've trying to draw the square wall by getting mouse clicks coordinates and extrude it. I've picking up the mouse coordinates by clicking at the scene.
var onDocumentMouseDown = function ( event )
{
//update the mouse variable
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse.y = -( event.clientY / window.innerHeight ) * 2 + 1;
var vector = new THREE.Vector3(mouse.x, mouse.y, 0.5);
vector.unproject( camera );
var dir = vector.sub( camera.position ).normalize();
var distance = - camera.position.z / dir.z;
var pos = camera.position.clone().add( dir.multiplyScalar( distance));
console.log('mouse_x ' + pos.x + ' mouse_y ' + pos.y);
if (clickCount <= 3){
coord[clickCount] = {'x' : pos.x, 'y' : pos.y};
clickCount ++;
} else {
//make new wall and stop function
newshape = new THREE.Shape();
shape.moveTo(coord['0'].x ,coord['0'].y);
shape.lineTo(coord['0'].x, coord['1'].y);
shape.lineTo(coord['2'].x, +coord['2'].y);
shape.lineTo(coord['3'].x, coord['3'].y);
shape.lineTo(coord['0'].x, coord['0'].y);
var newextrudeSettings = {
//*******/
};
}
And when I've recived four coordinates, three.js throw the error:
Uncaught TypeError: Cannot read property 'length' of null at Object.triangulateShape (three.js:26140) at ExtrudeGeometry.addShape (three.js:26330) at ExtrudeGeometry.addShapeList (three.js:26235) at new ExtrudeGeometry (three.js:26211) at HTMLDocument.onDocumentMouseDown (script.js:116)

shape.lineTo(coord['0'].x, coord['1'].y);shouldn't it be asshape.lineTo(coord['1'].x, coord['1'].y);? and why not to use indices of elements as integers instead of strings:coord['0'].x->coord[0].x, for example?+coord['2'].ymean?THREE.Raycaster()and a plane to find points of intersection and build aTHREE.ExtrudeGeometry(), so everything works totally fine in my code.