Files
vibemake/js/studio-environment.js
2026-10-30 18:43:45 +08:00

31 lines
1.1 KiB
JavaScript

import * as THREE from 'three';
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
const STUDIO_HDR_URL = new URL('../assets/environments/monochrome_studio_02_1k.hdr', import.meta.url).href;
// HDR 只参与照明和金属反射;场景背景由页面样式独立控制。
export function loadStudioHDR() {
return new RGBELoader().loadAsync(STUDIO_HDR_URL);
}
// HDR 加载失败时的本地备用环境。
export function createStudioEnvironment() {
const scene = new THREE.Scene();
const room = new THREE.Mesh(
new THREE.BoxGeometry(20, 20, 20),
new THREE.MeshBasicMaterial({ color: '#17191d', side: THREE.BackSide }),
);
scene.add(room);
const softbox = (width, height, position, intensity) => {
const material = new THREE.MeshBasicMaterial({ color: new THREE.Color().setScalar(intensity), side: THREE.DoubleSide });
const panel = new THREE.Mesh(new THREE.PlaneGeometry(width, height), material);
panel.position.set(...position);
panel.lookAt(0, 0, 0);
scene.add(panel);
};
softbox(4, 3, [-3, 4, 4], 6);
softbox(1.5, 4, [4, 2, 0], 4);
softbox(3, 2, [0, 5, -2], 3);
return scene;
}