diff --git a/docs/api/core/Object3D.html b/docs/api/core/Object3D.html index 776242c2f01f39b6cc6734fc1f360faac25eb8e3..82b8de89914c63e244b51bad556d84f8a62123b6 100644 --- a/docs/api/core/Object3D.html +++ b/docs/api/core/Object3D.html @@ -299,6 +299,11 @@ Rotate an object along an axis in object space. The axis is assumed to be normalized. +

[method:Array raycast]([page:Raycaster raycaster], [page:Array intersects])

+
+ Abstract method to get intersections between a casted ray and this object. Subclasses such as [page:Mesh], [page:Line], and [page:PointCloud] implement this method in order to participate in raycasting. +
+

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/core/Raycaster.html b/docs/api/core/Raycaster.html index c77bfa6d7bd72936047e876eacacd9c43f5b3078..b06160765f0b1353476fb294014e0daf213f3be4 100644 --- a/docs/api/core/Raycaster.html +++ b/docs/api/core/Raycaster.html @@ -11,18 +11,67 @@
This class makes raycasting easier. Raycasting is used for picking and more. +
+ +

Example

+ + var raycaster = new THREE.Raycaster(); + var mouse = new THREE.Vector2(); + + function onMouseMove( event ) { + + // calculate mouse position in normalized device coordinates + // (-1 to +1) for both components + + mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1 + mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1 + + } + + function render() { + + // update the picking ray with the camera and mouse position + raycaster.setFromCamera( mouse, camera ); + + // calculate objects intersecting the picking ray + var intersects = raycaster.intersectObjects( scene.children ); + + for ( var intersect in intersects ) { + + intersect.object.material.color = new THREE.Color( 0xff0000 ); + } + + renderer.render( scene, camera ); + + } + + window.addEventListener( 'mousemove', onMouseMove, false ); + + window.requestAnimationFrame(render); + + +
Examples: [example:webgl_interactive_cubes Raycasting to a Mesh], + [example:webgl_interactive_cubes_ortho Raycasting to a Mesh in using an OrthographicCamera], + [example:webgl_interactive_buffergeometry Raycasting to a Mesh with BufferGeometry], + [example:webgl_interactive_lines Raycasting to a Line], + [example:webgl_interactive_raycasting_pointcloud Raycasting to a PointCloud], + [example:webgl_geometry_terrain_raycast Terrain raycasting], + [example:webgl_octree_raycasting Raycasting using an octree], + [example:webgl_interactive_voxelpainter Raycasting to paint voxels]
+ + +

Constructor

-

[name]( [page:Vector3 origin], [page:Vector3 direction], [page:Float near], [page:Float far] ) {

[page:Vector3 origin] — The origin vector where the ray casts from.
[page:Vector3 direction] — The direction vector that gives direction to the ray.
- [page:Float near] — All results returned are further away then near. Near can't be negative. Default value is 0.
+ [page:Float near] — All results returned are further away than near. Near can't be negative. Default value is 0.
[page:Float far] — All results returned are closer then far. Far can't be lower then near . Default value is Infinity.
@@ -51,7 +100,12 @@

[property:float precision]

- The precision factor of the raycaster. + The precision factor of the raycaster when intersecting [page:Mesh] objects. +
+ +

.[page:float linePrecision]

+
+ The precision factor of the raycaster when intersecting [page:Line] objects.

Methods

@@ -65,16 +119,45 @@ Updates the ray with a new origin and direction.
+

[method:null setFromCamera]( [page:Vector2 coords], [page:Camera camera] )

+
+ [page:Vector2 coords] — 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1.
+ [page:Camera camera] — camera from which the ray should originate +
+
+ Updates the ray with a new origin and direction. +
+ +

[method:Array intersectObject]( [page:Object3D object], [page:Boolean recursive] )

+

[page:Object3D object] — The object to check for intersection with the ray.
[page:Boolean recursive] — If set, it also checks all descendants. Otherwise it only checks intersecton with the object. +

- checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. + Checks all intersection between the ray and the object with or without the descendants. Intersections are returned sorted by distance, closest first. An array of intersections is returned... - [ { distance, point, face, faceIndex, object }, ... ] + [ { distance, point, face, faceIndex, indices, object }, ... ] +

+ [page:Float distance] – distance between the origin of the ray and the intersection
+ [page:Vector3 point] – point of intersection, in world coordinates
+ [page:Face3 face] – intersected face
+ [page:Integer faceIndex] – index of the intersected face
+ [page:Array indices] – indices of vertices comprising the intersected face
+ [page:Object3D object] – the intersected object +

+

+ When intersecting a [page:Mesh] with a [page:BufferGeometry], the *faceIndex* will be *undefined*, and *indices* will be set; when intersecting a [page:Mesh] with a [page:Geometry], *indices* will be *undefined*. +

+

+ *Raycaster* delegates to the [page:Object3D.raycast raycast] method of the passed object, when evaluating whether the ray intersects the object or not. This allows [page:Mesh meshes] to respond differently to ray casting than [page:Line lines] and [page:PointCloud pointclouds]. +

+

+ *Note* that for meshes, faces must be pointed towards the origin of the [page:.ray ray] in order to be detected; intersections of the ray passing through the back of a face will not be detected. To raycast against both faces of an object, you'll want to set the [page:Mesh.material material]'s [page:Material.side side] property to *THREE.DoubleSide*. +

[method:Array intersectObjects]( [page:Array objects], [page:Boolean recursive] )

@@ -83,10 +166,7 @@ [page:Boolean recursive] — If set, it also checks all descendants of the objects. Otherwise it only checks intersecton with the objects.
- checks all intersection between the ray and the objects with or without the descendants. Intersections are returned sorted by distance, closest first. - - [ { distance, point, face, faceIndex, object }, ... ] - + Checks all intersection between the ray and the objects with or without the descendants. Intersections are returned sorted by distance, closest first. Intersections are of the same form as those returned by [page:.intersectObject].
diff --git a/docs/api/objects/Line.html b/docs/api/objects/Line.html index 6da58327765ce594b4f9542320eccee64e5ed10c..b70c86f74d14db6b11c8f57f2f48cdf6b2632d9d 100644 --- a/docs/api/objects/Line.html +++ b/docs/api/objects/Line.html @@ -70,6 +70,11 @@

Methods

+

[method:Array raycast]([page:Raycaster raycaster], [page:Array intersects])

+
+ Get intersections between a casted ray and this Line. [page:Raycaster.intersectObject] will call this method. +
+

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/objects/Mesh.html b/docs/api/objects/Mesh.html index 9984a97ee74ce0f536af3fe18316e30d531e9c6e..94bdfb2c092d6a186f92f03dd789152f29a1b41d 100644 --- a/docs/api/objects/Mesh.html +++ b/docs/api/objects/Mesh.html @@ -60,6 +60,12 @@ Updates the morphtargets to have no influence on the object. +

[method:Array raycast]([page:Raycaster raycaster], [page:Array intersects])

+
+ Get intersections between a casted ray and this mesh. [page:Raycaster.intersectObject] will call this method. +
+ +

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/objects/PointCloud.html b/docs/api/objects/PointCloud.html index 6dcfa9f0ea5e9b85bafd9a9c82a29acfa4a5496a..ca4e488c4514c5fa9f03b30d5ac5d3ae15401ff5 100644 --- a/docs/api/objects/PointCloud.html +++ b/docs/api/objects/PointCloud.html @@ -42,6 +42,11 @@ This creates a clone of the particle system. +

[method:Array raycast]([page:Raycaster raycaster], [page:Array intersects])

+
+ Get intersections between a casted ray and this PointCloud. [page:Raycaster.intersectObject] will call this method. +
+

Source

diff --git a/editor/css/dark.css b/editor/css/dark.css index 0814eca7a49b17f815e46276e4142f0aac58e3d5..dc1305f9b761fca0590a2dc9827a338ba5359c32 100644 --- a/editor/css/dark.css +++ b/editor/css/dark.css @@ -127,6 +127,10 @@ input.Number { overflow: auto; } + #sidebar * { + vertical-align: middle; + } + #sidebar input, #sidebar textarea, #sidebar select { diff --git a/editor/css/light.css b/editor/css/light.css index 073d644833d9caecafb0e3a8f45eaab693542f4c..27f1077c79ae8a94956148359fac6f572a1551bb 100644 --- a/editor/css/light.css +++ b/editor/css/light.css @@ -128,6 +128,10 @@ input.Number { overflow: auto; } + #sidebar * { + vertical-align: middle; + } + #sidebar input, #sidebar textarea, #sidebar select { diff --git a/editor/css/main.css b/editor/css/main.css index 24bb96b5014c2897c553e3b4a6097dc52361abb1..59d7904c66c9ed34c6608b86d0262e96ff387429 100644 --- a/editor/css/main.css +++ b/editor/css/main.css @@ -1,7 +1,3 @@ -* { - vertical-align: middle; -} - body { font-family: Helvetica, Arial, sans-serif; font-size: 14px; @@ -79,6 +75,7 @@ textarea, input { outline: none; } /* osx */ height: calc(100% - 37px) !important; } + /* scene types */ .type { @@ -119,7 +116,7 @@ textarea, input { outline: none; } /* osx */ color: #bbeebb; } .TorusGeometry { - color: #aaeeaa; + color: #aaeeaa; } /* */ diff --git a/editor/index.html b/editor/index.html index f9f0d763625782739202f3a15cb947cd5ebaa3b0..e3542923884a61164422c5cf10d529b3a68b7dd9 100644 --- a/editor/index.html +++ b/editor/index.html @@ -6,20 +6,6 @@ - - diff --git a/examples/js/Mirror.js b/examples/js/Mirror.js index 0c72356c4fb2f3f85ab4f180e446c130baf3e8e5..aaf36404481a2c63cd3c7d431ab298f9024400c5 100644 --- a/examples/js/Mirror.js +++ b/examples/js/Mirror.js @@ -110,6 +110,7 @@ THREE.Mirror = function ( renderer, camera, options ) { this.textureMatrix = new THREE.Matrix4(); this.mirrorCamera = this.camera.clone(); + this.mirrorCamera.matrixAutoUpdate = true; this.texture = new THREE.WebGLRenderTarget( width, height ); this.tempTexture = new THREE.WebGLRenderTarget( width, height ); @@ -142,7 +143,7 @@ THREE.Mirror = function ( renderer, camera, options ) { }; THREE.Mirror.prototype = Object.create( THREE.Object3D.prototype ); -THREE.Mirror.prototype.constructor = THREE.Mirror; +THREE.Mirror.prototype.constructor = THREE.Mirror; THREE.Mirror.prototype.renderWithMirror = function ( otherMirror ) { diff --git a/examples/js/postprocessing/EffectComposer.js b/examples/js/postprocessing/EffectComposer.js index ab7649bac604dbbfb644d37b519ad949f5ff2e8b..b675b7cb489c58898bef1833f5d451354e067856 100644 --- a/examples/js/postprocessing/EffectComposer.js +++ b/examples/js/postprocessing/EffectComposer.js @@ -8,8 +8,10 @@ THREE.EffectComposer = function ( renderer, renderTarget ) { if ( renderTarget === undefined ) { - var width = window.innerWidth || 1; - var height = window.innerHeight || 1; + var pixelRatio = renderer.getPixelRatio(); + + var width = Math.floor( renderer.context.canvas.width / pixelRatio ) || 1; + var height = Math.floor( renderer.context.canvas.height / pixelRatio ) || 1; var parameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false }; renderTarget = new THREE.WebGLRenderTarget( width, height, parameters ); @@ -108,8 +110,10 @@ THREE.EffectComposer.prototype = { renderTarget = this.renderTarget1.clone(); - renderTarget.width = window.innerWidth; - renderTarget.height = window.innerHeight; + var pixelRatio = renderer.getPixelRatio(); + + renderTarget.width = Math.floor( this.renderer.context.canvas.width / pixelRatio ); + renderTarget.height = Math.floor( this.renderer.context.canvas.height / pixelRatio ); } diff --git a/examples/webgl_mirror.html b/examples/webgl_mirror.html index d20e626aaf4af3a4ba3b96a379502651816c6ab5..4d3065307859233bcd7c923c07bda4f7d0293993 100644 --- a/examples/webgl_mirror.html +++ b/examples/webgl_mirror.html @@ -50,7 +50,7 @@ var NEAR = 1; var FAR = 500; - var camera, scane, renderer; + var camera, scene, renderer; var cameraControls;