Git Product home page Git Product logo

bom-three.js's Introduction

bom-three.js (THREE.BOMLoader)

A javascript library to import BOM (Binary Object/Material) files into three.js. Loaded assets will be output as a THREE.Mesh consisting of THREE.BufferGeometry and an associated THREE.Material. Multi-material assets may be split into multiple THREE.Mesh objects, per material.

Usage

Include the loader library in your project:

<script src="https://cdn.rawgit.com/NGenesis/bom-three.js/v0.6.3/examples/js/loaders/BOMLoader.min.js"></script>

Then create an instance of BOMLoader and specify the file path to load:

var filePath = 'https://example.com/path/to/file.bom';

var loader = new THREE.BOMLoader();
//loader.setDebug(true); // Output verbose debugging information (Disabled/false by default)
//loader.setPerfTimer(true); // Output loader performance timer information (Disabled/false by default)
//loader.setTexturePath(filePath.split('/').slice(0, -1).join('/') + '/'); // Specify base texture path (Searches relative to asset path by default)

loader.load(filePath, function(obj) {
	scene.add(obj); // Add object to scene once loaded.
});

A convenience loader is also provided to load one or more files in the order provided:

var filePaths = [
	{ name: 'File 1', url: 'https://example.com/path/to/file1.bom' },
	{ name: 'File 2', url: 'https://example.com/path/to/file2.bom' }
];

THREE.BOMLoaderUtil.multiload(filePaths, function(objects) {
	for(var object of objects) {
		console.log('File loaded: ', object.name);
		scene.add(object.object); // Add object to scene once loaded.
	}
});

A-Frame components and primitives for loading BOM files are also provided:

<a-entity bom-asset="src: https://example.com/path/to/file.bom"></a-entity>
<a-bom-asset src="https://example.com/path/to/file.bom"></a-bom-asset>

See also

obj2bom - A command line tool to convert OBJ and associated MTL files to BOM (Binary Object/Material) file format.

bom-three.js's People

Contributors

ngenesis avatar

Stargazers

Fabio Dias Rollo avatar SideQuest avatar Ben Forest avatar Craig Moore avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.