#
luxiaotao1123
2022-03-21 4f7e5d3dc070ea46f4ca243bcbae9eda76d8c8a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/**
 * 地板
 * @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;
}