three#Plane TypeScript Examples

The following examples show how to use three#Plane. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DisplayObject.ts    From FairyGUI-threejs with MIT License 6 votes vote down vote up
public update(clipPlanes: any, alpha: number) {
        if (this._clipRect) {
            this.transformRect(this._clipRect, null, s_rect);

            if (clipPlanes) {
                s_rect2.setMinMax(-clipPlanes[0].constant, -clipPlanes[3].constant,
                    clipPlanes[1].constant, clipPlanes[2].constant);
                s_rect.intersection(s_rect2);
            }
            if (!this._clipPlanes) {
                this._clipPlanes = [
                    new Plane(new Vector3(1, 0, 0)),
                    new Plane(new Vector3(-1, 0, 0)),
                    new Plane(new Vector3(0, -1, 0)),
                    new Plane(new Vector3(0, 1, 0))
                ];
            }

            clipPlanes = this._clipPlanes;
            clipPlanes[0].constant = -s_rect.x;
            clipPlanes[1].constant = s_rect.xMax;
            clipPlanes[2].constant = s_rect.yMax;
            clipPlanes[3].constant = -s_rect.y;
        }

        if (this._graphics)
            this._graphics.update(clipPlanes, this._alpha * alpha);
    }
Example #2
Source File: useRaycaster.ts    From trois with MIT License 6 votes vote down vote up
export default function useRaycaster(options: RaycasterConfigInterface): RaycasterInterface {
  const {
    camera,
    resetPosition = new Vector3(0, 0, 0),
  } = options

  const raycaster = new Raycaster()
  const position = resetPosition.clone()
  const plane = new Plane(new Vector3(0, 0, 1), 0)

  const updatePosition = (coords: Vector2) => {
    raycaster.setFromCamera(coords, camera)
    camera.getWorldDirection(plane.normal)
    raycaster.ray.intersectPlane(plane, position)
  }

  const intersect = (coords: Vector2, objects: Object3D[], recursive = false) => {
    raycaster.setFromCamera(coords, camera)
    return raycaster.intersectObjects(objects, recursive)
  }

  return {
    position,
    updatePosition,
    intersect,
  }
}
Example #3
Source File: DisplayObject.ts    From FairyGUI-threejs with MIT License 5 votes vote down vote up
protected _clipPlanes?: Array<Plane>;