title: Check points is inside a polygon - doesn't work correct
body: <p>I create a room based on any Array with points. Objects that can be moved are added to the room.
  The goal is to block the possibility of moving the object out of the room.</p>
  
  <p>When the object is moved, I check if all 4 bottom points belong to the floor - if so, you can move the object further - if not, it means that the object would go behind the wall, so you have to restore it to the previous position.</p>
  
  <p>The function responsible for creating room (wallsPoint is a Array with points)</p>
  
  <pre><code>var wallPoint = [
   {
     "X": 0,
     "Y": 0
   },
   {
     "X": 5,
     "Y": 0
  },
   {
    "X": 5,
    "Y": 3
  },
  {
    "X": 7,
    "Y": 3
  },
  {
    "X": 7,
    "Y": 5
  },
  {
    "X": 5,
    "Y": 5
  },
  {
    "X": 5,
    "Y": 7
  },
  {
    "X": 0,
    "Y": 7
  }
   ];
  
  function createRoom() {
  
  // create a walls
  var walls = new THREE.Geometry();
  var floorPoints = [];
  
  
  wallsPoint.forEach(r =&gt; {
      walls.vertices.push(new THREE.Vector3(r.X, r.Y, 0));
  walls.vertices.push(new THREE.Vector3(r.X, r.Y, 3));
  floorPoints.push(new THREE.Vector3(r.X, r.Y, 0));
  
  walls.name = "wall";
  });
      var previousVertexIndex = walls.vertices.length - 2;
      for (i = 0; i &lt; walls.vertices.length; i += 2) {
          walls.faces.push(new THREE.Face3(i + 1, i, 
  previousVertexIndex));
         walls.faces.push(new THREE.Face3(previousVertexIndex + 1, i + 
  1, previousVertexIndex));
         previousVertexIndex = i;
  
      }
      walls.computeFaceNormals();
  
  var wallsTexture = new THREE.TextureLoader().load( 'walls.jpg' );//  
  var mesh = new THREE.Mesh(walls, new THREE.MeshBasicMaterial({
      map: wallsTexture
  }));
  mesh.rotation.x= -Math.PI /2;
  
  //create a floor
  var floorShape = new THREE.Shape(floorPoints);
  var floorGeometry = new THREE.ShapeGeometry(floorShape);
  var floorTexture = new THREE.TextureLoader().load( 'wood.jpg' ); 
  floor = new THREE.Mesh(floorGeometry, new THREE.MeshBasicMaterial({
      map: floorTexture,
      side: THREE.DoubleSide
  }));
  
  
  floor.geometry.vertices = floorPoints;
  floor.geometry.name = "floor";
  floor.rotation.x =-Math.PI/2;
  
  group = new THREE.Object3D();
  group.add(mesh);
  group.add( floor );
  group.add(ceiling) ;
  scene.add( group );
    }
  </code></pre>
  
  <p>The function responsible to check if the points are on the floor. 
  Points are a helperBox.geometry.attributes.position.array (helper box for an object that we move with the mouse) </p>
  
  <pre><code>function checkPoints(points){
  
  var arrayToCheck = [new THREE.Vector3(points[6],points[7],points[8]),new THREE.Vector3(points[9],points[10],points[11]),new THREE.Vector3(points[18],points[19], points[20]),new THREE.Vector3(points[21],points[22],points[23])];
  
  
  var inside = [];
  var raycaster = new THREE.Raycaster();
  
  for(var i = 0; i&lt;arrayToCheck.length; i++){
      var pointToCheck = arrayToCheck[i];
      raycaster.set(pointToCheck, new THREE.Vector3(1,1,1));
      var intersects = raycaster.intersectObject(floor);
  
      if( intersects.length %2 === 1) {
          inside.push(true);
          console.log(true);
      }
      else{
          inside.push(false);
          console.log(false);
      }
  }
  if(!inside.includes(false)){
      return true
  }
  else{
      return false
  }
   }
  </code></pre>
  
  <p>I want the checkPoints function to show true or false depending on whether all 4 points are on the floor or not.
  Currently, in most cases, the function works well. Unfortunately, not all of them. Every time it works bad - it's about point 3 and / or 4.</p>
  
  <p>How to fix it?
  Alternatively, how else should not let the object (model is format obj - so irregular shape) go beyond the floor?</p>