three APIs
- Vector3
- Mesh
- Vector2
- Color
- Matrix4
- PerspectiveCamera
- MeshBasicMaterial
- Scene
- ShaderMaterial
- BufferGeometry
- Quaternion
- Object3D
- LineBasicMaterial
- TextureLoader
- EventDispatcher
- DoubleSide
- LineSegments
- FileLoader
- UniformsUtils
- Vector4
- Box3
- Group
- DirectionalLight
- BufferAttribute
- MathUtils
- NearestFilter
- LinearFilter
- Spherical
- OrthographicCamera
- WebGLRenderer
- BackSide
- Float32BufferAttribute
- MeshPhongMaterial
- Points
- MOUSE
- WebGLRenderTarget
- AmbientLight
- MeshStandardMaterial
- PlaneBufferGeometry
- BoxGeometry
- Raycaster
- FrontSide
- Sphere
- Loader
- PointsMaterial
- TOUCH
- sRGBEncoding
- AdditiveBlending
- Line
- RepeatWrapping
- RGBAFormat
- RGBFormat
- Plane
- ClampToEdgeWrapping
- ShaderLib
- UniformsLib
- Clock
- FloatType
- UnsignedByteType
- BoxBufferGeometry
- Euler
- Texture
- VertexColors
- InterleavedBufferAttribute
- Material
- DepthTexture
- PCFSoftShadowMap
- Matrix3
- LinearMipmapLinearFilter
- LoaderUtils
- AnimationClip
- Bone
- PointLight
- QuaternionKeyframeTrack
- Skeleton
- SkinnedMesh
- SpotLight
- VectorKeyframeTrack
- NearestMipmapLinearFilter
- DataTextureLoader
- HalfFloatType
- LinearEncoding
- RawShaderMaterial
- CanvasTexture
- Geometry
- MeshNormalMaterial
- DataTexture
- ShaderChunk
- Shape
- SphereGeometry
- SphereBufferGeometry
- HemisphereLight
- FogExp2
- Box3Helper
- InstancedMesh
- Frustum
- Curve
- MirroredRepeatWrapping
- MeshLambertMaterial
- NumberKeyframeTrack
- PropertyBinding
- InterleavedBuffer
- Interpolant
- InterpolateDiscrete
- InterpolateLinear
- LineLoop
- LinearMipmapNearestFilter
- MeshPhysicalMaterial
- NearestMipmapNearestFilter
- TangentSpaceNormalMap
- TriangleFanDrawMode
- TriangleStripDrawMode
- RGBEEncoding
- RGBEFormat
- NoBlending
- PlaneGeometry
- Face3
- AxesHelper
- Uniform
- MeshDepthMaterial
- RGBADepthPacking
- LuminanceFormat
- DepthStencilFormat
- UnsignedInt248Type
- NearestMipMapLinearFilter
- BufferGeometryLoader
- ExtrudeBufferGeometry
- ShapeBufferGeometry
- InstancedInterleavedBuffer
- Line3
- InstancedBufferGeometry
- WireframeGeometry
- NoColors
- LoadingManager
- CameraHelper
- CylinderBufferGeometry
- TorusBufferGeometry
- GridHelper
- RingBufferGeometry
- DefaultLoadingManager
- Ray
- EquirectangularReflectionMapping
- Uint16BufferAttribute
- TrianglesDrawMode
- LinearMipMapLinearFilter
- BoxHelper
- Triangle
- ShapeGeometry
- JSONLoader
- Path
- CylinderGeometry
- ImageUtils
- CompressedTextureLoader
- RGBA_S3TC_DXT3_Format
- RGBA_S3TC_DXT5_Format
- RGB_ETC1_Format
- RGB_S3TC_DXT1_Format
- CurvePath
- EdgesGeometry
- DynamicDrawUsage
- StaticDrawUsage
- RedFormat
- AddEquation
- CustomBlending
- DstAlphaFactor
- DstColorFactor
- UnsignedShortType
- ZeroFactor
- NormalBlending
- SrcAlphaFactor
- OneMinusSrcAlphaFactor
- UnsignedIntType
- WebGLMultisampleRenderTarget
- Camera
- IcosahedronBufferGeometry
- LineDashedMaterial
- CircleGeometry
OtherRelated APIs
- three#Vector3
- three#MeshBasicMaterial
- three#Mesh
- three#PerspectiveCamera
- three#Raycaster
- three#Scene
- three#WebGLRenderer
- three#Box3
- three#Float32BufferAttribute
- three#Sphere
- three#BufferGeometry
- three#Group
- three#LineBasicMaterial
- three#sRGBEncoding
- three#DirectionalLight
- three#AmbientLight
- three#TorusBufferGeometry
- three#AdditiveBlending
- three#Line
- three#RingBufferGeometry
three#GridHelper JavaScript Examples
The following examples show how to use
three#GridHelper.
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: vr.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( 0xbbbbbb );
renderer.outputEncoding = sRGBEncoding;
renderer.xr.enabled = true;
document.body.appendChild( renderer.domElement );
renderer.domElement.tabIndex = 1;
renderer.setAnimationLoop( animate );
// create workspace
workspace = new Group();
scene.add( workspace );
grid = new GridHelper( 10, 10, 0xffffff, 0xffffff );
grid.material.transparent = true;
grid.material.opacity = 0.5;
grid.material.depthWrite = false;
workspace.add( grid );
camera = new PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.1, 4000 );
camera.position.set( 0, 1, 0 );
workspace.add( camera );
// 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 );
// tile set
box = new Box3();
sphere = new Sphere();
// parent for centering the tileset
offsetParent = new Group();
offsetParent.rotation.x = Math.PI / 2;
offsetParent.position.y = 32;
scene.add( offsetParent );
tiles = new TilesRenderer( 'https://raw.githubusercontent.com/NASA-AMMOS/3DTilesSampleData/master/msl-dingo-gap/0528_0260184_to_s64o256_colorize/scene-tileset.json' );
offsetParent.add( tiles.group );
// We set camera for tileset
tiles.setCamera( camera );
tiles.setResolutionFromRenderer( camera, renderer );
// We define a custom scheduling callback to handle also active WebXR sessions
const tilesSchedulingCB = func => {
tasks.push( func );
};
// We set our scheduling callback for tiles downloading and parsing
tiles.downloadQueue.schedulingCallback = tilesSchedulingCB;
tiles.parseQueue.schedulingCallback = tilesSchedulingCB;
tiles.lruCache.maxSize = 1200;
tiles.lruCache.minSize = 900;
// Raycasting init
raycaster = new Raycaster();
fwdVector = new Vector3( 0, 0, 1 );
const rayIntersectMat = new MeshBasicMaterial( { color: 0xb2dfdb } );
intersectRing = new Mesh( new TorusBufferGeometry( 1.5, 0.2, 16, 100 ), rayIntersectMat );
intersectRing.visible = false;
scene.add( intersectRing );
// vr setup
document.body.appendChild( VRButton.createButton( renderer ) );
controller = renderer.xr.getController( 0 );
controller.addEventListener( 'selectstart', () => {
if ( intersectRing.visible ) {
workspace.position.copy( intersectRing.position );
}
} );
controller.addEventListener( 'connected', function ( event ) {
this.controllerActive = true;
this.add( buildController( event.data ) );
} );
controller.addEventListener( 'disconnected', function () {
this.controllerActive = false;
this.remove( this.children[ 0 ] );
} );
workspace.add( controller );
// controller models
const controllerModelFactory = new XRControllerModelFactory();
controllerGrip = renderer.xr.getControllerGrip( 0 );
controllerGrip.add( controllerModelFactory.createControllerModel( controllerGrip ) );
workspace.add( controllerGrip );
onWindowResize();
window.addEventListener( 'resize', onWindowResize, false );
// GUI
const gui = new GUI();
gui.width = 300;
gui.add( params, 'displayGrid' );
gui.add( params, 'displayBoxBounds' );
gui.add( params, 'colorMode', {
NONE,
SCREEN_ERROR,
GEOMETRIC_ERROR,
DISTANCE,
DEPTH,
RELATIVE_DEPTH,
IS_LEAF,
RANDOM_COLOR,
} );
gui.open();
}