LoginSignup
0
0

More than 3 years have passed since last update.

P5.js 日本語リファレンス(model)

Last updated at Posted at 2020-05-08

このページでは「P5.js 日本語リファレンス」 の model関数を説明します。

model()

説明文

3Dモデルを画面にレンダリングします。

構文

model(model)

パラメタ

  • model
    p5.Geometry:レンダリングされるロードされた3Dモデル

//回転するティーポットを描画します
function preload(){
  // normalizeパラメータをtrueに設定してモデルをロードします
  teapot = loadModel( 'https://dl.dropbox.com/s/29mn2slkvn3ojra/teapod.obj', true, loadingOk());
}

function setup(){
  createCanvas(100, 100, WEBGL);
}

function draw(){
  background(200);
  scale(0.4); //モデルをキャンバスに合わせるためにスケーリング
  rotateX(frameCount * 0.01);
  rotateY(frameCount * 0.01);

  // X軸に面するサーフェスは赤、Y軸に面するサーフェスは緑、
  // Z軸に面するサーフェスは青に設定
  normalMaterial();

  model(teapot); // 読み込んだモデルで描画
}

function loadingOk(loadModel){ 
  alert("モデルを読み込完了しました");
  return;
}

実行結果

著作権

p5.js was created by Lauren McCarthy and is developed by a community of collaborators, with support from the Processing Foundation and NYU ITP. Identity and graphic design by Jerel Johnson.

ライセンス

Creative Commons(CC BY-NC-SA 4.0) に従います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0