three#CylinderBufferGeometry JavaScript Examples
The following examples show how to use
three#CylinderBufferGeometry.
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: index.js From 3DTilesRendererJS with Apache License 2.0 | 4 votes |
function init() {
scene = new Scene();
// primary camera view
renderer = new WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor( 0x151c1f );
renderer.outputEncoding = sRGBEncoding;
document.body.appendChild( renderer.domElement );
renderer.domElement.tabIndex = 1;
camera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 4000 );
camera.position.set( 400, 400, 400 );
cameraHelper = new CameraHelper( camera );
scene.add( cameraHelper );
orthoCamera = new OrthographicCamera();
orthoCameraHelper = new CameraHelper( orthoCamera );
scene.add( orthoCameraHelper );
// secondary camera view
secondCamera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 4000 );
secondCamera.position.set( 400, 400, - 400 );
secondCamera.lookAt( 0, 0, 0 );
secondRenderer = new WebGLRenderer( { antialias: true } );
secondRenderer.setPixelRatio( window.devicePixelRatio );
secondRenderer.setSize( window.innerWidth, window.innerHeight );
secondRenderer.setClearColor( 0x151c1f );
secondRenderer.outputEncoding = sRGBEncoding;
document.body.appendChild( secondRenderer.domElement );
secondRenderer.domElement.style.position = 'absolute';
secondRenderer.domElement.style.right = '0';
secondRenderer.domElement.style.top = '0';
secondRenderer.domElement.style.outline = '#0f1416 solid 2px';
secondRenderer.domElement.tabIndex = 1;
secondControls = new FlyOrbitControls( secondCamera, secondRenderer.domElement );
secondControls.screenSpacePanning = false;
secondControls.minDistance = 1;
secondControls.maxDistance = 2000;
secondCameraHelper = new CameraHelper( secondCamera );
scene.add( secondCameraHelper );
// Third person camera view
thirdPersonCamera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 4000 );
thirdPersonCamera.position.set( 50, 40, 40 );
thirdPersonCamera.lookAt( 0, 0, 0 );
thirdPersonRenderer = new WebGLRenderer( { antialias: true } );
thirdPersonRenderer.setPixelRatio( window.devicePixelRatio );
thirdPersonRenderer.setSize( window.innerWidth, window.innerHeight );
thirdPersonRenderer.setClearColor( 0x0f1416 );
thirdPersonRenderer.outputEncoding = sRGBEncoding;
document.body.appendChild( thirdPersonRenderer.domElement );
thirdPersonRenderer.domElement.style.position = 'fixed';
thirdPersonRenderer.domElement.style.left = '5px';
thirdPersonRenderer.domElement.style.bottom = '5px';
thirdPersonRenderer.domElement.tabIndex = 1;
thirdPersonControls = new FlyOrbitControls( thirdPersonCamera, thirdPersonRenderer.domElement );
thirdPersonControls.screenSpacePanning = false;
thirdPersonControls.minDistance = 1;
thirdPersonControls.maxDistance = 2000;
// controls
controls = new FlyOrbitControls( camera, renderer.domElement );
controls.screenSpacePanning = false;
controls.minDistance = 1;
controls.maxDistance = 2000;
// lights
const dirLight = new DirectionalLight( 0xffffff );
dirLight.position.set( 1, 2, 3 );
scene.add( dirLight );
const ambLight = new AmbientLight( 0xffffff, 0.2 );
scene.add( ambLight );
box = new Box3();
sphere = new Sphere();
offsetParent = new Group();
scene.add( offsetParent );
// Raycasting init
raycaster = new Raycaster();
mouse = new Vector2();
rayIntersect = new Group();
const rayIntersectMat = new MeshBasicMaterial( { color: 0xe91e63 } );
const rayMesh = new Mesh( new CylinderBufferGeometry( 0.25, 0.25, 6 ), rayIntersectMat );
rayMesh.rotation.x = Math.PI / 2;
rayMesh.position.z += 3;
rayIntersect.add( rayMesh );
const rayRing = new Mesh( new TorusBufferGeometry( 1.5, 0.2, 16, 100 ), rayIntersectMat );
rayIntersect.add( rayRing );
scene.add( rayIntersect );
rayIntersect.visible = false;
reinstantiateTiles();
onWindowResize();
window.addEventListener( 'resize', onWindowResize, false );
renderer.domElement.addEventListener( 'pointermove', onPointerMove, false );
renderer.domElement.addEventListener( 'pointerdown', onPointerDown, false );
renderer.domElement.addEventListener( 'pointerup', onPointerUp, false );
renderer.domElement.addEventListener( 'pointerleave', onPointerLeave, false );
secondRenderer.domElement.addEventListener( 'pointermove', onPointerMove, false );
secondRenderer.domElement.addEventListener( 'pointerdown', onPointerDown, false );
secondRenderer.domElement.addEventListener( 'pointerup', onPointerUp, false );
secondRenderer.domElement.addEventListener( 'pointerleave', onPointerLeave, false );
// GUI
const gui = new GUI();
gui.width = 300;
const tileOptions = gui.addFolder( 'Tiles Options' );
tileOptions.add( params, 'loadSiblings' );
tileOptions.add( params, 'stopAtEmptyTiles' );
tileOptions.add( params, 'displayActiveTiles' );
tileOptions.add( params, 'errorTarget' ).min( 0 ).max( 50 );
tileOptions.add( params, 'errorThreshold' ).min( 0 ).max( 1000 );
tileOptions.add( params, 'maxDepth' ).min( 1 ).max( 100 );
tileOptions.add( params, 'up', [ '+Y', '+Z', '-Z' ] );
tileOptions.open();
const debug = gui.addFolder( 'Debug Options' );
debug.add( params, 'displayBoxBounds' );
debug.add( params, 'colorMode', {
NONE,
SCREEN_ERROR,
GEOMETRIC_ERROR,
DISTANCE,
DEPTH,
RELATIVE_DEPTH,
IS_LEAF,
RANDOM_COLOR,
RANDOM_NODE_COLOR,
CUSTOM_COLOR
} );
debug.open();
const exampleOptions = gui.addFolder( 'Example Options' );
exampleOptions.add( params, 'resolutionScale' ).min( 0.01 ).max( 2.0 ).step( 0.01 ).onChange( onWindowResize );
exampleOptions.add( params, 'orthographic' );
exampleOptions.add( params, 'showThirdPerson' );
exampleOptions.add( params, 'showSecondView' ).onChange( onWindowResize );
exampleOptions.add( params, 'enableUpdate' ).onChange( v => {
tiles.parseQueue.autoUpdate = v;
tiles.downloadQueue.autoUpdate = v;
if ( v ) {
tiles.parseQueue.scheduleJobRun();
tiles.downloadQueue.scheduleJobRun();
}
} );
exampleOptions.add( params, 'raycast', { NONE, ALL_HITS, FIRST_HIT_ONLY } );
exampleOptions.add( params, 'optimizeRaycast', );
exampleOptions.add( params, 'enableCacheDisplay' );
exampleOptions.add( params, 'enableRendererStats' );
exampleOptions.open();
gui.add( params, 'reload' );
gui.open();
statsContainer = document.createElement( 'div' );
statsContainer.style.position = 'absolute';
statsContainer.style.top = 0;
statsContainer.style.left = 0;
statsContainer.style.color = 'white';
statsContainer.style.width = '100%';
statsContainer.style.textAlign = 'center';
statsContainer.style.padding = '5px';
statsContainer.style.pointerEvents = 'none';
statsContainer.style.lineHeight = '1.5em';
document.body.appendChild( statsContainer );
// Stats
stats = new Stats();
stats.showPanel( 0 );
document.body.appendChild( stats.dom );
}
Example #2
Source File: ionExample.js From 3DTilesRendererJS with Apache License 2.0 | 4 votes |
function init() {
scene = new Scene();
// primary camera view
renderer = new WebGLRenderer( { antialias: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor( 0x151c1f );
renderer.outputEncoding = sRGBEncoding;
document.body.appendChild( renderer.domElement );
renderer.domElement.tabIndex = 1;
camera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 4000 );
camera.position.set( 400, 400, 400 );
cameraHelper = new CameraHelper( camera );
scene.add( cameraHelper );
orthoCamera = new OrthographicCamera();
orthoCameraHelper = new CameraHelper( orthoCamera );
scene.add( orthoCameraHelper );
// secondary camera view
secondCamera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 4000 );
secondCamera.position.set( 400, 400, - 400 );
secondCamera.lookAt( 0, 0, 0 );
secondRenderer = new WebGLRenderer( { antialias: true } );
secondRenderer.setPixelRatio( window.devicePixelRatio );
secondRenderer.setSize( window.innerWidth, window.innerHeight );
secondRenderer.setClearColor( 0x151c1f );
secondRenderer.outputEncoding = sRGBEncoding;
document.body.appendChild( secondRenderer.domElement );
secondRenderer.domElement.style.position = 'absolute';
secondRenderer.domElement.style.right = '0';
secondRenderer.domElement.style.top = '0';
secondRenderer.domElement.style.outline = '#0f1416 solid 2px';
secondRenderer.domElement.tabIndex = 1;
secondControls = new FlyOrbitControls( secondCamera, secondRenderer.domElement );
secondControls.screenSpacePanning = false;
secondControls.minDistance = 1;
secondControls.maxDistance = 2000;
secondCameraHelper = new CameraHelper( secondCamera );
scene.add( secondCameraHelper );
// Third person camera view
thirdPersonCamera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 4000 );
thirdPersonCamera.position.set( 50, 40, 40 );
thirdPersonCamera.lookAt( 0, 0, 0 );
thirdPersonRenderer = new WebGLRenderer( { antialias: true } );
thirdPersonRenderer.setPixelRatio( window.devicePixelRatio );
thirdPersonRenderer.setSize( window.innerWidth, window.innerHeight );
thirdPersonRenderer.setClearColor( 0x0f1416 );
thirdPersonRenderer.outputEncoding = sRGBEncoding;
document.body.appendChild( thirdPersonRenderer.domElement );
thirdPersonRenderer.domElement.style.position = 'fixed';
thirdPersonRenderer.domElement.style.left = '5px';
thirdPersonRenderer.domElement.style.bottom = '5px';
thirdPersonRenderer.domElement.tabIndex = 1;
thirdPersonControls = new FlyOrbitControls( thirdPersonCamera, thirdPersonRenderer.domElement );
thirdPersonControls.screenSpacePanning = false;
thirdPersonControls.minDistance = 1;
thirdPersonControls.maxDistance = 2000;
// controls
controls = new FlyOrbitControls( camera, renderer.domElement );
controls.screenSpacePanning = false;
controls.minDistance = 1;
controls.maxDistance = 2000;
// lights
const dirLight = new DirectionalLight( 0xffffff );
dirLight.position.set( 1, 2, 3 );
scene.add( dirLight );
const ambLight = new AmbientLight( 0xffffff, 0.2 );
scene.add( ambLight );
offsetParent = new Group();
scene.add( offsetParent );
// Raycasting init
raycaster = new Raycaster();
mouse = new Vector2();
rayIntersect = new Group();
const rayIntersectMat = new MeshBasicMaterial( { color: 0xe91e63 } );
const rayMesh = new Mesh( new CylinderBufferGeometry( 0.25, 0.25, 6 ), rayIntersectMat );
rayMesh.rotation.x = Math.PI / 2;
rayMesh.position.z += 3;
rayIntersect.add( rayMesh );
const rayRing = new Mesh( new TorusBufferGeometry( 1.5, 0.2, 16, 100 ), rayIntersectMat );
rayIntersect.add( rayRing );
scene.add( rayIntersect );
rayIntersect.visible = false;
reinstantiateTiles();
onWindowResize();
window.addEventListener( 'resize', onWindowResize, false );
renderer.domElement.addEventListener( 'mousemove', onMouseMove, false );
renderer.domElement.addEventListener( 'mousedown', onMouseDown, false );
renderer.domElement.addEventListener( 'mouseup', onMouseUp, false );
renderer.domElement.addEventListener( 'mouseleave', onMouseLeave, false );
secondRenderer.domElement.addEventListener( 'mousemove', onMouseMove, false );
secondRenderer.domElement.addEventListener( 'mousedown', onMouseDown, false );
secondRenderer.domElement.addEventListener( 'mouseup', onMouseUp, false );
secondRenderer.domElement.addEventListener( 'mouseleave', onMouseLeave, false );
// GUI
const gui = new GUI();
gui.width = 300;
const ionOptions = gui.addFolder( 'Ion' );
ionOptions.add( params, 'ionAssetId' );
ionOptions.add( params, 'ionAccessToken' );
ionOptions.add( params, 'reload' );
ionOptions.open();
const tileOptions = gui.addFolder( 'Tiles Options' );
tileOptions.add( params, 'loadSiblings' );
tileOptions.add( params, 'stopAtEmptyTiles' );
tileOptions.add( params, 'displayActiveTiles' );
tileOptions.add( params, 'errorTarget' ).min( 0 ).max( 50 );
tileOptions.add( params, 'errorThreshold' ).min( 0 ).max( 1000 );
tileOptions.add( params, 'maxDepth' ).min( 1 ).max( 100 );
tileOptions.add( params, 'up', [ '+Y', '+Z', '-Z' ] );
const debug = gui.addFolder( 'Debug Options' );
debug.add( params, 'displayBoxBounds' );
debug.add( params, 'colorMode', {
NONE,
SCREEN_ERROR,
GEOMETRIC_ERROR,
DISTANCE,
DEPTH,
RELATIVE_DEPTH,
IS_LEAF,
RANDOM_COLOR,
} );
const exampleOptions = gui.addFolder( 'Example Options' );
exampleOptions.add( params, 'resolutionScale' ).min( 0.01 ).max( 2.0 ).step( 0.01 ).onChange( onWindowResize );
exampleOptions.add( params, 'orthographic' );
exampleOptions.add( params, 'showThirdPerson' );
exampleOptions.add( params, 'showSecondView' ).onChange( onWindowResize );
exampleOptions.add( params, 'enableUpdate' ).onChange( v => {
tiles.parseQueue.autoUpdate = v;
tiles.downloadQueue.autoUpdate = v;
if ( v ) {
tiles.parseQueue.scheduleJobRun();
tiles.downloadQueue.scheduleJobRun();
}
} );
exampleOptions.add( params, 'raycast', { NONE, ALL_HITS, FIRST_HIT_ONLY } );
exampleOptions.add( params, 'enableCacheDisplay' );
exampleOptions.add( params, 'enableRendererStats' );
gui.open();
statsContainer = document.createElement( 'div' );
document.getElementById( 'info' ).appendChild( statsContainer );
// Stats
stats = new Stats();
stats.showPanel( 0 );
document.body.appendChild( stats.dom );
}