| New file | 
|  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 地板 | 
|---|
|  |  |  | * @param option | 
|---|
|  |  |  | * @constructor | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | function Floor(option) { | 
|---|
|  |  |  | this.length = option.length || 5000; | 
|---|
|  |  |  | this.width = option.width || 5000; | 
|---|
|  |  |  | this.height = option.height || 1; | 
|---|
|  |  |  | this.Name = option.objName; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | this.positionX = option.position.x || 0; | 
|---|
|  |  |  | this.positionY = option.position.y || 0; | 
|---|
|  |  |  | this.positionZ = option.position.z || 0; | 
|---|
|  |  |  | this.style = option.style || {color: 0xFF0000}; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 材质 | 
|---|
|  |  |  | // var texture = null; | 
|---|
|  |  |  | // var material = new THREE.MeshPhongMaterial({map: texture, color: option.style.color}); | 
|---|
|  |  |  | // if (option.style.image != null) { | 
|---|
|  |  |  | //     texture = new THREE.TextureLoader().load(option.style.image); | 
|---|
|  |  |  | //     if (option.style.allowRepeat === 1) { | 
|---|
|  |  |  | //         texture.repeat.x = option.length / 128; | 
|---|
|  |  |  | //         texture.repeat.y = option.width / 128; | 
|---|
|  |  |  | //         texture.repeat.y = 5; | 
|---|
|  |  |  | //         texture.wrapS = texture.wrapT = THREE.RepeatWrapping; | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | //     material = new THREE.MeshPhongMaterial({map: texture}); | 
|---|
|  |  |  | // } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var floorMat = new THREE.MeshStandardMaterial( { | 
|---|
|  |  |  | roughness: 0.8, | 
|---|
|  |  |  | color: 0xffffff, | 
|---|
|  |  |  | metalness: 0.2, | 
|---|
|  |  |  | bumpScale: 0.0005 | 
|---|
|  |  |  | } ); | 
|---|
|  |  |  | const textureLoader = new THREE.TextureLoader(); | 
|---|
|  |  |  | textureLoader.load( "../static/img/floor/hardwood2_diffuse.jpg", function ( map ) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map.wrapS = THREE.RepeatWrapping; | 
|---|
|  |  |  | map.wrapT = THREE.RepeatWrapping; | 
|---|
|  |  |  | map.anisotropy = 4; | 
|---|
|  |  |  | map.repeat.set( 10, 24 ); | 
|---|
|  |  |  | map.encoding = THREE.sRGBEncoding; | 
|---|
|  |  |  | floorMat.map = map; | 
|---|
|  |  |  | floorMat.needsUpdate = true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } ); | 
|---|
|  |  |  | textureLoader.load( "../static/img/floor/hardwood2_bump.jpg", function ( map ) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map.wrapS = THREE.RepeatWrapping; | 
|---|
|  |  |  | map.wrapT = THREE.RepeatWrapping; | 
|---|
|  |  |  | map.anisotropy = 4; | 
|---|
|  |  |  | map.repeat.set( 10, 24 ); | 
|---|
|  |  |  | floorMat.bumpMap = map; | 
|---|
|  |  |  | floorMat.needsUpdate = true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } ); | 
|---|
|  |  |  | textureLoader.load( "../static/img/floor/hardwood2_roughness.jpg", function ( map ) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | map.wrapS = THREE.RepeatWrapping; | 
|---|
|  |  |  | map.wrapT = THREE.RepeatWrapping; | 
|---|
|  |  |  | map.anisotropy = 4; | 
|---|
|  |  |  | map.repeat.set( 10, 24 ); | 
|---|
|  |  |  | floorMat.roughnessMap = map; | 
|---|
|  |  |  | floorMat.needsUpdate = true; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const floorGeometry = new THREE.PlaneGeometry( this.length, this.width ); | 
|---|
|  |  |  | const floorMesh = new THREE.Mesh( floorGeometry, floorMat ); | 
|---|
|  |  |  | floorMesh.receiveShadow = true; | 
|---|
|  |  |  | floorMesh.rotation.x = - Math.PI / 2.0; | 
|---|
|  |  |  | return floorMesh; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // if (option.style.transparent === 1) { | 
|---|
|  |  |  | //     material.transparent = true; | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | // if (option.style.depthTest === 0) { | 
|---|
|  |  |  | //     material.depthTest = false; | 
|---|
|  |  |  | // } | 
|---|
|  |  |  | // material.opacity = option.style.opacity; | 
|---|
|  |  |  | // // 模型 | 
|---|
|  |  |  | // let cubeGeometry = new THREE.BoxGeometry(this.length, this.height, this.width); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | // let cube = new THREE.Mesh(cubeGeometry, material); | 
|---|
|  |  |  | // cube.name = this.Name; | 
|---|
|  |  |  | // cube.position.x = this.positionX; | 
|---|
|  |  |  | // cube.position.y = this.positionY; | 
|---|
|  |  |  | // cube.position.z = this.positionZ; | 
|---|
|  |  |  | // return cube; | 
|---|
|  |  |  | } | 
|---|