threejs 引數化曲面

2021-09-10 02:44:10 字數 2352 閱讀 8944

參考: 

//建立場景物件

var scene = new three.scene();

// 平面

var plane = function(u, v, target)

// 旋轉拋物面 z = a2*(x2+y2)

var paraboloid = function(u,v, target)

var planegeometry = new three.parametricgeometry(plane, 10, 10);

//var planegeometry = new three.parametricgeometry(paraboloid, 10, 10);

var planematerial = new three.meshphongmaterial();

// 線條模式渲染

planematerial.wireframe = true;

var planemesh = new three.mesh(planegeometry, planematerial);

scene.add(planemesh);

// 旋轉造型

var points = [

new three.vector2(50,60),

new three.vector2(25,0),

new three.vector2(50,-60)

];var pointsgeometry = new three.lathegeometry(points, 30);

var pointsmaterial = new three.meshphongmaterial();

pointsmaterial.wireframe = true;

var pointsmesh = new three.mesh(pointsgeometry, pointsmaterial);

pointsmesh.translatex(300);

pointsmesh.translatey(150);

scene.add(pointsmesh);

var shape = new three.shape();

var points = [//定位定點

new three.vector2(50,60),

new three.vector2(25,0),

new three.vector2(50,-60)

];// 頂點帶入樣條插值計算函式

shape.splinethru(points);

// 插值計算細分數20

var splinepoints = shape.getpoints(20);

var splinegeometry = new three.lathegeometry(splinepoints, 30);

var splinematerial = new three.meshphongmaterial();

var splinemesh = new three.mesh(splinegeometry, splinematerial);

splinemesh.translatex(-300);

splinemesh.translatey(-200);

scene.add(splinemesh);

//環境光

var ambient=new three.ambientlight(0x444444);

scene.add(ambient);

var width = window.innerwidth;

var height = window.innerheight;

//視窗寬高比

var k = width / height;

//三維場景縮放係數

var s = 150;

//建立相機物件

var camera = new three.orthographiccamera(-s * k, s * k, s, -s, 1, 1000);

//設定相機位置

camera.position.set(200, 300, 200);

//設定相機方向(指向的場景物件)

camera.lookat(scene.position);

// 建立渲染器物件

var renderer = new three.webglrenderer();

renderer.setsize(width, height);

//設定背景顏色

renderer.setclearcolor(0xb9d3ff, 1);

//執行渲染操作

renderer.render(scene, camera);

曲面引數化定義

在計算機圖形學中,曲面資料報括兩方面 幾何資料結構和紋理資料結構。幾何資料結構一般是多面體三角網格,儲存為.obj m off stl等格式,表示曲面,可進行的幾何變換包括平移旋轉 射影變換等。紋理資料結構一般是平面影象,表示紋理資訊,如顏色 法向量場 區域性幾何細節鱗片結構 區域性材質特性brdf...

threejs燈光light引數

1.環境光ambientlight 環境光會均勻的照亮場景中的所有物體。var light new three.ambientlight 0x404040 1 白光,燈光強度為1 2.平行光directionallight 模擬遠處像太陽一樣的光源 var light new three.direc...

mysql 引數化 MySQL之sql引數化

奮鬥的路上,時間總是過得很快,目前的困難和麻煩是很多,但是只要不忘初心,腳踏實地一步一步的朝著目標前進,最後的結局交給時間來定奪。週末了,我們來說說一下,sql語句的引數化問題,為了避免sql注入的問題,我們把sql語句進行引數化,來增加資料庫的安全性。詞窮,先看看code吧!from mysqld...