1.0.1 • Published 5 years ago

obj2html v1.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

obj2html

npm.io npm.io npm.io npm.io npm.io npm.io

Convert 3D models of Wavefront obj to HTML using CSS3 transforms.

Install

$ npm install -g obj2html

Usage

CLI

$ obj2html -o model.html model.obj

API

JavaScript

import { readFileSync, writeFileSync } from 'fs';
import obj2html from 'obj2html';

const obj = readFileSync('src.obj').toString('utf-8');

const dom = obj2html(obj, {
  classPrefix: 'obj',
  scale: 100,
  number: false,
  fontSize: 20,
});

writeFileSync('dst.html', `<!DOCTYPE html>\r\n${dom.window.document.documentElement.outerHTML}`);

TypeScript

import { readFileSync, writeFileSync } from 'fs';
import obj2html from 'obj2html/ts';

const obj = readFileSync('src.obj').toString('utf-8');

const dom = obj2html(obj, {
  classPrefix: 'obj',
  scale: 100,
  number: false,
  fontSize: 20,
});

writeFileSync('dst.html', `<!DOCTYPE html>\r\n${dom.window.document.documentElement.outerHTML}`);

Webpack Loader

// webpack.config.js
module.exports = {
  module: {
    rules: [
      {
        test: /\.obj$/,
        loader: 'obj2html/obj-loader',
        options: {
          classPrefix: 'obj2html',
          fontSize: 20,
          number: falce,
          scale: 100,
        },
      },
    ],
  },
};
import { classPrefix, body, style } from 'path/to/model.obj';

console.log(classPrefix); // obj2html-XXXXXXXX
console.log(body); // <div class="obj2html-XXXXXXXX"><div class="...
console.log(style); // <style>...
1.0.1

5 years ago

1.0.0

5 years ago

0.3.5

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago