Skip to content

Commit fbb6ed6

Browse files
authored
Merge pull request #16547 from Mugen87/dev32
JSM: Added more modules and TS files for "objects".
2 parents 65a0a88 + 13a2517 commit fbb6ed6

File tree

15 files changed

+1121
-11
lines changed

15 files changed

+1121
-11
lines changed

docs/manual/en/introduction/Import-via-modules.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,11 @@ <h2>Importable Examples</h2>
153153
<li>Lensflare</li>
154154
<li>Reflector</li>
155155
<li>Refractor</li>
156+
<li>ReflectorRTT</li>
157+
<li>ShadowMesh</li>
158+
<li>Sky</li>
159+
<li>Water</li>
160+
<li>Water2</li>
156161
</ul>
157162
</li>
158163
<li>pmrem

examples/js/objects/ReflectorRTT.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* RTT version
3+
*/
4+
15
THREE.ReflectorRTT = function ( geometry, options ) {
26

37
THREE.Reflector.call( this, geometry, options );

examples/js/objects/ShadowMesh.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ THREE.ShadowMesh.prototype.update = function () {
4242

4343
var sme = shadowMatrix.elements;
4444

45-
sme[ 0 ] = dot - lightPosition4D.x * plane.normal.x;
46-
sme[ 4 ] = - lightPosition4D.x * plane.normal.y;
47-
sme[ 8 ] = - lightPosition4D.x * plane.normal.z;
45+
sme[ 0 ] = dot - lightPosition4D.x * plane.normal.x;
46+
sme[ 4 ] = - lightPosition4D.x * plane.normal.y;
47+
sme[ 8 ] = - lightPosition4D.x * plane.normal.z;
4848
sme[ 12 ] = - lightPosition4D.x * - plane.constant;
4949

50-
sme[ 1 ] = - lightPosition4D.y * plane.normal.x;
51-
sme[ 5 ] = dot - lightPosition4D.y * plane.normal.y;
52-
sme[ 9 ] = - lightPosition4D.y * plane.normal.z;
50+
sme[ 1 ] = - lightPosition4D.y * plane.normal.x;
51+
sme[ 5 ] = dot - lightPosition4D.y * plane.normal.y;
52+
sme[ 9 ] = - lightPosition4D.y * plane.normal.z;
5353
sme[ 13 ] = - lightPosition4D.y * - plane.constant;
5454

55-
sme[ 2 ] = - lightPosition4D.z * plane.normal.x;
56-
sme[ 6 ] = - lightPosition4D.z * plane.normal.y;
55+
sme[ 2 ] = - lightPosition4D.z * plane.normal.x;
56+
sme[ 6 ] = - lightPosition4D.z * plane.normal.y;
5757
sme[ 10 ] = dot - lightPosition4D.z * plane.normal.z;
5858
sme[ 14 ] = - lightPosition4D.z * - plane.constant;
5959

60-
sme[ 3 ] = - lightPosition4D.w * plane.normal.x;
61-
sme[ 7 ] = - lightPosition4D.w * plane.normal.y;
60+
sme[ 3 ] = - lightPosition4D.w * plane.normal.x;
61+
sme[ 7 ] = - lightPosition4D.w * plane.normal.y;
6262
sme[ 11 ] = - lightPosition4D.w * plane.normal.z;
6363
sme[ 15 ] = dot - lightPosition4D.w * - plane.constant;
6464

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { BufferGeometry } from '../../../src/Three';
2+
import { Reflector, ReflectorOptions } from './Reflector';
3+
4+
export class ReflectorRTT extends Reflector {
5+
constructor(geometry?: BufferGeometry, options?: ReflectorOptions);
6+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* RTT version
3+
*/
4+
5+
6+
import { Reflector } from "../objects/Reflector.js";
7+
8+
var ReflectorRTT = function ( geometry, options ) {
9+
10+
Reflector.call( this, geometry, options );
11+
12+
this.geometry.setDrawRange( 0, 0 ); // avoid rendering geometry
13+
14+
};
15+
16+
ReflectorRTT.prototype = Object.create( Reflector.prototype );
17+
18+
export { ReflectorRTT };
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import {
2+
Mesh,
3+
Plane,
4+
Vector4
5+
} from '../../../src/Three';
6+
7+
export class ShadowMesh extends Mesh {
8+
constructor();
9+
10+
update(plane: Plane, lightPosition4D: Vector4): void;
11+
}

examples/jsm/objects/ShadowMesh.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* @author erichlof / http://github.com/erichlof
3+
*
4+
* A shadow Mesh that follows a shadow-casting Mesh in the scene, but is confined to a single plane.
5+
*/
6+
7+
import {
8+
Matrix4,
9+
Mesh,
10+
MeshBasicMaterial
11+
} from "../../../build/three.module.js";
12+
13+
var ShadowMesh = function ( mesh ) {
14+
15+
var shadowMaterial = new MeshBasicMaterial( {
16+
17+
color: 0x000000,
18+
transparent: true,
19+
opacity: 0.6,
20+
depthWrite: false
21+
22+
} );
23+
24+
Mesh.call( this, mesh.geometry, shadowMaterial );
25+
26+
this.meshMatrix = mesh.matrixWorld;
27+
28+
this.frustumCulled = false;
29+
this.matrixAutoUpdate = false;
30+
31+
};
32+
33+
ShadowMesh.prototype = Object.create( Mesh.prototype );
34+
ShadowMesh.prototype.constructor = ShadowMesh;
35+
36+
ShadowMesh.prototype.update = function () {
37+
38+
var shadowMatrix = new Matrix4();
39+
40+
return function ( plane, lightPosition4D ) {
41+
42+
// based on https://www.opengl.org/archives/resources/features/StencilTalk/tsld021.htm
43+
44+
var dot = plane.normal.x * lightPosition4D.x +
45+
plane.normal.y * lightPosition4D.y +
46+
plane.normal.z * lightPosition4D.z +
47+
- plane.constant * lightPosition4D.w;
48+
49+
var sme = shadowMatrix.elements;
50+
51+
sme[ 0 ] = dot - lightPosition4D.x * plane.normal.x;
52+
sme[ 4 ] = - lightPosition4D.x * plane.normal.y;
53+
sme[ 8 ] = - lightPosition4D.x * plane.normal.z;
54+
sme[ 12 ] = - lightPosition4D.x * - plane.constant;
55+
56+
sme[ 1 ] = - lightPosition4D.y * plane.normal.x;
57+
sme[ 5 ] = dot - lightPosition4D.y * plane.normal.y;
58+
sme[ 9 ] = - lightPosition4D.y * plane.normal.z;
59+
sme[ 13 ] = - lightPosition4D.y * - plane.constant;
60+
61+
sme[ 2 ] = - lightPosition4D.z * plane.normal.x;
62+
sme[ 6 ] = - lightPosition4D.z * plane.normal.y;
63+
sme[ 10 ] = dot - lightPosition4D.z * plane.normal.z;
64+
sme[ 14 ] = - lightPosition4D.z * - plane.constant;
65+
66+
sme[ 3 ] = - lightPosition4D.w * plane.normal.x;
67+
sme[ 7 ] = - lightPosition4D.w * plane.normal.y;
68+
sme[ 11 ] = - lightPosition4D.w * plane.normal.z;
69+
sme[ 15 ] = dot - lightPosition4D.w * - plane.constant;
70+
71+
this.matrix.multiplyMatrices( shadowMatrix, this.meshMatrix );
72+
73+
};
74+
75+
}();
76+
77+
export { ShadowMesh };

examples/jsm/objects/Sky.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {
2+
Mesh
3+
} from '../../../src/Three';
4+
5+
export class Sky extends Mesh {
6+
constructor();
7+
8+
static SkyShader: object;
9+
}

0 commit comments

Comments
 (0)