mirror of https://gitee.com/cf-fz/WebCAD.git
commit
46df4f395c
@ -0,0 +1,22 @@
|
|||||||
|
import { Command } from "../Editor/CommandMachine";
|
||||||
|
import { DirectionalLight } from "../DatabaseServices/DirectionalLight";
|
||||||
|
import { app } from "../ApplicationServices/Application";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class TestDrawDirectionalLight
|
||||||
|
* @implements {Command}
|
||||||
|
*/
|
||||||
|
export class TestDrawDirectionalLight implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
let pl = new DirectionalLight();
|
||||||
|
|
||||||
|
app.m_Database.ModelSpace.Append(pl);
|
||||||
|
|
||||||
|
app.m_Editor.UpdateScreen();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
import { Command } from "../Editor/CommandMachine";
|
||||||
|
import { SpotLight } from "../DatabaseServices/SpotLight";
|
||||||
|
import { app } from "../ApplicationServices/Application";
|
||||||
|
import { Matrix4 } from "three";
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class TestDrawSpotLight
|
||||||
|
* @implements {Command}
|
||||||
|
*/
|
||||||
|
export class TestDrawSpotLight implements Command
|
||||||
|
{
|
||||||
|
async exec()
|
||||||
|
{
|
||||||
|
|
||||||
|
let pl = new SpotLight();
|
||||||
|
|
||||||
|
let ro = new Matrix4();
|
||||||
|
pl.ApplyMatrix(ro.makeRotationZ(0.4));
|
||||||
|
|
||||||
|
app.m_Database.ModelSpace.Append(pl);
|
||||||
|
|
||||||
|
app.m_Editor.UpdateScreen();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,80 @@
|
|||||||
|
import { Light } from "./Light";
|
||||||
|
import { Factory } from "./CADFactory";
|
||||||
|
import { RenderType } from "../GraphicsSystem/Enum";
|
||||||
|
import { Object3D, Mesh } from "three";
|
||||||
|
import * as THREE from "three";
|
||||||
|
import { CADFile } from "./CADFile";
|
||||||
|
import ThreeBSP from "../Geometry/ThreeCSG";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 平行光源
|
||||||
|
*
|
||||||
|
* @export
|
||||||
|
* @class DirectionalLight
|
||||||
|
* @extends {Light}
|
||||||
|
*/
|
||||||
|
@Factory
|
||||||
|
export class DirectionalLight extends Light
|
||||||
|
{
|
||||||
|
constructor()
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
this.m_Intensity = 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected m_Light: THREE.DirectionalLight;
|
||||||
|
Draw(renderType: RenderType = RenderType.Wireframe): Object3D
|
||||||
|
{
|
||||||
|
if (this.m_Light)
|
||||||
|
return this.m_Light;
|
||||||
|
|
||||||
|
this.m_Light = new THREE.DirectionalLight(this.m_LightColor, this.m_Intensity);
|
||||||
|
this.m_Light.castShadow = true;
|
||||||
|
|
||||||
|
//绘制灯光助手
|
||||||
|
let lightGeo = new THREE.BoxGeometry(0.05, 0.05, 0.05);
|
||||||
|
let geoMat = new THREE.MeshStandardMaterial({
|
||||||
|
emissive: 0xffffee,
|
||||||
|
emissiveIntensity: 1,
|
||||||
|
color: 0x000000
|
||||||
|
});
|
||||||
|
|
||||||
|
this.m_Light.add(new Mesh(lightGeo, geoMat));
|
||||||
|
|
||||||
|
this.m_Light.userData = this;
|
||||||
|
|
||||||
|
this.UpdatePostion();
|
||||||
|
|
||||||
|
this.m_DrawEntity.set(renderType, this.m_Light);
|
||||||
|
|
||||||
|
return this.m_Light;
|
||||||
|
}
|
||||||
|
|
||||||
|
Update()
|
||||||
|
{
|
||||||
|
super.Update();
|
||||||
|
if (!this.m_Light) return;
|
||||||
|
|
||||||
|
this.UpdatePostion();
|
||||||
|
}
|
||||||
|
|
||||||
|
//#region -------------------------File-------------------------
|
||||||
|
//对象应该实现dataIn和DataOut的方法,为了对象的序列化和反序列化
|
||||||
|
|
||||||
|
//对象从文件中读取数据,初始化自身
|
||||||
|
ReadFile(file: CADFile)
|
||||||
|
{
|
||||||
|
super.ReadFile(file);
|
||||||
|
let ver = file.Read();
|
||||||
|
|
||||||
|
|
||||||
|
this.Update();
|
||||||
|
}
|
||||||
|
//对象将自身数据写入到文件.
|
||||||
|
WriteFile(file: CADFile)
|
||||||
|
{
|
||||||
|
super.WriteFile(file);
|
||||||
|
file.Write(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue