瀏覽代碼

Improve Example (#26005)

* Improve example

* Update screenshot
WestLangley 2 年之前
父節點
當前提交
d6aaaa32bf
共有 2 個文件被更改,包括 27 次插入7 次删除
  1. 二進制
      examples/screenshots/webgl2_multisampled_renderbuffers.jpg
  2. 27 7
      examples/webgl2_multisampled_renderbuffers.html

二進制
examples/screenshots/webgl2_multisampled_renderbuffers.jpg


+ 27 - 7
examples/webgl2_multisampled_renderbuffers.html

@@ -55,13 +55,20 @@
 			import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
 			import { ShaderPass } from 'three/addons/postprocessing/ShaderPass.js';
 			import { CopyShader } from 'three/addons/shaders/CopyShader.js';
 			import { CopyShader } from 'three/addons/shaders/CopyShader.js';
 			import WebGL from 'three/addons/capabilities/WebGL.js';
 			import WebGL from 'three/addons/capabilities/WebGL.js';
+			import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
 
 
 			THREE.ColorManagement.enabled = false; // TODO: Consider enabling color management.
 			THREE.ColorManagement.enabled = false; // TODO: Consider enabling color management.
 
 
-			let camera, renderer, clock, group, container;
+			let camera, renderer, group, container;
 
 
 			let composer1, composer2;
 			let composer1, composer2;
 
 
+			const params = {
+
+				animate: true,
+
+			}
+
 			init();
 			init();
 
 
 			function init() {
 			function init() {
@@ -75,15 +82,13 @@
 
 
 				container = document.getElementById( 'container' );
 				container = document.getElementById( 'container' );
 
 
-				camera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 1, 2000 );
+				camera = new THREE.PerspectiveCamera( 45, container.offsetWidth / container.offsetHeight, 10, 2000 );
 				camera.position.z = 500;
 				camera.position.z = 500;
 
 
 				const scene = new THREE.Scene();
 				const scene = new THREE.Scene();
 				scene.background = new THREE.Color( 0xffffff );
 				scene.background = new THREE.Color( 0xffffff );
 				scene.fog = new THREE.Fog( 0xcccccc, 100, 1500 );
 				scene.fog = new THREE.Fog( 0xcccccc, 100, 1500 );
 
 
-				clock = new THREE.Clock();
-
 				//
 				//
 
 
 				const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x222222, 1.5 );
 				const hemiLight = new THREE.HemisphereLight( 0xffffff, 0x222222, 1.5 );
@@ -95,10 +100,16 @@
 				group = new THREE.Group();
 				group = new THREE.Group();
 
 
 				const geometry = new THREE.SphereGeometry( 10, 64, 40 );
 				const geometry = new THREE.SphereGeometry( 10, 64, 40 );
-				const material = new THREE.MeshLambertMaterial( { color: 0xee0808 } );
+				const material = new THREE.MeshLambertMaterial( {
+					color: 0xee0808,
+					polygonOffset: true,
+					polygonOffsetFactor: 1, // positive value pushes polygon further away
+					polygonOffsetUnits: 1
+
+				} );
 				const material2 = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
 				const material2 = new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true } );
 
 
-				for ( let i = 0; i < 10; i ++ ) {
+				for ( let i = 0; i < 50; i ++ ) {
 
 
 					const mesh = new THREE.Mesh( geometry, material );
 					const mesh = new THREE.Mesh( geometry, material );
 					mesh.position.x = Math.random() * 600 - 300;
 					mesh.position.x = Math.random() * 600 - 300;
@@ -149,6 +160,11 @@
 
 
 				//
 				//
 
 
+				const gui = new GUI();
+				gui.add( params, 'animate' );
+
+				//
+
 				window.addEventListener( 'resize', onWindowResize );
 				window.addEventListener( 'resize', onWindowResize );
 
 
 				animate();
 				animate();
@@ -172,7 +188,11 @@
 
 
 				const halfWidth = container.offsetWidth / 2;
 				const halfWidth = container.offsetWidth / 2;
 
 
-				group.rotation.y += clock.getDelta() * 0.1;
+				if ( params.animate ) {
+
+					group.rotation.y += 0.002;
+
+				}
 
 
 				renderer.setScissorTest( true );
 				renderer.setScissorTest( true );