motionary 10.4.0 → 10.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/README.md +97 -0
- package/dist/chunks/{anim-image-blQgPFFS.cjs → anim-image-DECLkPH4.cjs} +2 -2
- package/dist/chunks/{anim-image-blQgPFFS.cjs.map → anim-image-DECLkPH4.cjs.map} +1 -1
- package/dist/chunks/{anim-image-DDdb9q3X.js → anim-image-DNghy017.js} +2 -2
- package/dist/chunks/{anim-image-DDdb9q3X.js.map → anim-image-DNghy017.js.map} +1 -1
- package/dist/chunks/{keyframes-tC3I7anQ.cjs → keyframes-CbUZjD_5.cjs} +2 -2
- package/dist/chunks/{keyframes-tC3I7anQ.cjs.map → keyframes-CbUZjD_5.cjs.map} +1 -1
- package/dist/chunks/{keyframes-B5PWe5bU.js → keyframes-F6vp6tZZ.js} +2 -2
- package/dist/chunks/{keyframes-B5PWe5bU.js.map → keyframes-F6vp6tZZ.js.map} +1 -1
- package/dist/chunks/{registry-CT-TT_bx.js → registry-D8LAoXI-.js} +2 -2
- package/dist/chunks/{registry-CT-TT_bx.js.map → registry-D8LAoXI-.js.map} +1 -1
- package/dist/chunks/{registry-tzwKkldE.cjs → registry-dr1CPTk1.cjs} +2 -2
- package/dist/chunks/{registry-tzwKkldE.cjs.map → registry-dr1CPTk1.cjs.map} +1 -1
- package/dist/chunks/{ticker-Un0bvTWR.cjs → ticker-DaAlEyOd.cjs} +2 -2
- package/dist/chunks/{ticker-Un0bvTWR.cjs.map → ticker-DaAlEyOd.cjs.map} +1 -1
- package/dist/chunks/{ticker-C8lSGml9.js → ticker-Do9bGsaV.js} +2 -2
- package/dist/chunks/{ticker-C8lSGml9.js.map → ticker-Do9bGsaV.js.map} +1 -1
- package/dist/chunks/{tween-BcejKpsx.js → tween-BzCGq_Ba.js} +2 -2
- package/dist/chunks/{tween-BcejKpsx.js.map → tween-BzCGq_Ba.js.map} +1 -1
- package/dist/chunks/{tween-CwLLC3Ko.cjs → tween-CmkdSyaC.cjs} +2 -2
- package/dist/chunks/{tween-CwLLC3Ko.cjs.map → tween-CmkdSyaC.cjs.map} +1 -1
- package/dist/components/lite.cjs +179 -0
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +176 -1
- package/dist/components/lite.js.map +1 -1
- package/dist/components/tokens.cjs +179 -0
- package/dist/components/tokens.cjs.map +1 -1
- package/dist/components/tokens.d.cts +36 -1
- package/dist/components/tokens.d.ts +36 -1
- package/dist/components/tokens.js +176 -1
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/widgets.cjs +1138 -213
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +401 -2
- package/dist/components/widgets.d.ts +401 -2
- package/dist/components/widgets.js +1124 -214
- package/dist/components/widgets.js.map +1 -1
- package/dist/components.cjs +4 -0
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +36 -1
- package/dist/components.d.ts +36 -1
- package/dist/components.js +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/llms-full.txt +273 -1
- package/dist/llms.txt +14 -2
- package/dist/manifest.json +736 -1
- package/dist/runtime/format-apng.cjs +4 -4
- package/dist/runtime/format-apng.js +4 -4
- package/dist/runtime/format-css.cjs +4 -4
- package/dist/runtime/format-css.js +4 -4
- package/dist/runtime/format-gif.cjs +4 -4
- package/dist/runtime/format-gif.js +4 -4
- package/dist/runtime/format-gltf.cjs +207 -0
- package/dist/runtime/format-gltf.cjs.map +1 -0
- package/dist/runtime/format-gltf.d.cts +251 -0
- package/dist/runtime/format-gltf.d.ts +251 -0
- package/dist/runtime/format-gltf.iife.js +2 -0
- package/dist/runtime/format-gltf.iife.js.map +1 -0
- package/dist/runtime/format-gltf.js +200 -0
- package/dist/runtime/format-gltf.js.map +1 -0
- package/dist/runtime/format-motion.cjs +4 -4
- package/dist/runtime/format-motion.js +4 -4
- package/dist/runtime/format-obj.cjs +181 -0
- package/dist/runtime/format-obj.cjs.map +1 -0
- package/dist/runtime/format-obj.d.cts +176 -0
- package/dist/runtime/format-obj.d.ts +176 -0
- package/dist/runtime/format-obj.iife.js +2 -0
- package/dist/runtime/format-obj.iife.js.map +1 -0
- package/dist/runtime/format-obj.js +174 -0
- package/dist/runtime/format-obj.js.map +1 -0
- package/dist/runtime/format-sprite.cjs +3 -3
- package/dist/runtime/format-sprite.js +3 -3
- package/dist/runtime/format-svg.cjs +3 -3
- package/dist/runtime/format-svg.js +3 -3
- package/dist/runtime/format-webp.cjs +4 -4
- package/dist/runtime/format-webp.js +4 -4
- package/dist/runtime/gl.cjs +763 -0
- package/dist/runtime/gl.cjs.map +1 -0
- package/dist/runtime/gl.d.cts +260 -0
- package/dist/runtime/gl.d.ts +260 -0
- package/dist/runtime/gl.iife.js +2 -0
- package/dist/runtime/gl.iife.js.map +1 -0
- package/dist/runtime/gl.js +739 -0
- package/dist/runtime/gl.js.map +1 -0
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/smooth.cjs +1 -1
- package/dist/runtime/smooth.js +1 -1
- package/dist/runtime/text.cjs +1 -1
- package/dist/runtime/text.js +1 -1
- package/dist/runtime/vector.cjs +704 -0
- package/dist/runtime/vector.cjs.map +1 -0
- package/dist/runtime/vector.d.cts +306 -0
- package/dist/runtime/vector.d.ts +306 -0
- package/dist/runtime/vector.iife.js +2 -0
- package/dist/runtime/vector.iife.js.map +1 -0
- package/dist/runtime/vector.js +692 -0
- package/dist/runtime/vector.js.map +1 -0
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +5 -5
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components/README.md +11 -1
- package/docs/components/usa-gl-scene.md +66 -0
- package/docs/components/usa-gpu-particles.md +32 -0
- package/docs/components/usa-lottie-player.md +60 -0
- package/docs/components/usa-rive.md +57 -0
- package/docs/components/usa-shader-backdrop.md +36 -0
- package/docs/components/usa-three-scene.md +20 -0
- package/docs/components/usa-token-editor.md +32 -0
- package/docs/components.md +120 -0
- package/docs/runtime/format-gltf.md +63 -0
- package/docs/runtime/format-obj.md +59 -0
- package/docs/runtime/gl.md +62 -0
- package/docs/runtime/rive.md +55 -0
- package/docs/runtime/vector.md +67 -0
- package/package.json +47 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-gltf.js","sources":["../../src/runtime/format-gltf.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-gltf` (10.5) — glTF 2.0 / GLB loader for\n * `motionary/runtime/gl` (own implementation):\n *\n * - `.gltf` (JSON + external or `data:` buffers / images) and `.glb`\n * (binary container: JSON + BIN chunks);\n * - scenes and the node hierarchy (TRS or `matrix`), meshes with several\n * primitives (POSITION, NORMAL, TEXCOORD_0, indices; any component type,\n * normalised integers, interleaved `byteStride`; modes points, lines,\n * triangles, strips, fans);\n * - PBR metallic-roughness materials (base colour factor + texture,\n * metallic / roughness factors, emissive factor, alpha modes, double-sided);\n * images from buffer views or URIs (decoded with `createImageBitmap`);\n * - files that *require* an extension we do not implement (e.g. Draco /\n * KTX2 compression) fail with a clear error naming it.\n *\n * Skins, morph targets and animations arrive in 10.8. `parseGlb()` /\n * `gltfToNode()` with an `images` override are pure (SSR / workers).\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { GlNode, standardMaterial, computeNormals, texture, type Geometry, type Material, type Mesh, type Quat, type Vec3 } from './gl';\n\nexport interface GltfJson {\n asset: { version: string; generator?: string };\n scene?: number;\n scenes?: { nodes?: number[]; name?: string }[];\n nodes?: { name?: string; children?: number[]; mesh?: number; matrix?: number[]; translation?: number[]; rotation?: number[]; scale?: number[]; skin?: number; camera?: number }[];\n meshes?: { name?: string; primitives: { attributes: Record<string, number>; indices?: number; material?: number; mode?: number; targets?: Record<string, number>[] }[]; weights?: number[] }[];\n accessors?: { bufferView?: number; byteOffset?: number; componentType: number; normalized?: boolean; count: number; type: string; min?: number[]; max?: number[]; sparse?: unknown }[];\n bufferViews?: { buffer: number; byteOffset?: number; byteLength: number; byteStride?: number }[];\n buffers?: { uri?: string; byteLength: number }[];\n materials?: { name?: string; pbrMetallicRoughness?: { baseColorFactor?: number[]; baseColorTexture?: { index: number }; metallicFactor?: number; roughnessFactor?: number }; emissiveFactor?: number[]; alphaMode?: string; doubleSided?: boolean; extensions?: Record<string, any> }[];\n textures?: { source?: number; sampler?: number }[];\n images?: { uri?: string; bufferView?: number; mimeType?: string }[];\n extensionsUsed?: string[];\n extensionsRequired?: string[];\n animations?: unknown[];\n skins?: unknown[];\n}\n\n/** Extensions this loader understands (others that a file *requires* make it fail clearly). */\nexport const SUPPORTED_EXTENSIONS = ['KHR_materials_emissive_strength', 'KHR_materials_unlit'];\n\n/** Split a GLB container into its JSON and BIN chunk (pure). */\nexport function parseGlb(input: ArrayBuffer | Uint8Array): { json: GltfJson; bin: Uint8Array | null } {\n const b = input instanceof Uint8Array ? input : new Uint8Array(input);\n const v = new DataView(b.buffer, b.byteOffset, b.byteLength);\n if (v.getUint32(0, true) !== 0x46546c67) throw new Error('[motionary] format-gltf: not a GLB file');\n if (v.getUint32(4, true) !== 2) throw new Error('[motionary] format-gltf: only glTF 2.0 GLB is supported');\n const len = Math.min(v.getUint32(8, true), b.byteLength);\n let p = 12, json: GltfJson | null = null, bin: Uint8Array | null = null;\n while (p + 8 <= len) {\n const cl = v.getUint32(p, true), ct = v.getUint32(p + 4, true);\n const data = b.subarray(p + 8, p + 8 + cl);\n if (ct === 0x4e4f534a) json = JSON.parse(new TextDecoder().decode(data));\n else if (ct === 0x004e4942 && !bin) bin = data;\n p += 8 + cl;\n }\n if (!json) throw new Error('[motionary] format-gltf: GLB without a JSON chunk');\n return { json, bin };\n}\n\nconst COMP: Record<number, [number, any, number]> = {\n 5120: [1, Int8Array, 127], 5121: [1, Uint8Array, 255], 5122: [2, Int16Array, 32767], 5123: [2, Uint16Array, 65535], 5125: [4, Uint32Array, 0], 5126: [4, Float32Array, 0],\n};\nconst SIZE: Record<string, number> = { SCALAR: 1, VEC2: 2, VEC3: 3, VEC4: 4, MAT2: 4, MAT3: 9, MAT4: 16 };\n\n/** Read an accessor into a flat typed array (floats are de-interleaved; normalised ints become floats). */\nexport function readAccessor(json: GltfJson, buffers: Uint8Array[], index: number, asFloat = true): Float32Array | Uint16Array | Uint32Array | Uint8Array {\n const a = json.accessors?.[index];\n if (!a) throw new Error(`[motionary] format-gltf: accessor ${index} missing`);\n const [bytes, Ctor, max] = COMP[a.componentType] || [];\n if (!Ctor) throw new Error(`[motionary] format-gltf: component type ${a.componentType} unsupported`);\n const n = SIZE[a.type], count = a.count * n;\n const isFloat = Ctor === Float32Array;\n const out = asFloat || isFloat ? new Float32Array(count) : new Ctor(count);\n if (a.bufferView === undefined) return out; // all zeros (sparse-only accessors)\n const bv = json.bufferViews![a.bufferView];\n const buf = buffers[bv.buffer];\n const base = (bv.byteOffset || 0) + (a.byteOffset || 0);\n const stride = bv.byteStride || bytes * n;\n const dv = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n const get = (o: number): number => (bytes === 4 ? (isFloat ? dv.getFloat32(o, true) : dv.getUint32(o, true)) : bytes === 2 ? (Ctor === Int16Array ? dv.getInt16(o, true) : dv.getUint16(o, true)) : Ctor === Int8Array ? dv.getInt8(o) : dv.getUint8(o));\n for (let i = 0; i < a.count; i++)\n for (let k = 0; k < n; k++) {\n let x = get(base + i * stride + k * bytes);\n if (a.normalized && max) x = Math.max(x / max, -1);\n out[i * n + k] = x;\n }\n return out;\n}\n\nfunction toTriangles(idx: Uint32Array, mode: number): Uint32Array {\n const out: number[] = [];\n if (mode === 5) for (let i = 0; i + 2 < idx.length; i++) out.push(...(i % 2 ? [idx[i + 1], idx[i], idx[i + 2]] : [idx[i], idx[i + 1], idx[i + 2]]));\n else for (let i = 1; i + 1 < idx.length; i++) out.push(idx[0], idx[i], idx[i + 1]);\n return new Uint32Array(out);\n}\n\nexport interface GltfImages {\n /** Decoded images by glTF image index (pass your own for SSR / tests). */\n [index: number]: TexImageSource | undefined;\n}\n\n/** Build a runtime/gl node tree from parsed glTF (pure, given buffers and decoded images). */\nexport function gltfToNode(json: GltfJson, buffers: Uint8Array[], images: GltfImages = {}, sceneIndex?: number): GlNode {\n if (!json.asset || !/^2\\./.test(json.asset.version)) throw new Error('[motionary] format-gltf: only glTF 2.0 is supported');\n const missing = (json.extensionsRequired || []).filter((e) => !SUPPORTED_EXTENSIONS.includes(e));\n if (missing.length) throw new Error(`[motionary] format-gltf: this file requires ${missing.join(', ')}, which motionary/runtime/format-gltf does not implement${missing.some((e) => /draco|KHR_texture_basisu|meshopt/i.test(e)) ? ' (compressed geometry / textures need the official decoders — re-export the model without compression, or use the decoder hooks planned for 10.9)' : ''}`);\n const mats: Material[] = (json.materials || []).map((m) => {\n const pbr = m.pbrMetallicRoughness || {};\n const cf = pbr.baseColorFactor || [1, 1, 1, 1];\n // glTF factors are linear; the shader linearises colour input → convert the factor to sRGB space\n const toS = (x: number) => Math.pow(Math.max(0, x), 1 / 2.2);\n const strength = m.extensions?.KHR_materials_emissive_strength?.emissiveStrength ?? 1;\n const mat = standardMaterial({ color: [toS(cf[0]), toS(cf[1]), toS(cf[2]), cf[3] ?? 1], metallic: pbr.metallicFactor ?? 1, roughness: pbr.roughnessFactor ?? 1, emissive: ((m.emissiveFactor || [0, 0, 0]).map((x) => x * strength) as Vec3), doubleSided: !!m.doubleSided, transparent: m.alphaMode === 'BLEND' });\n if (m.extensions?.KHR_materials_unlit) mat.type = 'unlit';\n const ti = pbr.baseColorTexture?.index;\n const src = ti !== undefined ? json.textures?.[ti]?.source : undefined;\n if (src !== undefined && images[src]) mat.map = texture(images[src]!);\n return mat;\n });\n const meshes: Mesh[][] = (json.meshes || []).map((m) =>\n m.primitives.map((p) => {\n const mode = p.mode ?? 4;\n let g: Geometry = {\n positions: readAccessor(json, buffers, p.attributes.POSITION) as Float32Array,\n normals: p.attributes.NORMAL !== undefined ? (readAccessor(json, buffers, p.attributes.NORMAL) as Float32Array) : undefined,\n uvs: p.attributes.TEXCOORD_0 !== undefined ? (readAccessor(json, buffers, p.attributes.TEXCOORD_0) as Float32Array) : undefined,\n mode: mode === 0 ? 'points' : mode >= 1 && mode <= 3 ? 'lines' : 'triangles',\n };\n if (p.indices !== undefined) {\n let idx = readAccessor(json, buffers, p.indices, false) as Uint32Array | Uint16Array | Uint8Array;\n if (mode === 5 || mode === 6) idx = toTriangles(Uint32Array.from(idx), mode);\n g.indices = idx instanceof Uint8Array || (idx instanceof Uint32Array && g.positions.length / 3 <= 65535) ? Uint16Array.from(idx) : (idx as Uint16Array | Uint32Array);\n } else if (mode === 5 || mode === 6) g.indices = toTriangles(Uint32Array.from({ length: g.positions.length / 3 }, (_, i) => i), mode);\n if (!g.normals && g.mode === 'triangles') g = computeNormals(g);\n return { geometry: g, material: p.material !== undefined ? mats[p.material] : standardMaterial({ metallic: 0, roughness: 0.6 }) };\n })\n );\n const nodes = (json.nodes || []).map((n, i) => {\n const node = new GlNode(n.name || `node${i}`, n.mesh !== undefined ? meshes[n.mesh] : null);\n if (n.matrix) node.matrix = new Float32Array(n.matrix);\n if (n.translation) node.position = n.translation.slice(0, 3) as Vec3;\n if (n.rotation) node.rotation = n.rotation.slice(0, 4) as Quat;\n if (n.scale) node.scale = n.scale.slice(0, 3) as Vec3;\n node.extras.gltfIndex = i;\n return node;\n });\n (json.nodes || []).forEach((n, i) => (n.children || []).forEach((c) => nodes[i].add(nodes[c])));\n const root = new GlNode('gltf');\n const sc = json.scenes?.[sceneIndex ?? json.scene ?? 0];\n const tops = sc?.nodes ?? nodes.map((_, i) => i).filter((i) => !nodes[i].parent);\n tops.forEach((i) => root.add(nodes[i]));\n root.extras = { gltf: json, nodes };\n return root;\n}\n\nconst dataUri = (u: string): Uint8Array => {\n const [, meta, data] = /^data:([^,]*),(.*)$/s.exec(u) || [];\n if (meta === undefined) throw new Error('[motionary] format-gltf: bad data URI');\n if (/;base64/.test(meta)) {\n const s = atob(data);\n return Uint8Array.from(s, (c) => c.charCodeAt(0));\n }\n return new TextEncoder().encode(decodeURIComponent(data));\n};\n\n/** Load a `.gltf` / `.glb` (URL or bytes) with its buffers and images and build a node tree. */\nexport async function loadGltf(src: string | ArrayBuffer | Uint8Array, o: { baseUrl?: string; scene?: number } = {}): Promise<GlNode> {\n const base = o.baseUrl || (typeof src === 'string' ? new URL(src, typeof location !== 'undefined' ? location.href : 'file:///').href : typeof location !== 'undefined' ? location.href : 'file:///');\n const get = async (u: string) => {\n if (u.startsWith('data:')) return dataUri(u);\n const r = await fetch(new URL(u, base).href);\n if (!r.ok) throw new Error(`[motionary] format-gltf: could not load ${u} (${r.status})`);\n return new Uint8Array(await r.arrayBuffer());\n };\n const bytes = typeof src === 'string' ? await get(src) : src instanceof Uint8Array ? src : new Uint8Array(src);\n let json: GltfJson, bin: Uint8Array | null = null;\n if (bytes[0] === 0x67 && bytes[1] === 0x6c && bytes[2] === 0x54 && bytes[3] === 0x46) ({ json, bin } = parseGlb(bytes));\n else json = JSON.parse(new TextDecoder().decode(bytes));\n const buffers = await Promise.all((json.buffers || []).map((b, i) => (b.uri ? get(b.uri) : i === 0 && bin ? Promise.resolve(bin) : Promise.reject(new Error('[motionary] format-gltf: buffer without data')))));\n const images: GltfImages = {};\n await Promise.all((json.images || []).map(async (im, i) => {\n let data: Uint8Array;\n if (im.bufferView !== undefined) {\n const bv = json.bufferViews![im.bufferView];\n data = buffers[bv.buffer].subarray(bv.byteOffset || 0, (bv.byteOffset || 0) + bv.byteLength);\n } else if (im.uri) data = await get(im.uri);\n else return;\n images[i] = await createImageBitmap(new Blob([data as BlobPart], { type: im.mimeType || (im.uri && /\\.jpe?g$/i.test(im.uri) ? 'image/jpeg' : 'image/png') }));\n }));\n return gltfToNode(json, buffers, images, o.scene);\n}\n\nexport interface FormatGltfApi {\n parseGlb: typeof parseGlb;\n readAccessor: typeof readAccessor;\n gltfToNode: typeof gltfToNode;\n loadGltf: typeof loadGltf;\n SUPPORTED_EXTENSIONS: typeof SUPPORTED_EXTENSIONS;\n}\n\n/** The module object for `use(formatGltf)` (needs `gl`). */\nexport const formatGltf: RuntimeModule<FormatGltfApi> = { id: 'format-gltf', version: RUNTIME_VERSION, requires: ['core', 'gl'], api: { parseGlb, readAccessor, gltfToNode, loadGltf, SUPPORTED_EXTENSIONS } };\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;AAkBG;AAsBH;MACa,oBAAoB,GAAG,CAAC,iCAAiC,EAAE,qBAAqB;AAE7F;AACM,SAAU,QAAQ,CAAC,KAA+B,EAAA;AACtD,IAAA,MAAM,CAAC,GAAG,KAAK,YAAY,UAAU,GAAG,KAAK,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC;AACrE,IAAA,MAAM,CAAC,GAAG,IAAI,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC;IAC5D,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,UAAU;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;IACnG,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;AAC1G,IAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC;IACxD,IAAI,CAAC,GAAG,EAAE,EAAE,IAAI,GAAoB,IAAI,EAAE,GAAG,GAAsB,IAAI;AACvE,IAAA,OAAO,CAAC,GA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,CAAC;AACnD;AAUA;AACO,MAAM,UAAU,GAAiC,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,oBAAoB,EAAE;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var registry = require('../chunks/registry-
|
|
4
|
-
var tween = require('../chunks/tween-
|
|
3
|
+
var registry = require('../chunks/registry-dr1CPTk1.cjs');
|
|
4
|
+
var tween = require('../chunks/tween-CmkdSyaC.cjs');
|
|
5
5
|
var ease = require('../chunks/ease-HwYZnZat.cjs');
|
|
6
|
-
var keyframes = require('../chunks/keyframes-
|
|
7
|
-
require('../chunks/ticker-
|
|
6
|
+
var keyframes = require('../chunks/keyframes-CbUZjD_5.cjs');
|
|
7
|
+
require('../chunks/ticker-DaAlEyOd.cjs');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { R as RUNTIME_VERSION } from '../chunks/registry-
|
|
2
|
-
import { T as Timeline } from '../chunks/tween-
|
|
1
|
+
import { R as RUNTIME_VERSION } from '../chunks/registry-D8LAoXI-.js';
|
|
2
|
+
import { T as Timeline } from '../chunks/tween-BzCGq_Ba.js';
|
|
3
3
|
import { c as cubicBezier, E as EASES } from '../chunks/ease-XN8_0sXu.js';
|
|
4
|
-
import { f as framesToTimeline } from '../chunks/keyframes-
|
|
5
|
-
import '../chunks/ticker-
|
|
4
|
+
import { f as framesToTimeline } from '../chunks/keyframes-F6vp6tZZ.js';
|
|
5
|
+
import '../chunks/ticker-Do9bGsaV.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* `motionary/runtime/format-motion` (10.1) — play Motion / Framer-style
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var registry = require('../chunks/registry-dr1CPTk1.cjs');
|
|
4
|
+
var runtime_gl = require('./gl.cjs');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `motionary/runtime/format-obj` (10.5) — Wavefront OBJ + MTL loader for
|
|
8
|
+
* `motionary/runtime/gl` (own parser): `v` / `vt` / `vn`, faces with any
|
|
9
|
+
* number of vertices (fan-triangulated) and negative indices, `o` / `g`
|
|
10
|
+
* groups, `usemtl` material switches (one mesh per material), `s` ignored;
|
|
11
|
+
* MTL `Kd`, `Ks` + `Ns` (→ roughness), `Ke`, `d` / `Tr` (opacity), `map_Kd`
|
|
12
|
+
* (with options stripped), `illum` ignored. Missing normals are computed
|
|
13
|
+
* (flat). Parsing is pure (SSR / workers); `loadObj()` fetches the OBJ, its
|
|
14
|
+
* `mtllib` files and textures relative to the OBJ URL.
|
|
15
|
+
*/
|
|
16
|
+
const nums = (p, from, n) => Array.from({ length: n }, (_, i) => parseFloat(p[from + i]) || 0);
|
|
17
|
+
/** Parse OBJ text into groups (one geometry per object / group × material). */
|
|
18
|
+
function parseObj(text) {
|
|
19
|
+
const v = [], vt = [], vn = [];
|
|
20
|
+
const mtllibs = [];
|
|
21
|
+
const groups = [];
|
|
22
|
+
let cur = null;
|
|
23
|
+
let obj = 'default', mat = '', tris = 0;
|
|
24
|
+
const flush = () => {
|
|
25
|
+
if (cur && cur.p.length) {
|
|
26
|
+
const g = { positions: new Float32Array(cur.p), uvs: cur.hasT ? new Float32Array(cur.t) : undefined };
|
|
27
|
+
groups.push({ name: cur.name, material: cur.material, geometry: cur.hasN ? { ...g, normals: new Float32Array(cur.n) } : runtime_gl.computeNormals(g) });
|
|
28
|
+
}
|
|
29
|
+
cur = null;
|
|
30
|
+
};
|
|
31
|
+
const start = () => {
|
|
32
|
+
if (!cur || cur.name !== obj || cur.material !== mat) {
|
|
33
|
+
flush();
|
|
34
|
+
cur = { name: obj, material: mat, p: [], n: [], t: [], hasN: true, hasT: true };
|
|
35
|
+
}
|
|
36
|
+
return cur;
|
|
37
|
+
};
|
|
38
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
39
|
+
const line = raw.trim();
|
|
40
|
+
if (!line || line[0] === '#')
|
|
41
|
+
continue;
|
|
42
|
+
const p = line.split(/\s+/);
|
|
43
|
+
switch (p[0]) {
|
|
44
|
+
case 'v':
|
|
45
|
+
v.push(...nums(p, 1, 3));
|
|
46
|
+
break;
|
|
47
|
+
case 'vt':
|
|
48
|
+
vt.push(...nums(p, 1, 2));
|
|
49
|
+
break;
|
|
50
|
+
case 'vn':
|
|
51
|
+
vn.push(...nums(p, 1, 3));
|
|
52
|
+
break;
|
|
53
|
+
case 'o':
|
|
54
|
+
case 'g':
|
|
55
|
+
flush();
|
|
56
|
+
obj = p.slice(1).join(' ') || 'default';
|
|
57
|
+
break;
|
|
58
|
+
case 'usemtl':
|
|
59
|
+
mat = p.slice(1).join(' ');
|
|
60
|
+
break;
|
|
61
|
+
case 'mtllib':
|
|
62
|
+
mtllibs.push(...p.slice(1));
|
|
63
|
+
break;
|
|
64
|
+
case 'f': {
|
|
65
|
+
const c = start();
|
|
66
|
+
const verts = p.slice(1).map((s) => {
|
|
67
|
+
const [a, b, n] = s.split('/');
|
|
68
|
+
const ix = (x, len) => (x ? (+x < 0 ? len + +x : +x - 1) : -1);
|
|
69
|
+
return [ix(a, v.length / 3), ix(b, vt.length / 2), ix(n, vn.length / 3)];
|
|
70
|
+
});
|
|
71
|
+
for (let i = 1; i + 1 < verts.length; i++) {
|
|
72
|
+
for (const k of [verts[0], verts[i], verts[i + 1]]) {
|
|
73
|
+
c.p.push(v[k[0] * 3], v[k[0] * 3 + 1], v[k[0] * 3 + 2]);
|
|
74
|
+
if (k[1] >= 0)
|
|
75
|
+
c.t.push(vt[k[1] * 2], 1 - vt[k[1] * 2 + 1]);
|
|
76
|
+
else {
|
|
77
|
+
c.hasT = false;
|
|
78
|
+
c.t.push(0, 0);
|
|
79
|
+
}
|
|
80
|
+
if (k[2] >= 0)
|
|
81
|
+
c.n.push(vn[k[2] * 3], vn[k[2] * 3 + 1], vn[k[2] * 3 + 2]);
|
|
82
|
+
else {
|
|
83
|
+
c.hasN = false;
|
|
84
|
+
c.n.push(0, 0, 1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
tris++;
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
flush();
|
|
94
|
+
return { groups, mtllibs, vertexCount: v.length / 3, triangleCount: tris };
|
|
95
|
+
}
|
|
96
|
+
/** Parse MTL text. */
|
|
97
|
+
function parseMtl(text) {
|
|
98
|
+
const out = {};
|
|
99
|
+
let m = null;
|
|
100
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
101
|
+
const line = raw.trim();
|
|
102
|
+
if (!line || line[0] === '#')
|
|
103
|
+
continue;
|
|
104
|
+
const p = line.split(/\s+/);
|
|
105
|
+
const k = p[0];
|
|
106
|
+
if (k === 'newmtl') {
|
|
107
|
+
m = out[p.slice(1).join(' ')] = { name: p.slice(1).join(' '), Kd: [0.8, 0.8, 0.8], Ks: [0, 0, 0], Ke: [0, 0, 0], Ns: 10, d: 1 };
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
if (!m)
|
|
111
|
+
continue;
|
|
112
|
+
if (k === 'Kd' || k === 'Ks' || k === 'Ke')
|
|
113
|
+
m[k] = nums(p, 1, 3);
|
|
114
|
+
else if (k === 'Ns')
|
|
115
|
+
m.Ns = parseFloat(p[1]) || 0;
|
|
116
|
+
else if (k === 'd')
|
|
117
|
+
m.d = parseFloat(p[1]);
|
|
118
|
+
else if (k === 'Tr')
|
|
119
|
+
m.d = 1 - parseFloat(p[1]);
|
|
120
|
+
else if (k === 'map_Kd')
|
|
121
|
+
m.map_Kd = p[p.length - 1]; // options (-s, -o, -bm …) precede the file name
|
|
122
|
+
}
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
/** OBJ material → runtime/gl standard material (Ns 0–1000 → roughness). */
|
|
126
|
+
function objMaterial(m) {
|
|
127
|
+
if (!m)
|
|
128
|
+
return runtime_gl.standardMaterial({ color: [0.8, 0.8, 0.8, 1] });
|
|
129
|
+
const spec = Math.max(...m.Ks);
|
|
130
|
+
return runtime_gl.standardMaterial({ color: [m.Kd[0], m.Kd[1], m.Kd[2], m.d], roughness: Math.min(1, Math.max(0.05, 1 - Math.sqrt(Math.min(m.Ns, 1000) / 1000) * (spec > 0 ? 1 : 0.4))), metallic: 0, emissive: m.Ke, transparent: m.d < 1 });
|
|
131
|
+
}
|
|
132
|
+
/** Build a node tree (one child per OBJ object, one mesh per material). */
|
|
133
|
+
function objToNode(data, materials = {}, textures = {}) {
|
|
134
|
+
const root = new runtime_gl.GlNode('obj');
|
|
135
|
+
const byName = new Map();
|
|
136
|
+
for (const g of data.groups) {
|
|
137
|
+
let n = byName.get(g.name);
|
|
138
|
+
if (!n) {
|
|
139
|
+
n = new runtime_gl.GlNode(g.name, []);
|
|
140
|
+
byName.set(g.name, n);
|
|
141
|
+
root.add(n);
|
|
142
|
+
}
|
|
143
|
+
const om = materials[g.material];
|
|
144
|
+
const mat = objMaterial(om);
|
|
145
|
+
if (om?.map_Kd && textures[om.map_Kd])
|
|
146
|
+
mat.map = runtime_gl.texture(textures[om.map_Kd]);
|
|
147
|
+
n.mesh.push({ geometry: g.geometry, material: mat });
|
|
148
|
+
}
|
|
149
|
+
return root;
|
|
150
|
+
}
|
|
151
|
+
/** Fetch an OBJ (+ its MTL files and diffuse textures, relative to the OBJ URL) and build a node. */
|
|
152
|
+
async function loadObj(url) {
|
|
153
|
+
const get = async (u) => {
|
|
154
|
+
const r = await fetch(u);
|
|
155
|
+
if (!r.ok)
|
|
156
|
+
throw new Error(`[motionary] format-obj: could not load ${u} (${r.status})`);
|
|
157
|
+
return r;
|
|
158
|
+
};
|
|
159
|
+
const data = parseObj(await (await get(url)).text());
|
|
160
|
+
const materials = {};
|
|
161
|
+
for (const lib of data.mtllibs)
|
|
162
|
+
Object.assign(materials, parseMtl(await (await get(new URL(lib, new URL(url, location.href)).href)).text()));
|
|
163
|
+
const textures = {};
|
|
164
|
+
await Promise.all(Object.values(materials).filter((m) => m.map_Kd).map(async (m) => {
|
|
165
|
+
const blob = await (await get(new URL(m.map_Kd, new URL(url, location.href)).href)).blob();
|
|
166
|
+
textures[m.map_Kd] = await createImageBitmap(blob);
|
|
167
|
+
}));
|
|
168
|
+
const node = objToNode(data, materials, textures);
|
|
169
|
+
node.extras = { obj: data, materials };
|
|
170
|
+
return node;
|
|
171
|
+
}
|
|
172
|
+
/** The module object for `use(formatObj)` (needs `gl`). */
|
|
173
|
+
const formatObj = { id: 'format-obj', version: registry.RUNTIME_VERSION, requires: ['core', 'gl'], api: { parseObj, parseMtl, objMaterial, objToNode, loadObj } };
|
|
174
|
+
|
|
175
|
+
exports.formatObj = formatObj;
|
|
176
|
+
exports.loadObj = loadObj;
|
|
177
|
+
exports.objMaterial = objMaterial;
|
|
178
|
+
exports.objToNode = objToNode;
|
|
179
|
+
exports.parseMtl = parseMtl;
|
|
180
|
+
exports.parseObj = parseObj;
|
|
181
|
+
//# sourceMappingURL=format-obj.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-obj.cjs","sources":["../../src/runtime/format-obj.ts"],"sourcesContent":["/**\n * `motionary/runtime/format-obj` (10.5) — Wavefront OBJ + MTL loader for\n * `motionary/runtime/gl` (own parser): `v` / `vt` / `vn`, faces with any\n * number of vertices (fan-triangulated) and negative indices, `o` / `g`\n * groups, `usemtl` material switches (one mesh per material), `s` ignored;\n * MTL `Kd`, `Ks` + `Ns` (→ roughness), `Ke`, `d` / `Tr` (opacity), `map_Kd`\n * (with options stripped), `illum` ignored. Missing normals are computed\n * (flat). Parsing is pure (SSR / workers); `loadObj()` fetches the OBJ, its\n * `mtllib` files and textures relative to the OBJ URL.\n */\nimport { RUNTIME_VERSION, type RuntimeModule } from './registry';\nimport { GlNode, standardMaterial, computeNormals, texture, type Geometry, type Material, type Mesh } from './gl';\n\nexport interface ObjMaterial {\n name: string;\n Kd: [number, number, number];\n Ks: [number, number, number];\n Ke: [number, number, number];\n Ns: number;\n d: number;\n map_Kd?: string;\n}\n\nexport interface ObjGroup {\n name: string;\n material: string;\n geometry: Geometry;\n}\n\nexport interface ObjData {\n groups: ObjGroup[];\n mtllibs: string[];\n /** Vertex count read (before de-indexing). */\n vertexCount: number;\n triangleCount: number;\n}\n\nconst nums = (p: string[], from: number, n: number): number[] => Array.from({ length: n }, (_, i) => parseFloat(p[from + i]) || 0);\n\n/** Parse OBJ text into groups (one geometry per object / group × material). */\nexport function parseObj(text: string): ObjData {\n const v: number[] = [], vt: number[] = [], vn: number[] = [];\n const mtllibs: string[] = [];\n const groups: ObjGroup[] = [];\n let cur: { name: string; material: string; p: number[]; n: number[]; t: number[]; hasN: boolean; hasT: boolean } | null = null;\n let obj = 'default', mat = '', tris = 0;\n const flush = () => {\n if (cur && cur.p.length) {\n const g: Geometry = { positions: new Float32Array(cur.p), uvs: cur.hasT ? new Float32Array(cur.t) : undefined };\n groups.push({ name: cur.name, material: cur.material, geometry: cur.hasN ? { ...g, normals: new Float32Array(cur.n) } : computeNormals(g) });\n }\n cur = null;\n };\n const start = () => {\n if (!cur || cur.name !== obj || cur.material !== mat) {\n flush();\n cur = { name: obj, material: mat, p: [], n: [], t: [], hasN: true, hasT: true };\n }\n return cur;\n };\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.trim();\n if (!line || line[0] === '#') continue;\n const p = line.split(/\\s+/);\n switch (p[0]) {\n case 'v': v.push(...nums(p, 1, 3)); break;\n case 'vt': vt.push(...nums(p, 1, 2)); break;\n case 'vn': vn.push(...nums(p, 1, 3)); break;\n case 'o': case 'g': flush(); obj = p.slice(1).join(' ') || 'default'; break;\n case 'usemtl': mat = p.slice(1).join(' '); break;\n case 'mtllib': mtllibs.push(...p.slice(1)); break;\n case 'f': {\n const c = start();\n const verts = p.slice(1).map((s) => {\n const [a, b, n] = s.split('/');\n const ix = (x: string | undefined, len: number) => (x ? (+x < 0 ? len + +x : +x - 1) : -1);\n return [ix(a, v.length / 3), ix(b, vt.length / 2), ix(n, vn.length / 3)];\n });\n for (let i = 1; i + 1 < verts.length; i++) {\n for (const k of [verts[0], verts[i], verts[i + 1]]) {\n c.p.push(v[k[0] * 3], v[k[0] * 3 + 1], v[k[0] * 3 + 2]);\n if (k[1] >= 0) c.t.push(vt[k[1] * 2], 1 - vt[k[1] * 2 + 1]);\n else {\n c.hasT = false;\n c.t.push(0, 0);\n }\n if (k[2] >= 0) c.n.push(vn[k[2] * 3], vn[k[2] * 3 + 1], vn[k[2] * 3 + 2]);\n else {\n c.hasN = false;\n c.n.push(0, 0, 1);\n }\n }\n tris++;\n }\n break;\n }\n }\n }\n flush();\n return { groups, mtllibs, vertexCount: v.length / 3, triangleCount: tris };\n}\n\n/** Parse MTL text. */\nexport function parseMtl(text: string): Record<string, ObjMaterial> {\n const out: Record<string, ObjMaterial> = {};\n let m: ObjMaterial | null = null;\n for (const raw of text.split(/\\r?\\n/)) {\n const line = raw.trim();\n if (!line || line[0] === '#') continue;\n const p = line.split(/\\s+/);\n const k = p[0];\n if (k === 'newmtl') {\n m = out[p.slice(1).join(' ')] = { name: p.slice(1).join(' '), Kd: [0.8, 0.8, 0.8], Ks: [0, 0, 0], Ke: [0, 0, 0], Ns: 10, d: 1 };\n continue;\n }\n if (!m) continue;\n if (k === 'Kd' || k === 'Ks' || k === 'Ke') m[k] = nums(p, 1, 3) as [number, number, number];\n else if (k === 'Ns') m.Ns = parseFloat(p[1]) || 0;\n else if (k === 'd') m.d = parseFloat(p[1]);\n else if (k === 'Tr') m.d = 1 - parseFloat(p[1]);\n else if (k === 'map_Kd') m.map_Kd = p[p.length - 1]; // options (-s, -o, -bm …) precede the file name\n }\n return out;\n}\n\n/** OBJ material → runtime/gl standard material (Ns 0–1000 → roughness). */\nexport function objMaterial(m?: ObjMaterial): Material {\n if (!m) return standardMaterial({ color: [0.8, 0.8, 0.8, 1] });\n const spec = Math.max(...m.Ks);\n return standardMaterial({ color: [m.Kd[0], m.Kd[1], m.Kd[2], m.d], roughness: Math.min(1, Math.max(0.05, 1 - Math.sqrt(Math.min(m.Ns, 1000) / 1000) * (spec > 0 ? 1 : 0.4))), metallic: 0, emissive: m.Ke, transparent: m.d < 1 });\n}\n\n/** Build a node tree (one child per OBJ object, one mesh per material). */\nexport function objToNode(data: ObjData, materials: Record<string, ObjMaterial> = {}, textures: Record<string, TexImageSource> = {}): GlNode {\n const root = new GlNode('obj');\n const byName = new Map<string, GlNode>();\n for (const g of data.groups) {\n let n = byName.get(g.name);\n if (!n) {\n n = new GlNode(g.name, []);\n byName.set(g.name, n);\n root.add(n);\n }\n const om = materials[g.material];\n const mat = objMaterial(om);\n if (om?.map_Kd && textures[om.map_Kd]) mat.map = texture(textures[om.map_Kd]);\n (n.mesh as Mesh[]).push({ geometry: g.geometry, material: mat });\n }\n return root;\n}\n\n/** Fetch an OBJ (+ its MTL files and diffuse textures, relative to the OBJ URL) and build a node. */\nexport async function loadObj(url: string): Promise<GlNode & { extras: { obj: ObjData; materials: Record<string, ObjMaterial> } }> {\n const get = async (u: string) => {\n const r = await fetch(u);\n if (!r.ok) throw new Error(`[motionary] format-obj: could not load ${u} (${r.status})`);\n return r;\n };\n const data = parseObj(await (await get(url)).text());\n const materials: Record<string, ObjMaterial> = {};\n for (const lib of data.mtllibs) Object.assign(materials, parseMtl(await (await get(new URL(lib, new URL(url, location.href)).href)).text()));\n const textures: Record<string, TexImageSource> = {};\n await Promise.all(Object.values(materials).filter((m) => m.map_Kd).map(async (m) => {\n const blob = await (await get(new URL(m.map_Kd!, new URL(url, location.href)).href)).blob();\n textures[m.map_Kd!] = await createImageBitmap(blob);\n }));\n const node = objToNode(data, materials, textures) as any;\n node.extras = { obj: data, materials };\n return node;\n}\n\nexport interface FormatObjApi {\n parseObj: typeof parseObj;\n parseMtl: typeof parseMtl;\n objMaterial: typeof objMaterial;\n objToNode: typeof objToNode;\n loadObj: typeof loadObj;\n}\n\n/** The module object for `use(formatObj)` (needs `gl`). */\nexport const formatObj: RuntimeModule<FormatObjApi> = { id: 'format-obj', version: RUNTIME_VERSION, requires: ['core', 'gl'], api: { parseObj, parseMtl, objMaterial, objToNode, loadObj } };\n"],"names":["computeNormals","standardMaterial","GlNode","texture","RUNTIME_VERSION"],"mappings":";;;;;AAAA;;;;;;;;;AASG;AA4BH,MAAM,IAAI,GAAG,CAAC,CAAW,EAAE,IAAY,EAAE,CAAS,KAAe,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAElI;AACM,SAAU,QAAQ,CAAC,IAAY,EAAA;IACnC,MAAM,CAAC,GAAa,EAAE,EAAE,EAAE,GAAa,EAAE,EAAE,EAAE,GAAa,EAAE;IAC5D,MAAM,OAAO,GAAa,EAAE;IAC5B,MAAM,MAAM,GAAe,EAAE;IAC7B,IAAI,GAAG,GAAmH,IAAI;IAC9H,IAAI,GAAG,GAAG,SAAS,EAAE,GAAG,GAAG,EAAE,EAAE,IAAI,GAAG,CAAC;IACvC,MAAM,KAAK,GAAG,MAAK;QACjB,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE;AACvB,YAAA,MAAM,CAAC,GAAa,EAAE,SAAS,EAAE,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,GAAG,IAAI,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE;YAC/G,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EA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AI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE;QAC3F,QAAQ,CAAC,CAAC,CAAC,MAAO,CAAC,GAAG,MAAM,iBAAiB,CAAC,IAAI,CAAC;IACrD,CAAC,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAQ;IACxD,IAAI,CAAC,MAAM,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE;AACtC,IAAA,OAAO,IAAI;AACb;AAUA;AACO,MAAM,SAAS,GAAgC,EAAE,EAAE,EAAE,YAAY,EAAE,OAAO,EAAEC,wBAAe,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE;;;;;;;"}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/** A runtime module: `{ id, version, api }`, registered with `use()`. */
|
|
2
|
+
interface RuntimeModule<A = unknown> {
|
|
3
|
+
/** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Other modules this one needs (registered first by `use()` callers). */
|
|
7
|
+
requires?: string[];
|
|
8
|
+
/** The module's public API (what `requireModule(id)` returns). */
|
|
9
|
+
api: A;
|
|
10
|
+
/** Optional one-time setup, called on first registration. */
|
|
11
|
+
setup?(registry: RuntimeRegistry): void;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimeRegistry {
|
|
14
|
+
version: string;
|
|
15
|
+
modules: Map<string, RuntimeModule>;
|
|
16
|
+
/** Shared per-page state slots (the ticker lives here). */
|
|
17
|
+
slots: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `motionary/runtime/gl` (10.5) — a small WebGL2 scene renderer written for
|
|
22
|
+
* Motionary (not a Three.js clone; own API, own shaders):
|
|
23
|
+
*
|
|
24
|
+
* - **math** (`mat4`, quaternions — column-major `Float32Array`s), pure;
|
|
25
|
+
* - **scene graph**: `GlNode` (position / rotation quaternion / scale,
|
|
26
|
+
* children, optional mesh), `Camera` (perspective, `lookAt`), lights
|
|
27
|
+
* (`ambient`, up to 4 directional / point), `bounds()` + `frameNode()`;
|
|
28
|
+
* - **geometry** builders (`box`, `plane`, `sphere`, `torus`) and custom
|
|
29
|
+
* geometry from typed arrays (indexed 16 / 32-bit or not);
|
|
30
|
+
* - **materials**: `standard` (metallic-roughness PBR approximation, base
|
|
31
|
+
* colour texture, emissive, ACES-free Reinhard tone mapping, sRGB),
|
|
32
|
+
* `unlit`, and `shader` (your GLSL ES 3.00 fragment with the standard
|
|
33
|
+
* varyings + your uniforms);
|
|
34
|
+
* - **textures** from images, canvases, bitmaps and **videos** (updated per
|
|
35
|
+
* decoded frame with `requestVideoFrameCallback`; `scrubVideo()` seeks a
|
|
36
|
+
* video from a 0–1 progress, e.g. a scroll scene);
|
|
37
|
+
* - `orbitControls()` — drag / wheel / pinch / arrow keys, damping, optional
|
|
38
|
+
* auto-rotate (off under reduced motion).
|
|
39
|
+
*
|
|
40
|
+
* Math, geometry and the scene graph are pure (SSR / workers); rendering
|
|
41
|
+
* needs WebGL2 (`createRenderer()` throws a clear error without it). Model
|
|
42
|
+
* loaders live in `motionary/runtime/format-gltf` and `format-obj`.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
type Vec3 = [number, number, number];
|
|
46
|
+
type Quat = [number, number, number, number];
|
|
47
|
+
type Mat4 = Float32Array;
|
|
48
|
+
interface Geometry {
|
|
49
|
+
positions: Float32Array;
|
|
50
|
+
normals?: Float32Array;
|
|
51
|
+
uvs?: Float32Array;
|
|
52
|
+
indices?: Uint16Array | Uint32Array;
|
|
53
|
+
/** 'triangles' (default), 'lines', 'points'. */
|
|
54
|
+
mode?: 'triangles' | 'lines' | 'points';
|
|
55
|
+
/** Renderer cache. */
|
|
56
|
+
_gpu?: unknown;
|
|
57
|
+
}
|
|
58
|
+
interface GlTexture {
|
|
59
|
+
source: TexImageSource | {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
data: Uint8Array | Uint8ClampedArray;
|
|
63
|
+
};
|
|
64
|
+
/** sRGB colour data (default true for colour maps). */
|
|
65
|
+
srgb?: boolean;
|
|
66
|
+
repeat?: boolean;
|
|
67
|
+
flipY?: boolean;
|
|
68
|
+
/** Re-upload every frame a new video frame is ready. */
|
|
69
|
+
video?: boolean;
|
|
70
|
+
needsUpdate?: boolean;
|
|
71
|
+
_gpu?: unknown;
|
|
72
|
+
}
|
|
73
|
+
interface Material {
|
|
74
|
+
type: 'standard' | 'unlit' | 'shader';
|
|
75
|
+
/** Linear RGBA multiplier (sRGB input converted by the shader). */
|
|
76
|
+
color: [number, number, number, number];
|
|
77
|
+
map?: GlTexture | null;
|
|
78
|
+
metallic: number;
|
|
79
|
+
roughness: number;
|
|
80
|
+
emissive: Vec3;
|
|
81
|
+
doubleSided?: boolean;
|
|
82
|
+
transparent?: boolean;
|
|
83
|
+
wireframe?: boolean;
|
|
84
|
+
/** 'shader' materials: GLSL ES 3.00 fragment body + uniforms. */
|
|
85
|
+
fragment?: string;
|
|
86
|
+
uniforms?: Record<string, number | number[] | Float32Array | GlTexture>;
|
|
87
|
+
_gpu?: unknown;
|
|
88
|
+
}
|
|
89
|
+
interface Mesh {
|
|
90
|
+
geometry: Geometry;
|
|
91
|
+
material: Material;
|
|
92
|
+
}
|
|
93
|
+
declare class GlNode {
|
|
94
|
+
name: string;
|
|
95
|
+
position: Vec3;
|
|
96
|
+
rotation: Quat;
|
|
97
|
+
scale: Vec3;
|
|
98
|
+
/** Set to use a fixed local matrix instead of position / rotation / scale (glTF `matrix`). */
|
|
99
|
+
matrix: Mat4 | null;
|
|
100
|
+
children: GlNode[];
|
|
101
|
+
parent: GlNode | null;
|
|
102
|
+
mesh: Mesh | Mesh[] | null;
|
|
103
|
+
visible: boolean;
|
|
104
|
+
/** Free-form data (loaders put source info here). */
|
|
105
|
+
extras: Record<string, unknown>;
|
|
106
|
+
readonly world: Mat4;
|
|
107
|
+
constructor(name?: string, mesh?: Mesh | Mesh[] | null);
|
|
108
|
+
add(...nodes: GlNode[]): this;
|
|
109
|
+
remove(n: GlNode): void;
|
|
110
|
+
setEuler(x: number, y: number, z: number): this;
|
|
111
|
+
local(): Mat4;
|
|
112
|
+
/** Recompute world matrices of this subtree. */
|
|
113
|
+
updateWorld(parent?: Mat4): void;
|
|
114
|
+
traverse(fn: (n: GlNode) => void): void;
|
|
115
|
+
find(name: string): GlNode | null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `motionary/runtime/format-obj` (10.5) — Wavefront OBJ + MTL loader for
|
|
120
|
+
* `motionary/runtime/gl` (own parser): `v` / `vt` / `vn`, faces with any
|
|
121
|
+
* number of vertices (fan-triangulated) and negative indices, `o` / `g`
|
|
122
|
+
* groups, `usemtl` material switches (one mesh per material), `s` ignored;
|
|
123
|
+
* MTL `Kd`, `Ks` + `Ns` (→ roughness), `Ke`, `d` / `Tr` (opacity), `map_Kd`
|
|
124
|
+
* (with options stripped), `illum` ignored. Missing normals are computed
|
|
125
|
+
* (flat). Parsing is pure (SSR / workers); `loadObj()` fetches the OBJ, its
|
|
126
|
+
* `mtllib` files and textures relative to the OBJ URL.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
interface ObjMaterial {
|
|
130
|
+
name: string;
|
|
131
|
+
Kd: [number, number, number];
|
|
132
|
+
Ks: [number, number, number];
|
|
133
|
+
Ke: [number, number, number];
|
|
134
|
+
Ns: number;
|
|
135
|
+
d: number;
|
|
136
|
+
map_Kd?: string;
|
|
137
|
+
}
|
|
138
|
+
interface ObjGroup {
|
|
139
|
+
name: string;
|
|
140
|
+
material: string;
|
|
141
|
+
geometry: Geometry;
|
|
142
|
+
}
|
|
143
|
+
interface ObjData {
|
|
144
|
+
groups: ObjGroup[];
|
|
145
|
+
mtllibs: string[];
|
|
146
|
+
/** Vertex count read (before de-indexing). */
|
|
147
|
+
vertexCount: number;
|
|
148
|
+
triangleCount: number;
|
|
149
|
+
}
|
|
150
|
+
/** Parse OBJ text into groups (one geometry per object / group × material). */
|
|
151
|
+
declare function parseObj(text: string): ObjData;
|
|
152
|
+
/** Parse MTL text. */
|
|
153
|
+
declare function parseMtl(text: string): Record<string, ObjMaterial>;
|
|
154
|
+
/** OBJ material → runtime/gl standard material (Ns 0–1000 → roughness). */
|
|
155
|
+
declare function objMaterial(m?: ObjMaterial): Material;
|
|
156
|
+
/** Build a node tree (one child per OBJ object, one mesh per material). */
|
|
157
|
+
declare function objToNode(data: ObjData, materials?: Record<string, ObjMaterial>, textures?: Record<string, TexImageSource>): GlNode;
|
|
158
|
+
/** Fetch an OBJ (+ its MTL files and diffuse textures, relative to the OBJ URL) and build a node. */
|
|
159
|
+
declare function loadObj(url: string): Promise<GlNode & {
|
|
160
|
+
extras: {
|
|
161
|
+
obj: ObjData;
|
|
162
|
+
materials: Record<string, ObjMaterial>;
|
|
163
|
+
};
|
|
164
|
+
}>;
|
|
165
|
+
interface FormatObjApi {
|
|
166
|
+
parseObj: typeof parseObj;
|
|
167
|
+
parseMtl: typeof parseMtl;
|
|
168
|
+
objMaterial: typeof objMaterial;
|
|
169
|
+
objToNode: typeof objToNode;
|
|
170
|
+
loadObj: typeof loadObj;
|
|
171
|
+
}
|
|
172
|
+
/** The module object for `use(formatObj)` (needs `gl`). */
|
|
173
|
+
declare const formatObj: RuntimeModule<FormatObjApi>;
|
|
174
|
+
|
|
175
|
+
export { formatObj, loadObj, objMaterial, objToNode, parseMtl, parseObj };
|
|
176
|
+
export type { FormatObjApi, ObjData, ObjGroup, ObjMaterial };
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/** A runtime module: `{ id, version, api }`, registered with `use()`. */
|
|
2
|
+
interface RuntimeModule<A = unknown> {
|
|
3
|
+
/** Module id: 'core', 'format-css', 'scroll', … (import path `motionary/runtime/<id>`). */
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
/** Other modules this one needs (registered first by `use()` callers). */
|
|
7
|
+
requires?: string[];
|
|
8
|
+
/** The module's public API (what `requireModule(id)` returns). */
|
|
9
|
+
api: A;
|
|
10
|
+
/** Optional one-time setup, called on first registration. */
|
|
11
|
+
setup?(registry: RuntimeRegistry): void;
|
|
12
|
+
}
|
|
13
|
+
interface RuntimeRegistry {
|
|
14
|
+
version: string;
|
|
15
|
+
modules: Map<string, RuntimeModule>;
|
|
16
|
+
/** Shared per-page state slots (the ticker lives here). */
|
|
17
|
+
slots: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `motionary/runtime/gl` (10.5) — a small WebGL2 scene renderer written for
|
|
22
|
+
* Motionary (not a Three.js clone; own API, own shaders):
|
|
23
|
+
*
|
|
24
|
+
* - **math** (`mat4`, quaternions — column-major `Float32Array`s), pure;
|
|
25
|
+
* - **scene graph**: `GlNode` (position / rotation quaternion / scale,
|
|
26
|
+
* children, optional mesh), `Camera` (perspective, `lookAt`), lights
|
|
27
|
+
* (`ambient`, up to 4 directional / point), `bounds()` + `frameNode()`;
|
|
28
|
+
* - **geometry** builders (`box`, `plane`, `sphere`, `torus`) and custom
|
|
29
|
+
* geometry from typed arrays (indexed 16 / 32-bit or not);
|
|
30
|
+
* - **materials**: `standard` (metallic-roughness PBR approximation, base
|
|
31
|
+
* colour texture, emissive, ACES-free Reinhard tone mapping, sRGB),
|
|
32
|
+
* `unlit`, and `shader` (your GLSL ES 3.00 fragment with the standard
|
|
33
|
+
* varyings + your uniforms);
|
|
34
|
+
* - **textures** from images, canvases, bitmaps and **videos** (updated per
|
|
35
|
+
* decoded frame with `requestVideoFrameCallback`; `scrubVideo()` seeks a
|
|
36
|
+
* video from a 0–1 progress, e.g. a scroll scene);
|
|
37
|
+
* - `orbitControls()` — drag / wheel / pinch / arrow keys, damping, optional
|
|
38
|
+
* auto-rotate (off under reduced motion).
|
|
39
|
+
*
|
|
40
|
+
* Math, geometry and the scene graph are pure (SSR / workers); rendering
|
|
41
|
+
* needs WebGL2 (`createRenderer()` throws a clear error without it). Model
|
|
42
|
+
* loaders live in `motionary/runtime/format-gltf` and `format-obj`.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
type Vec3 = [number, number, number];
|
|
46
|
+
type Quat = [number, number, number, number];
|
|
47
|
+
type Mat4 = Float32Array;
|
|
48
|
+
interface Geometry {
|
|
49
|
+
positions: Float32Array;
|
|
50
|
+
normals?: Float32Array;
|
|
51
|
+
uvs?: Float32Array;
|
|
52
|
+
indices?: Uint16Array | Uint32Array;
|
|
53
|
+
/** 'triangles' (default), 'lines', 'points'. */
|
|
54
|
+
mode?: 'triangles' | 'lines' | 'points';
|
|
55
|
+
/** Renderer cache. */
|
|
56
|
+
_gpu?: unknown;
|
|
57
|
+
}
|
|
58
|
+
interface GlTexture {
|
|
59
|
+
source: TexImageSource | {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
data: Uint8Array | Uint8ClampedArray;
|
|
63
|
+
};
|
|
64
|
+
/** sRGB colour data (default true for colour maps). */
|
|
65
|
+
srgb?: boolean;
|
|
66
|
+
repeat?: boolean;
|
|
67
|
+
flipY?: boolean;
|
|
68
|
+
/** Re-upload every frame a new video frame is ready. */
|
|
69
|
+
video?: boolean;
|
|
70
|
+
needsUpdate?: boolean;
|
|
71
|
+
_gpu?: unknown;
|
|
72
|
+
}
|
|
73
|
+
interface Material {
|
|
74
|
+
type: 'standard' | 'unlit' | 'shader';
|
|
75
|
+
/** Linear RGBA multiplier (sRGB input converted by the shader). */
|
|
76
|
+
color: [number, number, number, number];
|
|
77
|
+
map?: GlTexture | null;
|
|
78
|
+
metallic: number;
|
|
79
|
+
roughness: number;
|
|
80
|
+
emissive: Vec3;
|
|
81
|
+
doubleSided?: boolean;
|
|
82
|
+
transparent?: boolean;
|
|
83
|
+
wireframe?: boolean;
|
|
84
|
+
/** 'shader' materials: GLSL ES 3.00 fragment body + uniforms. */
|
|
85
|
+
fragment?: string;
|
|
86
|
+
uniforms?: Record<string, number | number[] | Float32Array | GlTexture>;
|
|
87
|
+
_gpu?: unknown;
|
|
88
|
+
}
|
|
89
|
+
interface Mesh {
|
|
90
|
+
geometry: Geometry;
|
|
91
|
+
material: Material;
|
|
92
|
+
}
|
|
93
|
+
declare class GlNode {
|
|
94
|
+
name: string;
|
|
95
|
+
position: Vec3;
|
|
96
|
+
rotation: Quat;
|
|
97
|
+
scale: Vec3;
|
|
98
|
+
/** Set to use a fixed local matrix instead of position / rotation / scale (glTF `matrix`). */
|
|
99
|
+
matrix: Mat4 | null;
|
|
100
|
+
children: GlNode[];
|
|
101
|
+
parent: GlNode | null;
|
|
102
|
+
mesh: Mesh | Mesh[] | null;
|
|
103
|
+
visible: boolean;
|
|
104
|
+
/** Free-form data (loaders put source info here). */
|
|
105
|
+
extras: Record<string, unknown>;
|
|
106
|
+
readonly world: Mat4;
|
|
107
|
+
constructor(name?: string, mesh?: Mesh | Mesh[] | null);
|
|
108
|
+
add(...nodes: GlNode[]): this;
|
|
109
|
+
remove(n: GlNode): void;
|
|
110
|
+
setEuler(x: number, y: number, z: number): this;
|
|
111
|
+
local(): Mat4;
|
|
112
|
+
/** Recompute world matrices of this subtree. */
|
|
113
|
+
updateWorld(parent?: Mat4): void;
|
|
114
|
+
traverse(fn: (n: GlNode) => void): void;
|
|
115
|
+
find(name: string): GlNode | null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* `motionary/runtime/format-obj` (10.5) — Wavefront OBJ + MTL loader for
|
|
120
|
+
* `motionary/runtime/gl` (own parser): `v` / `vt` / `vn`, faces with any
|
|
121
|
+
* number of vertices (fan-triangulated) and negative indices, `o` / `g`
|
|
122
|
+
* groups, `usemtl` material switches (one mesh per material), `s` ignored;
|
|
123
|
+
* MTL `Kd`, `Ks` + `Ns` (→ roughness), `Ke`, `d` / `Tr` (opacity), `map_Kd`
|
|
124
|
+
* (with options stripped), `illum` ignored. Missing normals are computed
|
|
125
|
+
* (flat). Parsing is pure (SSR / workers); `loadObj()` fetches the OBJ, its
|
|
126
|
+
* `mtllib` files and textures relative to the OBJ URL.
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
interface ObjMaterial {
|
|
130
|
+
name: string;
|
|
131
|
+
Kd: [number, number, number];
|
|
132
|
+
Ks: [number, number, number];
|
|
133
|
+
Ke: [number, number, number];
|
|
134
|
+
Ns: number;
|
|
135
|
+
d: number;
|
|
136
|
+
map_Kd?: string;
|
|
137
|
+
}
|
|
138
|
+
interface ObjGroup {
|
|
139
|
+
name: string;
|
|
140
|
+
material: string;
|
|
141
|
+
geometry: Geometry;
|
|
142
|
+
}
|
|
143
|
+
interface ObjData {
|
|
144
|
+
groups: ObjGroup[];
|
|
145
|
+
mtllibs: string[];
|
|
146
|
+
/** Vertex count read (before de-indexing). */
|
|
147
|
+
vertexCount: number;
|
|
148
|
+
triangleCount: number;
|
|
149
|
+
}
|
|
150
|
+
/** Parse OBJ text into groups (one geometry per object / group × material). */
|
|
151
|
+
declare function parseObj(text: string): ObjData;
|
|
152
|
+
/** Parse MTL text. */
|
|
153
|
+
declare function parseMtl(text: string): Record<string, ObjMaterial>;
|
|
154
|
+
/** OBJ material → runtime/gl standard material (Ns 0–1000 → roughness). */
|
|
155
|
+
declare function objMaterial(m?: ObjMaterial): Material;
|
|
156
|
+
/** Build a node tree (one child per OBJ object, one mesh per material). */
|
|
157
|
+
declare function objToNode(data: ObjData, materials?: Record<string, ObjMaterial>, textures?: Record<string, TexImageSource>): GlNode;
|
|
158
|
+
/** Fetch an OBJ (+ its MTL files and diffuse textures, relative to the OBJ URL) and build a node. */
|
|
159
|
+
declare function loadObj(url: string): Promise<GlNode & {
|
|
160
|
+
extras: {
|
|
161
|
+
obj: ObjData;
|
|
162
|
+
materials: Record<string, ObjMaterial>;
|
|
163
|
+
};
|
|
164
|
+
}>;
|
|
165
|
+
interface FormatObjApi {
|
|
166
|
+
parseObj: typeof parseObj;
|
|
167
|
+
parseMtl: typeof parseMtl;
|
|
168
|
+
objMaterial: typeof objMaterial;
|
|
169
|
+
objToNode: typeof objToNode;
|
|
170
|
+
loadObj: typeof loadObj;
|
|
171
|
+
}
|
|
172
|
+
/** The module object for `use(formatObj)` (needs `gl`). */
|
|
173
|
+
declare const formatObj: RuntimeModule<FormatObjApi>;
|
|
174
|
+
|
|
175
|
+
export { formatObj, loadObj, objMaterial, objToNode, parseMtl, parseObj };
|
|
176
|
+
export type { FormatObjApi, ObjData, ObjGroup, ObjMaterial };
|