threejs之添加渐变背景

threejs之添加渐变背景

            const canvas1 = document.createElement('canvas');
            const context1 = canvas1.getContext('2d');
            canvas1.width = 256;
            canvas1.height = 256;
            const gradient = context1.createLinearGradient(0, 0, 0, canvas1.height / 4);
            gradient.addColorStop(0, '#777777'); // 顶部颜色
            gradient.addColorStop(1, '#000000'); // 底部颜色
            context1.fillStyle = gradient;
            context1.fillRect(0, 0, canvas1.width, canvas1.height);
            const texture1 = new THREE.CanvasTexture(canvas1);
            scene.background = texture1;

  

 

 

 

。。。。。。钻研不易,转载请注明出处

posted @ 2025-06-17 08:39  莫小龙  阅读(40)  评论(0)    收藏  举报