box() { const geometry = new THREE.BoxGeometry(); const material = new THREE.MeshBasicMaterial({ color: Math.random() * 0xffffff }); return new THREE.Mesh(geometry, material); }
function createTHREEOutlineFromOBB(box) { const geom = new THREE.BoxGeometry(box[3] * 2, box[7] * 2, box[11] * 2); const edges = new THREE.EdgesGeometry(geom); const line = new THREE.LineSegments(edges, new THREE.LineBasicMaterial({color: 0x800000})); const trans = new THREE.Matrix4().makeTranslation(box[0], box[1], box[2]); line.applyMatrix(trans); return line; }
const createBoxGeometry = ({position, size, color}) => { const geometry = new THREE.BoxGeometry(...size); const material = new THREE.MeshPhongMaterial({color}); const box = new THREE.Mesh(geometry, material); box.position.x = position[0]; box.position.y = position[1]; box.position.z = position[2]; return box; }
constructor(props) { super(props); this.state = {}; this.scene = new t3.Scene(); this.camera = new t3.PerspectiveCamera( 75, window.innerWidth/window.innerHeight, 0.1, 1000 ); this.renderer = new t3.WebGLRenderer(); this.renderer.setSize( window.innerWidth, window.innerHeight ); // Load the Orbitcontroller // eslint-disable-next-line var controls = new OrbitControls(this.camera, this.renderer.domElement ); const geometry = new t3.BoxGeometry( 4, 1 , 1); const material = new t3.MeshBasicMaterial( { color: 0x00ff00, wireframe: true } ); this.cube = new t3.Mesh( geometry, material ); this.scene.add( this.cube ); this.camera.position.z = 5; const animate = () => { requestAnimationFrame( animate ); this.cube.rotation.x += 0.01; this.cube.rotation.y += 0.01; this.renderer.render( this.scene, this.camera ); }; animate(); }
buildCube() { var geometry = new THREE.BoxGeometry( 1, 1, 1 ); var material = new THREE.MeshBasicMaterial( {color: 0x00ff00, wireframe: true} ); var cube = new THREE.Mesh( geometry, material ); return cube; }