three#Box3Helper JavaScript Examples
The following examples show how to use
three#Box3Helper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: aabb.js From plant-3d-explorer with GNU Affero General Public License v3.0 | 6 votes |
setBoundingBox(aabb) {
// We could maybe do without creating a new GeometryBuffer
// This is left as excercise for the next intern here :)
this.box = new Box3(
new Vector3(parseFloat(aabb.min.x), parseFloat(aabb.min.y), parseFloat(aabb.min.z)),
new Vector3(parseFloat(aabb.max.x), parseFloat(aabb.max.y), parseFloat(aabb.max.z))
)
let oldObj = this.object
const newObj = new Box3Helper(this.box, 0xffffff);
newObj.visible = oldObj.visible
//oldObj.visible = false
oldObj.parent.add(newObj)
newObj.parent.remove(oldObj)
this.object = newObj
}
Example #2
Source File: aabb.js From plant-3d-explorer with GNU Affero General Public License v3.0 | 6 votes |
resetBoundingBox()
{
let oldObj = this.object
const newObj = new Box3Helper(this.ogBox, 0xffffff);
newObj.visible = oldObj.visible
//oldObj.visible = false
oldObj.parent.add(newObj)
newObj.parent.remove(oldObj)
this.object = newObj
}
Example #3
Source File: aabb.js From plant-3d-explorer with GNU Affero General Public License v3.0 | 6 votes |
constructor(parent, box) {
this.ogBox = new Box3(
new Vector3(parseFloat(box.min.x), parseFloat(box.min.y), parseFloat(box.min.z)),
new Vector3(parseFloat(box.max.x), parseFloat(box.max.y), parseFloat(box.max.z))
)
this.object = new Box3Helper(this.ogBox, 0xffffff);
this.object.renderOrder = -1;
if(parent) parent.add(this.object);
}
Example #4
Source File: DebugTilesRenderer.js From 3DTilesRendererJS with Apache License 2.0 | 5 votes |
parseTile( buffer, tile, extension ) {
return super
.parseTile( buffer, tile, extension )
.then( () => {
const cached = tile.cached;
const scene = cached.scene;
if ( scene ) {
if ( cached.box && cached.boxTransform ) {
const cachedBox = cached.box;
const cachedBoxMat = cached.boxTransform;
// Create debug bounding box
// In some cases the bounding box may have a scale of 0 in one dimension resulting
// in the NaNs in an extracted rotation so we disable matrix updates instead.
const boxHelperGroup = new Group();
boxHelperGroup.name = 'DebugTilesRenderer.boxHelperGroup';
boxHelperGroup.matrix.copy( cachedBoxMat );
boxHelperGroup.matrixAutoUpdate = false;
const boxHelper = new Box3Helper( cachedBox, getIndexedRandomColor( tile.__depth ) );
boxHelper.raycast = emptyRaycast;
boxHelperGroup.add( boxHelper );
cached.boxHelperGroup = boxHelperGroup;
if ( this.visibleTiles.has( tile ) && this.displayBoxBounds ) {
this.boxGroup.add( boxHelperGroup );
boxHelperGroup.updateMatrixWorld( true );
}
}
if ( cached.sphere ) {
// Create debugbounding sphere
const cachedSphere = cached.sphere;
const sphereHelper = new SphereHelper( cachedSphere );
sphereHelper.raycast = emptyRaycast;
cached.sphereHelper = sphereHelper;
if ( this.visibleTiles.has( tile ) && this.displaySphereBounds ) {
this.sphereGroup.add( sphereHelper );
sphereHelper.updateMatrixWorld( true );
}
}
// Cache the original materials
scene.traverse( c => {
const material = c.material;
if ( material ) {
c[ ORIGINAL_MATERIAL ] = material;
}
} );
}
} );
}