How to use the gltf-pipeline.processGlb function in gltf-pipeline

To help you get started, we’ve selected a few gltf-pipeline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vpdb / vpx-js / lib / gltf / gltf-exporter.ts View on Github external
const totalByteLength = GLB_HEADER_BYTES
					+ jsonChunkPrefix.byteLength + jsonChunk.byteLength
					+ binaryChunkPrefix.byteLength + binaryChunk.byteLength;
				header.writeUInt32LE(totalByteLength, 8);

				const glb = Buffer.concat([
					header,
					jsonChunkPrefix,
					jsonChunk,
					binaryChunkPrefix,
					binaryChunk,
				]);

				if (this.options.compressVertices) {
					logger().info('[GLTFExporter.parse] Compressing vertices...');
					const result = await gltfPipeline.processGlb(glb, {
						dracoOptions: {
							compressionLevel: this.options.dracoOptions!.compressionLevel,
							quantizePositionBits: this.options.dracoOptions!.quantizePosition,
							quantizeNormalBits: this.options.dracoOptions!.quantizeNormal,
							quantizeTexcoordBits: this.options.dracoOptions!.quantizeTexcoord,
							quantizeColorBits: this.options.dracoOptions!.quantizeColor,
							unifiedQuantization: this.options.dracoOptions!.unifiedQuantization,
						},
					});
					return result.glb;

				} else {
					return glb;
				}

			} else {
github vpdb / server / src / app / vpinball / gltf / gltf-exporter.ts View on Github external
const totalByteLength = GLB_HEADER_BYTES
					+ jsonChunkPrefix.byteLength + jsonChunk.byteLength
					+ binaryChunkPrefix.byteLength + binaryChunk.byteLength;
				header.writeUInt32LE(totalByteLength, 8);

				const glb = Buffer.concat([
					header,
					jsonChunkPrefix,
					jsonChunk,
					binaryChunkPrefix,
					binaryChunk,
				]);

				if (this.options.compressVertices) {
					logger.info(this.options.state, '[GLTFExporter.parse] Compressing vertices...');
					const result = await gltfPipeline.processGlb(glb, {
						dracoOptions: {
							compressionLevel: this.options.dracoOptions.compressionLevel,
							quantizePositionBits: this.options.dracoOptions.quantizePosition,
							quantizeNormalBits: this.options.dracoOptions.quantizeNormal,
							quantizeTexcoordBits: this.options.dracoOptions.quantizeTexcoord,
							quantizeColorBits: this.options.dracoOptions.quantizeColor,
							unifiedQuantization: this.options.dracoOptions.unifiedQuantization,
						},
					});
					return result.glb;

				} else {
					return glb;
				}

			} else {