file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
components/ui/tooltip/Tooltip.vue
Vue
<script setup lang="ts"> import { TooltipRoot, type TooltipRootEmits, type TooltipRootProps, useForwardPropsEmits } from 'radix-vue' const props = defineProps<TooltipRootProps>() const emits = defineEmits<TooltipRootEmits>() const forwarded = useForwardPropsEmits(props, emits) </script> <template> <TooltipRoot v-b...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
components/ui/tooltip/TooltipContent.vue
Vue
<script setup lang="ts"> import { TooltipContent, type TooltipContentEmits, type TooltipContentProps, TooltipPortal, useForwardPropsEmits } from 'radix-vue' import { cn } from '@/utils' const props = withDefaults(defineProps<TooltipContentProps>(), { sideOffset: 4, }) const emits = defineEmits<TooltipContentEmits>()...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
components/ui/tooltip/TooltipProvider.vue
Vue
<script setup lang="ts"> import { TooltipProvider, type TooltipProviderProps } from 'radix-vue' const props = defineProps<TooltipProviderProps>() </script> <template> <TooltipProvider v-bind="props"> <slot /> </TooltipProvider> </template>
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
components/ui/tooltip/TooltipTrigger.vue
Vue
<script setup lang="ts"> import { TooltipTrigger, type TooltipTriggerProps } from 'radix-vue' const props = defineProps<TooltipTriggerProps>() </script> <template> <TooltipTrigger v-bind="props" class=""> <slot /> </TooltipTrigger> </template>
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
components/ui/tooltip/index.ts
TypeScript
export { default as Tooltip } from './Tooltip.vue' export { default as TooltipContent } from './TooltipContent.vue' export { default as TooltipTrigger } from './TooltipTrigger.vue' export { default as TooltipProvider } from './TooltipProvider.vue'
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
composables/openai.ts
TypeScript
export function useOpenAIKey() { return useLocalStorage('openai_key', () => '') } export function useNewPrompt() { return useState('init', () => false) } type FetchRequest = Parameters<typeof $fetch>[0] export function usePrompt() { const fetchResult = createEventHook<void>() const fetchError = createEventHook...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
composables/parse.ts
TypeScript
import { Parser } from 'htmlparser2' import { DomHandler } from 'domhandler' import domSerializer from 'dom-serializer' export function parseTemplate(inputHTML: string) { const handler = new DomHandler() // Parse HTML const parser = new Parser(handler, { xmlMode: true }) parser.write(inputHTML) parser.end() ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
drizzle.config.ts
TypeScript
import { join } from 'pathe' import type { Config } from 'drizzle-kit' export default { out: 'server/database/migrations', schema: 'server/database/schema.ts', driver: 'better-sqlite', dbCredentials: { url: join(process.cwd(), './db.sqlite'), }, // driver: 'turso', // dbCredentials: { // // url: ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
eslint.config.js
JavaScript
import antfu from '@antfu/eslint-config' export default antfu({ rules: { 'no-console': 'off', 'node/prefer-global/process': 'off', }, })
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
layouts/blank.vue
Vue
<template> <slot /> </template>
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
layouts/default.vue
Vue
<script setup lang="ts"> import { GithubLogoIcon } from '@radix-icons/vue' </script> <template> <div> <div class=" w-full h-full flex flex-col items-center justify-center "> <header class="sticky top-0 flex p-2 md:p-4 w-full z-10"> <NuxtLink to="/" class="group h-10 flex items-center gap-1 ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
nuxt.config.ts
TypeScript
// https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ // devtools totally broken, not sure why devtools: { enabled: false }, app: { head: { link: [{ rel: 'icon', type: 'image/svg', href: '/logo.svg' }], }, }, runtimeConfig: { public: { siteUrl: '', ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
pages/[...name].vue
Vue
<script setup lang="ts"> const route = useRoute() const name = computed(() => route.params.name) const { data } = await useFetch<DBComponent[]>(`/api/component/user/${name.value}`) const dataUser = computed(() => data.value?.at(-1)?.user) if (!data.value?.length) { throw createError({ statusCode: 404, statu...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
pages/faq.vue
Vue
<script setup lang="ts"> useSeoMeta({ title: 'FAQs', description: 'Get answers to common questions about vue0, the generative UI tool.', }) </script> <template> <div class="prose mx-auto py-6"> <h1 class="font-bold text-4xl px-6 "> FAQs </h1> <article class="mt-8 bg-muted rounded-xl px-6 py-4 ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
pages/index.vue
Vue
<script setup lang="ts"> import { Github } from 'lucide-vue-next' import { useToast } from '~/components/ui/toast' const prompt = ref('') const { data } = useFetch<DBComponent[]>('/api/component/all') const { isNewPrompt, handleInit, loading } = usePrompt() const { toast } = useToast() const openaiKey = useOpenAIKey(...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
pages/p/[slug].vue
Vue
<script setup lang="ts"> const route = useRoute() const slug = computed(() => route.params.slug.toString()) const { data } = await useFetch<DBComponent[]>(`/api/component/${slug.value}`) const sfcString = ref(data.value?.[0].code ?? '') const errorMessage = ref(data.value?.[0].error) onMounted(() => { window.addEve...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
pages/s/[id].vue
Vue
<script setup lang="ts"> const route = useRoute() const id = computed(() => route.params.id.toString()) const { data } = await useFetch<DBComponent[]>(`/api/component/id/${id.value}`) const sfcString = ref(data.value?.[0].code ?? '') definePageMeta({ layout: 'blank', }) useHead({ script: [ { src: 'https://cd...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
pages/t/[slug].vue
Vue
<script setup lang="ts"> import { upperFirst } from 'scule' import { AlertTriangle, Clipboard, ClipboardCheck, Clock, Code2Icon, GitBranch, IterationCw, MoreVertical, MousePointerSquare, Share, Trash, Trash2 } from 'lucide-vue-next' import { differenceInMinutes } from 'date-fns' import { useToast } from '~/components/u...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
public/cdn/tailwind.js
JavaScript
(()=>{var Qx=Object.create;var xn=Object.defineProperty;var Jx=Object.getOwnPropertyDescriptor;var Xx=Object.getOwnPropertyNames;var Kx=Object.getPrototypeOf,Zx=Object.prototype.hasOwnProperty;var Gc=t=>xn(t,"__esModule",{value:!0});var Hc=t=>{if(typeof require!="undefined")return require(t);throw new Error('Dynamic re...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/auth/github.get.ts
TypeScript
declare module '#auth-utils' { interface UserSession { // define the type here id: number email: string name: string avatar_url: string login: string } } export {} export default oauth.githubEventHandler({ config: { emailRequired: true, }, async onSuccess(event, { user }) { tr...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/component/[slug].get.ts
TypeScript
import { desc, eq } from 'drizzle-orm' export default defineEventHandler(async (event) => { const slug = event.context.params?.slug ?? '' const { components, users } = tables const res = await useDB() // @ts-expect-error fetch latest components .select({ ...components, user: users, }) ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/component/all.get.ts
TypeScript
import { desc, eq, max } from 'drizzle-orm' export default defineEventHandler(async (_event) => { const { components, users } = tables const res = await useDB() // @ts-expect-error fetch latest components .select({ ...components, user: users, value: max(components.createdAt), }) ....
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/component/delete.post.ts
TypeScript
import { eq } from 'drizzle-orm' import { z } from 'zod' import { validateBody, validateUser } from '~/server/utils/validateBody' export default defineEventHandler(async (event) => { const { id, slug } = await validateBody(event, z.object({ id: z.string(), slug: z.string().optional(), }).safeParse) const...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/component/fork.post.ts
TypeScript
import { desc, eq } from 'drizzle-orm' import { z } from 'zod' import { validateBody, validateUser } from '~/server/utils/validateBody' export default defineEventHandler(async (event) => { const { id, slug } = await validateBody(event, z.object({ id: z.string(), slug: z.string(), }).safeParse) const user...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/component/id/[id].get.ts
TypeScript
import { desc, eq } from 'drizzle-orm' export default defineEventHandler(async (event) => { const id = event.context.params?.id ?? '' const { components, users } = tables const res = await useDB() // @ts-expect-error fetch latest components .select({ ...components, user: users, }) .fro...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/component/user/[name].get.ts
TypeScript
import { and, desc, eq, max } from 'drizzle-orm' export default defineEventHandler(async (event) => { const name = event.context.params?.name ?? '' const { components, users } = tables const res = await useDB() // @ts-expect-error fetch latest components .select({ ...components, value: max(com...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/create.post.ts
TypeScript
import { eq } from 'drizzle-orm' import { z } from 'zod' export default defineEventHandler(async (event) => { const { id } = await validateBody(event, z.object({ id: z.string(), prompt: z.string(), }).safeParse) const { close } = useSSE(event) try { await designComponentNew(event) await buildC...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/image/[id].ts
TypeScript
import { and, desc, eq, max } from 'drizzle-orm' export default defineEventHandler(async (event) => { const { id } = getRouterParams(event) const { slug } = getQuery(event) const { components, images } = tables if (id) { let result: typeof images.$inferSelect | undefined // If slug is true, meaning th...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/init.post.ts
TypeScript
import { z } from 'zod' import { readValidatedBody } from 'h3' export default defineEventHandler(async (event) => { const result = await readValidatedBody(event, z.object({ slug: z.string().optional(), prompt: z.string(), basedOnResultId: z.string().optional(), }).safeParse) const user = await valida...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/api/iterate.post.ts
TypeScript
import { eq } from 'drizzle-orm' import { alias } from 'drizzle-orm/sqlite-core' import { z } from 'zod' export default defineEventHandler(async (event) => { const { id } = await validateBody(event, z.object({ id: z.string(), prompt: z.string(), }).safeParse) const { components } = tables const compon...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0000_lying_nomad.sql
SQL
CREATE TABLE `components` ( `id` text PRIMARY KEY NOT NULL, `slug` text, `description` text NOT NULL, `code` text, `created_at` integer );
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0001_stale_gideon.sql
SQL
ALTER TABLE components ADD `metadata` text;--> statement-breakpoint ALTER TABLE components ADD `completed` integer;
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0004_needy_dark_phoenix.sql
SQL
CREATE TABLE `users` ( `id` integer PRIMARY KEY NOT NULL, `email` text NOT NULL, `avatar_url` text );
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0006_secret_fallen_one.sql
SQL
ALTER TABLE components ADD `user_id` integer;
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0008_breezy_zarda.sql
SQL
ALTER TABLE `components` DROP COLUMN `user_id`;
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0009_slimy_sunfire.sql
SQL
ALTER TABLE components ADD `user_id` integer REFERENCES users(id);
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0010_remarkable_loki.sql
SQL
ALTER TABLE users ADD `name` text;
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0011_plain_randall_flagg.sql
SQL
CREATE TABLE `images` ( `id` text PRIMARY KEY NOT NULL, `buffer` blob );
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0012_cute_layla_miller.sql
SQL
ALTER TABLE components ADD `error` text;
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/migrations/0013_whole_the_liberteens.sql
SQL
ALTER TABLE components ADD `based_on_id` text REFERENCES components(id);
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/database/schema.ts
TypeScript
import type { AnySQLiteColumn } from 'drizzle-orm/sqlite-core' import { blob, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core' import { init } from '@paralleldrive/cuid2' const createId = init({ length: 12, }) export const users = sqliteTable('users', { id: integer('id').notNull().primaryKey(), email...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/middleware/openai.ts
TypeScript
export default defineEventHandler((event) => { const protectedPath = ['/api/create', '/api/init', '/api/iterate'] if (protectedPath.includes(getRequestURL(event).pathname)) { if (!event.node.req.headers['x-openai-key']?.toString().includes('sk-')) return createError('Missing Open AI key') } })
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/plugins/migrations.ts
TypeScript
import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3' import { migrate } from 'drizzle-orm/better-sqlite3/migrator' export default defineNitroPlugin(async () => { // if (process.dev) // migrate(useDB() as BetterSQLite3Database, { migrationsFolder: 'server/database/migrations' }) })
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/common.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import { OpenAI } from 'openai' export { upperFirst as capitalize } from 'scule' export function useOpenAI(event: H3Event<EventHandlerRequest>) { const apiKey = process.env.NUXT_OPENAI_API_KEY || event.node.req.headers['x-openai-key']?.toString() return new O...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/db.ts
TypeScript
import { createClient as createLibSQLClient } from '@libsql/client/http' import Database from 'better-sqlite3' import type { BetterSQLite3Database } from 'drizzle-orm/better-sqlite3' import { drizzle } from 'drizzle-orm/better-sqlite3' import type { LibSQLDatabase } from 'drizzle-orm/libsql' import { drizzle as drizzle...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/encoding.ts
TypeScript
import { getEncoding } from 'js-tiktoken' export function encoding() { return getEncoding('cl100k_base') }
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/multipass/buildComponentGeneration.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import type { OpenAI } from 'openai' declare module 'h3' { interface NodeIncomingMessage { componentDesignContext: OpenAI.ChatCompletionMessageParam[] } } export default async (event: H3Event<EventHandlerRequest>) => { console.log('> init : building com...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/multipass/designComponentIteration.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import { z } from 'zod' import { zodToJsonSchema } from 'zod-to-json-schema' import type { OpenAI } from 'openai' export default async (event: H3Event<EventHandlerRequest>, component: DBComponent) => { console.log('> init : design component iteration') const {...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/multipass/designComponentNew.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import { z } from 'zod' import { zodToJsonSchema } from 'zod-to-json-schema' import type { OpenAI } from 'openai' declare module 'h3' { interface NodeIncomingMessage { componentDesignTask: { description: { user: string llm: string ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/multipass/generateComponentIteration.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import type { OpenAI } from 'openai' declare module 'h3' { interface NodeIncomingMessage { componentGeneratedCode: string } } export default async (event: H3Event<EventHandlerRequest>, component: DBComponent) => { console.log('> init : generate componen...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/multipass/generateComponentNew.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import type { OpenAI } from 'openai' declare module 'h3' { interface NodeIncomingMessage { componentGeneratedCode: string } } export default async (event: H3Event<EventHandlerRequest>) => { console.log('> init : generate new component') const encoder...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/multipass/storeComponent.ts
TypeScript
import type { EventHandlerRequest, H3Event } from 'h3' import { eq } from 'drizzle-orm' declare module 'h3' { interface NodeIncomingMessage { componentGeneratedCode: string } } export default async (event: H3Event<EventHandlerRequest>, id: string, slug?: string | null) => { console.log('> init : store compo...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/screenshot.ts
TypeScript
import { connect, launch } from 'puppeteer-core' const chromeExecutables = { linux: '/usr/bin/chromium-browser', win32: 'C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe', darwin: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', } export async function screenshot(id: string) { c...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
server/utils/validateBody.ts
TypeScript
import type { z } from 'zod' import type { EventHandlerRequest, H3Event, ValidateFunction } from 'h3' import { readValidatedBody } from 'h3' import type { UserSession } from '#auth-utils' export async function validateBody<T, U>(event: H3Event<EventHandlerRequest>, validate: ValidateFunction<z.SafeParseReturnType<T, U...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
tailwind.config.js
JavaScript
const animate = require('tailwindcss-animate') const typography = require('@tailwindcss/typography') /** @type {import('tailwindcss').Config} */ module.exports = { darkMode: ['class'], theme: { container: { center: true, padding: '2rem', screens: { '2xl': '1400px', }, }, ...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
template/downloadRepo.ts
TypeScript
import { downloadTemplate } from 'giget' downloadTemplate('gh:radix-vue/shadcn-vue/apps/www/src#dev', { dir: 'shadcn-vue/.repo', force: true, forceClean: true, })
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
template/shadcn-vue/parseMeta.ts
TypeScript
import * as fs from 'node:fs' import { kebabCase } from 'scule' import matter from 'gray-matter' const componentMds = fs.readdirSync('template/shadcn-vue/.repo/content/docs/components') const exampleMds = fs.readdirSync('template/shadcn-vue/.repo/lib/registry/default/example').filter(file => file.endsWith('.vue')) co...
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
utils/index.ts
TypeScript
import { type ClassValue, clsx } from 'clsx' import { twMerge } from 'tailwind-merge' export type { DBComponent } from '@/server/utils/db' export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) }
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
utils/types.ts
TypeScript
export interface IframeData { code: string error?: string | null | undefined }
zernonia/vue0
823
Vue version open source alternative for v0.dev
Vue
zernonia
zernonia
Troop Travel
demo/ansi.c
C
/* This file makes sure the library can be used by C89 code */ #include "../src/meshoptimizer.h"
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
demo/clusterlod.h
C/C++ Header
/** * clusterlod - a small "library"/example built on top of meshoptimizer to generate cluster LOD hierarchies * This is intended to either be used as is, or as a reference for implementing similar functionality in your engine. * * To use this code, you need to have one source file which includes meshoptimizer.h an...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
demo/index.html
HTML
<!doctype html> <html lang="en"> <head> <title>meshoptimizer - demo</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" /> <style> body { font-family: Monospace; background-color: #000; color: #fff; margi...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
demo/main.cpp
C++
#include "../src/meshoptimizer.h" #include <assert.h> #include <math.h> #include <stdio.h> #include <string.h> #include <time.h> #include <vector> #include "../extern/fast_obj.h" #define SDEFL_IMPLEMENTATION #include "../extern/sdefl.h" // This file uses assert() to verify algorithm correctness #undef NDEBUG #incl...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
demo/nanite.cpp
C++
// For reference, see the original Nanite paper: // Brian Karis. Nanite: A Deep Dive. 2021 #include "../src/meshoptimizer.h" #include <float.h> #include <math.h> #include <stdio.h> #include <string.h> #include <algorithm> #include <vector> #define CLUSTERLOD_IMPLEMENTATION #include "clusterlod.h" struct Vertex { f...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
demo/simplify.html
HTML
<!doctype html> <html lang="en"> <head> <title>meshoptimizer - demo</title> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" /> <style> body { font-family: Monospace; background-color: #300a24; color: #fff; ma...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
demo/tests.cpp
C++
#include "../src/meshoptimizer.h" #include <assert.h> #include <math.h> #include <stdlib.h> #include <string.h> #include <vector> // This file uses assert() to verify algorithm correctness #undef NDEBUG #include <assert.h> struct PV { unsigned short px, py, pz; unsigned char nu, nv; // octahedron encoded normal, ...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
extern/cgltf.h
C/C++ Header
/** * cgltf - a single-file glTF 2.0 parser written in C99. * * Version: 1.15 * * Website: https://github.com/jkuhlmann/cgltf * * Distributed under the MIT License, see notice at the end of this file. * * Building: * Include this file where you need the struct and function * declarations. Have exactly one so...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
extern/fast_obj.h
C/C++ Header
/* * fast_obj * * Version 1.3 * * MIT License * * Copyright (c) 2018-2021 Richard Knight * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without li...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
extern/sdefl.h
C/C++ Header
/*# Small Deflate `sdefl` is a small bare bone lossless compression library in ANSI C (ISO C90) which implements the Deflate (RFC 1951) compressed data format specification standard. It is mainly tuned to get as much speed and compression ratio from as little code as needed to keep the implementation as concise as poss...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/animation.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <algorithm> #include <float.h> #include <math.h> #include <string.h> static float getDelta(const Attr& l, const Attr& r, cgltf_animation_path_type type) { switch (type) { case cgltf_animation_path_type_tran...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/cli.js
JavaScript
#!/usr/bin/env node // This file is part of gltfpack and is distributed under the terms of MIT License. import { pack } from './library.js'; import fs from 'fs'; var args = process.argv.slice(2); var iface = { read: function (path) { return fs.readFileSync(path); }, write: function (path, data) { fs.writeFileS...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/encodebasis.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #ifdef WITH_BASISU #include "gltfpack.h" #define BASISU_NO_ITERATOR_DEBUG_LEVEL #ifdef __clang__ #pragma GCC diagnostic ignored "-Wunknown-warning-option" #pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wc++1...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/encodewebp.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #ifdef WITH_LIBWEBP #include "gltfpack.h" #include "webp/decode.h" #include "webp/encode.h" #ifndef WITH_LIBWEBP_BASIS #include "imageio/image_dec.h" #endif #include <atomic> #include <memory> #include <thread> static int writeWebP(const u...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/fileio.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _WIN32 #include <process.h> #else #include <unistd.h> #endif std::string getTempPrefix() { #if defined(_WIN32) const char* temp_dir = getenv("TEMP"); ...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/gltfpack.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <algorithm> #include <unordered_map> #include <locale.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef __wasi__ #include <unistd.h> #endif #include "../src/meshoptimize...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/gltfpack.h
C/C++ Header
/** * gltfpack - version 1.0 * * Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) * Report bugs and download new versions at https://github.com/zeux/meshoptimizer * * This application is distributed under the MIT License. See notice at the end of this file. */ #pragma once #ifndef _CR...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/image.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <stdlib.h> #include <string.h> static const char* kMimeTypes[][2] = { {"image/jpeg", ".jpg"}, {"image/jpeg", ".jpeg"}, {"image/png", ".png"}, {"image/ktx2", ".ktx2"}, {"image/webp", ".webp"}...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/json.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <float.h> #include <math.h> #include <stdio.h> void comma(std::string& s) { char ch = s.empty() ? 0 : s[s.size() - 1]; if (ch != 0 && ch != '[' && ch != '{') s += ","; } void append(std::string& s, size_t...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/library.js
JavaScript
// This file is part of gltfpack and is distributed under the terms of MIT License. /** * Initialize the library with the Wasm module (library.wasm) * * @param wasm Promise with contents of library.wasm * * Note: this is called automatically in node.js */ function init(wasm) { if (ready) { throw new Error('in...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/material.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <string.h> static bool areTexturesEqual(const cgltf_texture& lhs, const cgltf_texture& rhs) { if (lhs.image != rhs.image) return false; if (lhs.sampler != rhs.sampler) return false; if (lhs.basisu_imag...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/mesh.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <algorithm> #include <unordered_map> #include <math.h> #include <stdint.h> #include <string.h> #include "../src/meshoptimizer.h" static float inverseTranspose(float* result, const float* transform) { float m...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/node.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <math.h> #include <string.h> void markScenes(cgltf_data* data, std::vector<NodeInfo>& nodes) { for (size_t i = 0; i < nodes.size(); ++i) nodes[i].scene = -1; for (size_t i = 0; i < data->scenes_count; ++i)...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/parsegltf.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include "../src/meshoptimizer.h" static const size_t kMaxStreams = 16; static const char* getError(cgltf_result result, cgltf_data* data) { switch (result) ...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/parselib.cpp
C++
#ifndef _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS #endif #define CGLTF_IMPLEMENTATION #include "../extern/cgltf.h" #define FAST_OBJ_IMPLEMENTATION #include "../extern/fast_obj.h" #undef CGLTF_IMPLEMENTATION #undef FAST_OBJ_IMPLEMENTATION
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/parseobj.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include "../extern/fast_obj.h" #include "../src/meshoptimizer.h" #include <stdlib.h> #include <string.h> static void defaultFree(void*, void* p) { free(p); } static int textureIndex(const std::vector<unsigned int>& ...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/stream.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <algorithm> #include <float.h> #include <limits.h> #include <math.h> #include <stdint.h> #include "../src/meshoptimizer.h" struct Bounds { Attr min, max; Bounds() { min.f[0] = min.f[1] = min.f[2] = min....
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/wasistubs.cpp
C++
#ifdef __wasi__ #include <stdlib.h> #include <string.h> #include <wasi/api.h> extern "C" void __cxa_throw(void* ptr, void* type, void* destructor) { abort(); } extern "C" void* __cxa_allocate_exception(size_t thrown_size) { abort(); } extern "C" int32_t __wasi_path_open32(int32_t arg0, int32_t arg1, int32_t arg2,...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
gltf/write.cpp
C++
// This file is part of gltfpack; see gltfpack.h for version/license details #include "gltfpack.h" #include <float.h> #include <stdio.h> #include <stdlib.h> #include <string.h> static const char* componentType(cgltf_component_type type) { switch (type) { case cgltf_component_type_r_8: return "5120"; case cgltf_...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/benchmark.js
JavaScript
import { MeshoptEncoder as encoder } from './meshopt_encoder.js'; import { MeshoptDecoder as decoder } from './meshopt_decoder.mjs'; import { performance } from 'perf_hooks'; process.on('unhandledRejection', (error) => { console.log('unhandledRejection', error); process.exit(1); }); function bytes(view) { return n...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/index.d.ts
TypeScript
export * from './meshopt_encoder.js'; export * from './meshopt_decoder.js'; export * from './meshopt_simplifier.js'; export * from './meshopt_clusterizer.js';
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/index.js
JavaScript
export * from './meshopt_encoder.js'; export * from './meshopt_decoder.mjs'; export * from './meshopt_simplifier.js'; export * from './meshopt_clusterizer.js';
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_clusterizer.d.ts
TypeScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) export class Bounds { centerX: number; centerY: number; centerZ: number; radius: number; coneApexX: number; coneApexY: number; coneApexZ...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_clusterizer.js
JavaScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) var MeshoptClusterizer = (function () { // Built with clang version 19.1.5-wasi-sdk // Built from meshoptimizer 1.0 var wasm = 'b9H79Tebbbe...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_clusterizer.test.js
JavaScript
import assert from 'assert/strict'; import { MeshoptClusterizer as clusterizer } from './meshopt_clusterizer.js'; process.on('unhandledRejection', (error) => { console.log('unhandledRejection', error); process.exit(1); }); const cubeWithNormals = { vertices: new Float32Array([ // n = (0, 0, 1) -1.0, -1.0, 1.0,...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_decoder.cjs
JavaScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) var MeshoptDecoder = (function () { // Built with clang version 19.1.5-wasi-sdk // Built from meshoptimizer 1.0 var wasm_base = 'b9H79Tebbb...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_decoder.d.ts
TypeScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) export const MeshoptDecoder: { supported: boolean; ready: Promise<void>; decodeVertexBuffer: (target: Uint8Array, count: number, size: numbe...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_decoder.mjs
JavaScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) var MeshoptDecoder = (function () { // Built with clang version 19.1.5-wasi-sdk // Built from meshoptimizer 1.0 var wasm_base = 'b9H79Tebbb...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_decoder.test.js
JavaScript
import assert from 'assert/strict'; import { MeshoptDecoder as decoder } from './meshopt_decoder.mjs'; process.on('unhandledRejection', (error) => { console.log('unhandledRejection', error); process.exit(1); }); var tests = { decodeVertexBuffer: function () { var encoded = new Uint8Array([ 0xa0, 0x01, 0x3f, 0...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_decoder_reference.js
JavaScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) // This is the reference decoder implementation by Jasper St. Pierre. // It follows the decoder interface and should be a drop-in replacement f...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine
js/meshopt_encoder.d.ts
TypeScript
// This file is part of meshoptimizer library and is distributed under the terms of MIT License. // Copyright (C) 2016-2026, by Arseny Kapoulkine (arseny.kapoulkine@gmail.com) export type ExpMode = 'Separate' | 'SharedVector' | 'SharedComponent' | 'Clamped'; export const MeshoptEncoder: { supported: boolean; ready: ...
zeux/meshoptimizer
7,278
Mesh optimization library that makes meshes smaller and faster to render
C++
zeux
Arseny Kapoulkine