網上有很多關于pos機如何入門,THREEJS 使用入門的知識,也有很多人為大家解答關于pos機如何入門的問題,今天pos機之家(www.www690aa.com)為大家整理了關于這方面的知識,讓我們一起來看下吧!
本文目錄一覽:
1、pos機如何入門
pos機如何入門
1、THREEJS 官方網址: <u>https://threejs.org/。</u> threejs 通過封裝WEBGL API 實現了在網頁端直接進行三維3d模型渲染。應用場景包括:小游戲,在線展廳,DIY 互動等現代互聯網應用,極具發展前景。
2、官方使用案例https://threejs.org/examples/,可以直接套用。
webglmaterial.png
以 <u>https://github.com/mrdoob/three.js/blob/master/examples/webgl_materials.html</u> 為例,講解如何使用Threejs構建自己的應用:步驟一、新建html頁面。
<!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - materials</title> <meta charset="utf-8"> <meta name="viewport" content="width="360px",height="auto" />
script type="module"> import * as THREE from '../build/three.module.js'; //引入threejs 主框架 import Stats from './jsm/libs/stats.module.js'; //引入狀態幀計數狀態顯示 let stats; let camera, scene, renderer; let pointLight; const objects = [], materials = []; init(); animate(); function init() { const container = document.createElement( 'div' );//創建3d 場景所在的區域 document.body.appendChild( container ); camera = new THREE.PerspectiveCamera( 45, window.innerwidth="360px",height="auto" />requestAnimationFrame( animate );//這部分是關鍵,通過設置瀏覽器的動畫循環調用animate函數。保障畫面循環渲染。好比cpu的時鐘,一直在運轉。 render();//場景渲染,webgl 渲染實際工作內容。 stats.update(); } function render() { const timer = 0.0001 * Date.now(); camera.position.x = Math.cos( timer ) * 1000; camera.position.z = Math.sin( timer ) * 1000; camera.lookAt( scene.position ); for ( let i = 0, l = objects.length; i < l; i ++ ) { const object = objects[ i ]; object.rotation.x += 0.01; object.rotation.y += 0.005; } materials[ materials.length - 2 ].emissive.setHSL( 0.54, 1, 0.35 * ( 0.5 + 0.5 * Math.sin( 35 * timer ) ) ); materials[ materials.length - 3 ].emissive.setHSL( 0.04, 1, 0.35 * ( 0.5 + 0.5 * Math.cos( 35 * timer ) ) ); pointLight.position.x = Math.sin( timer * 7 ) * 300; pointLight.position.y = Math.cos( timer * 5 ) * 400; pointLight.position.z = Math.cos( timer * 3 ) * 300; renderer.render( scene, camera );//調用renderer引擎實際渲染場景scene,camera,后續另外再講場景渲染的數學模型。 } </script> </body> </html>3、如何在vue中引入THREEJS步驟一、新建threejs 組件,ZeusStage.vue
大畫家效果圖.jpg
<template> <div ref="container" > </div></template><script> import * as THREE from 'three' export default { name: 'ZeusStage', provide () { return { parentObj: null, // avoid "injection not found" warning _baseUrl: null, global: this.global } }, props: { size: { type: Object, // { w, h } required: false, default: function(){ return { w:100, h:100 } } }, scenejson:{ type: Object }, scene_url:{ type:String } }, data () { return { g_material_selected:'黃金', img_blend:'', popover_active: false, }; }, watch: { size(newval, oldval) { if (newval != oldval) { this.$refs.container.style.width="360px",height="auto" />
instanceof THREE.OrthographicCamera) { camera.left = dom.offsetwidth="360px",height="auto" />步驟二、調用ZeusStage.vue組件
<template> <div id="app"> <div class="container " style="background-image:url(images/background-3d.png)"> <ZeusStage ref="zeus_stage" :size="size" :scenejson="scenejson" :scene_url="scene_url"></ZeusStage> </div> </div></template><script>import ZeusStage from './components/ZeusStage.vue' export default { name: 'App', components: { ZeusStage }, mounted(){ var _this = this; function onresize(){ _this.size = { w: window.innerwidth="360px",height="auto" />
0人點贊
THREEJS web3d
以上就是關于pos機如何入門,THREEJS 使用入門的知識,后面我們會繼續為大家整理關于pos機如何入門的知識,希望能夠幫助到大家!
