사이트 CSP connect-src 에 blob: 추가: 3D 파일 안 텍스처를 막아 요원이 흰색 · 맵 3D 가 미니맵으로 나오던 문제
- three.js GLTFLoader 는 glb 안 이미지를 blob: 주소로 fetch 해 읽는데 connect-src 가 막아 텍스처가 모두 실패했다 (요원 흰색, 두 층 맵 재질은 텍스처 실패로 맵 전체가 실패 → 미니맵 바닥) - CSP 를 csp.ts 하나로 모으고 vite preview 도 같은 CSP 로 열어 헤드리스 확인이 실제와 같은 제한에서 되게 함 - 맵 B 층 텍스처 하나를 못 읽어도 맵 전체를 버리지 않음 - 시험: connect-src 에 blob: 확인 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -105,9 +105,12 @@ export function loadMap3d(url: string, clip: THREE.Plane, fallback: () => THREE.
|
||||
async function blendLayer(parser: { getDependency: (type: string, i: number) => Promise<unknown> }, m: THREE.MeshStandardMaterial, b: { texture?: number; tint?: number[] }) {
|
||||
let texB: THREE.Texture | null = null;
|
||||
if (b.texture != null) {
|
||||
texB = (await parser.getDependency('texture', b.texture)) as THREE.Texture;
|
||||
texB.colorSpace = THREE.SRGBColorSpace;
|
||||
texB.anisotropy = 4;
|
||||
// 텍스처 하나를 못 읽어도 맵 전체를 버리지 않고 B 층 색만 쓴다
|
||||
texB = (await parser.getDependency('texture', b.texture).catch(() => null)) as THREE.Texture | null;
|
||||
if (texB) {
|
||||
texB.colorSpace = THREE.SRGBColorSpace;
|
||||
texB.anisotropy = 4;
|
||||
}
|
||||
}
|
||||
const tintB = new THREE.Color().setRGB(b.tint?.[0] ?? 1, b.tint?.[1] ?? 1, b.tint?.[2] ?? 1, THREE.SRGBColorSpace);
|
||||
const md = m as unknown as { defines?: Record<string, string> };
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import react from '@vitejs/plugin-react';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { contentSecurityPolicy } from '../server/src/csp';
|
||||
|
||||
const sharedSrc = fileURLToPath(new URL('../../packages/shared/src/index.ts', import.meta.url));
|
||||
// 목 서버(mock/server.mjs) 주소. 실제 배포에서는 사이트 서버가 같은 오리진으로 정적 파일을 서빙한다.
|
||||
@@ -19,6 +20,7 @@ export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: { alias: { '@gvr/shared': sharedSrc } },
|
||||
server: { port: 5173, host: '127.0.0.1', proxy, fs: { allow: ['.', '../../packages/shared'] } },
|
||||
preview: { port: 4173, host: '127.0.0.1', proxy },
|
||||
// 미리보기(빌드 결과)는 실제 사이트와 같은 CSP 로 연다 (dev 는 vite 가 인라인 스크립트를 넣어 못 씀)
|
||||
preview: { port: 4173, host: '127.0.0.1', proxy, headers: { 'content-security-policy': contentSecurityPolicy('ws://127.0.0.1:4173') } },
|
||||
build: { outDir: 'dist', sourcemap: false, chunkSizeWarningLimit: 900 },
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user