123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 |
- import { Injectable } from '@angular/core';
- import { Observable, of } from 'rxjs';
- // 灯光分析结果接口
- export interface LightingAnalysisResult {
- lightSourceIdentification: LightSourceIdentification;
- illuminationAnalysis: IlluminationAnalysis;
- shadowAnalysis: ShadowAnalysis;
- ambientAnalysis: AmbientAnalysis;
- lightingRecommendations: string[];
- }
- // 光源识别
- export interface LightSourceIdentification {
- primarySources: Array<{
- type: 'natural' | 'artificial' | 'mixed';
- subtype: string; // 如:'sunlight', 'LED', 'fluorescent', 'incandescent', 'candle'
- position: {
- direction: 'top' | 'front' | 'back' | 'left' | 'right' | 'multiple';
- angle: number; // 0-360度
- distance: 'close' | 'medium' | 'far' | 'unknown';
- };
- intensity: number; // 0-100
- confidence: number; // 0-100
- }>;
- lightingSetup: {
- complexity: 'simple' | 'moderate' | 'complex' | 'professional';
- sourceCount: number;
- dominantSource: string;
- lightingStyle: 'dramatic' | 'soft' | 'even' | 'accent' | 'task' | 'ambient';
- };
- }
- // 照明效果分析
- export interface IlluminationAnalysis {
- brightness: {
- overall: number; // 0-100
- distribution: 'even' | 'uneven' | 'gradient' | 'spotty';
- dynamicRange: number; // 0-100
- exposure: 'underexposed' | 'well-exposed' | 'overexposed' | 'mixed';
- };
- contrast: {
- level: number; // 0-100
- type: 'low' | 'medium' | 'high' | 'extreme';
- areas: {
- highlights: number; // 0-100
- midtones: number; // 0-100
- shadows: number; // 0-100
- };
- };
- colorTemperature: {
- kelvin: number; // 色温值
- warmth: 'very-warm' | 'warm' | 'neutral' | 'cool' | 'very-cool';
- consistency: number; // 0-100
- mixedLighting: boolean;
- };
- lightQuality: {
- softness: number; // 0-100 (0=hard, 100=soft)
- diffusion: number; // 0-100
- directionality: number; // 0-100 (0=omnidirectional, 100=highly directional)
- evenness: number; // 0-100
- };
- }
- // 阴影分析
- export interface ShadowAnalysis {
- shadowPresence: {
- coverage: number; // 0-100
- intensity: number; // 0-100
- sharpness: 'very-soft' | 'soft' | 'medium' | 'sharp' | 'very-sharp';
- definition: number; // 0-100
- };
- shadowCharacteristics: {
- direction: string;
- length: 'short' | 'medium' | 'long' | 'varied';
- density: number; // 0-100
- falloff: 'gradual' | 'medium' | 'abrupt';
- };
- shadowTypes: Array<{
- type: 'cast' | 'form' | 'occlusion' | 'contact';
- prominence: number; // 0-100
- contribution: string;
- }>;
- dimensionalEffect: {
- depth: number; // 0-100
- volume: number; // 0-100
- threedimensionality: number; // 0-100
- };
- }
- // 环境光分析
- export interface AmbientAnalysis {
- ambientLevel: {
- strength: number; // 0-100
- uniformity: number; // 0-100
- contribution: number; // 0-100 (相对于直接光的贡献)
- };
- lightingMood: {
- primary: 'dramatic' | 'romantic' | 'energetic' | 'calm' | 'mysterious' | 'cheerful' | 'professional';
- intensity: number; // 0-100
- emotional_impact: string[];
- };
- atmosphericEffects: {
- haze: number; // 0-100
- glare: number; // 0-100
- reflections: number; // 0-100
- transparency: number; // 0-100
- };
- spatialPerception: {
- depth_enhancement: number; // 0-100
- space_definition: number; // 0-100
- focal_guidance: number; // 0-100
- };
- }
- @Injectable({
- providedIn: 'root'
- })
- export class LightingAnalysisService {
- constructor() { }
- /**
- * 分析图片中的灯光效果
- * @param imageFile 图片文件
- */
- analyzeImageLighting(imageFile: File): Observable<LightingAnalysisResult> {
- return of(this.simulateLightingAnalysis(imageFile));
- }
- /**
- * 分析URL图片的灯光效果
- * @param imageUrl 图片URL
- */
- analyzeLightingFromUrl(imageUrl: string): Observable<LightingAnalysisResult> {
- return of(this.simulateLightingAnalysisFromUrl(imageUrl));
- }
- /**
- * 模拟灯光分析
- */
- private simulateLightingAnalysis(imageFile: File): LightingAnalysisResult {
- const fileName = imageFile.name.toLowerCase();
- return this.generateLightingAnalysis(fileName);
- }
- private simulateLightingAnalysisFromUrl(imageUrl: string): LightingAnalysisResult {
- const urlLower = imageUrl.toLowerCase();
- return this.generateLightingAnalysis(urlLower);
- }
- private generateLightingAnalysis(context: string): LightingAnalysisResult {
- const lightingType = this.inferLightingType(context);
-
- return {
- lightSourceIdentification: this.generateLightSourceIdentification(lightingType, context),
- illuminationAnalysis: this.generateIlluminationAnalysis(lightingType, context),
- shadowAnalysis: this.generateShadowAnalysis(lightingType, context),
- ambientAnalysis: this.generateAmbientAnalysis(lightingType, context),
- lightingRecommendations: this.generateLightingRecommendations(lightingType, context)
- };
- }
- private inferLightingType(context: string): string {
- if (context.includes('natural') || context.includes('sun') || context.includes('daylight')) return 'natural';
- if (context.includes('artificial') || context.includes('led') || context.includes('lamp')) return 'artificial';
- if (context.includes('dramatic') || context.includes('shadow')) return 'dramatic';
- if (context.includes('soft') || context.includes('diffuse')) return 'soft';
- if (context.includes('bright') || context.includes('high')) return 'bright';
- if (context.includes('dim') || context.includes('low')) return 'dim';
- if (context.includes('warm')) return 'warm';
- if (context.includes('cool')) return 'cool';
- return 'mixed'; // 默认混合光源
- }
- private generateLightSourceIdentification(lightingType: string, context: string): LightSourceIdentification {
- const isNatural = lightingType === 'natural' || context.includes('outdoor');
- const isComplex = context.includes('complex') || context.includes('multiple');
-
- return {
- primarySources: this.generatePrimarySources(lightingType, isNatural, isComplex),
- lightingSetup: {
- complexity: isComplex ? 'complex' : this.getLightingComplexity(lightingType),
- sourceCount: isComplex ? 3 + Math.floor(Math.random() * 3) : this.getSourceCount(lightingType),
- dominantSource: this.getDominantSource(lightingType, isNatural),
- lightingStyle: this.getLightingStyle(lightingType)
- }
- };
- }
- private generatePrimarySources(lightingType: string, isNatural: boolean, isComplex: boolean): any[] {
- const sources = [];
-
- if (isNatural) {
- sources.push({
- type: 'natural',
- subtype: 'sunlight',
- position: {
- direction: 'top',
- angle: 45 + Math.random() * 90,
- distance: 'far'
- },
- intensity: 70 + Math.random() * 25,
- confidence: 85 + Math.random() * 10
- });
- } else {
- sources.push({
- type: 'artificial',
- subtype: this.getArtificialSubtype(lightingType),
- position: {
- direction: this.getLightDirection(lightingType),
- angle: Math.random() * 360,
- distance: this.getLightDistance(lightingType)
- },
- intensity: this.getLightIntensity(lightingType),
- confidence: 80 + Math.random() * 15
- });
- }
- if (isComplex) {
- // 添加辅助光源
- sources.push({
- type: 'artificial',
- subtype: 'LED',
- position: {
- direction: 'front',
- angle: 30 + Math.random() * 60,
- distance: 'medium'
- },
- intensity: 40 + Math.random() * 30,
- confidence: 70 + Math.random() * 20
- });
- }
- return sources;
- }
- private generateIlluminationAnalysis(lightingType: string, context: string): IlluminationAnalysis {
- const isBright = lightingType === 'bright' || context.includes('bright');
- const isDim = lightingType === 'dim' || context.includes('dim');
- const isWarm = lightingType === 'warm' || context.includes('warm');
- const isCool = lightingType === 'cool' || context.includes('cool');
-
- return {
- brightness: {
- overall: this.getBrightnessLevel(lightingType, isBright, isDim),
- distribution: this.getBrightnessDistribution(lightingType),
- dynamicRange: this.getDynamicRange(lightingType),
- exposure: this.getExposureLevel(lightingType, isBright, isDim)
- },
- contrast: {
- level: this.getContrastLevel(lightingType),
- type: this.getContrastType(lightingType),
- areas: {
- highlights: this.getHighlights(lightingType),
- midtones: this.getMidtones(lightingType),
- shadows: this.getShadowsLevel(lightingType)
- }
- },
- colorTemperature: {
- kelvin: this.getColorTemperature(lightingType, isWarm, isCool),
- warmth: this.getWarmthLevel(lightingType, isWarm, isCool),
- consistency: this.getTemperatureConsistency(lightingType),
- mixedLighting: lightingType === 'mixed' || context.includes('mixed')
- },
- lightQuality: {
- softness: this.getLightSoftness(lightingType),
- diffusion: this.getLightDiffusion(lightingType),
- directionality: this.getLightDirectionality(lightingType),
- evenness: this.getLightEvenness(lightingType)
- }
- };
- }
- private generateShadowAnalysis(lightingType: string, context: string): ShadowAnalysis {
- const isDramatic = lightingType === 'dramatic' || context.includes('dramatic');
- const isSoft = lightingType === 'soft' || context.includes('soft');
-
- return {
- shadowPresence: {
- coverage: this.getShadowCoverage(lightingType, isDramatic),
- intensity: this.getShadowIntensity(lightingType, isDramatic),
- sharpness: this.getShadowSharpness(lightingType, isSoft),
- definition: this.getShadowDefinition(lightingType)
- },
- shadowCharacteristics: {
- direction: this.getShadowDirection(lightingType),
- length: this.getShadowLength(lightingType),
- density: this.getShadowDensity(lightingType),
- falloff: this.getShadowFalloff(lightingType, isSoft)
- },
- shadowTypes: this.getShadowTypes(lightingType),
- dimensionalEffect: {
- depth: this.getDepthEffect(lightingType, isDramatic),
- volume: this.getVolumeEffect(lightingType),
- threedimensionality: this.get3DEffect(lightingType, isDramatic)
- }
- };
- }
- private generateAmbientAnalysis(lightingType: string, context: string): AmbientAnalysis {
- return {
- ambientLevel: {
- strength: this.getAmbientStrength(lightingType),
- uniformity: this.getAmbientUniformity(lightingType),
- contribution: this.getAmbientContribution(lightingType)
- },
- lightingMood: {
- primary: this.getLightingMood(lightingType, context),
- intensity: this.getMoodIntensity(lightingType),
- emotional_impact: this.getEmotionalImpact(lightingType, context)
- },
- atmosphericEffects: {
- haze: this.getHazeLevel(lightingType, context),
- glare: this.getGlareLevel(lightingType),
- reflections: this.getReflectionLevel(lightingType, context),
- transparency: this.getTransparencyLevel(lightingType)
- },
- spatialPerception: {
- depth_enhancement: this.getDepthEnhancement(lightingType),
- space_definition: this.getSpaceDefinition(lightingType),
- focal_guidance: this.getFocalGuidance(lightingType)
- }
- };
- }
- private generateLightingRecommendations(lightingType: string, context: string): string[] {
- const recommendations = [];
-
- // 基于光照类型的建议
- switch (lightingType) {
- case 'natural':
- recommendations.push('充分利用自然光的方向性和时间变化');
- recommendations.push('考虑添加辅助人工光源平衡光照');
- break;
- case 'artificial':
- recommendations.push('注意人工光源的色温一致性');
- recommendations.push('避免过度依赖单一光源');
- break;
- case 'dramatic':
- recommendations.push('保持强烈的明暗对比效果');
- recommendations.push('注意阴影的艺术表现力');
- break;
- case 'soft':
- recommendations.push('维持柔和均匀的光照效果');
- recommendations.push('避免产生过强的阴影');
- break;
- case 'bright':
- recommendations.push('控制过度曝光的风险');
- recommendations.push('注意高光区域的细节保留');
- break;
- case 'dim':
- recommendations.push('增强关键区域的照明');
- recommendations.push('注意暗部细节的可见性');
- break;
- }
-
- // 基于上下文的建议
- if (context.includes('interior')) {
- recommendations.push('考虑室内空间的光照层次');
- recommendations.push('注意光照对材质表现的影响');
- }
- if (context.includes('portrait')) {
- recommendations.push('优化面部光照的均匀性');
- recommendations.push('避免产生不利的阴影');
- }
- if (context.includes('product')) {
- recommendations.push('确保产品细节的清晰展示');
- recommendations.push('避免反光和眩光问题');
- }
-
- return recommendations.length > 0 ? recommendations : ['保持光照设计的整体协调性'];
- }
- // 辅助方法实现
- private getLightingComplexity(lightingType: string): 'simple' | 'moderate' | 'complex' | 'professional' {
- const complexities: { [key: string]: 'simple' | 'moderate' | 'complex' | 'professional' } = {
- natural: 'simple', artificial: 'moderate', dramatic: 'complex',
- soft: 'moderate', bright: 'simple', dim: 'moderate',
- warm: 'simple', cool: 'simple', mixed: 'complex'
- };
- return complexities[lightingType] || 'moderate';
- }
- private getSourceCount(lightingType: string): number {
- const counts: { [key: string]: number } = {
- natural: 1, artificial: 2, dramatic: 3, soft: 2,
- bright: 1, dim: 2, warm: 1, cool: 1, mixed: 3
- };
- return counts[lightingType] || 2;
- }
- private getDominantSource(lightingType: string, isNatural: boolean): string {
- if (isNatural) return 'sunlight';
- const sources: { [key: string]: string } = {
- artificial: 'LED', dramatic: 'spotlight', soft: 'softbox',
- bright: 'floodlight', dim: 'ambient', warm: 'incandescent',
- cool: 'fluorescent', mixed: 'multiple'
- };
- return sources[lightingType] || 'LED';
- }
- private getLightingStyle(lightingType: string): 'dramatic' | 'soft' | 'even' | 'accent' | 'task' | 'ambient' {
- const styles: { [key: string]: 'dramatic' | 'soft' | 'even' | 'accent' | 'task' | 'ambient' } = {
- natural: 'even', artificial: 'task', dramatic: 'dramatic',
- soft: 'soft', bright: 'even', dim: 'ambient',
- warm: 'ambient', cool: 'task', mixed: 'accent'
- };
- return styles[lightingType] || 'even';
- }
- private getArtificialSubtype(lightingType: string): string {
- const subtypes: { [key: string]: string } = {
- artificial: 'LED', dramatic: 'spotlight', soft: 'softbox',
- bright: 'floodlight', dim: 'ambient', warm: 'incandescent',
- cool: 'fluorescent', mixed: 'LED'
- };
- return subtypes[lightingType] || 'LED';
- }
- private getLightDirection(lightingType: string): 'top' | 'front' | 'back' | 'left' | 'right' | 'multiple' {
- const directions: { [key: string]: 'top' | 'front' | 'back' | 'left' | 'right' | 'multiple' } = {
- natural: 'top', artificial: 'front', dramatic: 'left',
- soft: 'front', bright: 'top', dim: 'multiple',
- warm: 'front', cool: 'top', mixed: 'multiple'
- };
- return directions[lightingType] || 'front';
- }
- private getLightDistance(lightingType: string): 'close' | 'medium' | 'far' | 'unknown' {
- const distances: { [key: string]: 'close' | 'medium' | 'far' | 'unknown' } = {
- natural: 'far', artificial: 'medium', dramatic: 'close',
- soft: 'medium', bright: 'far', dim: 'close',
- warm: 'close', cool: 'medium', mixed: 'medium'
- };
- return distances[lightingType] || 'medium';
- }
- private getLightIntensity(lightingType: string): number {
- const intensities: { [key: string]: number } = {
- natural: 80, artificial: 70, dramatic: 85, soft: 60,
- bright: 90, dim: 30, warm: 65, cool: 75, mixed: 70
- };
- return (intensities[lightingType] || 70) + Math.random() * 15;
- }
- private getBrightnessLevel(lightingType: string, isBright: boolean, isDim: boolean): number {
- if (isBright) return 80 + Math.random() * 15;
- if (isDim) return 20 + Math.random() * 20;
-
- const levels: { [key: string]: number } = {
- natural: 75, artificial: 65, dramatic: 60, soft: 70,
- warm: 60, cool: 70, mixed: 65
- };
- return (levels[lightingType] || 65) + Math.random() * 15;
- }
- private getBrightnessDistribution(lightingType: string): 'even' | 'uneven' | 'gradient' | 'spotty' {
- const distributions: { [key: string]: 'even' | 'uneven' | 'gradient' | 'spotty' } = {
- natural: 'gradient', artificial: 'even', dramatic: 'uneven',
- soft: 'even', bright: 'even', dim: 'uneven',
- warm: 'gradient', cool: 'even', mixed: 'spotty'
- };
- return distributions[lightingType] || 'even';
- }
- private getDynamicRange(lightingType: string): number {
- const ranges: { [key: string]: number } = {
- natural: 85, artificial: 70, dramatic: 90, soft: 60,
- bright: 75, dim: 80, warm: 70, cool: 75, mixed: 85
- };
- return (ranges[lightingType] || 75) + Math.random() * 10;
- }
- private getExposureLevel(lightingType: string, isBright: boolean, isDim: boolean): 'underexposed' | 'well-exposed' | 'overexposed' | 'mixed' {
- if (isBright) return 'overexposed';
- if (isDim) return 'underexposed';
-
- const exposures: { [key: string]: 'underexposed' | 'well-exposed' | 'overexposed' | 'mixed' } = {
- natural: 'well-exposed', artificial: 'well-exposed', dramatic: 'mixed',
- soft: 'well-exposed', warm: 'well-exposed', cool: 'well-exposed', mixed: 'mixed'
- };
- return exposures[lightingType] || 'well-exposed';
- }
- private getContrastLevel(lightingType: string): number {
- const contrasts: { [key: string]: number } = {
- natural: 70, artificial: 60, dramatic: 90, soft: 40,
- bright: 65, dim: 75, warm: 55, cool: 65, mixed: 80
- };
- return (contrasts[lightingType] || 65) + Math.random() * 15;
- }
- private getContrastType(lightingType: string): 'low' | 'medium' | 'high' | 'extreme' {
- const types: { [key: string]: 'low' | 'medium' | 'high' | 'extreme' } = {
- natural: 'medium', artificial: 'medium', dramatic: 'extreme',
- soft: 'low', bright: 'medium', dim: 'high',
- warm: 'low', cool: 'medium', mixed: 'high'
- };
- return types[lightingType] || 'medium';
- }
- private getHighlights(lightingType: string): number {
- const highlights: { [key: string]: number } = {
- natural: 80, artificial: 70, dramatic: 85, soft: 60,
- bright: 90, dim: 40, warm: 65, cool: 75, mixed: 75
- };
- return (highlights[lightingType] || 70) + Math.random() * 15;
- }
- private getMidtones(lightingType: string): number {
- const midtones: { [key: string]: number } = {
- natural: 60, artificial: 65, dramatic: 50, soft: 70,
- bright: 55, dim: 45, warm: 65, cool: 60, mixed: 60
- };
- return (midtones[lightingType] || 60) + Math.random() * 15;
- }
- private getShadowsLevel(lightingType: string): number {
- const shadows: { [key: string]: number } = {
- natural: 40, artificial: 45, dramatic: 20, soft: 55,
- bright: 35, dim: 65, warm: 50, cool: 40, mixed: 45
- };
- return (shadows[lightingType] || 45) + Math.random() * 15;
- }
- private getColorTemperature(lightingType: string, isWarm: boolean, isCool: boolean): number {
- if (isWarm) return 2700 + Math.random() * 500;
- if (isCool) return 5500 + Math.random() * 1000;
-
- const temperatures: { [key: string]: number } = {
- natural: 5500, artificial: 4000, dramatic: 3200,
- soft: 4500, bright: 5000, dim: 3000, mixed: 4200
- };
- return temperatures[lightingType] || 4000;
- }
- private getWarmthLevel(lightingType: string, isWarm: boolean, isCool: boolean): 'very-warm' | 'warm' | 'neutral' | 'cool' | 'very-cool' {
- if (isWarm) return 'warm';
- if (isCool) return 'cool';
-
- const warmths: { [key: string]: 'very-warm' | 'warm' | 'neutral' | 'cool' | 'very-cool' } = {
- natural: 'neutral', artificial: 'neutral', dramatic: 'warm',
- soft: 'warm', bright: 'cool', dim: 'warm', mixed: 'neutral'
- };
- return warmths[lightingType] || 'neutral';
- }
- private getTemperatureConsistency(lightingType: string): number {
- const consistencies: { [key: string]: number } = {
- natural: 90, artificial: 85, dramatic: 70, soft: 80,
- bright: 85, dim: 75, warm: 90, cool: 85, mixed: 60
- };
- return (consistencies[lightingType] || 80) + Math.random() * 10;
- }
- private getLightSoftness(lightingType: string): number {
- const softnesses: { [key: string]: number } = {
- natural: 70, artificial: 60, dramatic: 30, soft: 90,
- bright: 50, dim: 80, warm: 75, cool: 55, mixed: 65
- };
- return (softnesses[lightingType] || 65) + Math.random() * 15;
- }
- private getLightDiffusion(lightingType: string): number {
- const diffusions: { [key: string]: number } = {
- natural: 75, artificial: 65, dramatic: 40, soft: 85,
- bright: 60, dim: 70, warm: 70, cool: 60, mixed: 70
- };
- return (diffusions[lightingType] || 65) + Math.random() * 15;
- }
- private getLightDirectionality(lightingType: string): number {
- const directionalities: { [key: string]: number } = {
- natural: 80, artificial: 70, dramatic: 90, soft: 40,
- bright: 75, dim: 50, warm: 60, cool: 70, mixed: 60
- };
- return (directionalities[lightingType] || 65) + Math.random() * 15;
- }
- private getLightEvenness(lightingType: string): number {
- const evennesses: { [key: string]: number } = {
- natural: 60, artificial: 75, dramatic: 30, soft: 85,
- bright: 80, dim: 50, warm: 70, cool: 75, mixed: 55
- };
- return (evennesses[lightingType] || 65) + Math.random() * 15;
- }
- private getShadowCoverage(lightingType: string, isDramatic: boolean): number {
- if (isDramatic) return 60 + Math.random() * 30;
-
- const coverages: { [key: string]: number } = {
- natural: 50, artificial: 40, soft: 25, bright: 30,
- dim: 70, warm: 45, cool: 35, mixed: 50
- };
- return (coverages[lightingType] || 45) + Math.random() * 20;
- }
- private getShadowIntensity(lightingType: string, isDramatic: boolean): number {
- if (isDramatic) return 75 + Math.random() * 20;
-
- const intensities: { [key: string]: number } = {
- natural: 60, artificial: 50, soft: 30, bright: 45,
- dim: 65, warm: 40, cool: 55, mixed: 55
- };
- return (intensities[lightingType] || 50) + Math.random() * 20;
- }
- private getShadowSharpness(lightingType: string, isSoft: boolean): 'very-soft' | 'soft' | 'medium' | 'sharp' | 'very-sharp' {
- if (isSoft) return 'soft';
-
- const sharpnesses: { [key: string]: 'very-soft' | 'soft' | 'medium' | 'sharp' | 'very-sharp' } = {
- natural: 'medium', artificial: 'medium', dramatic: 'sharp',
- bright: 'sharp', dim: 'soft', warm: 'soft', cool: 'medium', mixed: 'medium'
- };
- return sharpnesses[lightingType] || 'medium';
- }
- private getShadowDefinition(lightingType: string): number {
- const definitions: { [key: string]: number } = {
- natural: 70, artificial: 65, dramatic: 85, soft: 40,
- bright: 75, dim: 55, warm: 50, cool: 70, mixed: 60
- };
- return (definitions[lightingType] || 60) + Math.random() * 15;
- }
- private getShadowDirection(lightingType: string): string {
- const directions = ['左下', '右下', '正下', '左侧', '右侧', '多方向'];
- return directions[Math.floor(Math.random() * directions.length)];
- }
- private getShadowLength(lightingType: string): 'short' | 'medium' | 'long' | 'varied' {
- const lengths: { [key: string]: 'short' | 'medium' | 'long' | 'varied' } = {
- natural: 'medium', artificial: 'short', dramatic: 'long',
- soft: 'short', bright: 'short', dim: 'medium',
- warm: 'medium', cool: 'short', mixed: 'varied'
- };
- return lengths[lightingType] || 'medium';
- }
- private getShadowDensity(lightingType: string): number {
- const densities: { [key: string]: number } = {
- natural: 60, artificial: 55, dramatic: 80, soft: 35,
- bright: 45, dim: 70, warm: 50, cool: 60, mixed: 60
- };
- return (densities[lightingType] || 55) + Math.random() * 20;
- }
- private getShadowFalloff(lightingType: string, isSoft: boolean): 'gradual' | 'medium' | 'abrupt' {
- if (isSoft) return 'gradual';
-
- const falloffs: { [key: string]: 'gradual' | 'medium' | 'abrupt' } = {
- natural: 'gradual', artificial: 'medium', dramatic: 'abrupt',
- bright: 'medium', dim: 'gradual', warm: 'gradual',
- cool: 'medium', mixed: 'medium'
- };
- return falloffs[lightingType] || 'medium';
- }
- private getShadowTypes(lightingType: string): Array<{type: 'cast' | 'form' | 'occlusion' | 'contact', prominence: number, contribution: string}> {
- const types: Array<{type: 'cast' | 'form' | 'occlusion' | 'contact', prominence: number, contribution: string}> = [
- { type: 'cast', prominence: 70 + Math.random() * 25, contribution: '主要阴影效果' },
- { type: 'form', prominence: 50 + Math.random() * 30, contribution: '形体塑造' }
- ];
-
- if (lightingType === 'dramatic') {
- types.push({ type: 'occlusion', prominence: 60 + Math.random() * 30, contribution: '遮挡阴影' });
- }
-
- types.push({ type: 'contact', prominence: 40 + Math.random() * 20, contribution: '接触阴影' });
-
- return types;
- }
- private getDepthEffect(lightingType: string, isDramatic: boolean): number {
- if (isDramatic) return 80 + Math.random() * 15;
-
- const depths: { [key: string]: number } = {
- natural: 70, artificial: 60, soft: 45, bright: 55,
- dim: 75, warm: 60, cool: 65, mixed: 65
- };
- return (depths[lightingType] || 60) + Math.random() * 20;
- }
- private getVolumeEffect(lightingType: string): number {
- const volumes: { [key: string]: number } = {
- natural: 65, artificial: 55, dramatic: 85, soft: 40,
- bright: 50, dim: 70, warm: 55, cool: 60, mixed: 60
- };
- return (volumes[lightingType] || 60) + Math.random() * 20;
- }
- private get3DEffect(lightingType: string, isDramatic: boolean): number {
- if (isDramatic) return 85 + Math.random() * 10;
-
- const effects: { [key: string]: number } = {
- natural: 75, artificial: 65, soft: 45, bright: 60,
- dim: 70, warm: 60, cool: 70, mixed: 70
- };
- return (effects[lightingType] || 65) + Math.random() * 20;
- }
- private getAmbientStrength(lightingType: string): number {
- const strengths: { [key: string]: number } = {
- natural: 70, artificial: 60, dramatic: 40, soft: 80,
- bright: 65, dim: 85, warm: 75, cool: 55, mixed: 65
- };
- return (strengths[lightingType] || 65) + Math.random() * 15;
- }
- private getAmbientUniformity(lightingType: string): number {
- const uniformities: { [key: string]: number } = {
- natural: 60, artificial: 75, dramatic: 30, soft: 85,
- bright: 70, dim: 50, warm: 70, cool: 75, mixed: 55
- };
- return (uniformities[lightingType] || 65) + Math.random() * 15;
- }
- private getAmbientContribution(lightingType: string): number {
- const contributions: { [key: string]: number } = {
- natural: 40, artificial: 50, dramatic: 25, soft: 70,
- bright: 35, dim: 80, warm: 60, cool: 45, mixed: 55
- };
- return (contributions[lightingType] || 50) + Math.random() * 20;
- }
- private getLightingMood(lightingType: string, context: string): 'dramatic' | 'romantic' | 'energetic' | 'calm' | 'mysterious' | 'cheerful' | 'professional' {
- if (context.includes('romantic')) return 'romantic';
- if (context.includes('energetic')) return 'energetic';
- if (context.includes('calm')) return 'calm';
- if (context.includes('mysterious')) return 'mysterious';
- if (context.includes('cheerful')) return 'cheerful';
- if (context.includes('professional')) return 'professional';
-
- const moods: { [key: string]: 'dramatic' | 'romantic' | 'energetic' | 'calm' | 'mysterious' | 'cheerful' | 'professional' } = {
- natural: 'cheerful', artificial: 'professional', dramatic: 'dramatic',
- soft: 'romantic', bright: 'energetic', dim: 'mysterious',
- warm: 'calm', cool: 'professional', mixed: 'energetic'
- };
- return moods[lightingType] || 'calm';
- }
- private getMoodIntensity(lightingType: string): number {
- const intensities: { [key: string]: number } = {
- natural: 70, artificial: 60, dramatic: 90, soft: 75,
- bright: 80, dim: 85, warm: 70, cool: 65, mixed: 75
- };
- return (intensities[lightingType] || 70) + Math.random() * 15;
- }
- private getEmotionalImpact(lightingType: string, context: string): string[] {
- const impacts: { [key: string]: string[] } = {
- natural: ['自然', '舒适', '健康'],
- artificial: ['现代', '功能性', '可控'],
- dramatic: ['戏剧性', '强烈', '艺术感'],
- soft: ['温柔', '浪漫', '舒缓'],
- bright: ['活力', '清晰', '积极'],
- dim: ['神秘', '私密', '放松'],
- warm: ['温暖', '舒适', '亲密'],
- cool: ['清爽', '专业', '现代'],
- mixed: ['丰富', '层次', '复杂']
- };
- return impacts[lightingType] || ['平衡', '和谐'];
- }
- private getHazeLevel(lightingType: string, context: string): number {
- const base = context.includes('haze') || context.includes('fog') ? 60 : 20;
- return base + Math.random() * 30;
- }
- private getGlareLevel(lightingType: string): number {
- const glares: { [key: string]: number } = {
- natural: 30, artificial: 25, dramatic: 40, soft: 10,
- bright: 60, dim: 5, warm: 15, cool: 35, mixed: 30
- };
- return (glares[lightingType] || 25) + Math.random() * 20;
- }
- private getReflectionLevel(lightingType: string, context: string): number {
- const base = context.includes('reflection') || context.includes('mirror') ? 70 : 30;
- return base + Math.random() * 25;
- }
- private getTransparencyLevel(lightingType: string): number {
- const transparencies: { [key: string]: number } = {
- natural: 85, artificial: 75, dramatic: 60, soft: 80,
- bright: 90, dim: 50, warm: 70, cool: 80, mixed: 70
- };
- return (transparencies[lightingType] || 75) + Math.random() * 15;
- }
- private getDepthEnhancement(lightingType: string): number {
- const enhancements: { [key: string]: number } = {
- natural: 75, artificial: 65, dramatic: 90, soft: 50,
- bright: 60, dim: 80, warm: 60, cool: 70, mixed: 75
- };
- return (enhancements[lightingType] || 70) + Math.random() * 15;
- }
- private getSpaceDefinition(lightingType: string): number {
- const definitions: { [key: string]: number } = {
- natural: 70, artificial: 80, dramatic: 85, soft: 60,
- bright: 75, dim: 55, warm: 65, cool: 75, mixed: 70
- };
- return (definitions[lightingType] || 70) + Math.random() * 15;
- }
- private getFocalGuidance(lightingType: string): number {
- const guidances: { [key: string]: number } = {
- natural: 60, artificial: 70, dramatic: 90, soft: 50,
- bright: 65, dim: 75, warm: 55, cool: 70, mixed: 75
- };
- return (guidances[lightingType] || 65) + Math.random() * 15;
- }
- }
|