auto-git:
[change] src/geometry/box-brush-mesh.ts [change] src/geometry/box-face-uvs.ts
This commit is contained in:
@@ -62,22 +62,6 @@ function cloneVec3(vector: Vec3): Vec3 {
|
|||||||
return { x: vector.x, y: vector.y, z: vector.z };
|
return { x: vector.x, y: vector.y, z: vector.z };
|
||||||
}
|
}
|
||||||
|
|
||||||
function subtractVec3(left: Vec3, right: Vec3): Vec3 {
|
|
||||||
return {
|
|
||||||
x: left.x - right.x,
|
|
||||||
y: left.y - right.y,
|
|
||||||
z: left.z - right.z
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function crossVec3(left: Vec3, right: Vec3): Vec3 {
|
|
||||||
return {
|
|
||||||
x: left.y * right.z - left.z * right.y,
|
|
||||||
y: left.z * right.x - left.x * right.z,
|
|
||||||
z: left.x * right.y - left.y * right.x
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function dotVec3(left: Vec3, right: Vec3): number {
|
function dotVec3(left: Vec3, right: Vec3): number {
|
||||||
return left.x * right.x + left.y * right.y + left.z * right.z;
|
return left.x * right.x + left.y * right.y + left.z * right.z;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,12 @@ import type { Vec2, Vec3 } from "../core/vector";
|
|||||||
import { BOX_FACE_IDS, createDefaultFaceUvState, type BoxBrush, type BoxFaceId, type FaceUvState } from "../document/brushes";
|
import { BOX_FACE_IDS, createDefaultFaceUvState, type BoxBrush, type BoxFaceId, type FaceUvState } from "../document/brushes";
|
||||||
import { getBoxBrushHalfSize } from "./box-brush";
|
import { getBoxBrushHalfSize } from "./box-brush";
|
||||||
|
|
||||||
export function getBoxBrushFaceSize(brush: BoxBrush, faceId: BoxFaceId): Vec2 {
|
interface BoxBrushUvProjectionSource {
|
||||||
|
size: Vec3;
|
||||||
|
faces: Record<BoxFaceId, { uv: FaceUvState }>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getBoxBrushFaceSize(brush: BoxBrushUvProjectionSource, faceId: BoxFaceId): Vec2 {
|
||||||
switch (faceId) {
|
switch (faceId) {
|
||||||
case "posX":
|
case "posX":
|
||||||
case "negX":
|
case "negX":
|
||||||
@@ -39,7 +44,7 @@ export function createFitToFaceBoxBrushFaceUvState(brush: BoxBrush, faceId: BoxF
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function projectBoxFaceVertexToUv(vertexPosition: Vec3, brush: BoxBrush, faceId: BoxFaceId): Vec2 {
|
export function projectBoxFaceVertexToUv(vertexPosition: Vec3, brush: BoxBrushUvProjectionSource, faceId: BoxFaceId): Vec2 {
|
||||||
const halfSize = getBoxBrushHalfSize(brush);
|
const halfSize = getBoxBrushHalfSize(brush);
|
||||||
|
|
||||||
switch (faceId) {
|
switch (faceId) {
|
||||||
@@ -113,7 +118,7 @@ export function transformProjectedFaceUv(baseUv: Vec2, faceSize: Vec2, uvState:
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function applyBoxBrushFaceUvsToGeometry(geometry: BoxGeometry, brush: BoxBrush): void {
|
export function applyBoxBrushFaceUvsToGeometry(geometry: BoxGeometry, brush: BoxBrushUvProjectionSource): void {
|
||||||
const positionAttribute = geometry.getAttribute("position");
|
const positionAttribute = geometry.getAttribute("position");
|
||||||
const uvAttribute = geometry.getAttribute("uv");
|
const uvAttribute = geometry.getAttribute("uv");
|
||||||
const indexAttribute = geometry.getIndex();
|
const indexAttribute = geometry.getIndex();
|
||||||
|
|||||||
Reference in New Issue
Block a user