three-js-csg

WebJar for three-js-csg

License

License

MIT
Categories

Categories

JavaScript Languages
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

three-js-csg
Last Version

Last Version

72.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

three-js-csg
WebJar for three-js-csg
Project URL

Project URL

http://webjars.org

Download three-js-csg

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/three-js-csg/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>three-js-csg</artifactId>
    <version>72.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/three-js-csg/
implementation 'org.webjars.npm:three-js-csg:72.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/three-js-csg/
implementation ("org.webjars.npm:three-js-csg:72.0.0")
'org.webjars.npm:three-js-csg:jar:72.0.0'
<dependency org="org.webjars.npm" name="three-js-csg" rev="72.0.0">
  <artifact name="three-js-csg" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='three-js-csg', version='72.0.0')
)
libraryDependencies += "org.webjars.npm" % "three-js-csg" % "72.0.0"
[org.webjars.npm/three-js-csg "72.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

three-js-csg

three-js-csg is a wrapper for NPM around chandlerprall's Constructive Solid Geometry port to three.js. This package provides support for use with ES2015/AMD/CommonJS style modularity and composability.

install

npm i --save three-js-csg

example mesh module

import THREE from 'three';
const ThreeBSP = require('../../index.js')(THREE);

export const meshFactory = () => {
  const box = new THREE.Mesh(new THREE.BoxGeometry(500, 100, 100));
  const sphere = new THREE.Mesh(new THREE.SphereGeometry(100, 50, 50));

  const sBSP = new ThreeBSP(sphere);
  const bBSP = new ThreeBSP(box);

  const sub = bBSP.subtract(sBSP);
  const newMesh = sub.toMesh();

  newMesh.material = new THREE.MeshPhongMaterial({ color: 0xdddddd, specular: 0x1a1a1a, shininess: 30, shading: THREE.FlatShading  });

  return Object.assign({}, { csg: newMesh  });

};

When instantiating the NPM module, it takes an instance of three.js therefore doesn't need to sit globally on the window object. In a currying-esque manner, the NPM module returns a function with which you can pass in three.js geometry like usual.

demo

three-js-csg

See a full demo using this module in this repo at: ./demo. First clone the repo, run npm install and then npm run watch. Open ./demo/index.html in browser to see the demo in action.

Versions

Version
72.0.0