Skip to content

armgit / kiln

Public Imported from GitHub
0

Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.

chore(client): import kiln primitives from core, delete local copy

Matt Kissinger5db24cf07091
diff --git a/index.ts b/index.ts
index 9c4b5e61..02a24cac 100644
--- a/index.ts
+++ b/index.ts
@@ -34,6 +34,29 @@ export {
countTriangles,
countMaterials,
getJointNames,
+ validateAsset,
+ // Primitive re-exports so the editor can `import { createRoot, boxGeo, ... } from '@pixel-forge/core/kiln'`
+ createRoot,
+ createPivot,
+ createPart,
+ capsuleGeo,
+ cylinderGeo,
+ boxGeo,
+ sphereGeo,
+ coneGeo,
+ torusGeo,
+ planeGeo,
+ gameMaterial,
+ basicMaterial,
+ glassMaterial,
+ lambertMaterial,
+ rotationTrack,
+ positionTrack,
+ scaleTrack,
+ createClip,
+ idleBreathing,
+ bobbingAnimation,
+ spinAnimation,
} from './primitives';
// =============================================================================
diff --git a/primitives.ts b/primitives.ts
index 4035683f..c15b7799 100644
--- a/primitives.ts
+++ b/primitives.ts
@@ -376,6 +376,39 @@ export function getJointNames(root: THREE.Object3D): string[] {
return joints;
}
+/**
+ * Validates asset against category guidelines.
+ * Returns warnings for guidance but doesn't block on limits.
+ */
+export function validateAsset(
+ root: THREE.Object3D,
+ category: 'character' | 'prop' | 'vfx' | 'environment'
+): { valid: boolean; errors: string[]; warnings: string[] } {
+ const errors: string[] = [];
+ const warnings: string[] = [];
+
+ const guidelines = {
+ character: { suggestedTris: 5000, suggestedMats: 8 },
+ prop: { suggestedTris: 3000, suggestedMats: 6 },
+ vfx: { suggestedTris: 2000, suggestedMats: 4 },
+ environment: { suggestedTris: 15000, suggestedMats: 12 },
+ };
+
+ const limits = guidelines[category];
+ const tris = countTriangles(root);
+ const mats = countMaterials(root);
+
+ if (tris > limits.suggestedTris) {
+ warnings.push(`High triangle count: ${tris} (suggested: ${limits.suggestedTris})`);
+ }
+
+ if (mats > limits.suggestedMats) {
+ warnings.push(`High material count: ${mats} (suggested: ${limits.suggestedMats})`);
+ }
+
+ return { valid: true, errors, warnings };
+}
+
/**
* The full sandbox globals used when executing Kiln code. Kept in one place
* so render.ts and any future evaluator share the same surface area as what
@@ -388,6 +421,7 @@ export function buildSandboxGlobals(): Record<string, unknown> {
gameMaterial, basicMaterial, glassMaterial, lambertMaterial,
rotationTrack, positionTrack, scaleTrack, createClip,
spinAnimation, bobbingAnimation, idleBreathing,
+ countTriangles, countMaterials, getJointNames, validateAsset,
Math, console,
};
}