V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
humbass
V2EX  ›  前端开发

一个 Three.js 设置背景的问题求教

  •  
  •   humbass · 17 天前 · 469 次点击

    想简单的设置个背景

      import test from '@/assets/test.jpg'
      scene = new THREE.Scene()
      const textureLoader = new THREE.TextureLoader()
      const texture = textureLoader.load(test)
      scene.background = texture
    
    

    结果发现图片是半透明的状态

    就像这样 https://update.ld160.eu.org/pics/2541717182785_.pic_hd.jpg 左上角是原图,右边是加载的背景

    3 条回复    2024-06-01 19:42:12 +08:00
    IvanLi127
        1
    IvanLi127  
       17 天前
    canvas 后面是啥颜色的?看起来不像半透明,只感觉色彩不太好
    alphardex
        2
    alphardex  
       17 天前   ❤️ 1
    确实是色彩的问题,新版 three 默认是 SRGB 色彩空间,贴图的 colorSpace 也要对应上,texture.colorSpace = THREE.SRGBColorSpace
    humbass
        3
    humbass  
    OP
       17 天前
    @alphardex 谢谢!上午换成老版本的 three.js 就 ok ,感谢!!
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2927 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 12:27 · PVG 20:27 · LAX 05:27 · JFK 08:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.