How to use the @gltf-transform/core.NodeIO function in @gltf-transform/core

To help you get started, we’ve selected a few @gltf-transform/core 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 donmccurdy / glTF-Transform / packages / cli / src / cli.js View on Github external
#!/usr/bin/env node

const fs = require('fs');
const path = require('path');
const gl = require('gl');
const { createCanvas, Image } = require('canvas');
const program = require('caporal');
const { version } = require('../package.json');
const { GLTFUtil, NodeIO } = require('@gltf-transform/core');
const { ao } = require('@gltf-transform/ao');
const { atlas } = require('@gltf-transform/atlas');
const { colorspace } = require('@gltf-transform/colorspace');
const { split } = require('@gltf-transform/split');
const { prune } = require('@gltf-transform/prune');

const io = new NodeIO(fs, path);

program
    .version(version);

// ANALYZE
program
    .command('analyze', 'Analyzes a model\'s contents')
    .argument('<input>', 'Path to glTF 2.0 (.glb, .gltf) model')
    .action(({input}, options, logger) =&gt; {
        const container = io.read(input);
        const analysis = GLTFUtil.analyze(container);
        logger.info(JSON.stringify(analysis, null, 2));
    });

// AMBIENT OCCLUSION
program