three-csg-ts
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [3.0.1](https://github.com/Jiro-Digital/three-csg-ts/compare/v3.0.0...v3.0.1) (2021-05-14) | ||
### Bug Fixes | ||
* re-add CSG toGeometry method ([0d82369](https://github.com/Jiro-Digital/three-csg-ts/commit/0d82369d2b3b8d18b9a987ee8b2a06a11f678c61)) | ||
## [3.0.0](https://github.com/Jiro-Digital/three-csg-ts/compare/v2.3.0...v3.0.0) (2021-05-14) | ||
@@ -7,0 +14,0 @@ |
@@ -10,2 +10,3 @@ import { BufferGeometry, Material, Matrix4, Mesh } from 'three'; | ||
static fromGeometry(geom: BufferGeometry, objectIndex?: any): CSG; | ||
static toGeometry(csg: CSG, toMatrix: Matrix4): BufferGeometry; | ||
static fromMesh(mesh: Mesh, objectIndex?: any): CSG; | ||
@@ -12,0 +13,0 @@ static toMesh(csg: CSG, toMatrix: Matrix4, toMaterial?: Material | Material[]): Mesh; |
@@ -61,18 +61,3 @@ "use strict"; | ||
} | ||
static fromMesh(mesh, objectIndex) { | ||
const csg = CSG.fromGeometry(mesh.geometry, objectIndex); | ||
const ttvv0 = new three_1.Vector3(); | ||
const tmpm3 = new three_1.Matrix3(); | ||
tmpm3.getNormalMatrix(mesh.matrix); | ||
for (let i = 0; i < csg.polygons.length; i++) { | ||
const p = csg.polygons[i]; | ||
for (let j = 0; j < p.vertices.length; j++) { | ||
const v = p.vertices[j]; | ||
v.pos.copy(ttvv0.copy(v.pos.toVector3()).applyMatrix4(mesh.matrix)); | ||
v.normal.copy(ttvv0.copy(v.normal.toVector3()).applyMatrix3(tmpm3)); | ||
} | ||
} | ||
return csg; | ||
} | ||
static toMesh(csg, toMatrix, toMaterial) { | ||
static toGeometry(csg, toMatrix) { | ||
let triCount = 0; | ||
@@ -137,2 +122,21 @@ const ps = csg.polygons; | ||
geom.computeBoundingBox(); | ||
return geom; | ||
} | ||
static fromMesh(mesh, objectIndex) { | ||
const csg = CSG.fromGeometry(mesh.geometry, objectIndex); | ||
const ttvv0 = new three_1.Vector3(); | ||
const tmpm3 = new three_1.Matrix3(); | ||
tmpm3.getNormalMatrix(mesh.matrix); | ||
for (let i = 0; i < csg.polygons.length; i++) { | ||
const p = csg.polygons[i]; | ||
for (let j = 0; j < p.vertices.length; j++) { | ||
const v = p.vertices[j]; | ||
v.pos.copy(ttvv0.copy(v.pos.toVector3()).applyMatrix4(mesh.matrix)); | ||
v.normal.copy(ttvv0.copy(v.normal.toVector3()).applyMatrix3(tmpm3)); | ||
} | ||
} | ||
return csg; | ||
} | ||
static toMesh(csg, toMatrix, toMaterial) { | ||
const geom = CSG.toGeometry(csg, toMatrix); | ||
const m = new three_1.Mesh(geom, toMaterial); | ||
@@ -139,0 +143,0 @@ m.matrix.copy(toMatrix); |
@@ -10,2 +10,3 @@ import { BufferGeometry, Material, Matrix4, Mesh } from 'three'; | ||
static fromGeometry(geom: BufferGeometry, objectIndex?: any): CSG; | ||
static toGeometry(csg: CSG, toMatrix: Matrix4): BufferGeometry; | ||
static fromMesh(mesh: Mesh, objectIndex?: any): CSG; | ||
@@ -12,0 +13,0 @@ static toMesh(csg: CSG, toMatrix: Matrix4, toMaterial?: Material | Material[]): Mesh; |
@@ -58,18 +58,3 @@ import { BufferAttribute, BufferGeometry, Matrix3, Matrix4, Mesh, Vector3, } from 'three'; | ||
} | ||
static fromMesh(mesh, objectIndex) { | ||
const csg = CSG.fromGeometry(mesh.geometry, objectIndex); | ||
const ttvv0 = new Vector3(); | ||
const tmpm3 = new Matrix3(); | ||
tmpm3.getNormalMatrix(mesh.matrix); | ||
for (let i = 0; i < csg.polygons.length; i++) { | ||
const p = csg.polygons[i]; | ||
for (let j = 0; j < p.vertices.length; j++) { | ||
const v = p.vertices[j]; | ||
v.pos.copy(ttvv0.copy(v.pos.toVector3()).applyMatrix4(mesh.matrix)); | ||
v.normal.copy(ttvv0.copy(v.normal.toVector3()).applyMatrix3(tmpm3)); | ||
} | ||
} | ||
return csg; | ||
} | ||
static toMesh(csg, toMatrix, toMaterial) { | ||
static toGeometry(csg, toMatrix) { | ||
let triCount = 0; | ||
@@ -134,2 +119,21 @@ const ps = csg.polygons; | ||
geom.computeBoundingBox(); | ||
return geom; | ||
} | ||
static fromMesh(mesh, objectIndex) { | ||
const csg = CSG.fromGeometry(mesh.geometry, objectIndex); | ||
const ttvv0 = new Vector3(); | ||
const tmpm3 = new Matrix3(); | ||
tmpm3.getNormalMatrix(mesh.matrix); | ||
for (let i = 0; i < csg.polygons.length; i++) { | ||
const p = csg.polygons[i]; | ||
for (let j = 0; j < p.vertices.length; j++) { | ||
const v = p.vertices[j]; | ||
v.pos.copy(ttvv0.copy(v.pos.toVector3()).applyMatrix4(mesh.matrix)); | ||
v.normal.copy(ttvv0.copy(v.normal.toVector3()).applyMatrix3(tmpm3)); | ||
} | ||
} | ||
return csg; | ||
} | ||
static toMesh(csg, toMatrix, toMaterial) { | ||
const geom = CSG.toGeometry(csg, toMatrix); | ||
const m = new Mesh(geom, toMaterial); | ||
@@ -136,0 +140,0 @@ m.matrix.copy(toMatrix); |
{ | ||
"name": "three-csg-ts", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "CSG library for use with THREE.js", | ||
@@ -5,0 +5,0 @@ "main": "lib/cjs/index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
61342
1381
0