同步源码
This commit is contained in:
97
api.esm.js
97
api.esm.js
@@ -681,7 +681,7 @@ class CADFiler {
|
||||
Read() {
|
||||
return this._datas[this.readIndex++];
|
||||
}
|
||||
ReadBool(v) {
|
||||
ReadBool() {
|
||||
return Boolean(this.Read());
|
||||
}
|
||||
ReadArray(count) {
|
||||
@@ -763,11 +763,11 @@ AllObjectData = __decorate([
|
||||
|
||||
let EraseEntityData = class EraseEntityData {
|
||||
ReadFile(file) {
|
||||
this.isErase = file.Read();
|
||||
this.isErase = file.ReadBool();
|
||||
return this;
|
||||
}
|
||||
WriteFile(file) {
|
||||
file.Write(this.isErase);
|
||||
file.WriteBool(this.isErase);
|
||||
return this;
|
||||
}
|
||||
constructor(isErase = true) {
|
||||
@@ -864,7 +864,7 @@ class CADObject {
|
||||
this.objectId = id;
|
||||
id.Object = this;
|
||||
}
|
||||
this._isErase = file.Read();
|
||||
this._isErase = file.ReadBool();
|
||||
if (ver > 1)
|
||||
this._Owner = file.ReadObjectId();
|
||||
}
|
||||
@@ -872,7 +872,7 @@ class CADObject {
|
||||
WriteFile(file) {
|
||||
file.Write(2);
|
||||
file.WriteObjectId(this.objectId);
|
||||
file.Write(this._isErase);
|
||||
file.WriteBool(this._isErase);
|
||||
file.WriteObjectId(this._Owner);
|
||||
}
|
||||
//局部撤销
|
||||
@@ -1480,6 +1480,7 @@ let Entity = Entity_1 = class Entity extends CADObject {
|
||||
//模块空间的标系
|
||||
this._SpaceOCS = new Matrix4();
|
||||
this._Visible = true;
|
||||
this._VisibleInRender = true; //在渲染器中显示
|
||||
this._Freeze = false; //冻结(无法被选中)
|
||||
//加工组
|
||||
this.ProcessingGroupList = [];
|
||||
@@ -1512,6 +1513,13 @@ let Entity = Entity_1 = class Entity extends CADObject {
|
||||
this.WriteAllObjectRecord();
|
||||
this._Freeze = f;
|
||||
}
|
||||
get VisibleInRender() { return this._VisibleInRender; }
|
||||
set VisibleInRender(v) {
|
||||
if (this._VisibleInRender !== v) {
|
||||
this.WriteAllObjectRecord();
|
||||
this._VisibleInRender = v;
|
||||
}
|
||||
}
|
||||
set Material(materialId) {
|
||||
if (materialId === this._MaterialId)
|
||||
return;
|
||||
@@ -1973,6 +1981,8 @@ let Entity = Entity_1 = class Entity extends CADObject {
|
||||
super.ReadFile(file);
|
||||
this._Color = file.Read();
|
||||
this._MaterialId = file.ReadHardObjectId();
|
||||
if (!this._MaterialId)
|
||||
this._MaterialId = file.database?.DefaultMaterial?.Id;
|
||||
this._Matrix.fromArray(file.Read());
|
||||
if (ver === 2)
|
||||
this.Owner = file.ReadObjectId();
|
||||
@@ -1981,7 +1991,7 @@ let Entity = Entity_1 = class Entity extends CADObject {
|
||||
if (ver > 4)
|
||||
this.GroupId = file.ReadHardObjectId();
|
||||
if (ver > 5)
|
||||
this._Visible = file.Read();
|
||||
this._Visible = file.ReadBool();
|
||||
if (ver > 6)
|
||||
this._SpaceOCS.fromArray(file.Read());
|
||||
if (ver > 7) {
|
||||
@@ -1994,25 +2004,30 @@ let Entity = Entity_1 = class Entity extends CADObject {
|
||||
}
|
||||
}
|
||||
if (ver > 8)
|
||||
this._Freeze = file.Read();
|
||||
this._Freeze = file.ReadBool();
|
||||
else
|
||||
this._Freeze = false;
|
||||
if (ver > 9)
|
||||
this._VisibleInRender = file.ReadBool();
|
||||
else
|
||||
this._VisibleInRender = true;
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file) {
|
||||
file.Write(9);
|
||||
file.Write(10);
|
||||
super.WriteFile(file);
|
||||
file.Write(this._Color);
|
||||
file.WriteHardObjectId(this._MaterialId);
|
||||
file.Write(this._Matrix.toArray());
|
||||
file.WriteObjectId(this.Template);
|
||||
file.WriteHardObjectId(this.GroupId);
|
||||
file.Write(this._Visible);
|
||||
file.WriteBool(this._Visible);
|
||||
file.Write(this._SpaceOCS.toArray());
|
||||
file.Write(this.ProcessingGroupList.length);
|
||||
for (let id of this.ProcessingGroupList)
|
||||
file.WriteHardObjectId(id);
|
||||
file.WriteBool(this._Freeze);
|
||||
file.WriteBool(this._VisibleInRender);
|
||||
}
|
||||
//局部撤销
|
||||
ApplyPartialUndo(undoData) {
|
||||
@@ -9353,7 +9368,7 @@ let Arc = Arc_1 = class Arc extends Curve {
|
||||
this._Radius = file.Read();
|
||||
this._StartAngle = file.Read();
|
||||
this._EndAngle = file.Read();
|
||||
this._Clockwise = file.Read();
|
||||
this._Clockwise = file.ReadBool();
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file) {
|
||||
@@ -9362,7 +9377,7 @@ let Arc = Arc_1 = class Arc extends Curve {
|
||||
file.Write(this._Radius);
|
||||
file.Write(this._StartAngle);
|
||||
file.Write(this._EndAngle);
|
||||
file.Write(this._Clockwise);
|
||||
file.WriteBool(this._Clockwise);
|
||||
}
|
||||
};
|
||||
Arc._X = new Vector3;
|
||||
@@ -21042,6 +21057,8 @@ let Board = Board_1 = class Board extends ExtrudeSolid {
|
||||
}
|
||||
}
|
||||
HandleBoardMaterial(renderType, obj) {
|
||||
if (!obj)
|
||||
return;
|
||||
if (!this.IsChaiDan) {
|
||||
if (renderType === RenderType.Conceptual || renderType === RenderType.Physical2) {
|
||||
obj.children.length = 1;
|
||||
@@ -23530,8 +23547,20 @@ let Text = class Text extends Entity {
|
||||
return this.BoundingBoxInOCS.applyMatrix4((this.OCSNoClone));
|
||||
}
|
||||
get BoundingBoxInOCS() {
|
||||
let w = Math.max(Math.abs(this.Width / 2), 1);
|
||||
let h = Math.max(Math.abs(this.Height / 2), 1);
|
||||
let width = this.Width;
|
||||
let height = this.Height;
|
||||
let obj = this._CacheDrawObject.get(RenderType.Wireframe);
|
||||
if (obj && obj.children.length === 1) {
|
||||
let geo = obj.children[0].geometry;
|
||||
if (geo) {
|
||||
if (!geo.boundingBox)
|
||||
geo.computeBoundingBox();
|
||||
width = geo.boundingBox.max.x - geo.boundingBox.min.x;
|
||||
height = geo.boundingBox.max.y - geo.boundingBox.min.y;
|
||||
}
|
||||
}
|
||||
let w = Math.max(Math.abs(width / 2), 1);
|
||||
let h = Math.max(Math.abs(height / 2), 1);
|
||||
let box = new Box3Ext(new Vector3(-w, -h, 0), new Vector3(w, h, 0));
|
||||
let offset = new Vector3;
|
||||
if (this.TextAligen & TextAligen.LeftMid)
|
||||
@@ -23622,6 +23651,19 @@ let Text = class Text extends Entity {
|
||||
this.Height = this.Height + v.y;
|
||||
}
|
||||
}
|
||||
//捕捉点
|
||||
GetObjectSnapPoints(snapMode, pickPoint, lastPoint, viewXform) {
|
||||
if (snapMode === ObjectSnapMode.End) {
|
||||
let box = this.BoundingBoxInOCS;
|
||||
let p2 = new Vector3(box.min.x, box.max.y);
|
||||
let p3 = new Vector3(box.max.x, box.min.y);
|
||||
let pts = [box.min, p2, p3, box.max];
|
||||
for (let p of pts)
|
||||
p.applyMatrix4(this.OCSNoClone);
|
||||
return pts;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
GetStretchPoints() {
|
||||
return [this.Position];
|
||||
}
|
||||
@@ -26593,7 +26635,7 @@ let SymbolTable = class SymbolTable extends CADObject {
|
||||
}
|
||||
WriteFile(file) {
|
||||
super.WriteFile(file);
|
||||
file.Write(3);
|
||||
file.Write(4);
|
||||
file.Write(this.Symbols.size);
|
||||
for (let [key, record] of this.Symbols) {
|
||||
file.WriteObject(record);
|
||||
@@ -27008,6 +27050,10 @@ let BlockTableRecord = class BlockTableRecord extends SymbolTableRecord {
|
||||
if (!entity.Material)
|
||||
entity.Material = this._db.MaterialTable.CurFloorMtl;
|
||||
}
|
||||
else if (entity instanceof Board) {
|
||||
if (!entity.Material)
|
||||
entity.Material = this._db.MaterialTable.CurBoardMtl;
|
||||
}
|
||||
}
|
||||
this.EntityCol.Append(entity, isCheckObjectCleanly);
|
||||
entity.Owner = this.objectId;
|
||||
@@ -28144,6 +28190,7 @@ HemisphereLight = __decorate([
|
||||
class MaterialTable extends SymbolTable {
|
||||
get CurFloorMtl() { return this._CurFloorMtl; }
|
||||
get CurWallMtl() { return this._CurWallMtl; }
|
||||
get CurBoardMtl() { return this._CurDrawMtl; }
|
||||
set CurFloorMtl(id) {
|
||||
if (id === this._CurFloorMtl)
|
||||
return;
|
||||
@@ -28160,6 +28207,14 @@ class MaterialTable extends SymbolTable {
|
||||
if (this._db && this._db.IsDefaultDatabase)
|
||||
HostApplicationServices.DefaultWallMaterial = id.Object.Material;
|
||||
}
|
||||
set CurBoardMtl(id) {
|
||||
if (id === this._CurDrawMtl)
|
||||
return;
|
||||
this.WriteAllObjectRecord();
|
||||
this._CurDrawMtl = id;
|
||||
if (this._db && this._db.IsDefaultDatabase)
|
||||
HostApplicationServices.DefaultMeshMaterial = id.Object.Material;
|
||||
}
|
||||
get Materials() {
|
||||
return this.Symbols;
|
||||
}
|
||||
@@ -28175,6 +28230,12 @@ class MaterialTable extends SymbolTable {
|
||||
AllocateName(name = "材质") {
|
||||
return super.AllocateName(name);
|
||||
}
|
||||
Destroy() {
|
||||
super.Destroy();
|
||||
this._CurDrawMtl = undefined;
|
||||
this._CurFloorMtl = undefined;
|
||||
this._CurWallMtl = undefined;
|
||||
}
|
||||
//#region -------------------------File-------------------------
|
||||
//对象从文件中读取数据,初始化自身
|
||||
ReadFile(file) {
|
||||
@@ -28183,12 +28244,15 @@ class MaterialTable extends SymbolTable {
|
||||
this._CurFloorMtl = file.ReadObjectId();
|
||||
this._CurWallMtl = file.ReadObjectId();
|
||||
}
|
||||
if (this._FileVer > 3)
|
||||
this._CurDrawMtl = file.ReadHardObjectId();
|
||||
}
|
||||
//对象将自身数据写入到文件.
|
||||
WriteFile(file) {
|
||||
super.WriteFile(file);
|
||||
file.WriteObjectId(this._CurFloorMtl);
|
||||
file.WriteObjectId(this._CurWallMtl);
|
||||
file.WriteObjectId(this._CurDrawMtl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28405,6 +28469,7 @@ let Database = class Database {
|
||||
this.DefaultMaterial.roughnessMap = texture.Id;
|
||||
this.DefaultMaterial.bumpMap = texture.Id;
|
||||
this.MaterialTable.Add(this.DefaultMaterial);
|
||||
this.MaterialTable.CurBoardMtl = this.DefaultMaterial.Id;
|
||||
texture.Update();
|
||||
}
|
||||
InitLight() {
|
||||
@@ -28424,7 +28489,9 @@ let Database = class Database {
|
||||
return;
|
||||
this.DefaultMaterial = this.GetObjectId(71)?.Object ?? this.DefaultMaterial;
|
||||
this.DefaultMaterial.Update();
|
||||
HostApplicationServices.DefaultMeshMaterial = this.DefaultMaterial.Material;
|
||||
HostApplicationServices.DefaultMeshMaterial = this.MaterialTable.CurBoardMtl?.Object?.Material ?? this.DefaultMaterial.Material;
|
||||
HostApplicationServices.DefaultWallMaterial = this.MaterialTable.CurWallMtl?.Object?.Material ?? this.DefaultMaterial.Material;
|
||||
HostApplicationServices.DefaultFloorMaterial = this.MaterialTable.CurFloorMtl?.Object?.Material ?? this.DefaultMaterial.Material;
|
||||
HostApplicationServices.CurrentDimStyle = this.DimStyleTable.Current;
|
||||
}
|
||||
Destroy() {
|
||||
|
Reference in New Issue
Block a user