42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { DirectionalLight } from '@babylonjs/core/Lights/directionalLight';
|
|
import { ShadowGenerator } from '@babylonjs/core/Lights/Shadows/shadowGenerator';
|
|
import '@babylonjs/core/Lights/Shadows/shadowGeneratorSceneComponent';
|
|
import { Vector3, Quaternion } from '@babylonjs/core/Maths/math.vector';
|
|
import { Monobehiver } from '../base/Monobehiver';
|
|
import { MeshBuilder } from '@babylonjs/core/Meshes/meshBuilder';
|
|
import { StandardMaterial } from '@babylonjs/core/Materials/standardMaterial';
|
|
import { Color3 } from '@babylonjs/core/Maths/math.color';
|
|
import { GizmoManager } from '@babylonjs/core/Gizmos/gizmoManager';
|
|
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
|
|
type DebugMarkers = {
|
|
marker: Mesh;
|
|
arrow: Mesh;
|
|
gizmoManager: GizmoManager;
|
|
onKey: (e: KeyboardEvent) => void;
|
|
};
|
|
|
|
/**
|
|
* 灯光管理类- 负责创建和管理场景灯光
|
|
*/
|
|
export class AppLight extends Monobehiver {
|
|
lightList: DirectionalLight[];
|
|
shadowGenerator: ShadowGenerator | null;
|
|
debugMarkers?: DebugMarkers;
|
|
coneMesh?: Mesh;
|
|
updateCone?: () => void;
|
|
|
|
constructor(mainApp: any) {
|
|
super(mainApp);
|
|
this.lightList = [];
|
|
this.shadowGenerator = null;
|
|
}
|
|
|
|
/** 初始化灯光并开启阴影 */
|
|
Awake(): void {
|
|
// 主光源(模拟太阳)
|
|
const light = new DirectionalLight("sun", new Vector3(-1, -2, -1), this.mainApp.appScene.object);
|
|
light.intensity = 1;
|
|
}
|
|
}
|