|
|
|
@ -1,18 +1,17 @@
|
|
|
|
|
import * as THREE from "three";
|
|
|
|
|
import { Object3D, Vector3, Matrix4, RectAreaLightHelper } from "three";
|
|
|
|
|
import { Factory } from "../CADFactory";
|
|
|
|
|
import { Light } from "./Light";
|
|
|
|
|
import { BoxBufferGeometry, Group, Matrix4, Mesh, MeshBasicMaterial, Object3D, PlaneBufferGeometry, RectAreaLight as TRectAreaLight, RectAreaLightHelper, Vector3 } from "three";
|
|
|
|
|
import { UpdateDraw } from "../../Common/Status";
|
|
|
|
|
import { RenderType } from "../../GraphicsSystem/RenderType";
|
|
|
|
|
import { Factory } from "../CADFactory";
|
|
|
|
|
import { CADFiler } from "../CADFiler";
|
|
|
|
|
import { UpdateDraw } from "../../Common/Status";
|
|
|
|
|
import { Light } from "./Light";
|
|
|
|
|
|
|
|
|
|
@Factory
|
|
|
|
|
export class RectAreaLight extends Light
|
|
|
|
|
{
|
|
|
|
|
private m_Width: number = 1;
|
|
|
|
|
private m_Height: number = 1;
|
|
|
|
|
protected m_ShowHelper = true;
|
|
|
|
|
protected m_Intensity = 3;
|
|
|
|
|
protected _ShowHelper = true;
|
|
|
|
|
protected _Intensity = 3;
|
|
|
|
|
private m_Target = new Vector3();
|
|
|
|
|
|
|
|
|
|
get Target()
|
|
|
|
@ -66,18 +65,18 @@ export class RectAreaLight extends Light
|
|
|
|
|
}
|
|
|
|
|
protected InitDrawObject(renderType: RenderType = RenderType.Wireframe): Object3D
|
|
|
|
|
{
|
|
|
|
|
let lightGroup = new THREE.Group();
|
|
|
|
|
let lightGroup = new Group();
|
|
|
|
|
|
|
|
|
|
let light = new THREE.RectAreaLight(this.Color, this.m_Intensity, this.m_Width, this.m_Height);
|
|
|
|
|
let light = new TRectAreaLight(this.Color, this._Intensity, this.m_Width, this.m_Height);
|
|
|
|
|
//绘制灯光助手
|
|
|
|
|
let rectLightMesh = new THREE.Mesh(new THREE.PlaneBufferGeometry(), new THREE.MeshBasicMaterial({ color: this.m_LightColor }));
|
|
|
|
|
let rectLightMesh = new Mesh(new PlaneBufferGeometry(), new MeshBasicMaterial({ color: this._LightColor }));
|
|
|
|
|
|
|
|
|
|
light.add(rectLightMesh);
|
|
|
|
|
|
|
|
|
|
let helper = new RectAreaLightHelper(light);
|
|
|
|
|
|
|
|
|
|
// 灯光目标点
|
|
|
|
|
let box = new THREE.Mesh(new THREE.BoxBufferGeometry(50, 50, 50), new THREE.MeshBasicMaterial({ color: this.m_LightColor }));
|
|
|
|
|
let box = new Mesh(new BoxBufferGeometry(50, 50, 50), new MeshBasicMaterial({ color: this._LightColor }));
|
|
|
|
|
|
|
|
|
|
lightGroup.add(light, helper, box);
|
|
|
|
|
lightGroup.matrixAutoUpdate = false;
|
|
|
|
@ -88,29 +87,29 @@ export class RectAreaLight extends Light
|
|
|
|
|
}
|
|
|
|
|
UpdateDrawObject(type: RenderType, en: Object3D)
|
|
|
|
|
{
|
|
|
|
|
let lg = en.children[0] as THREE.RectAreaLight;
|
|
|
|
|
let lg = en.children[0] as TRectAreaLight;
|
|
|
|
|
super.UpdateDrawObject(type, lg);
|
|
|
|
|
lg.width = this.m_Width;
|
|
|
|
|
lg.height = this.m_Height;
|
|
|
|
|
lg.lookAt(this.m_Target);
|
|
|
|
|
let mesh = lg.children[0] as THREE.Mesh;
|
|
|
|
|
mesh.visible = this.m_ShowHelper;
|
|
|
|
|
let mesh = lg.children[0] as Mesh;
|
|
|
|
|
mesh.visible = this._ShowHelper;
|
|
|
|
|
mesh.scale.x = lg.width;
|
|
|
|
|
mesh.scale.y = lg.height;
|
|
|
|
|
(mesh.material as THREE.MeshBasicMaterial).color = this.m_LightColor;
|
|
|
|
|
(mesh.material as MeshBasicMaterial).color = this._LightColor;
|
|
|
|
|
|
|
|
|
|
let helper = en.children[1] as RectAreaLightHelper;
|
|
|
|
|
helper.visible = this.m_ShowHelper;
|
|
|
|
|
if (this.m_ShowHelper)
|
|
|
|
|
helper.visible = this._ShowHelper;
|
|
|
|
|
if (this._ShowHelper)
|
|
|
|
|
{
|
|
|
|
|
helper.matrix = lg.matrix;
|
|
|
|
|
helper.update();
|
|
|
|
|
helper.lookAt(this.m_Target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let box = en.children[2] as THREE.Mesh;
|
|
|
|
|
box.visible = this.m_ShowHelper;
|
|
|
|
|
if (this.m_ShowHelper)
|
|
|
|
|
let box = en.children[2] as Mesh;
|
|
|
|
|
box.visible = this._ShowHelper;
|
|
|
|
|
if (this._ShowHelper)
|
|
|
|
|
{
|
|
|
|
|
box.matrix.identity();
|
|
|
|
|
box.applyMatrix(new Matrix4().setPosition(this.Target.applyMatrix4(this.OCSInv)));
|
|
|
|
|