-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🦄 refactor: refactor IHighlighter and ThreeGeometry
- Loading branch information
1 parent
d8bc988
commit 18104db
Showing
16 changed files
with
351 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license. | ||
|
||
export * from "./mesh"; | ||
export * from "./utils"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2022-2023 the Chili authors. All rights reserved. AGPL-3.0 license. | ||
|
||
import { EdgeMeshData, FaceMeshData, MathUtils } from "chili-core"; | ||
|
||
export class MeshUtils { | ||
static subFace(mesh: FaceMeshData, index: number) { | ||
let group = mesh?.groups[index]; | ||
if (!group) return undefined; | ||
|
||
let indices = mesh.indices.slice(group.start, group.start + group.count); | ||
let minMax = MathUtils.minMax(indices)!; | ||
let [indiceStart, indiceEnd] = [minMax.min, minMax.max + 1]; | ||
|
||
let positions = mesh.positions.slice(indiceStart * 3, indiceEnd * 3); | ||
let normals = mesh.normals.slice(indiceStart * 3, indiceEnd * 3); | ||
indices = indices.map((i) => i - indiceStart); | ||
|
||
return { | ||
positions, | ||
normals, | ||
indices, | ||
}; | ||
} | ||
|
||
static subEdge(mesh: EdgeMeshData, index: number) { | ||
let group = mesh?.groups[index]; | ||
if (!group) return undefined; | ||
|
||
let positions = mesh.positions.slice(group.start * 3, (group.start + group.count) * 3); | ||
return { | ||
positions, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.