Tilted 3D Box / 傾いた3Dボックス

モバイルを使用してボックスを傾けます。

tilt gyroscope 3D
Mobile 3D

View Source Code

/*
 * @name Tilted 3D Box
 * @description Use mobile to tilt a box
 */
function setup() {
  // createCanvas(displayWidth, displayHeight, WEBGL);
  createCanvas(windowWidth, windowHeight, WEBGL);
}

function draw() {
  background(250);
  normalMaterial();
  rotateX(accelerationX * 0.01);
  rotateY(accelerationY * 0.01);
  box(100, 100, 100);
}

License

Source code is available on GitHub p5.js website legacy.

All examples are licensed under CC BY-NC-SA 4.0.