提交 bc5e51d4 编写于 作者: M Mugen87

Merge remote-tracking branch 'upstream/dev' into dev33

......@@ -103,6 +103,14 @@
This value shouldn't be negative and should be smaller than the far property.
</p>
<h3>[property:Camera camera]</h3>
<p>
The camera to use when raycasting against view-dependent objects such as billboarded objects like [page:Sprites]. This field
can be set manually or is set when calling "setFromCamera".
Defaults to null.
</p>
<h3>[property:Object params]</h3>
<p>
An object with the following properties:
......
......@@ -61,6 +61,7 @@ THREE.TranslucentShader = {
].join( "\n" ),
fragmentShader: [
"#define USE_UV",
"#define USE_MAP",
"#define PHONG",
"#define TRANSLUCENT",
......@@ -137,7 +138,7 @@ THREE.TranslucentShader = {
" RE_Direct( directLight, geometry, material, reflectedLight );",
" #if defined( TRANSLUCENT ) && defined( USE_MAP )",
" #if defined( TRANSLUCENT ) && defined( USE_UV )",
" RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);",
" #endif",
" }",
......@@ -159,7 +160,7 @@ THREE.TranslucentShader = {
" RE_Direct( directLight, geometry, material, reflectedLight );",
" #if defined( TRANSLUCENT ) && defined( USE_MAP )",
" #if defined( TRANSLUCENT ) && defined( USE_UV )",
" RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);",
" #endif",
" }",
......
......@@ -68,6 +68,7 @@ var TranslucentShader = {
].join( "\n" ),
fragmentShader: [
"#define USE_UV",
"#define USE_MAP",
"#define PHONG",
"#define TRANSLUCENT",
......@@ -144,7 +145,7 @@ var TranslucentShader = {
" RE_Direct( directLight, geometry, material, reflectedLight );",
" #if defined( TRANSLUCENT ) && defined( USE_MAP )",
" #if defined( TRANSLUCENT ) && defined( USE_UV )",
" RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);",
" #endif",
" }",
......@@ -166,7 +167,7 @@ var TranslucentShader = {
" RE_Direct( directLight, geometry, material, reflectedLight );",
" #if defined( TRANSLUCENT ) && defined( USE_MAP )",
" #if defined( TRANSLUCENT ) && defined( USE_UV )",
" RE_Direct_Scattering(directLight, vUv, geometry, reflectedLight);",
" #endif",
" }",
......
......@@ -55,6 +55,12 @@ export class Raycaster {
*/
far: number;
/**
* The camera to use when raycasting against view-dependent objects such as billboarded objects like Sprites. This field
* can be set manually or is set when calling "setFromCamera".
*/
camera: Camera;
params: RaycasterParameters;
/**
......
......@@ -13,6 +13,7 @@ function Raycaster( origin, direction, near, far ) {
this.near = near || 0;
this.far = far || Infinity;
this.camera = null;
this.params = {
Mesh: {},
......@@ -79,13 +80,13 @@ Object.assign( Raycaster.prototype, {
this.ray.origin.setFromMatrixPosition( camera.matrixWorld );
this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize();
this._camera = camera;
this.camera = camera;
} else if ( ( camera && camera.isOrthographicCamera ) ) {
this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera
this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
this._camera = camera;
this.camera = camera;
} else {
......
......@@ -71,14 +71,20 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
raycast: function ( raycaster, intersects ) {
if ( raycaster.camera === null ) {
console.error( 'THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.' );
}
_worldScale.setFromMatrixScale( this.matrixWorld );
_viewWorldMatrix.copy( raycaster._camera.matrixWorld );
this.modelViewMatrix.multiplyMatrices( raycaster._camera.matrixWorldInverse, this.matrixWorld );
_viewWorldMatrix.copy( raycaster.camera.matrixWorld );
this.modelViewMatrix.multiplyMatrices( raycaster.camera.matrixWorldInverse, this.matrixWorld );
_mvPosition.setFromMatrixPosition( this.modelViewMatrix );
if ( raycaster._camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) {
if ( raycaster.camera.isPerspectiveCamera && this.material.sizeAttenuation === false ) {
_worldScale.multiplyScalar( - _mvPosition.z );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册