如何在 HTML5 中繪製 3D 球體?


要建立一個 3D 球體,請使用 HTML5 畫布。你可以在程式碼中使用以下函式

function display(r) {
   this.point = new Array();
   this.color = "blue)"
   this.r = (typeof(r) == "undefined") ? 20.0 : r;
   this.r = (typeof(r) != "number") ? 20.0 : r;
   this.vertexes = 0;

   for(alpha = 0; alpha <= 6.28; alpha += 0.17) {
      p = this.point[this. vertexes] = new Point3D();
      p.x = Math.cos(alpha) * this.r;
      p.y = 0;
      p.z = Math.sin(alpha) * this.r;
      this.vertexes ++;
   }
}

更新於: 2020 年 6 月 25 日

601 次瀏覽

開啟你的 職業生涯

完成課程,獲得認證

開始
廣告
© . All rights reserved.