poppygl 0.0.5 → 0.0.6

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 (2) hide show
  1. package/dist/index.js +18 -13
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10,13 +10,7 @@ function computeWorldAABB(drawCalls) {
10
10
  for (const dc of drawCalls) {
11
11
  const { positions, model } = dc;
12
12
  for (let i = 0; i < positions.length; i += 3) {
13
- vec4.set(
14
- tmp,
15
- positions[i],
16
- positions[i + 1],
17
- positions[i + 2],
18
- 1
19
- );
13
+ vec4.set(tmp, positions[i], positions[i + 1], positions[i + 2], 1);
20
14
  vec4.transformMat4(tmp, tmp, model);
21
15
  const x = tmp[0];
22
16
  const y = tmp[1];
@@ -799,7 +793,8 @@ function parseGLB(arrayBuffer) {
799
793
  const chunkLength = view.getUint32(offset, true);
800
794
  const chunkType = view.getUint32(offset + 4, true);
801
795
  offset += 8;
802
- if (offset + chunkLength > length) throw new Error("Truncated GLB chunk data.");
796
+ if (offset + chunkLength > length)
797
+ throw new Error("Truncated GLB chunk data.");
803
798
  const chunkData = new Uint8Array(arrayBuffer, offset, chunkLength);
804
799
  offset += chunkLength;
805
800
  if (chunkType === JSON_CHUNK_TYPE) {
@@ -817,7 +812,8 @@ function parseGLB(arrayBuffer) {
817
812
  // lib/gltf/loadGLTFWithResourcesFromURL.ts
818
813
  function ensureFetch(fetchImpl) {
819
814
  const impl = fetchImpl ?? globalThis.fetch;
820
- if (!impl) throw new Error("Global fetch API is not available; provide fetchImpl.");
815
+ if (!impl)
816
+ throw new Error("Global fetch API is not available; provide fetchImpl.");
821
817
  return impl;
822
818
  }
823
819
  async function fetchBinary(fetchImpl, url) {
@@ -832,7 +828,9 @@ async function loadGLTFWithResourcesFromURL(url, options = {}) {
832
828
  const fetchImpl = ensureFetch(options.fetchImpl);
833
829
  const response = await fetchImpl(url);
834
830
  if (!response.ok)
835
- throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
831
+ throw new Error(
832
+ `Failed to fetch ${url}: ${response.status} ${response.statusText}`
833
+ );
836
834
  const resolvedURL = new URL(response.url || url);
837
835
  const baseURL = resolvedURL;
838
836
  const sourceBuffer = await response.arrayBuffer();
@@ -867,7 +865,9 @@ async function loadGLTFWithResourcesFromURL(url, options = {}) {
867
865
  buffers[index] = buf;
868
866
  return buf;
869
867
  }
870
- throw new Error(`Buffer ${index} is missing a uri and no GLB chunk was provided.`);
868
+ throw new Error(
869
+ `Buffer ${index} is missing a uri and no GLB chunk was provided.`
870
+ );
871
871
  }
872
872
  await Promise.all(
873
873
  (gltf.buffers || []).map(async (entry, idx) => {
@@ -892,7 +892,10 @@ async function loadGLTFWithResourcesFromURL(url, options = {}) {
892
892
  const bufferView = gltf.bufferViews?.[img.bufferView];
893
893
  if (!bufferView)
894
894
  throw new Error(`Invalid image bufferView index ${img.bufferView}`);
895
- const buffer = await resolveBuffer(bufferView.buffer, gltf.buffers?.[bufferView.buffer]);
895
+ const buffer = await resolveBuffer(
896
+ bufferView.buffer,
897
+ gltf.buffers?.[bufferView.buffer]
898
+ );
896
899
  if (!buffer)
897
900
  throw new Error(`Missing buffer for image bufferView ${img.bufferView}`);
898
901
  const byteOffset = bufferView.byteOffset ?? 0;
@@ -981,7 +984,9 @@ async function renderGLTFToPNGBufferFromGLBBuffer(glb, options = {}) {
981
984
  continue;
982
985
  }
983
986
  if (!binaryChunk) {
984
- throw new Error(`GLB is missing the binary chunk required for buffer ${index}.`);
987
+ throw new Error(
988
+ `GLB is missing the binary chunk required for buffer ${index}.`
989
+ );
985
990
  }
986
991
  buffers[index] = binaryChunk;
987
992
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "poppygl",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.5",
4
+ "version": "0.0.6",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/tscircuit/poppygl.git"