poppygl 0.0.11 → 0.0.12
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/dist/index.d.ts +1 -1
- package/dist/index.js +11 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -124,7 +124,7 @@ declare function renderGLTFToPNGBufferFromURL(url: string, options?: RenderGLTFT
|
|
|
124
124
|
type RenderGLTFToPNGBufferFromGLBBufferOptions = RenderOptionsInput;
|
|
125
125
|
declare function renderGLTFToPNGBufferFromGLBBuffer(glb: ArrayBuffer | Uint8Array, options?: RenderGLTFToPNGBufferFromGLBBufferOptions): Promise<Buffer>;
|
|
126
126
|
|
|
127
|
-
declare function renderGLTFToPNGBuffer(
|
|
127
|
+
declare function renderGLTFToPNGBuffer(gltfPathOrString: string, options?: RenderOptionsInput): Promise<Buffer>;
|
|
128
128
|
|
|
129
129
|
declare function renderSceneFromGLTF(scene: GLTFScene, options?: RenderOptionsInput, imageFactory?: ImageFactory): RenderResult;
|
|
130
130
|
|
package/dist/index.js
CHANGED
|
@@ -1135,8 +1135,17 @@ async function loadGLTFWithResources(gltfPath) {
|
|
|
1135
1135
|
}
|
|
1136
1136
|
|
|
1137
1137
|
// cli/renderGLTFToPNGBuffer.ts
|
|
1138
|
-
async function renderGLTFToPNGBuffer(
|
|
1139
|
-
|
|
1138
|
+
async function renderGLTFToPNGBuffer(gltfPathOrString, options = {}) {
|
|
1139
|
+
let gltf;
|
|
1140
|
+
let resources;
|
|
1141
|
+
try {
|
|
1142
|
+
gltf = JSON.parse(gltfPathOrString);
|
|
1143
|
+
resources = { buffers: [], images: [] };
|
|
1144
|
+
} catch {
|
|
1145
|
+
const result = await loadGLTFWithResources(gltfPathOrString);
|
|
1146
|
+
gltf = result.gltf;
|
|
1147
|
+
resources = result.resources;
|
|
1148
|
+
}
|
|
1140
1149
|
const scene = createSceneFromGLTF(gltf, resources);
|
|
1141
1150
|
const { bitmap } = renderSceneFromGLTF(scene, options, pureImageFactory);
|
|
1142
1151
|
return encodePNGToBuffer(bitmap);
|