From cf53ed66d787f8a4108bacdb1afc99fc457b2d74 Mon Sep 17 00:00:00 2001 From: ChenX Date: Mon, 2 Dec 2019 09:06:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/DatabaseServices/3DSolid/CylinderHole.ts | 2 +- src/DatabaseServices/Database.ts | 8 ++++---- src/Geometry/CreateWireframe.ts | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/DatabaseServices/3DSolid/CylinderHole.ts b/src/DatabaseServices/3DSolid/CylinderHole.ts index b226260c0..0e35da354 100644 --- a/src/DatabaseServices/3DSolid/CylinderHole.ts +++ b/src/DatabaseServices/3DSolid/CylinderHole.ts @@ -219,7 +219,7 @@ export function FastDrillingEdgeGeometry(radius: number, height: number): Buffer coords.push(p.x, p.y, 0, p.x, p.y, height);//edge } - geo.addAttribute('position', new Float32BufferAttribute(coords, 3)); + geo.setAttribute('position', new Float32BufferAttribute(coords, 3)); cache2.set(key, geo); return geo; } diff --git a/src/DatabaseServices/Database.ts b/src/DatabaseServices/Database.ts index 089f73b5d..bf4e27cba 100644 --- a/src/DatabaseServices/Database.ts +++ b/src/DatabaseServices/Database.ts @@ -110,7 +110,7 @@ export class Database if (!this.defaultDatabase) return; - this.DefaultMaterial = this.GetObjectId(71).Object as PhysicalMaterialRecord; + this.DefaultMaterial = this.GetObjectId(71)?.Object as PhysicalMaterialRecord ?? this.DefaultMaterial; this.DefaultMaterial.Update(); HostApplicationServices.DefaultMeshMaterial = this.DefaultMaterial.Material; } @@ -174,9 +174,9 @@ export class Database if (ver > 3) { this.Lights.ReadFile(file); - this.AmbientLight = this.Lights.Entitys[0] as AmbientLight; - this.SunLight = this.Lights.Entitys[1] as DirectionalLight; - this.HemisphereLight = this.Lights.Entitys[2] as HemisphereLight; + this.AmbientLight = this.Lights.Entitys[0] as AmbientLight ?? this.AmbientLight; + this.SunLight = this.Lights.Entitys[1] as DirectionalLight ?? this.SunLight; + this.HemisphereLight = this.Lights.Entitys[2] as HemisphereLight ?? this.HemisphereLight; } else { diff --git a/src/Geometry/CreateWireframe.ts b/src/Geometry/CreateWireframe.ts index 5bf1c143d..84d0e0f03 100644 --- a/src/Geometry/CreateWireframe.ts +++ b/src/Geometry/CreateWireframe.ts @@ -166,13 +166,13 @@ export function FastWireframe2(dr: ExtrudeHole, color = 0) coords.push(p.x, p.y, height); let edgeGeo = new BufferGeometry(); - edgeGeo.addAttribute('position', new Float32BufferAttribute(edgeCoords, 3)); - geo.addAttribute('position', new Float32BufferAttribute(coords, 3)); + edgeGeo.setAttribute('position', new Float32BufferAttribute(edgeCoords, 3)); + geo.setAttribute('position', new Float32BufferAttribute(coords, 3)); let line = new Line(geo, material); line.applyMatrix(cu.OCS); - let edge = new LineSegments(edgeGeo, material) + let edge = new LineSegments(edgeGeo, material); edge.applyMatrix(cu.OCS); let result = [line, edge];