书接上回,这里讨论贴图的运用!!!
// 创建球网格const ball = MeshBuilder.CreateSphere('ball',{diameter:1},scene)ball.position = new Vector3(0,1,0)// 创建PRB材质const ballMat = new PBRMaterial('pbr',scene)// albedoTexture 反照率贴图ballMat.albedoTexture = new Texture('./textures/aerial_beach_02_diff_4k.jpg',scene)// 法线贴图ballMat.bumpTexture = new Texture('./textures/aerial_beach_02_nor_gl_4k.jpg',scene)ballMat.invertNormalMapX = trueballMat.invertNormalMapY = true// ao贴图ballMat.metallicTexture = new Texture('./textures/aerial_beach_02_ao_4k.jpg',scene)ballMat.useAmbientOcclusionFromMetallicTextureRed = trueballMat.useRoughnessFromMetallicTextureGreen = trueballMat.useMetallnessFromMetallicTextureBlue = true// 发光贴图ballMat.emissiveTexture = new Texture('./textures/emissive.jpg',scene)// 默认是黑色 不发光ballMat.emissiveColor = new Color3(1,1,1)// 发光强度ballMat.emissiveIntensity = 1// 材质接收到的环境光强度ballMat.environmentIntensity = 0.25// 发光层const glowLayer = new GlowLayer('glow',scene)glowLayer.intensity = 1// 应用材质ball.material = ballMat;