Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
Add toolbar buttons ruler and cut previews
This commit is contained in:
@@ -4,10 +4,20 @@ import { createLocalId } from "@/lib/localIds";
|
||||
import type { WorkplaneShape } from "@/types/sketchforge";
|
||||
|
||||
const stlLoader = new STLLoader();
|
||||
const SUPPORTED_IMPORT_EXTENSIONS = new Set(["stl"]);
|
||||
|
||||
export function importedShapeFromStl(fileName: string, buffer: ArrayBuffer): WorkplaneShape {
|
||||
const rawGeometry = stlLoader.parse(buffer);
|
||||
const geometry = rawGeometry.index ? rawGeometry.toNonIndexed() : rawGeometry.clone();
|
||||
function fileExtension(fileName: string) {
|
||||
return fileName.split(".").pop()?.toLowerCase() ?? "";
|
||||
}
|
||||
|
||||
function importedShapeFromTriangleSoup(fileName: string, rawPositions: number[], rawNormals: number[] | undefined): WorkplaneShape {
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
geometry.setAttribute("position", new THREE.Float32BufferAttribute(rawPositions, 3));
|
||||
if (rawNormals?.length === rawPositions.length) {
|
||||
geometry.setAttribute("normal", new THREE.Float32BufferAttribute(rawNormals, 3));
|
||||
} else {
|
||||
geometry.computeVertexNormals();
|
||||
}
|
||||
geometry.computeBoundingBox();
|
||||
|
||||
const box = geometry.boundingBox;
|
||||
@@ -70,3 +80,25 @@ export function importedShapeFromStl(fileName: string, buffer: ArrayBuffer): Wor
|
||||
hidden: false,
|
||||
};
|
||||
}
|
||||
|
||||
export function importExtensionSupported(fileName: string) {
|
||||
return SUPPORTED_IMPORT_EXTENSIONS.has(fileExtension(fileName));
|
||||
}
|
||||
|
||||
export function importedShapeFromStl(fileName: string, buffer: ArrayBuffer): WorkplaneShape {
|
||||
const rawGeometry = stlLoader.parse(buffer);
|
||||
const geometry = rawGeometry.index ? rawGeometry.toNonIndexed() : rawGeometry.clone();
|
||||
const position = geometry.getAttribute("position");
|
||||
const normal = geometry.getAttribute("normal");
|
||||
const rawPositions: number[] = [];
|
||||
const rawNormals: number[] = [];
|
||||
|
||||
for (let i = 0; i < position.count; i += 1) {
|
||||
rawPositions.push(position.getX(i), position.getY(i), position.getZ(i));
|
||||
if (normal) {
|
||||
rawNormals.push(normal.getX(i), normal.getY(i), normal.getZ(i));
|
||||
}
|
||||
}
|
||||
|
||||
return importedShapeFromTriangleSoup(fileName, rawPositions, rawNormals.length ? rawNormals : undefined);
|
||||
}
|
||||
Reference in New Issue
Block a user