{"id":449,"date":"2022-08-26T17:48:58","date_gmt":"2022-08-26T09:48:58","guid":{"rendered":"http:\/\/gjweb.top\/?p=449"},"modified":"2022-08-26T17:52:02","modified_gmt":"2022-08-26T09:52:02","slug":"03-rgb%e6%9d%90%e8%b4%a8%e7%ba%b9%e7%90%86","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=449","title":{"rendered":"03.RGB\u6750\u8d28\u7eb9\u7406"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"1-\u57fa\u672c\u4f7f\u7528\">1. \u57fa\u672c\u4f7f\u7528<\/h2>\n\n\n\n<p>\u4f7f\u7528 MeshStandardMaterial \u5b9e\u4f8b\u6e32\u67d3 RGB \u6750\u8d28<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u6dfb\u52a0\u73af\u5883\u5149<br>const light = new THREE.AmbientLight(\"#ffffff\")<br>scene.add(light)<br>\/\/ \u76f4\u7ebf\u5149<br>const directionalLinght = new THREE.DirectionalLight(\"#ffffff\",0.5)<br>directionalLinght.position.set(10,10,10)<br>scene.add(directionalLinght)<br>\/\/ \u7f6e\u6362\u8d34\u56fe<br>const doorHeightTexture = textureLoader.load(\"\/gltf\/Default_metalRoughness.jpg\")<br> &nbsp; &nbsp; &nbsp;<br>\/\/\u7c97\u7cd9\u7a0b\u5ea6<br>const roughnessTexture = textureLoader.load(\"\/gltf\/Default_metalRoughness.jpg\")<br>\u200b<br>\/\/ \u91d1\u5c5e\u8d34\u56fe<br>const metalnessTexture = textureLoader.load(\"\/gltf\/Default_albedo.jpg\")<br>\u200b<br>\/\/ \u6cd5\u7ebf\u8d34\u56fe<br>const bumpMap = textureLoader.load(\"\/gltf\/Default_albedo.jpg\")<br>\/\/ \u521b\u5efa\u51e0\u4f55\u4f53<br>const cubeGeometry = new THREE.BoxBufferGeometry(1,1,1,1)<br>\/\/ \u521b\u5efaRBG\u6750\u8d28<br>const standardMaterial = new THREE.MeshStandardMaterial({<br> &nbsp; &nbsp; &nbsp; &nbsp;color:\"#ffff00\",<br> &nbsp; &nbsp; &nbsp; &nbsp;map:doorColorTexture,<br> &nbsp; &nbsp; &nbsp; &nbsp;displacementMap:doorHeightTexture, \/\/ \u8fd9\u662f\u7f6e\u6362\u56fe\u7247<br> &nbsp; &nbsp; &nbsp; &nbsp;displacementScale:0.1, \/\/ \u8bbe\u7f6e\u7a81\u51fa\u7684\u7a0b\u5ea6<br> &nbsp; &nbsp; &nbsp; &nbsp;roughness:0, \/\/ \u5149\u6ed1\u7a0b\u5ea6<br> &nbsp; &nbsp; &nbsp; &nbsp;roughnessMap:roughnessTexture, \/\/ \u7c97\u7cd9\u7a0b\u5ea6<br> &nbsp; &nbsp; &nbsp; &nbsp;metalness:0.5, \/\/ \u91d1\u5c5e\u76f8\u4f3c\u7a0b\u5ea6<br> &nbsp; &nbsp; &nbsp; &nbsp;metalnessMap:metalnessTexture, \/\/ \u91d1\u5c5e\u8d34\u56fe<br> &nbsp; &nbsp; &nbsp; &nbsp;bumpMap:bumpMap, \/\/ \u6cd5\u7ebf\u8d34\u56fe<br>\u200b<br>})<br>cube = new THREE.Mesh(cubeGeometry,standardMaterial);<br>scene.add(cube)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2-\u7eb9\u7406\u52a0\u8f7d\u7ba1\u7406\u5668\">2. \u7eb9\u7406\u52a0\u8f7d\u7ba1\u7406\u5668<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>     &nbsp;\/\/ \u8bbe\u7f6e\u7eb9\u7406\u52a0\u8f7d\u7ba1\u7406\u5668<br> &nbsp; &nbsp; &nbsp;const loadingManager = new THREE.LoadingManager(<br> &nbsp; &nbsp; &nbsp;  ()=&gt;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(\"\u52a0\u8f7d\u5b8c\u6210\")<br> &nbsp; &nbsp; &nbsp;  },<br> &nbsp; &nbsp; &nbsp;  (url,num,total)=&gt;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(`\u5f53\u524d\u6b63\u5728\u52a0\u8f7d: ${url}; \u5f53\u524d\u52a0\u8f7d\u7b2c\u51e0\u4e2a: ${num} ; \u52a0\u8f7d\u7684\u603b\u6570: ${total}`)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(\"\u52a0\u8f7d\u603b\u8fdb\u5ea6:\",((num\/total)*100).toFixed(2)+\"%\")<br> &nbsp; &nbsp; &nbsp;  },<br> &nbsp; &nbsp; &nbsp;  ()=&gt;{<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;console.log(\"\u52a0\u8f7d\u62a5\u9519\")<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp; &nbsp;  )<br> &nbsp; &nbsp; &nbsp;\/\/ \u5bfc\u5165\u7eb9\u7406<br> &nbsp; &nbsp; &nbsp;const textureLoader = new THREE.TextureLoader(loadingManager);<br> &nbsp; &nbsp; &nbsp;const doorColorTexture = textureLoader.load(\"\/gltf\/Default_albedo.jpg\")<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-\u73af\u5883\u8d34\u56fe\">3. \u73af\u5883\u8d34\u56fe<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u5bfc\u5165\u73af\u5883\u8d34\u56fe<br>const cubeTextureLoader = new THREE.CubeTextureLoader(); &nbsp;<br>const envMapTexture = cubeTextureLoader.load(&#91;<br> &nbsp; &nbsp;\"\/vr\/px.jpg\",<br> &nbsp; &nbsp;\"\/vr\/nx.jpg\",<br> &nbsp; &nbsp;\"\/vr\/py.jpg\",<br> &nbsp; &nbsp;\"\/vr\/ny.jpg\",<br> &nbsp; &nbsp;\"\/vr\/pz.jpg\",<br> &nbsp; &nbsp;\"\/vr\/nz.jpg\"<br>])<br>\/\/ \u521b\u5efa\u7403\u4f53<br>const geometry &nbsp; = new THREE.SphereGeometry(1,20,20);<br>\/\/ \u8bbe\u7f6e\u6750\u8d28<br>const material = new THREE.MeshStandardMaterial({<br> &nbsp; metalness:0.7,<br> &nbsp; roughness:0.1,<br> &nbsp; \/\/ envMap:envMapTexture<br>})<br>\/\/ \u8bbe\u7f6e\u573a\u666f\u7684\u80cc\u666f<br>scene.background = envMapTexture;<br>\/\/ \u7ed9\u6240\u6709\u7684\u7269\u4f53\u6dfb\u52a0\u9ed8\u8ba4\u7684\u73af\u5883\u8d34\u56fe<br>scene.environment = envMapTexture;<br>cube = new THREE.Mesh(geometry,material);<br>scene.add(cube)<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"3-\u5bfc\u5165hbr\u8d34\u56fe\">3. \u5bfc\u5165HBR\u8d34\u56fe<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import {RGBELoader} from \"three\/examples\/jsm\/loaders\/RGBELoader\"<br>const rgbeLoader = new RGBELoader()<br>rgbeLoader.loadAsync(\"\/equirectangular\/blouberg_sunrise_2_1k.hdr\").then((texture)=&gt;{<br> &nbsp; &nbsp;texture.mapping = THREE.EquirectangularReflectionMapping; \/\/ hdr\u8bbe\u7f6e\u80cc\u666f\u56fe\u4e3aVR\u5168\u666f\u6548\u679c<br> &nbsp; &nbsp;scene.background = texture; \/\/ \u8bbe\u7f6e\u80cc\u666f\u989c\u8272<br> &nbsp; &nbsp;scene.environment = texture; \/\/ \u8bbe\u7f6e\u5176\u4ed6\u7269\u4f53\u53cd\u5149\u4e3a\u73af\u5883\u6750\u8d28<br>})<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u57fa\u672c\u4f7f\u7528 \u4f7f\u7528 MeshStandardMaterial \u5b9e\u4f8b\u6e32\u67d3 RGB \u6750\u8d28 2. \u7eb9\u7406\u52a0\u8f7d\u7ba1\u7406\u5668  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[],"class_list":["post-449","post","type-post","status-publish","format-standard","hentry","category-three"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=449"}],"version-history":[{"count":2,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/449\/revisions"}],"predecessor-version":[{"id":453,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/449\/revisions\/453"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}