@margoengine/gltf 0.1.0 → 1.0.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.
Files changed (83) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +4 -4
  3. package/README.md +1754 -1438
  4. package/dist/accessor-CU_1uSZ1.js +1 -0
  5. package/dist/asset-DN3ocEdY.js +4 -0
  6. package/dist/asset-entry.js +1 -1
  7. package/dist/asset.d.ts +76 -0
  8. package/dist/audio.js +1 -1
  9. package/dist/auto.js +1 -1
  10. package/dist/compression-CUOCmjmE.js +1 -0
  11. package/dist/compression.d.ts +6 -0
  12. package/dist/dds.js +1 -1
  13. package/dist/default-materials.d.ts +3 -1
  14. package/dist/default-transmission.d.ts +13 -0
  15. package/dist/extended.js +1 -1
  16. package/dist/group.d.ts +15 -3
  17. package/dist/index.d.ts +11 -0
  18. package/dist/index.js +1 -1
  19. package/dist/{instanced-shader-BebTnbkj.js → instanced-shader-C9ZMazvo.js} +1 -1
  20. package/dist/instancing.js +1 -1
  21. package/dist/lights.js +1 -1
  22. package/dist/material-draw-state-GKiHDb0p.js +1 -0
  23. package/dist/material-draw.js +1 -1
  24. package/dist/meshopt.js +1 -1
  25. package/dist/mipmaps-38NmjDc3.js +21 -0
  26. package/dist/model-C77ATxi1.js +25 -0
  27. package/dist/model-entry.js +1 -1
  28. package/dist/model.d.ts +84 -7
  29. package/dist/native-glass-D85twud0.js +19 -0
  30. package/dist/pack-DdxRO8k6.js +1 -0
  31. package/dist/pbr-instancing.js +1 -1
  32. package/dist/pbr.js +1 -1
  33. package/dist/physics.js +1 -1
  34. package/dist/prepare.js +1 -1
  35. package/dist/progressive-lod.d.ts +13 -0
  36. package/dist/progressive.d.ts +5 -2
  37. package/dist/progressive.js +3 -3
  38. package/dist/quantized.js +1 -1
  39. package/dist/report.js +1 -1
  40. package/dist/scene-data.js +1 -1
  41. package/dist/scene-scope-CZDEkd24.js +2 -2
  42. package/dist/scene.js +3 -3
  43. package/dist/{shader-DPqfUcmp.js → shader-C29RtPAw.js} +43 -39
  44. package/dist/shader.d.ts +24 -0
  45. package/dist/shared/caster.d.ts +159 -152
  46. package/dist/shared/gltf.d.ts +257 -257
  47. package/dist/shared/iridescence.d.ts +2 -2
  48. package/dist/shared/prepared-geometry.d.ts +8 -8
  49. package/dist/soft-mesh.d.ts +39 -1
  50. package/dist/soft-mesh.js +2 -2
  51. package/dist/spec-gloss.js +2 -2
  52. package/dist/splats.js +1 -1
  53. package/dist/src-Btvz5f6i.js +4 -0
  54. package/dist/stream-CrfNNCRd.js +1 -0
  55. package/dist/stream.d.ts +20 -3
  56. package/dist/stroke-width-B2cnYGgn.js +1 -0
  57. package/dist/stroke-width.d.ts +18 -0
  58. package/dist/strokes.d.ts +12 -0
  59. package/dist/strokes.js +1 -0
  60. package/dist/texture-stream-Cu_XpyVO.js +3 -3
  61. package/dist/textured.js +3 -3
  62. package/dist/transmission.d.ts +81 -0
  63. package/dist/transmission.js +66 -0
  64. package/dist/version-B6NE5cJf.js +1 -0
  65. package/dist/vertex-inputs.d.ts +6 -0
  66. package/dist/{unit-light-DvtsuFYP.js → warning-UqjZyyqW.js} +2 -22
  67. package/dist/warning.d.ts +24 -0
  68. package/dist/worker.d.ts +1 -1
  69. package/dist/worker.js +3 -3
  70. package/dist/workers/gltf.js +36 -36
  71. package/dist/workers/progressive.js +1 -1
  72. package/package.json +234 -213
  73. package/dist/accessor-nVsu_f1L.js +0 -1
  74. package/dist/asset-1b8ejkZX.js +0 -4
  75. package/dist/compression-D4IkO5vE.js +0 -1
  76. package/dist/errors-THVaUwlL.js +0 -1
  77. package/dist/material-draw-state-BHeTb1FP.js +0 -1
  78. package/dist/model-iRvuj19h.js +0 -39
  79. package/dist/optimize-7SEzNA23.js +0 -1
  80. package/dist/pack-BVDYuqZe.js +0 -1
  81. package/dist/src-WMRHArDp.js +0 -4
  82. package/dist/stream-C3bKMy1B.js +0 -1
  83. package/dist/version-BmU1nesQ.js +0 -1
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A problem in a glTF file that the loaders work around instead of refusing the file, listed once on
3
+ * `model.warnings` (both loaders). `code` says which kind; the other fields name what it concerns.
4
+ */
5
+ export interface GLTFWarning {
6
+ /**
7
+ * `'missing-texcoord'`: a material's map reads a TEXCOORD set that a primitive using the material lacks. glTF 2.0
8
+ * section 5.24 (`textureInfo.texCoord`) has the map read `TEXCOORD_<texCoord>`; the loaders draw that primitive with
9
+ * the map left out (its factor only), as other loaders do, instead of stopping the load (KB-GLTFA A2).
10
+ */
11
+ readonly code: 'missing-texcoord';
12
+ /** What happened and how to fix the file. */
13
+ readonly message: string;
14
+ /** The glTF material index. */
15
+ readonly material: number;
16
+ /** The map's glTF property, for example `'baseColorTexture'` or `'normalTexture'`. */
17
+ readonly map: string;
18
+ /** The TEXCOORD set the map reads and the primitive lacks. */
19
+ readonly texCoord: number;
20
+ }
21
+ /** The warning for material `material` whose `map` reads `TEXCOORD_<texCoord>`, which a primitive lacks. */
22
+ export declare function missingTexCoord(material: number, name: unknown, map: string, texCoord: number): GLTFWarning;
23
+ /** Adds `warning` to `list` unless one with the same code, material, map and set is there (each is reported once). */
24
+ export declare function addWarning(list: GLTFWarning[], warning: GLTFWarning): void;
package/dist/worker.d.ts CHANGED
@@ -6,7 +6,7 @@ export type { PreparedGLTF } from './prepare.js';
6
6
  /**
7
7
  * Build a PBRModel from a worker's PreparedGLTF on this thread (GPU uploads happen here, at the model's setup).
8
8
  * `decoders` takes only the `instancing` reader (@margoengine/gltf/pbr-instancing) for EXT_mesh_gpu_instancing and the
9
- * `materials` shaders (@margoengine/gltf/extended-materials).
9
+ * `materials` shaders (@margoengine/gltf/extended-materials). Points and lines draw 1 px wide.
10
10
  */
11
11
  export declare function modelFromPrepared(instance: EngineKernel, prepared: PreparedGLTF, signal?: AbortSignal, decoders?: Pick<GLTFDecoderHooks, 'instancing' | 'materials'>): PBRModel;
12
12
  /**
package/dist/worker.js CHANGED
@@ -1,4 +1,4 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
- const h=(engine,version="0.1.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
- import{n as e}from"./errors-THVaUwlL.js";import{t}from"./scene-scope-CZDEkd24.js";import{t as n}from"./decoder-default-CxLH8Vz0.js";import{n as r}from"./model-iRvuj19h.js";import{A as i,g as a,o,t as s}from"./asset-1b8ejkZX.js";import{i as c}from"./pack-BVDYuqZe.js";import{loadGLTF as l,parseGLTFAsync as u}from"./pbr.js";import{prepareAsset as d}from"./prepare.js";import{n as f,r as p,t as m}from"./worker-CY1TQnYX.js";import{engineRuntime as __margoRuntime}from"@margoengine/core/extension";var g=({decoders:e={},fetch:t,draco:n,ktx2:r})=>!!(t||n||r||e.draco||e.meshopt||e.ktx2);function _(t,n,a,l={}){let u;try{if(a?.throwIfAborted(),n.deferred)throw e(`state`,`Compressed PreparedGLTF requires the asynchronous worker loader; call loadGLTF or parseGLTFAsync`);let o=new s(n.doc,n.buffers,void 0,l,n.maxDownloadBytes,n.maxNodes);o.baseURL=n.baseURL,n.maxPartVertices!==void 0&&(o.partVertices=i(n.maxPartVertices));for(let[e,t]of n.accessors)o.cache.set(e,t);return n.doc.meshes?.forEach((e,t)=>e?.primitives?.forEach((e,r)=>{let i=n.geometry[t]?.[r];i&&e&&typeof e==`object`&&c.set(e,Array.isArray(i)?i:[i])})),u=new r(t,o,n.images),h(t).use(u),u}catch(e){throw u?u.dispose():o(n.images),e}}async function v(e,t,i,s){if(t.deferred){let{asset:c,images:l}=await a(t.baseURL,n({...i,buffers:t.buffers}),t.doc,{device:h(e).gpu??void 0,ktx2:i.ktx2},!1,t.downloadedBytes);if(c.hooks.splats){let t=s.run(()=>new r(e,c,l));try{return s.run(()=>h(e).use(t)),await s.run(()=>t.attachSplats(i.signal)),t}catch(e){throw t.dispose(),e}}try{t=d(c,l)}catch(e){throw o(l),e}}return s.run(()=>_(e,t,i.signal,i.decoders))}var y=()=>new URL(`./workers/gltf.js?no-inline`,import.meta.url);async function b(e,n,r={}){if(!m()||g(r)||r.optimize)return l(e,n,r);let i=t(e);return v(e,await p(y(),{url:new URL(n,globalThis.location.href).href,maxDownloadBytes:r.maxDownloadBytes,maxNodes:r.maxNodes,allowedURLs:r.allowedURLs,maxPartVertices:r.maxPartVertices},r.signal),r,i)}async function x(e,n,r={}){if(!m()||g(r))return u(e,n,r);let i=t(e),a={url:globalThis.location.href,input:typeof n==`object`&&!(n instanceof ArrayBuffer)&&!ArrayBuffer.isView(n)?n:f(n),buffers:r.buffers?.map(f),maxDownloadBytes:r.maxDownloadBytes,maxNodes:r.maxNodes,allowedURLs:r.allowedURLs,maxPartVertices:r.maxPartVertices};return v(e,await p(y(),a,r.signal),r,i)}export{b as loadGLTFInWorker,_ as modelFromPrepared,x as parseGLTFInWorker};
3
+ const v=(engine,version="1.0.0",source=import.meta.url)=>__margoRuntime(engine,version,source);
4
+ import{t as e}from"./scene-scope-CZDEkd24.js";import{t}from"./decoder-default-CxLH8Vz0.js";import{n,u as r}from"./model-C77ATxi1.js";import{M as i,_ as a,o,r as s,s as c,t as l}from"./asset-DN3ocEdY.js";import{t as u}from"./stroke-width-B2cnYGgn.js";import{i as d}from"./pack-DdxRO8k6.js";import{loadGLTF as f,parseGLTFAsync as p}from"./pbr.js";import{prepareAsset as m}from"./prepare.js";import{n as h,r as g,t as _}from"./worker-CY1TQnYX.js";import{engineRuntime as __margoRuntime,margoError as y}from"@margoengine/core/extension";var b=({decoders:e={},fetch:t,draco:n,ktx2:r})=>!!(t||n||r||e.draco||e.meshopt||e.ktx2);function x(e,t,n,r={}){return S(e,t,n,r)}function S(e,t,r,a,o=1){let u;try{if(r?.throwIfAborted(),t.deferred)throw y(`state`,`Compressed PreparedGLTF requires the asynchronous worker loader; call loadGLTF or parseGLTFAsync`);let c=new l(t.doc,t.buffers,void 0,a,t.maxDownloadBytes,t.maxNodes);s.set(c,o),c.baseURL=t.baseURL,t.maxPartVertices!==void 0&&(c.partVertices=i(t.maxPartVertices));for(let[e,n]of t.accessors)c.cache.set(e,n);return t.doc.meshes?.forEach((e,n)=>e?.primitives?.forEach((e,r)=>{let i=t.geometry[n]?.[r];i&&e&&typeof e==`object`&&d.set(e,Array.isArray(i)?i:[i])})),u=new n(e,c,t.images),v(e).use(u),u}catch(e){throw u?u.dispose():c(t.images),e}}async function C(e,i,o,s,l){if(i.deferred){let{asset:r,images:u}=await a(i.baseURL,t({...o,maxAnisotropy:l,buffers:i.buffers}),i.doc,{device:v(e).gpu??void 0,ktx2:o.ktx2},!1,i.downloadedBytes);if(r.hooks.splats){let t=s.run(()=>new n(e,r,u));try{return s.run(()=>v(e).use(t)),await s.run(()=>t.attachSplats(o.signal)),await s.run(()=>t.attachStrokes(o.signal)),t}catch(e){throw t.dispose(),e}}try{i=m(r,u)}catch(e){throw c(u),e}}let d=await r(i.doc,o.decoders??{}),f=d.strokes===void 0&&u(i.doc)?{...d,strokes:(await import(`./strokes.js`)).wideStrokes}:d,p=s.run(()=>S(e,i,o.signal,f,l));try{return await s.run(()=>p.attachStrokes(o.signal)),p}catch(e){throw p.dispose(),e}}var w=()=>new URL(`./workers/gltf.js?no-inline`,import.meta.url);async function T(t,n,r={}){if(!_()||b(r)||r.optimize)return f(t,n,r);let i=o(r.maxAnisotropy),a=e(t);return C(t,await g(w(),{url:new URL(n,globalThis.location.href).href,maxDownloadBytes:r.maxDownloadBytes,maxNodes:r.maxNodes,allowedURLs:r.allowedURLs,maxPartVertices:r.maxPartVertices},r.signal),r,a,i)}async function E(t,n,r={}){if(!_()||b(r))return p(t,n,r);let i=o(r.maxAnisotropy),a=e(t),s={url:globalThis.location.href,input:typeof n==`object`&&!(n instanceof ArrayBuffer)&&!ArrayBuffer.isView(n)?n:h(n),buffers:r.buffers?.map(h),maxDownloadBytes:r.maxDownloadBytes,maxNodes:r.maxNodes,allowedURLs:r.allowedURLs,maxPartVertices:r.maxPartVertices};return C(t,await g(w(),s,r.signal),r,a,i)}export{T as loadGLTFInWorker,x as modelFromPrepared,E as parseGLTFInWorker};