国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

動漫做h在線觀看網站b2b模式的電商平臺有哪些

動漫做h在線觀看網站,b2b模式的電商平臺有哪些,我的網站360搜索被做跳轉,線上營銷技巧和營銷方法個人簡介 👀個人主頁: 前端雜貨鋪 🙋?♂?學習方向: 主攻前端方向,正逐漸往全干發(fā)展 📃個人狀態(tài): 研發(fā)工程師,現效力于中國工業(yè)軟件事業(yè) 🚀人生格言: 積跬步…

個人簡介

👀個人主頁: 前端雜貨鋪
🙋?♂?學習方向: 主攻前端方向,正逐漸往全干發(fā)展
📃個人狀態(tài): 研發(fā)工程師,現效力于中國工業(yè)軟件事業(yè)
🚀人生格言: 積跬步至千里,積小流成江海
🥇推薦學習:🍍前端面試寶典 🍉Vue2 🍋Vue3 🍓Vue2/3項目實戰(zhàn) 🥝Node.js🍒Three.js🍖數據結構與算法體系教程

🌕個人推廣:每篇文章最下方都有加入方式,旨在交流學習&資源分享,快加入進來吧

內容參考鏈接
WebGL專欄WebGL 入門
Three.js(一)創(chuàng)建場景、渲染三維對象、添加燈光、添加陰影、添加霧化

文章目錄

    • 前言
    • 一、scene 場景
    • 二、幾何體位置、旋轉、縮放
    • 三、正射投影相機
    • 四、透視投影相機
    • 總結

前言

大家好,這里是前端雜貨鋪。

上篇文章我們學習了 創(chuàng)建場景、渲染三維對象、添加燈光、添加陰影、添加霧化,接下來繼續(xù)我們 three.js 的學習!

在學習的過程中,如若需要深入了解或擴展某些知識,可以自行查閱 => three.js官方文檔


一、scene 場景

在上篇文章中,我們已經使用過它,scene 場景能夠讓我們在什么地方、擺放什么東西來交給 three.js 來渲染,這是我們放置物體、燈光和攝像機的地方。

接下來,我們熟悉幾個 scene 的常用 方法和屬性

方法名用途
add()向場景中添加對象
getObjectByName()通過命名獲取對象
remove()從場景中移除對象
屬性名用途
children返回場景中所有對象的列表
fog設置場景中的霧化效果
overrideMaterial強制場景中所有對象使用相同材質

下面代碼的場景中,我們添加了兩個物體:立方體和球體。

我們使用 getObjectByName() 方法實現獲取球體并放大球體為原來的兩倍。使用 remove 方法移除了球體。

我們使用 chidren 屬性查看場景中的對象列表(由于我們刪除了球體,所有只有立方體和聚光燈)。使用 fog 屬性在場景中添加霧化效果。使用 overrideMaterial 強制場景中所有對象使用同一材質。

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><script src="../lib/three/three.js"></script><style>* {margin: 0;padding: 0;}</style>
</head><body><script>// 創(chuàng)建場景const scene = new THREE.Scene();// 創(chuàng)建相機 視野角度FOV、長寬比、近截面、遠截面const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000);// 設置相機位置camera.position.set(0, 0, 20);// 創(chuàng)建渲染器const renderer = new THREE.WebGLRenderer();// 設置渲染器尺寸renderer.setSize(window.innerWidth, window.innerHeight);document.body.appendChild(renderer.domElement);// 添加立方體const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);// 創(chuàng)建立方體材質const cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000,wireframe: false});const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);// 添加到場景scene.add(cube);// 添加球體const sphereGeometry = new THREE.SphereGeometry(1, 10, 10);// 創(chuàng)建球體材質const sphereMatrial = new THREE.MeshBasicMaterial({color: 0x00ff00,wireframe: true})const sphere = new THREE.Mesh(sphereGeometry, sphereMatrial);// 給球體命名sphere.name = 'sphere';// 添加到場景scene.add(sphere);// 通過命名放大球體為原來的兩倍scene.getObjectByName("sphere").scale.set(2, 2, 2);// 添加燈光const spotLight = new THREE.SpotLight(0xffffff);spotLight.position.set(-10, 10, 10);scene.add(spotLight);// 查看場景中所有對象列表console.log(scene.children);// 設置場景中的霧化效果scene.fog = new THREE.Fog(0xffffff, 1, 50);// 移除立方體scene.remove(sphere);// 強制場景中所有對象使用相同材質scene.overrideMaterial = new THREE.MeshLambertMaterial({ color: 0xff0000});const animation = () => {cube.rotation.x += 0.01;cube.rotation.y += 0.01;sphere.rotation.x += 0.01;sphere.rotation.y += 0.01;// 渲染renderer.render(scene, camera);requestAnimationFrame(animation);}animation();</script>
</body></html>

在這里插入圖片描述


二、幾何體位置、旋轉、縮放

position 控制物體的位置、rotation 控制物體的旋轉、scale 控制物體的縮放。

下面的代碼,我們使用 單個賦值方法賦值 的方式來操作幾何體。

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><script src="../lib/three/three.js"></script><style>* {margin: 0;padding: 0;}</style>
</head><body><script>// 創(chuàng)建場景const scene = new THREE.Scene();// 創(chuàng)建相機 視野角度FOV、長寬比、近截面、遠截面const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000);// 設置相機位置camera.position.set(0, 0, 20);// 創(chuàng)建渲染器const renderer = new THREE.WebGLRenderer();// 設置渲染器尺寸renderer.setSize(window.innerWidth, window.innerHeight);document.body.appendChild(renderer.domElement);// 添加立方體const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);// 創(chuàng)建立方體材質const cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000,wireframe: false});const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);// 單個賦值 效果同下// // 位置 x => 3// cube.position.x = 3;// // 旋轉 45 度// cube.rotation.x = 0.125 * Math.PI;// cube.rotation.y = 0.125 * Math.PI;// cube.rotation.z = 0.125 * Math.PI;// // x 放大 2 倍// cube.scale.x = 2;// 通過方法賦值cube.position.set(3, 0, 0);cube.rotation.set(0.125 * Math.PI, 0.125 * Math.PI, 0.125 * Math.PI);cube.scale.set(2, 1, 1);// 添加到場景scene.add(cube);// 渲染renderer.render(scene, camera);</script>
</body></html>

在這里插入圖片描述


三、正射投影相機

正射投影相機 new THREE.OrthographicCamera(渲染的圖片中物體的大小都保持不變),它接收六個參數:

  1. left:左邊界
  2. right:右邊界
  3. top:上邊界
  4. bottom:下邊界
  5. near:近面
  6. far:遠面
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><script src="../lib/three/three.js"></script><style>* {margin: 0;padding: 0;}</style>
</head><body><script>// 創(chuàng)建場景const scene = new THREE.Scene();// 正射投影相機const camera = new THREE.OrthographicCamera(-10, 10, 10, -10, 1, 1000)// 設置相機位置camera.position.set(0, 0, 20);// 創(chuàng)建渲染器const renderer = new THREE.WebGLRenderer();// 設置渲染器尺寸renderer.setSize(window.innerWidth, window.innerHeight);document.body.appendChild(renderer.domElement);// 添加立方體const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);// 創(chuàng)建立方體材質const cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000,wireframe: false});const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);cube.rotation.set(0.125 * Math.PI, 0.125 * Math.PI, 0.125 * Math.PI);// 添加到場景scene.add(cube);// 渲染renderer.render(scene, camera);</script>
</body></html>

在這里插入圖片描述


四、透視投影相機

正射投影相機 new THREE.PerspectiveCamera (用來模擬人眼所看到的景象,近大遠小),它接收四個參數:

  1. fov:視角
  2. aspect:寬高比
  3. near:近面
  4. far:遠面
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><script src="../lib/three/three.js"></script><style>* {margin: 0;padding: 0;}</style>
</head><body><script>// 創(chuàng)建場景const scene = new THREE.Scene();// 透視投影相機 視野角度FOV、長寬比、近截面、遠截面const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 1000);// 設置相機位置camera.position.set(0, 0, 20);// 創(chuàng)建渲染器const renderer = new THREE.WebGLRenderer();// 設置渲染器尺寸renderer.setSize(window.innerWidth, window.innerHeight);document.body.appendChild(renderer.domElement);// 添加立方體const cubeGeometry = new THREE.BoxGeometry(2, 2, 2);// 創(chuàng)建立方體材質const cubeMaterial = new THREE.MeshBasicMaterial({color: 0xff0000,wireframe: false});const cube = new THREE.Mesh(cubeGeometry, cubeMaterial);cube.rotation.set(0.125 * Math.PI, 0.125 * Math.PI, 0.125 * Math.PI);// 添加到場景scene.add(cube);// 渲染renderer.render(scene, camera);</script>
</body></html>

在這里插入圖片描述


總結

本篇文章我們熟悉了scene場景的一些方法和屬性的使用,認識了如何對幾何體進行位置、選擇和縮放的操作,并簡單了解了正射投影相機和透視投影相機。

更多內容擴展請大家自行查閱 => three.js官方文檔,真心推薦讀一讀!!

好啦,本篇文章到這里就要和大家說再見啦,祝你這篇文章閱讀愉快,你下篇文章的閱讀愉快留著我下篇文章再祝!


參考資料:

  1. Three.js 官方文檔
  2. WebGL+Three.js 入門與實戰(zhàn)【作者:慕課網_yancy】

在這里插入圖片描述


http://aloenet.com.cn/news/46064.html

相關文章:

  • 創(chuàng)業(yè)初期要建立公司的網站嗎鄭州百度關鍵詞seo
  • 網站大屏輪播圖效果怎么做公眾號排名優(yōu)化軟件
  • 怎樣做永久網站二維碼北京seo公司有哪些
  • 網站做線上銷售蘇州百度關鍵詞優(yōu)化
  • wordpress兼職sem seo
  • 精品網站建設平臺如何自己免費制作網站
  • 哈爾濱網站建設外包公司申請自媒體平臺注冊
  • 網站建設銷售問答品牌營銷是什么
  • ps 怎么做網站杭州網站定制
  • win7 iis創(chuàng)建網站網絡推廣營銷網
  • 重慶網站建設吧營銷型網站
  • 自己制作的網站怎么做分頁今日時事新聞
  • 寧波網站建設的企業(yè)太原今日頭條
  • 百度推廣做網站什么價位網站開發(fā)流程的8個步驟
  • asp網站vps搬家2024年重大新聞簡短
  • 武漢做網站找哪家好世界球隊最新排名榜
  • 杭州未來科技網站建設高端建站
  • 企業(yè)信用網查詢網站優(yōu)化推廣培訓
  • 建甌網站制作百度網站怎么提升排名
  • 自己做產品品牌網站谷歌官網網址
  • 杭州富陽區(qū)網站建設公司seo排名軟件有用嗎
  • 鄭州響應式網站建設如何找外包的銷售團隊
  • 網絡工作室頭像seo積分優(yōu)化
  • 用flash做的網站展示品牌策劃方案模板
  • 網站二級域名 權重 盧松松學seo網絡推廣
  • 國內醫(yī)療美容網站建設培訓機構不退費最有效方式
  • 電子書推送網站怎么做會計培訓班
  • 政府采購網站的建設情況bing收錄提交
  • 個人博客網站開發(fā)的原因鄭州seo排名優(yōu)化公司
  • flash 做ppt的模板下載網站北京seo招聘信息