<commit_before>import * as THREE from 'three'
import * as Color from 'color'
import PostProcessor from './postprocessor'
import Scene from './scene'

interface ICube {
  mesh: THREE.Mesh
  objectPivot: THREE.Object3D
  originPivot: THREE.Object3D
  rotationAxis: THREE.Vector3
  rotationAngle: number
  rotationSpeed: number
}

export default class SimpleCubes extends Scene {

  private cubes: ICube[] = []
  private cameraRotation = 0
  private light: THREE.Light
  private hue: number = 0
  private cameraTarget: THREE.Vector3 = new THREE.Vector3(0, 0, 0)
  private cameraDirection: THREE.Vector3 = new THREE.Vector3(0, 0, 0)
  private postProcessor: PostProcessor

  constructor(element: HTMLElement, nCubes: number = 250, radius: number = 100, size = 10) {
    super(element, false)

    const material = new THREE.MeshPhongMaterial({ color: 0xffffff, shininess: 50, specular: 30 })
    const scale = size * radius / nCubes

    this.light = new THREE.PointLight(0xffff00, 5, 150)
    this.light.position.set(50, 50, 50)
    this.scene.add(this.light)
    this.camera.lookAt(this.scene.position)
    this.cameraDirection = this.scene.position
    this.camera.position.x = radius * 0.75
    this.camera.position.z = radius * 0.75

    for (let i = 0; i < nCubes; i++) {
      const cube = this.randCube(scale, radius, material)
      this.cubes.push(cube)
      this.scene.add(cube.originPivot)
    }

    document.onmousemove = (e: MouseEvent) => {
      const x = (e.clientX - element.clientWidth / 2) / element.clientWidth * radius / 5
      const y = (e.clientY - element.clientHeight / 2) / element.clientHeight * radius / 5
      this.cameraTarget = new THREE.Vector3(-x, y, 0)
    }

    window.ondeviceorientation = (e: DeviceOrientationEvent) => {
      // const z = e.alpha / 180.0 - 1
      const x = e.beta / 180.0 // front to back
      const y = e.gamma / 90.0 // left to right
      this.cameraTarget = new THREE.Vector3(-x * radius / 5, y * radius / 5, 0)
    }

    this.postProcessor = new PostProcessor(element, this.renderer, this.scene, this.camera)
  }

  protected render(dt: number): void {<commit_msg>fix device orientation axes<commit_after>import * as THREE from 'three'
import * as Color from 'color'
import PostProcessor from './postprocessor'
import Scene from './scene'

interface ICube {
  mesh: THREE.Mesh
  objectPivot: THREE.Object3D
  originPivot: THREE.Object3D
  rotationAxis: THREE.Vector3
  rotationAngle: number
  rotationSpeed: number
}

export default class SimpleCubes extends Scene {

  private cubes: ICube[] = []
  private cameraRotation = 0
  private light: THREE.Light
  private hue: number = 0
  private cameraTarget: THREE.Vector3 = new THREE.Vector3(0, 0, 0)
  private cameraDirection: THREE.Vector3 = new THREE.Vector3(0, 0, 0)
  private postProcessor: PostProcessor

  constructor(element: HTMLElement, nCubes: number = 250, radius: number = 100, size = 10) {
    super(element, false)

    const material = new THREE.MeshPhongMaterial({ color: 0xffffff, shininess: 50, specular: 30 })
    const scale = size * radius / nCubes

    this.light = new THREE.PointLight(0xffff00, 5, 150)
    this.light.position.set(50, 50, 50)
    this.scene.add(this.light)
    this.camera.lookAt(this.scene.position)
    this.cameraDirection = this.scene.position
    this.camera.position.x = radius * 0.75
    this.camera.position.z = radius * 0.75

    for (let i = 0; i < nCubes; i++) {
      const cube = this.randCube(scale, radius, material)
      this.cubes.push(cube)
      this.scene.add(cube.originPivot)
    }

    document.onmousemove = (e: MouseEvent) => {
      const x = (e.clientX - element.clientWidth / 2) / element.clientWidth * radius / 5
      const y = (e.clientY - element.clientHeight / 2) / element.clientHeight * radius / 5
      this.cameraTarget = new THREE.Vector3(-x, y, 0)
    }

    window.ondeviceorientation = (e: DeviceOrientationEvent) => {
      // const z = e.alpha / 180.0 - 1
      const x = e.gamma / 90.0 // left to right
      const y = e.beta / 180.0 // front to back
      this.cameraTarget = new THREE.Vector3(-x * radius, y * radius, 0)
    }

    this.postProcessor = new PostProcessor(element, this.renderer, this.scene, this.camera)
  }

  protected render(dt: number): void {
{'fraction_non_alphanumeric': 0.11579934364744492, 'fraction_numerical': 0.03234880450070324, 'mean_word_length': 3.1107899807321773, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1167707', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1345, 'n_words': 385}