|  | 
| 26 | 26 | 		<a id='newWindow' href='./material-browser.html' target='_blank'>Open in New Window</a> | 
| 27 | 27 | 
 | 
| 28 | 28 | 		<script type="module"> | 
| 29 |  | -			import { | 
| 30 |  | -				AdditiveBlending, CustomBlending, MultiplyBlending, NormalBlending, NoBlending, SubtractiveBlending, | 
| 31 |  | -				AddEquation, ReverseSubtractEquation, SubtractEquation, | 
| 32 |  | -				AddOperation, MixOperation, MultiplyOperation, | 
| 33 |  | -				AmbientLight, | 
| 34 |  | -				Color, | 
| 35 |  | -				CubeTextureLoader, | 
| 36 |  | -				CubeRefractionMapping, | 
| 37 |  | -				DoubleSide, FrontSide, BackSide, | 
| 38 |  | -				DstAlphaFactor, DstColorFactor, OneFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, ZeroFactor, | 
| 39 |  | -				Float32BufferAttribute, | 
| 40 |  | -				Fog, | 
| 41 |  | -				LineBasicMaterial, | 
| 42 |  | -				Mesh, | 
| 43 |  | -				MeshBasicMaterial, | 
| 44 |  | -				MeshDepthMaterial, | 
| 45 |  | -				MeshLambertMaterial, | 
| 46 |  | -				MeshMatcapMaterial, | 
| 47 |  | -				MeshNormalMaterial, | 
| 48 |  | -				MeshPhongMaterial, | 
| 49 |  | -				MeshPhysicalMaterial, | 
| 50 |  | -				MeshStandardMaterial, | 
| 51 |  | -				MeshToonMaterial, | 
| 52 |  | -				NearestFilter, | 
| 53 |  | -				PerspectiveCamera, | 
| 54 |  | -				PointLight, | 
| 55 |  | -				RepeatWrapping, | 
| 56 |  | -				RGBFormat, | 
| 57 |  | -				Scene, | 
| 58 |  | -				TextureLoader, | 
| 59 |  | -				TorusKnotGeometry, | 
| 60 |  | -				WebGLRenderer | 
| 61 |  | -			} from "../../build/three.module.js"; | 
| 62 |  | - | 
| 63 |  | -			import { GUI } from '../../examples/jsm/libs/dat.gui.module.js'; | 
|  | 29 | + | 
|  | 30 | +			import * as THREE from '../../build/three.module.js'; | 
|  | 31 | +			import * as DAT from '../../examples/jsm/libs/dat.gui.module.js'; | 
| 64 | 32 | 
 | 
| 65 | 33 | 			const constants = { | 
| 66 | 34 | 
 | 
| 67 | 35 | 				combine: { | 
| 68 | 36 | 
 | 
| 69 |  | -					'THREE.MultiplyOperation': MultiplyOperation, | 
| 70 |  | -					'THREE.MixOperation': MixOperation, | 
| 71 |  | -					'THREE.AddOperation': AddOperation | 
|  | 37 | +					'THREE.MultiplyOperation': THREE.MultiplyOperation, | 
|  | 38 | +					'THREE.MixOperation': THREE.MixOperation, | 
|  | 39 | +					'THREE.AddOperation': THREE.AddOperation | 
| 72 | 40 | 
 | 
| 73 | 41 | 				}, | 
| 74 | 42 | 
 | 
| 75 | 43 | 				side: { | 
| 76 | 44 | 
 | 
| 77 |  | -					'THREE.FrontSide': FrontSide, | 
| 78 |  | -					'THREE.BackSide': BackSide, | 
| 79 |  | -					'THREE.DoubleSide': DoubleSide | 
|  | 45 | +					'THREE.FrontSide': THREE.FrontSide, | 
|  | 46 | +					'THREE.BackSide': THREE.BackSide, | 
|  | 47 | +					'THREE.DoubleSide': THREE.DoubleSide | 
| 80 | 48 | 
 | 
| 81 | 49 | 				}, | 
| 82 | 50 | 
 | 
| 83 | 51 | 				blendingMode: { | 
| 84 | 52 | 
 | 
| 85 |  | -					'THREE.NoBlending': NoBlending, | 
| 86 |  | -					'THREE.NormalBlending': NormalBlending, | 
| 87 |  | -					'THREE.AdditiveBlending': AdditiveBlending, | 
| 88 |  | -					'THREE.SubtractiveBlending': SubtractiveBlending, | 
| 89 |  | -					'THREE.MultiplyBlending': MultiplyBlending, | 
| 90 |  | -					'THREE.CustomBlending': CustomBlending | 
|  | 53 | +					'THREE.NoBlending': THREE.NoBlending, | 
|  | 54 | +					'THREE.NormalBlending': THREE.NormalBlending, | 
|  | 55 | +					'THREE.AdditiveBlending': THREE.AdditiveBlending, | 
|  | 56 | +					'THREE.SubtractiveBlending': THREE.SubtractiveBlending, | 
|  | 57 | +					'THREE.MultiplyBlending': THREE.MultiplyBlending, | 
|  | 58 | +					'THREE.CustomBlending': THREE.CustomBlending | 
| 91 | 59 | 
 | 
| 92 | 60 | 				}, | 
| 93 | 61 | 
 | 
| 94 | 62 | 				equations: { | 
| 95 | 63 | 
 | 
| 96 |  | -					'THREE.AddEquation': AddEquation, | 
| 97 |  | -					'THREE.SubtractEquation': SubtractEquation, | 
| 98 |  | -					'THREE.ReverseSubtractEquation': ReverseSubtractEquation | 
|  | 64 | +					'THREE.AddEquation': THREE.AddEquation, | 
|  | 65 | +					'THREE.SubtractEquation': THREE.SubtractEquation, | 
|  | 66 | +					'THREE.ReverseSubtractEquation': THREE.ReverseSubtractEquation | 
| 99 | 67 | 
 | 
| 100 | 68 | 				}, | 
| 101 | 69 | 
 | 
| 102 | 70 | 				destinationFactors: { | 
| 103 | 71 | 
 | 
| 104 |  | -					'THREE.ZeroFactor': ZeroFactor, | 
| 105 |  | -					'THREE.OneFactor': OneFactor, | 
| 106 |  | -					'THREE.SrcColorFactor': SrcColorFactor, | 
| 107 |  | -					'THREE.OneMinusSrcColorFactor': OneMinusSrcColorFactor, | 
| 108 |  | -					'THREE.SrcAlphaFactor': SrcAlphaFactor, | 
| 109 |  | -					'THREE.OneMinusSrcAlphaFactor': OneMinusSrcAlphaFactor, | 
| 110 |  | -					'THREE.DstAlphaFactor': DstAlphaFactor, | 
| 111 |  | -					'THREE.OneMinusDstAlphaFactor': OneMinusDstAlphaFactor | 
|  | 72 | +					'THREE.ZeroFactor': THREE.ZeroFactor, | 
|  | 73 | +					'THREE.OneFactor': THREE.OneFactor, | 
|  | 74 | +					'THREE.SrcColorFactor': THREE.SrcColorFactor, | 
|  | 75 | +					'THREE.OneMinusSrcColorFactor': THREE.OneMinusSrcColorFactor, | 
|  | 76 | +					'THREE.SrcAlphaFactor': THREE.SrcAlphaFactor, | 
|  | 77 | +					'THREE.OneMinusSrcAlphaFactor': THREE.OneMinusSrcAlphaFactor, | 
|  | 78 | +					'THREE.DstAlphaFactor': THREE.DstAlphaFactor, | 
|  | 79 | +					'THREE.OneMinusDstAlphaFactor': THREE.OneMinusDstAlphaFactor | 
| 112 | 80 | 
 | 
| 113 | 81 | 				}, | 
| 114 | 82 | 
 | 
| 115 | 83 | 				sourceFactors: { | 
| 116 | 84 | 
 | 
| 117 |  | -					'THREE.DstColorFactor': DstColorFactor, | 
| 118 |  | -					'THREE.OneMinusDstColorFactor': OneMinusDstColorFactor, | 
| 119 |  | -					'THREE.SrcAlphaSaturateFactor': SrcAlphaSaturateFactor | 
|  | 85 | +					'THREE.DstColorFactor': THREE.DstColorFactor, | 
|  | 86 | +					'THREE.OneMinusDstColorFactor': THREE.OneMinusDstColorFactor, | 
|  | 87 | +					'THREE.SrcAlphaSaturateFactor': THREE.SrcAlphaSaturateFactor | 
| 120 | 88 | 
 | 
| 121 | 89 | 				} | 
| 122 | 90 | 
 | 
|  | 
| 140 | 108 | 
 | 
| 141 | 109 | 			} | 
| 142 | 110 | 
 | 
| 143 |  | -			const textureLoader = new TextureLoader(); | 
| 144 |  | -			const cubeTextureLoader = new CubeTextureLoader(); | 
|  | 111 | +			const textureLoader = new THREE.TextureLoader(); | 
|  | 112 | +			const cubeTextureLoader = new THREE.CubeTextureLoader(); | 
| 145 | 113 | 
 | 
| 146 | 114 | 			const envMaps = ( function () { | 
| 147 | 115 | 
 | 
|  | 
| 154 | 122 | 				]; | 
| 155 | 123 | 
 | 
| 156 | 124 | 				const reflectionCube = cubeTextureLoader.load( urls ); | 
| 157 |  | -				reflectionCube.format = RGBFormat; | 
|  | 125 | +				reflectionCube.format = THREE.RGBFormat; | 
| 158 | 126 | 
 | 
| 159 | 127 | 				const refractionCube = cubeTextureLoader.load( urls ); | 
| 160 |  | -				refractionCube.mapping = CubeRefractionMapping; | 
| 161 |  | -				refractionCube.format = RGBFormat; | 
|  | 128 | +				refractionCube.mapping = THREE.CubeRefractionMapping; | 
|  | 129 | +				refractionCube.format = THREE.RGBFormat; | 
| 162 | 130 | 
 | 
| 163 | 131 | 				return { | 
| 164 | 132 | 					none: null, | 
|  | 
| 171 | 139 | 			const diffuseMaps = ( function () { | 
| 172 | 140 | 
 | 
| 173 | 141 | 				const bricks = textureLoader.load( '../../examples/textures/brick_diffuse.jpg' ); | 
| 174 |  | -				bricks.wrapS = RepeatWrapping; | 
| 175 |  | -				bricks.wrapT = RepeatWrapping; | 
|  | 142 | +				bricks.wrapS = THREE.RepeatWrapping; | 
|  | 143 | +				bricks.wrapT = THREE.RepeatWrapping; | 
| 176 | 144 | 				bricks.repeat.set( 9, 1 ); | 
| 177 | 145 | 
 | 
| 178 | 146 | 				return { | 
|  | 
| 185 | 153 | 			const roughnessMaps = ( function () { | 
| 186 | 154 | 
 | 
| 187 | 155 | 				const bricks = textureLoader.load( '../../examples/textures/brick_roughness.jpg' ); | 
| 188 |  | -				bricks.wrapT = RepeatWrapping; | 
| 189 |  | -				bricks.wrapS = RepeatWrapping; | 
|  | 156 | +				bricks.wrapT = THREE.RepeatWrapping; | 
|  | 157 | +				bricks.wrapS = THREE.RepeatWrapping; | 
| 190 | 158 | 				bricks.repeat.set( 9, 1 ); | 
| 191 | 159 | 
 | 
| 192 | 160 | 				return { | 
|  | 
| 208 | 176 | 			const alphaMaps = ( function () { | 
| 209 | 177 | 
 | 
| 210 | 178 | 				const fibers = textureLoader.load( '../../examples/textures/alphaMap.jpg' ); | 
| 211 |  | -				fibers.wrapT = RepeatWrapping; | 
| 212 |  | -				fibers.wrapS = RepeatWrapping; | 
|  | 179 | +				fibers.wrapT = THREE.RepeatWrapping; | 
|  | 180 | +				fibers.wrapS = THREE.RepeatWrapping; | 
| 213 | 181 | 				fibers.repeat.set( 9, 1 ); | 
| 214 | 182 | 
 | 
| 215 | 183 | 				return { | 
|  | 
| 222 | 190 | 			const gradientMaps = ( function () { | 
| 223 | 191 | 
 | 
| 224 | 192 | 				const threeTone = textureLoader.load( '../../examples/textures/gradientMaps/threeTone.jpg' ); | 
| 225 |  | -				threeTone.minFilter = NearestFilter; | 
| 226 |  | -				threeTone.magFilter = NearestFilter; | 
|  | 193 | +				threeTone.minFilter = THREE.NearestFilter; | 
|  | 194 | +				threeTone.magFilter = THREE.NearestFilter; | 
| 227 | 195 | 
 | 
| 228 | 196 | 				const fiveTone = textureLoader.load( '../../examples/textures/gradientMaps/fiveTone.jpg' ); | 
| 229 |  | -				fiveTone.minFilter = NearestFilter; | 
| 230 |  | -				fiveTone.magFilter = NearestFilter; | 
|  | 197 | +				fiveTone.minFilter = THREE.NearestFilter; | 
|  | 198 | +				fiveTone.magFilter = THREE.NearestFilter; | 
| 231 | 199 | 
 | 
| 232 | 200 | 				return { | 
| 233 | 201 | 					none: null, | 
|  | 
| 249 | 217 | 				const positionAttribute = geometry.attributes.position; | 
| 250 | 218 | 
 | 
| 251 | 219 | 				const colors = []; | 
| 252 |  | -				const color = new Color(); | 
|  | 220 | +				const color = new THREE.Color(); | 
| 253 | 221 | 
 | 
| 254 | 222 | 				for ( let i = 0, il = positionAttribute.count; i < il; i ++ ) { | 
| 255 | 223 | 
 | 
|  | 
| 258 | 226 | 
 | 
| 259 | 227 | 				} | 
| 260 | 228 | 
 | 
| 261 |  | -				geometry.setAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); | 
|  | 229 | +				geometry.setAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); | 
| 262 | 230 | 
 | 
| 263 | 231 | 			} | 
| 264 | 232 | 
 | 
|  | 
| 334 | 302 | 
 | 
| 335 | 303 | 				const fogFolder = folder.addFolder( 'scene.fog' ); | 
| 336 | 304 | 
 | 
| 337 |  | -				const fog = new Fog( 0x3f7b9d, 0, 60 ); | 
|  | 305 | +				const fog = new THREE.Fog( 0x3f7b9d, 0, 60 ); | 
| 338 | 306 | 
 | 
| 339 | 307 | 				const data = { | 
| 340 | 308 | 					fog: { | 
|  | 
| 623 | 591 | 
 | 
| 624 | 592 | 					case 'MeshBasicMaterial' : | 
| 625 | 593 | 
 | 
| 626 |  | -						material = new MeshBasicMaterial( { color: 0x2194CE } ); | 
|  | 594 | +						material = new THREE.MeshBasicMaterial( { color: 0x2194CE } ); | 
| 627 | 595 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 628 | 596 | 						guiMeshBasicMaterial( gui, mesh, material, geometry ); | 
| 629 | 597 | 
 | 
|  | 
| 633 | 601 | 
 | 
| 634 | 602 | 					case 'MeshLambertMaterial' : | 
| 635 | 603 | 
 | 
| 636 |  | -						material = new MeshLambertMaterial( { color: 0x2194CE } ); | 
|  | 604 | +						material = new THREE.MeshLambertMaterial( { color: 0x2194CE } ); | 
| 637 | 605 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 638 | 606 | 						guiMeshLambertMaterial( gui, mesh, material, geometry ); | 
| 639 | 607 | 
 | 
|  | 
| 643 | 611 | 
 | 
| 644 | 612 | 					case 'MeshMatcapMaterial' : | 
| 645 | 613 | 
 | 
| 646 |  | -						material = new MeshMatcapMaterial( { matcap: matcaps.porcelainWhite } ); | 
|  | 614 | +						material = new THREE.MeshMatcapMaterial( { matcap: matcaps.porcelainWhite } ); | 
| 647 | 615 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 648 | 616 | 						guiMeshMatcapMaterial( gui, mesh, material, geometry ); | 
| 649 | 617 | 
 | 
|  | 
| 653 | 621 | 
 | 
| 654 | 622 | 					case 'MeshPhongMaterial' : | 
| 655 | 623 | 
 | 
| 656 |  | -						material = new MeshPhongMaterial( { color: 0x2194CE } ); | 
|  | 624 | +						material = new THREE.MeshPhongMaterial( { color: 0x2194CE } ); | 
| 657 | 625 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 658 | 626 | 						guiMeshPhongMaterial( gui, mesh, material, geometry ); | 
| 659 | 627 | 
 | 
|  | 
| 663 | 631 | 
 | 
| 664 | 632 | 					case 'MeshToonMaterial' : | 
| 665 | 633 | 
 | 
| 666 |  | -						material = new MeshToonMaterial( { color: 0x2194CE, gradientMap: gradientMaps.threeTone } ); | 
|  | 634 | +						material = new THREE.MeshToonMaterial( { color: 0x2194CE, gradientMap: gradientMaps.threeTone } ); | 
| 667 | 635 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 668 | 636 | 						guiMeshToonMaterial( gui, mesh, material, geometry ); | 
| 669 | 637 | 
 | 
|  | 
| 678 | 646 | 
 | 
| 679 | 647 | 					case 'MeshStandardMaterial' : | 
| 680 | 648 | 
 | 
| 681 |  | -						material = new MeshStandardMaterial( { color: 0x2194CE } ); | 
|  | 649 | +						material = new THREE.MeshStandardMaterial( { color: 0x2194CE } ); | 
| 682 | 650 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 683 | 651 | 						guiMeshStandardMaterial( gui, mesh, material, geometry ); | 
| 684 | 652 | 
 | 
|  | 
| 688 | 656 | 
 | 
| 689 | 657 | 					case 'MeshPhysicalMaterial' : | 
| 690 | 658 | 
 | 
| 691 |  | -						material = new MeshPhysicalMaterial( { color: 0x2194CE } ); | 
|  | 659 | +						material = new THREE.MeshPhysicalMaterial( { color: 0x2194CE } ); | 
| 692 | 660 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 693 | 661 | 						guiMeshPhysicalMaterial( gui, mesh, material, geometry ); | 
| 694 | 662 | 
 | 
|  | 
| 698 | 666 | 
 | 
| 699 | 667 | 					case 'MeshDepthMaterial' : | 
| 700 | 668 | 
 | 
| 701 |  | -						material = new MeshDepthMaterial(); | 
|  | 669 | +						material = new THREE.MeshDepthMaterial(); | 
| 702 | 670 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 703 | 671 | 						guiMeshDepthMaterial( gui, mesh, material, geometry ); | 
| 704 | 672 | 
 | 
|  | 
| 708 | 676 | 
 | 
| 709 | 677 | 					case 'MeshNormalMaterial' : | 
| 710 | 678 | 
 | 
| 711 |  | -						material = new MeshNormalMaterial(); | 
|  | 679 | +						material = new THREE.MeshNormalMaterial(); | 
| 712 | 680 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 713 | 681 | 						guiMeshNormalMaterial( gui, mesh, material, geometry ); | 
| 714 | 682 | 
 | 
|  | 
| 718 | 686 | 
 | 
| 719 | 687 | 					case 'LineBasicMaterial' : | 
| 720 | 688 | 
 | 
| 721 |  | -						material = new LineBasicMaterial( { color: 0x2194CE } ); | 
|  | 689 | +						material = new THREE.LineBasicMaterial( { color: 0x2194CE } ); | 
| 722 | 690 | 						guiMaterial( gui, mesh, material, geometry ); | 
| 723 | 691 | 						guiLineBasicMaterial( gui, mesh, material, geometry ); | 
| 724 | 692 | 
 | 
|  | 
| 734 | 702 | 
 | 
| 735 | 703 | 			document.getElementById( 'newWindow' ).href += window.location.hash; | 
| 736 | 704 | 
 | 
| 737 |  | -			const gui = new GUI(); | 
|  | 705 | +			const gui = new DAT.GUI(); | 
| 738 | 706 | 
 | 
| 739 |  | -			const scene = new Scene(); | 
| 740 |  | -			scene.background = new Color( 0x444444 ); | 
|  | 707 | +			const scene = new THREE.Scene(); | 
|  | 708 | +			scene.background = new THREE.Color( 0x444444 ); | 
| 741 | 709 | 
 | 
| 742 |  | -			const camera = new PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 10, 50 ); | 
|  | 710 | +			const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 10, 50 ); | 
| 743 | 711 | 			camera.position.z = 30; | 
| 744 | 712 | 
 | 
| 745 |  | -			const renderer = new WebGLRenderer( { antialias: true } ); | 
|  | 713 | +			const renderer = new THREE.WebGLRenderer( { antialias: true } ); | 
| 746 | 714 | 			renderer.setPixelRatio( window.devicePixelRatio ); | 
| 747 | 715 | 			renderer.setSize( window.innerWidth, window.innerHeight ); | 
| 748 | 716 | 			document.body.appendChild( renderer.domElement ); | 
| 749 | 717 | 
 | 
| 750 |  | -			const ambientLight = new AmbientLight( 0x000000 ); | 
|  | 718 | +			const ambientLight = new THREE.AmbientLight( 0x000000 ); | 
| 751 | 719 | 			scene.add( ambientLight ); | 
| 752 | 720 | 
 | 
| 753 | 721 | 			const lights = []; | 
| 754 |  | -			lights[ 0 ] = new PointLight( 0xffffff, 1, 0 ); | 
| 755 |  | -			lights[ 1 ] = new PointLight( 0xffffff, 1, 0 ); | 
| 756 |  | -			lights[ 2 ] = new PointLight( 0xffffff, 1, 0 ); | 
|  | 722 | +			lights[ 0 ] = new THREE.PointLight( 0xffffff, 1, 0 ); | 
|  | 723 | +			lights[ 1 ] = new THREE.PointLight( 0xffffff, 1, 0 ); | 
|  | 724 | +			lights[ 2 ] = new THREE.PointLight( 0xffffff, 1, 0 ); | 
| 757 | 725 | 
 | 
| 758 | 726 | 			lights[ 0 ].position.set( 0, 200, 0 ); | 
| 759 | 727 | 			lights[ 1 ].position.set( 100, 200, 100 ); | 
|  | 
| 765 | 733 | 
 | 
| 766 | 734 | 			guiScene( gui, scene, camera ); | 
| 767 | 735 | 
 | 
| 768 |  | -			let geometry = new TorusKnotGeometry( 10, 3, 100, 16 ); | 
|  | 736 | +			let geometry = new THREE.TorusKnotGeometry( 10, 3, 100, 16 ); | 
| 769 | 737 | 			geometry = geometry.toNonIndexed(); | 
| 770 | 738 | 
 | 
| 771 | 739 | 			generateVertexColors( geometry ); | 
| 772 | 740 | 
 | 
| 773 |  | -			const mesh = new Mesh( geometry ); | 
|  | 741 | +			const mesh = new THREE.Mesh( geometry ); | 
| 774 | 742 | 			mesh.material = chooseFromHash( gui, mesh, geometry ); | 
| 775 | 743 | 
 | 
| 776 | 744 | 			scene.add( mesh ); | 
|  | 
0 commit comments