清理格式

pull/336/MERGE
ChenX 5 years ago
parent f34ba48485
commit b110cf3eaa

@ -10,7 +10,7 @@ import { ObjectId } from "../../DatabaseServices/ObjectId";
import { userConfig } from "../../Editor/UserConfig";
import { CollisionDetection } from "../../Geometry/DrillParse/CollisionDetection";
import { Face } from "../../Geometry/DrillParse/Face";
import { cZAxis, equaln, MoveMatrix } from "../../Geometry/GeUtils";
import { ZAxis, equaln, MoveMatrix } from "../../Geometry/GeUtils";
import { FaceDirection } from "../../UI/Store/BoardInterface";
import { DrillingOption, SpacingType } from "../../UI/Store/drillInterface";
import { toJS } from "mobx";
@ -75,7 +75,7 @@ export class DrawDrillingTool extends Singleton
for (let d of this.drillEnts)
{
d.ApplyMatrix(MoveMatrix(cZAxis.clone().multiplyScalar(-ljgLength)));
d.ApplyMatrix(MoveMatrix(ZAxis.clone().multiplyScalar(-ljgLength)));
if (d === pxlEnt)
{
//偏心轮下偏距离

@ -1,16 +1,16 @@
import { Matrix4, Vector2, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { arrayLast, arrayRemoveDuplicateBySort, arraySortByNumber } from "../../Common/ArrayExt";
import { Vec3DTo2D } from "../../Common/CurveUtils";
import { Board } from "../../DatabaseServices/Board";
import { Line } from "../../DatabaseServices/Line";
import { Polyline } from "../../DatabaseServices/Polyline";
import { cXAxis, cYAxis, cZAxis, equaln, MoveMatrix, polar } from "../../Geometry/GeUtils";
import { equaln, MoveMatrix, polar, XAxis, YAxis, ZAxis } from "../../Geometry/GeUtils";
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
import { IntersectOption } from "../../GraphicsSystem/IntersectWith";
import { EFullType, EWRackArrayType, EFullDir } from "../../UI/Store/WineRackInterface";
import { EFullDir, EFullType, EWRackArrayType } from "../../UI/Store/WineRackInterface";
import { GetMirrorMat } from "../Mirror";
import { DrawWineRackTool, SIN45 } from "./DrawWinRackTool";
import { arrayLast, arrayRemoveDuplicateBySort, arraySortByNumber } from "../../Common/ArrayExt";
import { Board, BoardType } from "../../DatabaseServices/Board";
import { app } from "../../ApplicationServices/Application";
export interface IWineRackData
{
@ -42,13 +42,13 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
if (config.fullType === EFullType.ByWidth)
{
miMat = MoveMatrix(ptMid)
.multiply(GetMirrorMat(cYAxis))
.multiply(GetMirrorMat(YAxis))
.multiply(MoveMatrix(ptMid.clone().negate()));
}
else
{
miMat = MoveMatrix(ptMid)
.multiply(GetMirrorMat(cXAxis))
.multiply(GetMirrorMat(XAxis))
.multiply(MoveMatrix(ptMid.clone().negate()));
}
@ -557,12 +557,12 @@ export class DrawBlisWineRackTool extends DrawWineRackTool
let vecY = arrayLast(pts).clone().sub(pts[0]);
let length = vecY.length();
let thick = vecX.length();
let mat = new Matrix4().makeBasis(vecX.normalize(), vecY.normalize(), cZAxis).setPosition(pts[0]);
let mat = new Matrix4().makeBasis(vecX.normalize(), vecY.normalize(), ZAxis).setPosition(pts[0]);
let matInv = new Matrix4().getInverse(mat);
if (equaln(length * thick, area, 0.01))
{
let an = vecY.angleTo(cXAxis);
let an = vecY.angleTo(XAxis);
if (equaln(an, Math.PI / 4))
{

@ -1,10 +1,10 @@
import { Math, Vector3, Matrix4 } from 'three';
import { Math, Matrix4, Vector3 } from 'three';
import { app } from '../ApplicationServices/Application';
import { Entity } from '../DatabaseServices/Entity';
import { Command } from '../Editor/CommandMachine';
import { JigUtils } from '../Editor/JigUtils';
import { PromptStatus } from '../Editor/PromptResult';
import { cZAxis } from '../Geometry/GeUtils';
import { ZAxis } from '../Geometry/GeUtils';
export class Command_Rotate implements Command
{
@ -83,7 +83,7 @@ export class Command_Rotate implements Command
let moveMat = new Matrix4().setPosition(basePt);
let moveMatInv = new Matrix4().getInverse(moveMat);
let roMat = new Matrix4()
.makeRotationAxis(cZAxis.clone().applyMatrix4(app.m_Editor.UCSMatrix), Math.degToRad(an));
.makeRotationAxis(ZAxis.clone().applyMatrix4(app.m_Editor.UCSMatrix), Math.degToRad(an));
let mat = moveMat.multiply(roMat).multiply(moveMatInv);
ens.forEach(en => en.ApplyMatrix(mat));
}

@ -8,7 +8,7 @@ import { IsPointInBowArc } from '../DatabaseServices/PointInPolyline';
import { Polyline } from '../DatabaseServices/Polyline';
import { Count } from '../Geometry/Count';
import { CurveMap } from '../Geometry/CurveMap';
import { cZeroVec, equaln, equalv2, equalv3, isParallelTo } from '../Geometry/GeUtils';
import { ZeroVec, equaln, equalv2, equalv3, isParallelTo } from '../Geometry/GeUtils';
import { PlaneExt } from '../Geometry/Plane';
import { Stand } from '../Geometry/RegionParse';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
@ -67,6 +67,7 @@ export function getDeterminantFor2V(v1: Vector2, v2: Vector2): number
{
return v1.x * v2.y - v1.y * v2.x;
}
export function getDeterminantFor3V(v1: Vector3, v2: Vector3, v3: Vector3)
{
let mat = new Matrix3();
@ -78,14 +79,11 @@ export function Vec2DTo3D(pt: Vector2)
{
return new Vector3(pt.x, pt.y, 0);
}
export function Vec3DTo2D(pt: Vector3)
{
return new Vector2(pt.x, pt.y);
}
export function getLineAndLineAngle(l1: Line, l2: Line)
{
return l1.GetFistDeriv(0).angleTo(l2.GetFistDeriv(0));
}
/**
* 线,线.
@ -385,7 +383,7 @@ export function ConverCircleToPolyline(cir: Circle): Polyline
return pl;
}
export function getTanPtsOnArcOrCircle(cu: Arc | Circle, lastPoint?: Vector3)
export function GetTanPtsOnArcOrCircle(cu: Arc | Circle, lastPoint?: Vector3)
{
if (lastPoint)
{
@ -440,8 +438,8 @@ export function CircleInternalTangentLines(cir0: Circle, cir1: Circle): Line[]
(h1 * c0.y + h0 * c1.y) / dist
).applyMatrix4(cir0.OCS);
let [c0p0, c0p1] = getTanPtsOnArcOrCircle(cir0, i);
let [c1p0, c1p1] = getTanPtsOnArcOrCircle(cir1, i);
let [c0p0, c0p1] = GetTanPtsOnArcOrCircle(cir0, i);
let [c1p0, c1p1] = GetTanPtsOnArcOrCircle(cir1, i);
return [
new Line(c0p0, c1p0),
@ -503,8 +501,8 @@ export function CircleOuterTangentLines(circle0: Circle, circle1: Circle): Line[
p.applyMatrix4(circle0.OCS);
let [c0p0, c0p1] = getTanPtsOnArcOrCircle(circle0, p);
let [c1p0, c1p1] = getTanPtsOnArcOrCircle(circle1, p);
let [c0p0, c0p1] = GetTanPtsOnArcOrCircle(circle0, p);
let [c1p0, c1p1] = GetTanPtsOnArcOrCircle(circle1, p);
return [
new Line(c0p0, c1p0),
@ -552,7 +550,7 @@ export function getTanPtsOnEllipse(cu: Ellipse, lastPoint: Vector3)
return [];
}
export function isRect(cu: Curve): { isRect: boolean, size?: Vector3, box?: Box3, OCS?: Matrix4 }
export function IsRect(cu: Curve): { isRect: boolean, size?: Vector3, box?: Box3, OCS?: Matrix4 }
{
if (cu instanceof Polyline)
{
@ -567,7 +565,7 @@ export function isRect(cu: Curve): { isRect: boolean, size?: Vector3, box?: Box3
for (let i = 1; i < pts.length; i++)
{
xVec = pts[i].clone().sub(p1).normalize();
if (!equalv3(xVec, cZeroVec))
if (!equalv3(xVec, ZeroVec))
break;
}

@ -1,12 +1,12 @@
import * as THREE from 'three';
import { Box3, BufferGeometry, Matrix4, Object3D, Shape, Vector2, Vector3, Matrix3 } from 'three';
import { ColorMaterial } from '../Common/ColorPalette';
import { getCircleCenter, getTanPtsOnArcOrCircle, Vec2DTo3D, getArcOrCirNearPts } from '../Common/CurveUtils';
import { getCircleCenter, GetTanPtsOnArcOrCircle, Vec2DTo3D, getArcOrCirNearPts } from '../Common/CurveUtils';
import { matrixSetVector, reviseMirrorMatrix } from '../Common/Matrix4Utils';
import { Status } from '../Common/Status';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
import { BufferGeometryUtils } from '../Geometry/BufferGeometryUtils';
import { angle, angleTo2Pi, equaln, equalv3, midPoint, MoveMatrix, polar } from '../Geometry/GeUtils';
import { angle, clampRad, equaln, equalv3, midPoint, MoveMatrix, polar } from '../Geometry/GeUtils';
import { RenderType } from '../GraphicsSystem/RenderType';
import { IntersectArcAndArc, IntersectCircleAndArc, IntersectLineAndArc, IntersectOption, IntersectPolylineAndCurve, reverseIntersectOption, IntersectEllipseAndCircleOrArc } from '../GraphicsSystem/IntersectWith';
import { Factory } from './CADFactory';
@ -37,8 +37,8 @@ export class Arc extends Curve
super();
this.m_Matrix.setPosition(center);
this.m_Radius = radius;
this.m_StartAngle = angleTo2Pi(startAngle);
this.m_EndAngle = angleTo2Pi(endAngle);
this.m_StartAngle = clampRad(startAngle);
this.m_EndAngle = clampRad(endAngle);
this.m_Clockwise = clockwise;
}
private m_Radius: number;
@ -302,7 +302,7 @@ export class Arc extends Curve
GetAngleAtParam(param: number)
{
return angleTo2Pi(this.m_StartAngle + param * this.AllAngle * (this.m_Clockwise ? -1 : 1));
return clampRad(this.m_StartAngle + param * this.AllAngle * (this.m_Clockwise ? -1 : 1));
}
GetSplitCurves(param: number[] | number): Arc[]
@ -645,7 +645,7 @@ export class Arc extends Curve
return l.IntersectWith(this, IntersectOption.ExtendBoth).filter(p => this.PtOnCurve(p));
}
case ObjectSnapMode.Tan:
let pts = getTanPtsOnArcOrCircle(this, lastPoint);
let pts = GetTanPtsOnArcOrCircle(this, lastPoint);
if (pts)
return pts.filter(p => this.PtOnCurve(p));
default:

@ -2,7 +2,7 @@ import * as THREE from 'three';
import { Box3, BufferGeometry, EllipseCurve, Material, Matrix3, Matrix4, Object3D, Shape, Vector3 } from 'three';
import { arrayLast, arrayRemoveDuplicateBySort } from '../Common/ArrayExt';
import { ColorMaterial } from '../Common/ColorPalette';
import { getArcOrCirNearPts, getTanPtsOnArcOrCircle, Vec2DTo3D } from '../Common/CurveUtils';
import { getArcOrCirNearPts, GetTanPtsOnArcOrCircle, Vec2DTo3D } from '../Common/CurveUtils';
import { reviseMirrorMatrix } from '../Common/Matrix4Utils';
import { clamp } from '../Common/Utils';
import { ObjectSnapMode } from '../Editor/ObjectSnapMode';
@ -288,7 +288,7 @@ export class Circle extends Curve
return l.IntersectWith(this, IntersectOption.ExtendBoth);
}
case ObjectSnapMode.Tan:
let pts = getTanPtsOnArcOrCircle(this, lastPoint);
let pts = GetTanPtsOnArcOrCircle(this, lastPoint);
if (pts)
return pts;
case ObjectSnapMode.End:

@ -12,7 +12,7 @@ import { boardUVGenerator } from "../Geometry/BoardUVGenerator";
import { BSPGroupParse } from "../Geometry/BSPGroupParse";
import { FastWireframe } from "../Geometry/CreateWireframe";
import { EdgesGeometry } from "../Geometry/EdgeGeometry";
import { cZeroVec, equaln, equalv2, equalv3, isIntersect, isParallelTo, MoveMatrix, cXAxis } from "../Geometry/GeUtils";
import { ZeroVec, equaln, equalv2, equalv3, isIntersect, isParallelTo, MoveMatrix, XAxis } from "../Geometry/GeUtils";
import { ScaleUV } from "../Geometry/UVUtils";
import { RenderType } from "../GraphicsSystem/RenderType";
import { BlockTableRecord } from "./BlockTableRecord";
@ -288,12 +288,12 @@ export class ExtureSolid extends Entity
this.isRect = equaln(this.width * this.height, this.ContourCurve.Area, 1);
//修正轮廓基点
if (!equalv3(box.min, cZeroVec))
if (!equalv3(box.min, ZeroVec))
{
this.contourCurve.Position =
this.contourCurve.Position.sub(box.min);
let v = box.min.applyMatrix4(this.OCS.setPosition(cZeroVec));
let v = box.min.applyMatrix4(this.OCS.setPosition(ZeroVec));
this.m_Matrix.setPosition(this.Position.add(v));
}
}
@ -579,7 +579,7 @@ export class ExtureSolid extends Entity
if (indexList.every(v => v < stretchCount === isFront))
{
//Change thickness
let lvec = vec.clone().applyMatrix4(this.OCSInv.setPosition(cZeroVec));
let lvec = vec.clone().applyMatrix4(this.OCSInv.setPosition(ZeroVec));
if (isFront)
{
// if (lvec.z >= this.thickness) return;
@ -611,7 +611,7 @@ export class ExtureSolid extends Entity
indexList = [...new Set(indexList)];
let localVec = vec.clone().applyMatrix4(this.OCSInv.setPosition(cZeroVec));
let localVec = vec.clone().applyMatrix4(this.OCSInv.setPosition(ZeroVec));
if (dragType === DragPointType.Grip)
{

@ -6,14 +6,13 @@ import { FixIndex } from "../Common/Utils";
import { commandMachine } from "../Editor/CommandMachine";
import { PromptSsgetResult, PromptStatus } from "../Editor/PromptResult";
import { SelectBox, SelectType } from "../Editor/SelectBox";
import { cZeroVec, equaln, equalv3, MoveMatrix } from "../Geometry/GeUtils";
import { ZeroVec, equaln, equalv3, MoveMatrix } from "../Geometry/GeUtils";
import { HotCMD } from "../Hot/HotCommand";
import { Board } from "./Board";
import { Entity } from "./Entity";
import { ObjectId } from "./ObjectId";
import { SymbolTableRecord } from "./SymbolTableRecord";
/**
*
*/
@ -46,6 +45,7 @@ export enum TemplateType
export class TemplateParam
{
name: string;
expr: string;
value: string | number;
default: string | number;
@ -201,7 +201,7 @@ export class TemplateRecord extends SymbolTableRecord
oldParam.UpdateParam(newParams[i]);
}
}
UpdateParam(name: string, value: any)
UpdateParam(name: string, value: any, expr?: string)
{
let param = this.GetParam(name);
if (param)
@ -219,6 +219,32 @@ export class TemplateRecord extends SymbolTableRecord
}
/**
*
*/
function ParamRegister(params: {}, name: string, value: string, isRoot = false)
{
params[name] = value;
if (isRoot)
params["@" + name] = value;
}
/**
*
*/
function ParameterBecomeFater(params: {})
{
let nparams = {};
for (let name in params)
{
if (name[0] === "@")
nparams[name] = params[name];
else
nparams["_" + name] = params[name];
}
return nparams;
}
@HotCMD
export class TestTemplateAction
{
@ -306,7 +332,7 @@ export class AddTemplateAction
return;
let direction = toRes.Point.sub(bpRes.Point).normalize();
if (equalv3(direction, cZeroVec))
if (equalv3(direction, ZeroVec))
return;
this.GripStretchAction(direction, ssRes);

@ -10,7 +10,7 @@ import { Line as DbLine } from "../DatabaseServices/Line";
import { Polyline } from '../DatabaseServices/Polyline';
import { BufferGeometryUtils } from '../Geometry/BufferGeometryUtils';
import { CurveIntersection } from '../Geometry/CurveIntersection';
import { cXAxis, cYAxis, cZAxis, equaln, equalv3, midPoint, SnapPoint } from '../Geometry/GeUtils';
import { XAxis, YAxis, ZAxis, equaln, equalv3, midPoint, SnapPoint } from '../Geometry/GeUtils';
import { PointShapeUtils } from '../Geometry/PointShapeUtils';
import { IntersectOption } from '../GraphicsSystem/IntersectWith';
import { DrawMode } from '../GraphicsSystem/PreViewer';
@ -61,8 +61,8 @@ interface SupportSnapPoint
}
//正交捕捉轴
const OrthoAxis = [cXAxis, cYAxis, cZAxis];
const PolarAxis = [cXAxis, new Vector3(1, 1).normalize(), cYAxis, new Vector3(-1, 1).normalize(), cZAxis];
const OrthoAxis = [XAxis, YAxis, ZAxis];
const PolarAxis = [XAxis, new Vector3(1, 1).normalize(), YAxis, new Vector3(-1, 1).normalize(), ZAxis];
//提供点捕捉的服务.
export class SnapServices
@ -445,7 +445,7 @@ export class SnapServices
minDist = dist;
minP = cp;
minCurve = new DbLine(supportSnapPt.Point, p2);
isZAxis = equalv3(cZAxis, axisVec);
isZAxis = equalv3(ZAxis, axisVec);
}
}

@ -4,7 +4,7 @@ import { matrixIsCoplane } from "../../Common/Matrix4Utils";
import { Board } from "../../DatabaseServices/Board";
import { Curve } from "../../DatabaseServices/Curve";
import { Region } from "../../DatabaseServices/Region";
import { cZAxis, equalv3, rotatePoint, equaln } from "../GeUtils";
import { ZAxis, equalv3, rotatePoint, equaln } from "../GeUtils";
import { Face } from "./Face";
import { DrillType } from "../../UI/Store/BoardInterface";
import { Arc } from "../../DatabaseServices/Arc";
@ -61,7 +61,7 @@ export class BoardGetFace
if (opt.backDrill)
{
let mat = GetMirrorMat(cZAxis).setPosition(new Vector3());
let mat = GetMirrorMat(ZAxis).setPosition(new Vector3());
this.m_Faces.push(new Face({
type: BoardFaceType.NoSide,
localBoard: this.m_Board,
@ -95,7 +95,7 @@ export class BoardGetFace
//构建面矩阵
let z = rotatePoint(derv.clone(), -Math.PI / 2 * dir);
let y = cZAxis.clone();
let y = ZAxis.clone();
let x = y.clone().cross(z).multiplyScalar(dir);
let mat = new Matrix4()
.makeBasis(x, y, z)

@ -4,7 +4,7 @@ import { Line } from "../../DatabaseServices/Line";
import { Region } from "../../DatabaseServices/Region";
import { BoolOpeartionType } from "../../GraphicsSystem/BoolOperateUtils";
import { Box3Ext } from "../Box";
import { cXAxis, equaln } from "../GeUtils";
import { XAxis, equaln } from "../GeUtils";
import { BoardFaceType } from "./BoardGetFace";
export interface BoardFaceParams
@ -91,7 +91,7 @@ export class Face
let isSuccess = false;
let x = new Vector3().setFromMatrixColumn(diffMat, 0);
let ang = x.angleTo(cXAxis);
let ang = x.angleTo(XAxis);
//盒子旋转0,90,180度不会被破坏
let canUseBoxCalc = equaln(ang, 0) || equaln(ang, Math.PI / 2) || equaln(ang, Math.PI);

@ -1,10 +1,19 @@
import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3, Scene } from 'three';
import { Box3, BufferGeometry, Geometry, Line, Matrix4, Mesh, Object3D, Vector, Vector2, Vector3 } from 'three';
import { ToFixed } from '../Common/Utils';
import { Matrix2 } from './Matrix2';
export const cZeroVec = new Vector3();
export const cXAxis = new Vector3(1, 0, 0);
export const cYAxis = new Vector3(0, 1, 0);
export const cZAxis = new Vector3(0, 0, 1);
export const ZeroVec = new Vector3();
export const XAxis = new Vector3(1, 0, 0);
export const YAxis = new Vector3(0, 1, 0);
export const ZAxis = new Vector3(0, 0, 1);
export function AsVector2(p: { x: number, y: number })
{
return new Vector2(p.x, p.y);
}
export function AsVector3(p: { x: number, y: number, z?: number })
{
return new Vector3(p.x, p.y, p.z);
}
/**
* 线ab
@ -16,16 +25,21 @@ export function isIntersect(amin: number, amax: number, bmin: number, bmax: numb
/**
* ,
*
* @export
* @param {Vector3} pt
* @param {number} ang .
* @param {Vector3} p
* @param {number} a .
* @returns {Vector3} pt.
*/
export function rotatePoint(pt: Vector3, ang: number): Vector3
export function rotatePoint(p: Vector3, a: number): Vector3
{
new Matrix2().setRotate(ang).applyVector(pt);
return pt;
let s = Math.sin(a);
let c = Math.cos(a);
let x = p.x * c - p.y * s;
let y = p.x * s + p.y * c;
p.x = x;
p.y = y;
return p;
}
export function equaln(v1: number, v2: number, fuzz = 1e-5)
@ -82,14 +96,14 @@ export function angleTo(v1: Vector3, v2: Vector3, ref: Vector3 = new Vector3(0,
ref.multiplyScalar(-1);
let up = getLoocAtUpVec(ref);
let refOcs = new Matrix4();
refOcs.lookAt(cZeroVec, ref, up);
refOcs.lookAt(ZeroVec, ref, up);
let refOcsInv = new Matrix4().getInverse(refOcs);
v1.applyMatrix4(refOcsInv);
v2.applyMatrix4(refOcsInv);
v1.z = 0;
v2.z = 0;
}
if (v1.equals(cZeroVec) || v2.equals(cZeroVec))
if (v1.equals(ZeroVec) || v2.equals(ZeroVec))
return 0;
let cv = new Vector3().crossVectors(v1, v2).normalize();
return cv.z === 0 ? v1.angleTo(v2) : v1.angleTo(v2) * cv.z;
@ -97,23 +111,23 @@ export function angleTo(v1: Vector3, v2: Vector3, ref: Vector3 = new Vector3(0,
export function getLoocAtUpVec(dir: Vector3): Vector3
{
if (dir.equals(cZeroVec))
if (dir.equals(ZeroVec))
{
throw ("zero vector")
}
let norm = dir.clone().normalize();
if (norm.equals(cZAxis))
if (norm.equals(ZAxis))
{
return new Vector3(0, 1, 0);
}
else if (norm.equals(cZAxis.clone().negate()))
else if (norm.equals(ZAxis.clone().negate()))
{
return new Vector3(0, -1, 0);
}
else
{
let xv: Vector3 = new Vector3();
xv.crossVectors(cZAxis, norm);
xv.crossVectors(ZAxis, norm);
let up = new Vector3();
up.crossVectors(norm, xv);
@ -125,7 +139,7 @@ export function createLookAtMat4(dir: Vector3): Matrix4
{
let up = getLoocAtUpVec(dir);
let mat = new Matrix4();
mat.lookAt(cZeroVec, dir, up);
mat.lookAt(ZeroVec, dir, up);
return mat;
}
@ -200,15 +214,6 @@ export function MoveMatrix(v: Vector3): Matrix4
return new Matrix4().setPosition(v);
}
export function getProjectDist(v1: Vector3, v2: Vector3)
{
let ang = v1.angleTo(v2);
let dist = v1.length();
return {
h: dist * Math.cos(ang),
v: dist * Math.sin(ang)
}
}
//获得输入点在2线组成的4个区间的位置
export function getPtPostion(sp: Vector3, ep: Vector3, c: Vector3, inPt: Vector3)
{
@ -241,16 +246,14 @@ export function angleAndX(v: Vector3 | Vector2)
/**
* 0-2pi
*
* @export
* @param {number} an
*/
export function angleTo2Pi(an: number)
export function clampRad(an: number)
{
an = an % (Math.PI * 2);
if (an < 0) an += Math.PI * 2
return an;
}
export function updateGeometry(l: Line | Mesh, geometry: Geometry | BufferGeometry)
{
let geo = l.geometry as Geometry;
@ -329,7 +332,7 @@ export function getEulerAngle(x: Vector3, y: Vector3, z: Vector3)
{
let roY = Math.atan2(x.z, Math.sqrt(x.x ** 2 + x.y ** 2)) * -180 / Math.PI;
let roZ = Math.atan2(x.y, x.x);
let vec = cYAxis.clone();
let vec = YAxis.clone();
let roMat = new Matrix4().makeRotationZ(roZ);
roZ *= 180 / Math.PI;
vec.applyMatrix4(roMat);

@ -1,5 +1,5 @@
import { Vector3, Math as TMath } from "three";
import { cYAxis, cZAxis, equaln } from "./GeUtils";
import { YAxis, ZAxis, equaln } from "./GeUtils";
/**
* ,
@ -69,9 +69,9 @@ export class Orbit
static ComputUpDirection(n: Vector3, ay: Vector3 = new Vector3(), ax: Vector3 = new Vector3()): Vector3
{
if (Math.abs(n.x) < 0.015625 && Math.abs(n.y) < 0.015625)
ax.crossVectors(cYAxis, n);
ax.crossVectors(YAxis, n);
else
ax.crossVectors(cZAxis, n);
ax.crossVectors(ZAxis, n);
ay.crossVectors(n, ax);
return ay;

@ -2,7 +2,7 @@ import { Matrix4, Vector3 } from "three";
import { arrayRemoveDuplicateBySort2 } from "../../Common/ArrayExt";
import { Board, BoardType } from "../../DatabaseServices/Board";
import { Box3Ext, SplitType } from "../Box";
import { cXAxis, cYAxis, cZAxis, cZeroVec, equaln, equalv3 } from "../GeUtils";
import { XAxis, YAxis, ZAxis, ZeroVec, equaln, equalv3 } from "../GeUtils";
import { FuzzDirection } from "../FuzzVector";
@ -73,7 +73,7 @@ export class ISpaceParse
if (this.m_Boards && this.m_Boards.length > 0)
{
this.m_BoardMap.clear();
let spaceOCSInv = this.m_SpaceOCSInv.clone().setPosition(cZeroVec);
let spaceOCSInv = this.m_SpaceOCSInv.clone().setPosition(ZeroVec);
let fuzzNormal = new FuzzDirection();
@ -83,11 +83,11 @@ export class ISpaceParse
let normal = br.Normal.applyMatrix4(spaceOCSInv);
fuzzNormal.GetKey(normal, true);
let type: BoardType;
if (equalv3(cXAxis, normal))
if (equalv3(XAxis, normal))
type = BoardType.Vertical;
else if (equalv3(cYAxis, normal))
else if (equalv3(YAxis, normal))
type = BoardType.Behind;
else if (equalv3(cZAxis, normal))
else if (equalv3(ZAxis, normal))
type = BoardType.Layer;
let brs = this.m_BoardMap.get(type);

@ -2,7 +2,7 @@ import { Matrix4, Vector3 } from "three";
import { app } from "../../ApplicationServices/Application";
import { PromptStatus } from "../../Editor/PromptResult";
import { Box3Ext } from "../Box";
import { cZAxis, equaln } from "../GeUtils";
import { ZAxis, equaln } from "../GeUtils";
import { ISpaceParse } from "./ISpaceParse";
export class Point2SpaceParse extends ISpaceParse
@ -21,7 +21,7 @@ export class Point2SpaceParse extends ISpaceParse
if (distRes.Status === PromptStatus.OK)
{
let depth = distRes.Distance;
let nor = cZAxis.clone().applyMatrix4(app.m_Editor.UCSMatrix);
let nor = ZAxis.clone().applyMatrix4(app.m_Editor.UCSMatrix);
let p1 = res.Point1WCS;
let p2 = res.Point2WCS;

@ -8,7 +8,7 @@ import { Shape } from "../../DatabaseServices/Shape";
import { ShapeManager } from "../../DatabaseServices/ShapeManager";
import { BoolOpeartionType } from "../BoolOperateUtils";
import { OptimizeToolPath } from "./OptimizeToolPath";
import { equalCurve, isRect } from "../../Common/CurveUtils";
import { equalCurve, IsRect } from "../../Common/CurveUtils";
import { Vector3 } from "three";
/**
@ -210,7 +210,7 @@ export class FeedingToolPath extends Singleton
//若是矩形,应用槽加长
if (addLen > 0)
{
let curveData = isRect(shape.Outline.Curve);
let curveData = IsRect(shape.Outline.Curve);
if (curveData.isRect)
{
let box = curveData.box;

@ -6,7 +6,7 @@ import { Database } from '../DatabaseServices/Database';
import { Entity } from '../DatabaseServices/Entity';
import { GenerateRaycaster } from '../Editor/PointPick';
import { userConfig } from '../Editor/UserConfig';
import { cZeroVec, GetBox, GetBoxArr, isPerpendicularityTo } from '../Geometry/GeUtils';
import { ZeroVec, GetBox, GetBoxArr, isPerpendicularityTo } from '../Geometry/GeUtils';
import { PlaneExt } from '../Geometry/Plane';
import { CameraUpdate } from './CameraUpdate';
import { GripScene } from './GripScene';
@ -257,7 +257,7 @@ export class Viewer
if (!box.isEmpty())
this.m_LookTarget = box.getCenter(new Vector3());
else
this.m_LookTarget = cZeroVec;
this.m_LookTarget = ZeroVec;
}
Rotate(mouseMove: Vector3)
{

Loading…
Cancel
Save