浏览代码

先做SKy

xushiting 5 年之前
父节点
当前提交
442f148fa2

文件差异内容过多而无法显示
+ 398 - 1
build/three.js


文件差异内容过多而无法显示
+ 398 - 2
build/three.module.js


+ 273 - 0
examples/Fdage1.html

@@ -0,0 +1,273 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<title>three.js webgl - interactive - buffergeometry</title>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+		<style>
+			body {
+				color: #cccccc;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+
+				background-color: #050505;
+				margin: 0px;
+				overflow: hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+			}
+
+			a {
+
+				color: #0080ff;
+			}
+
+		</style>
+	</head>
+	<body>
+
+		<div id="container"></div>
+
+		<script src="../build/three.js"></script>
+        <script src="js/controls/OrbitControls.js"></script>
+		<script src="js/Detector.js"></script>
+		<script src="js/libs/stats.min.js"></script>
+
+		<script>
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+			var container, stats;
+
+			var camera, controls, scene, renderer;
+
+
+			var mesh;
+
+			init();
+			render();
+
+			function init() {
+
+				container = document.getElementById( 'container' );
+
+				//
+
+				camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 100, 2000000 );
+				camera.position.set( -3, 0.4, -18 );
+				camera.updateProjectionMatrix();
+				scene = new THREE.Scene();
+
+				//
+
+				//scene.add( new THREE.AmbientLight( 0x444444 ) );
+
+				// var light1 = new THREE.DirectionalLight( 0xffffff, 0.5 );
+				// light1.position.set( 1, 1, 1 );
+				// scene.add( light1 );
+
+				// var light2 = new THREE.DirectionalLight( 0xffffff, 1.5 );
+				// light2.position.set( 0, -1, 0 );
+				// scene.add( light2 );
+
+				//
+
+                /*
+				var triangles = 5000;
+
+				var geometry = new THREE.BufferGeometry();
+
+				var positions = new Float32Array( triangles * 3 * 3 );
+				var normals = new Float32Array( triangles * 3 * 3 );
+				var colors = new Float32Array( triangles * 3 * 3 );
+
+				var color = new THREE.Color();
+
+				var n = 800, n2 = n/2;	// triangles spread in the cube
+				var d = 120, d2 = d/2;	// individual triangle size
+
+				var pA = new THREE.Vector3();
+				var pB = new THREE.Vector3();
+				var pC = new THREE.Vector3();
+
+				var cb = new THREE.Vector3();
+				var ab = new THREE.Vector3();
+
+				for ( var i = 0; i < positions.length; i += 9 ) {
+
+					// positions
+
+					var x = Math.random() * n - n2;
+					var y = Math.random() * n - n2;
+					var z = Math.random() * n - n2;
+
+					var ax = x + Math.random() * d - d2;
+					var ay = y + Math.random() * d - d2;
+					var az = z + Math.random() * d - d2;
+
+					var bx = x + Math.random() * d - d2;
+					var by = y + Math.random() * d - d2;
+					var bz = z + Math.random() * d - d2;
+
+					var cx = x + Math.random() * d - d2;
+					var cy = y + Math.random() * d - d2;
+					var cz = z + Math.random() * d - d2;
+
+					positions[ i ]     = ax;
+					positions[ i + 1 ] = ay;
+					positions[ i + 2 ] = az;
+
+					positions[ i + 3 ] = bx;
+					positions[ i + 4 ] = by;
+					positions[ i + 5 ] = bz;
+
+					positions[ i + 6 ] = cx;
+					positions[ i + 7 ] = cy;
+					positions[ i + 8 ] = cz;
+
+					// flat face normals
+
+					pA.set( ax, ay, az );
+					pB.set( bx, by, bz );
+					pC.set( cx, cy, cz );
+
+					cb.subVectors( pC, pB );
+					ab.subVectors( pA, pB );
+					cb.cross( ab );
+
+					cb.normalize();
+
+					var nx = cb.x;
+					var ny = cb.y;
+					var nz = cb.z;
+
+					normals[ i ]     = nx;
+					normals[ i + 1 ] = ny;
+					normals[ i + 2 ] = nz;
+
+					normals[ i + 3 ] = nx;
+					normals[ i + 4 ] = ny;
+					normals[ i + 5 ] = nz;
+
+					normals[ i + 6 ] = nx;
+					normals[ i + 7 ] = ny;
+					normals[ i + 8 ] = nz;
+
+					// colors
+
+					var vx = ( x / n ) + 0.5;
+					var vy = ( y / n ) + 0.5;
+					var vz = ( z / n ) + 0.5;
+
+					color.setRGB( vx, vy, vz );
+
+					colors[ i ]     = color.r;
+					colors[ i + 1 ] = color.g;
+					colors[ i + 2 ] = color.b;
+
+					colors[ i + 3 ] = color.r;
+					colors[ i + 4 ] = color.g;
+					colors[ i + 5 ] = color.b;
+
+					colors[ i + 6 ] = color.r;
+					colors[ i + 7 ] = color.g;
+					colors[ i + 8 ] = color.b;
+
+				}
+                */
+               var shader = {
+                    uniforms: {
+                        "b":{type:'f',value:null},
+                        "tex":{type:'t',value:null}
+                    },
+                    vertexShader: [
+                        "precision highp float;",
+                        "varying vec2 tc;",
+                        "attribute vec4 p;",
+                        "void main(){",
+                        "   gl_Position=p;",
+                        "   tc=vec2(0.5,0.5/8.0)*p.xy+vec2(0.5,6.5/8.0);",
+                        "}"
+                    ].join( "\n" ),
+                    fragmentShader: [
+                        "precision highp float;",
+                        "varying vec2 tc;",
+                        "uniform sampler2D tex;",
+                        "uniform float b;",
+                        "void main(){",
+                        "   vec4 s=texture2D(tex,tc); ",
+                        "   gl_FragColor.xyz=s.xyz*(b*s.w);",
+                        "}"
+                    ].join( "\n" )
+               };
+
+               var positions = new Float32Array([-1, -1, 0.5, 1, 3, -1, 0.5, 1, -1, 3, 0.5, 1]);
+
+               var geometry = new THREE.BufferGeometry();
+				geometry.addAttribute( 'p', new THREE.BufferAttribute( positions, 3 ) );
+
+                geometry.computeBoundingSphere();
+                
+                new THREE.TextureLoader().load( 'textures/sky.png', function ( texture ) {
+                    this.material = new THREE.RawShaderMaterial( {
+                        uniforms: shader.uniforms,
+                        vertexShader: shader.vertexShader,
+                        fragmentShader: shader.fragmentShader
+                    } );
+     
+                    this.material.uniforms.b.value = 7 * Math.sqrt(0.488874);
+                    this.material.uniforms.tex.value = texture;
+                    mesh = new THREE.Mesh( geometry, this.material );
+					scene.add( mesh );
+
+                }.bind(this));
+
+                // this.material = new RawShaderMaterial( {
+                //     uniforms: shader.uniforms,
+                //     vertexShader: shader.vertexShader,
+                //     fragmentShader: shader.fragmentShader
+                // } );
+
+
+                //this.material.uniforms.b.value = 7 * Math.sqrt(0.488874);//7 * Math.sqrt(this.backgroundBrightness))
+				//
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setPixelRatio( window.devicePixelRatio );
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				container.appendChild( renderer.domElement );
+
+                controls = new THREE.OrbitControls( camera, renderer.domElement );
+				controls.addEventListener( 'change', render );
+
+				stats = new Stats();
+				container.appendChild( stats.dom );
+
+				window.addEventListener( 'resize', onWindowResize, false );
+
+			}
+
+			function onWindowResize() {
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				render();
+
+			}
+
+			function render() {
+				renderer.render( scene, camera );
+			}
+
+		</script>
+
+	</body>
+</html>

文件差异内容过多而无法显示
+ 139 - 0
examples/js/objects/FdageSky.js


二进制
examples/textures/sky.png


+ 31 - 9
package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "three",
-  "version": "0.94.0",
+  "version": "0.95.0",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {
@@ -349,6 +349,12 @@
         "js-tokens": "^3.0.2"
       }
     },
+    "balanced-match": {
+      "version": "0.4.2",
+      "resolved": "https://registry.npm.taobao.org/balanced-match/download/balanced-match-0.4.2.tgz",
+      "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=",
+      "dev": true
+    },
     "base": {
       "version": "0.11.2",
       "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz",
@@ -2241,13 +2247,15 @@
           "version": "1.0.0",
           "resolved": false,
           "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "brace-expansion": {
           "version": "1.1.11",
           "resolved": false,
           "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
           "dev": true,
+          "optional": true,
           "requires": {
             "balanced-match": "^1.0.0",
             "concat-map": "0.0.1"
@@ -2264,19 +2272,22 @@
           "version": "1.1.0",
           "resolved": false,
           "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "concat-map": {
           "version": "0.0.1",
           "resolved": false,
           "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "console-control-strings": {
           "version": "1.1.0",
           "resolved": false,
           "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "core-util-is": {
           "version": "1.0.2",
@@ -2407,7 +2418,8 @@
           "version": "2.0.3",
           "resolved": false,
           "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "ini": {
           "version": "1.3.5",
@@ -2421,6 +2433,7 @@
           "resolved": false,
           "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
           "dev": true,
+          "optional": true,
           "requires": {
             "number-is-nan": "^1.0.0"
           }
@@ -2437,6 +2450,7 @@
           "resolved": false,
           "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
           "dev": true,
+          "optional": true,
           "requires": {
             "brace-expansion": "^1.1.7"
           }
@@ -2445,13 +2459,15 @@
           "version": "0.0.8",
           "resolved": false,
           "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "minipass": {
           "version": "2.2.4",
           "resolved": false,
           "integrity": "sha512-hzXIWWet/BzWhYs2b+u7dRHlruXhwdgvlTMDKC6Cb1U7ps6Ac6yQlR39xsbjWJE377YTCtKwIXIpJ5oP+j5y8g==",
           "dev": true,
+          "optional": true,
           "requires": {
             "safe-buffer": "^5.1.1",
             "yallist": "^3.0.0"
@@ -2472,6 +2488,7 @@
           "resolved": false,
           "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
           "dev": true,
+          "optional": true,
           "requires": {
             "minimist": "0.0.8"
           }
@@ -2560,7 +2577,8 @@
           "version": "1.0.1",
           "resolved": false,
           "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
-          "dev": true
+          "dev": true,
+          "optional": true
         },
         "object-assign": {
           "version": "4.1.1",
@@ -2574,6 +2592,7 @@
           "resolved": false,
           "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
           "dev": true,
+          "optional": true,
           "requires": {
             "wrappy": "1"
           }
@@ -2711,6 +2730,7 @@
           "resolved": false,
           "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
           "dev": true,
+          "optional": true,
           "requires": {
             "code-point-at": "^1.0.0",
             "is-fullwidth-code-point": "^1.0.0",
@@ -4850,9 +4870,11 @@
           "dependencies": {
             "brace-expansion": {
               "version": "1.1.6",
-              "resolved": "",
+              "resolved": "https://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.6.tgz",
+              "integrity": "sha1-cZfX6qm4fmSDkOph/GbIRCdCDfk=",
               "dev": true,
               "requires": {
+                "balanced-match": "^0.4.1",
                 "concat-map": "0.0.1"
               }
             }

+ 313 - 0
src/constants.js

@@ -139,3 +139,316 @@ export var BasicDepthPacking = 3200;
 export var RGBADepthPacking = 3201;
 export var TangentSpaceNormalMap = 0;
 export var ObjectSpaceNormalMap = 1;
+
+//xst
+export var Matrix = {
+    type: Float32Array,
+    create: function(a, c, b, d, e, f, g, h, k, n, m, l, p, r, s, u) {
+        var q = new Matrix.type(16);
+        q[0] = a;
+        q[4] = c;
+        q[8] = b;
+        q[12] = d;
+        q[1] = e;
+        q[5] = f;
+        q[9] = g;
+        q[13] = h;
+        q[2] = k;
+        q[6] = n;
+        q[10] = m;
+        q[14] = l;
+        q[3] = p;
+        q[7] = r;
+        q[11] = s;
+        q[15] = u;
+        return q
+    },
+    empty: function() {
+        return new Matrix.type(16)
+    },
+    identity: function() {
+        var a = new Matrix.type(16);
+        a[0] = 1;
+        a[4] = 0;
+        a[8] = 0;
+        a[12] = 0;
+        a[1] = 0;
+        a[5] = 1;
+        a[9] = 0;
+        a[13] = 0;
+        a[2] = 0;
+        a[6] = 0;
+        a[10] = 1;
+        a[14] = 0;
+        a[3] = 0;
+        a[7] = 0;
+        a[11] = 0;
+        a[15] = 1;
+        return a
+    },
+    set: function(a, c, b, d, e, f, g, h, k, n, m, l, p, r, s, u, q) {
+        a[0] = c;
+        a[4] = b;
+        a[8] = d;
+        a[12] = e;
+        a[1] = f;
+        a[5] = g;
+        a[9] = h;
+        a[13] = k;
+        a[2] = n;
+        a[6] = m;
+        a[10] = l;
+        a[14] = p;
+        a[3] = r;
+        a[7] = s;
+        a[11] = u;
+        a[15] = q
+    },
+    translation: function(a, c, b, d) {
+        Matrix.set(a, 1, 0, 0, c, 0, 1, 0, b, 0, 0, 1, d, 0, 0, 0, 1);
+        return a
+    },
+    rotation: function(a, c, b) {
+        a[0] = 1;
+        a[4] = 0;
+        a[8] = 0;
+        a[12] = 0;
+        a[1] = 0;
+        a[5] = 1;
+        a[9] = 0;
+        a[13] = 0;
+        a[2] = 0;
+        a[6] = 0;
+        a[10] = 1;
+        a[14] = 0;
+        a[3] = 0;
+        a[7] = 0;
+        a[11] = 0;
+        a[15] = 1;
+        var d = 0.0174532925 * c;
+        c = Math.sin(d);
+        d = Math.cos(d);
+        switch (b) {
+        case 0:
+            a[5] = d;
+            a[9] = -c;
+            a[6] = c;
+            a[10] = d;
+            break;
+        case 1:
+            a[0] = d;
+            a[8] = c;
+            a[2] = -c;
+            a[10] = d;
+            break;
+        case 2:
+            a[0] = d,
+            a[4] = -c,
+            a[1] = c,
+            a[5] = d
+        }
+        return a
+    },
+    mul: function(a, c, b) {
+        var d = c[0]
+          , e = c[1]
+          , f = c[2]
+          , g = c[3]
+          , h = c[4]
+          , k = c[5]
+          , n = c[6]
+          , m = c[7]
+          , l = c[8]
+          , p = c[9]
+          , r = c[10]
+          , s = c[11]
+          , u = c[12]
+          , q = c[13]
+          , x = c[14];
+        c = c[15];
+        var w = b[0]
+          , v = b[1]
+          , t = b[2]
+          , y = b[3];
+        a[0] = w * d + v * h + t * l + y * u;
+        a[1] = w * e + v * k + t * p + y * q;
+        a[2] = w * f + v * n + t * r + y * x;
+        a[3] = w * g + v * m + t * s + y * c;
+        w = b[4];
+        v = b[5];
+        t = b[6];
+        y = b[7];
+        a[4] = w * d + v * h + t * l + y * u;
+        a[5] = w * e + v * k + t * p + y * q;
+        a[6] = w * f + v * n + t * r + y * x;
+        a[7] = w * g + v * m + t * s + y * c;
+        w = b[8];
+        v = b[9];
+        t = b[10];
+        y = b[11];
+        a[8] = w * d + v * h + t * l + y * u;
+        a[9] = w * e + v * k + t * p + y * q;
+        a[10] = w * f + v * n + t * r + y * x;
+        a[11] = w * g + v * m + t * s + y * c;
+        w = b[12];
+        v = b[13];
+        t = b[14];
+        y = b[15];
+        a[12] = w * d + v * h + t * l + y * u;
+        a[13] = w * e + v * k + t * p + y * q;
+        a[14] = w * f + v * n + t * r + y * x;
+        a[15] = w * g + v * m + t * s + y * c;
+        return a
+    },
+    invert: function(a, c) {
+        var b = c[0]
+          , d = c[1]
+          , e = c[2]
+          , f = c[3]
+          , g = c[4]
+          , h = c[5]
+          , k = c[6]
+          , n = c[7]
+          , m = c[8]
+          , l = c[9]
+          , p = c[10]
+          , r = c[11]
+          , s = c[12]
+          , u = c[13]
+          , q = c[14]
+          , x = c[15]
+          , w = b * h - d * g
+          , v = b * k - e * g
+          , t = b * n - f * g
+          , y = d * k - e * h
+          , E = d * n - f * h
+          , F = e * n - f * k
+          , A = m * u - l * s
+          , B = m * q - p * s
+          , z = m * x - r * s
+          , C = l * q - p * u
+          , G = l * x - r * u
+          , H = p * x - r * q
+          , D = w * H - v * G + t * C + y * z - E * B + F * A;
+        if (!D)
+            return null;
+        D = 1 / D;
+        a[0] = (h * H - k * G + n * C) * D;
+        a[1] = (e * G - d * H - f * C) * D;
+        a[2] = (u * F - q * E + x * y) * D;
+        a[3] = (p * E - l * F - r * y) * D;
+        a[4] = (k * z - g * H - n * B) * D;
+        a[5] = (b * H - e * z + f * B) * D;
+        a[6] = (q * t - s * F - x * v) * D;
+        a[7] = (m * F - p * t + r * v) * D;
+        a[8] = (g * G - h * z + n * A) * D;
+        a[9] = (d * z - b * G - f * A) * D;
+        a[10] = (s * E - u * t + x * w) * D;
+        a[11] = (l * t - m * E - r * w) * D;
+        a[12] = (h * B - g * C - k * A) * D;
+        a[13] = (b * C - d * B + e * A) * D;
+        a[14] = (u * v - s * y - q * w) * D;
+        a[15] = (m * y - l * v + p * w) * D;
+        return a
+    },
+    transpose: function(a, c) {
+        a[0] = c[0];
+        a[4] = c[1];
+        a[8] = c[2];
+        a[12] = c[3];
+        a[1] = c[4];
+        a[5] = c[5];
+        a[9] = c[6];
+        a[13] = c[7];
+        a[2] = c[8];
+        a[6] = c[9];
+        a[10] = c[10];
+        a[14] = c[11];
+        a[3] = c[12];
+        a[7] = c[13];
+        a[11] = c[14];
+        a[15] = c[15];
+        return a
+    },
+    mul4: function(a, c, b, d, e, f) {
+        a[0] = c[0] * b + c[4] * d + c[8] * e + c[12] * f;
+        a[1] = c[1] * b + c[5] * d + c[9] * e + c[13] * f;
+        a[2] = c[2] * b + c[6] * d + c[10] * e + c[14] * f;
+        a[3] = c[3] * b + c[7] * d + c[11] * e + c[15] * f;
+        return a
+    },
+    mulPoint: function(a, c, b, d, e) {
+        a[0] = c[0] * b + c[4] * d + c[8] * e + c[12];
+        a[1] = c[1] * b + c[5] * d + c[9] * e + c[13];
+        a[2] = c[2] * b + c[6] * d + c[10] * e + c[14];
+        return a
+    },
+    mulVec: function(a, c, b, d, e) {
+        a[0] = c[0] * b + c[4] * d + c[8] * e;
+        a[1] = c[1] * b + c[5] * d + c[9] * e;
+        a[2] = c[2] * b + c[6] * d + c[10] * e;
+        return a
+    },
+    perspective: function(a, c, b, d, e, f) {
+        f = f || 0;
+        c = 1 / Math.tan(0.00872664625 * c);
+        a[0] = c / b;
+        a[1] = a[2] = a[3] = 0;
+        a[5] = c;
+        a[4] = a[6] = a[7] = 0;
+        a[8] = a[9] = 0;
+        a[10] = (e + d) / (d - e) - 3.0518044E-5 * f;
+        a[11] = -1;
+        a[14] = 2 * e * d / (d - e);
+        a[12] = a[13] = a[15] = 0;
+        return a
+    },
+    perspectiveInfinite: function(a, c, b, d, e) {
+        e = e || 0;
+        c = 1 / Math.tan(0.00872664625 * c);
+        a[0] = c / b;
+        a[1] = a[2] = a[3] = 0;
+        a[5] = c;
+        a[4] = a[6] = a[7] = 0;
+        a[8] = a[9] = 0;
+        a[10] = a[11] = -1 - 3.0518044E-5 * e;
+        a[14] = -2 * d;
+        a[12] = a[13] = a[15] = 0;
+        return a
+    },
+    ortho: function(a, c, b, d, e, f, g, h) {
+        var k = 1 / (b - c)
+          , n = 1 / (e - d)
+          , m = 1 / (g - f);
+        a[0] = k + k;
+        a[1] = a[2] = a[3] = 0;
+        a[5] = n + n;
+        a[4] = a[6] = a[7] = 0;
+        a[12] = -(b + c) * k;
+        a[13] = -(e + d) * n;
+        a[10] = -(m + m) - 3.0518044E-5 * (h || 0);
+        a[14] = -(g + f) * m;
+        a[8] = a[9] = a[11] = 0;
+        a[15] = 1;
+        return a
+    },
+    lookAt: function(a, c, b, d) {
+        var e = a.subarray(0, 3)
+          , f = a.subarray(4, 7)
+          , g = a.subarray(8, 11);
+        Vect.sub(g, c, b);
+        Vect.cross(e, d, g);
+        Vect.normalize(g, g);
+        Vect.normalize(e, e);
+        Vect.cross(f, g, e);
+        Matrix.set(a, e[0], e[1], e[2], -Vect.dot(e, c), f[0], f[1], f[2], -Vect.dot(f, c), g[0], g[1], g[2], -Vect.dot(g, c), 0, 0, 0, 1)
+    },
+    copy: function(a, c) {
+        for (var b = 0; 16 > b; ++b)
+            a[b] = c[b]
+    },
+    copyToBuffer: function(a, c, b) {
+        for (var d = 0; 16 > d; ++d)
+            a[c + d] = b[d]
+    }
+};

+ 57 - 1
src/renderers/shaders/ShaderChunk.js

@@ -115,6 +115,34 @@ import shadow_vert from './ShaderLib/shadow_vert.glsl';
 import sprite_frag from './ShaderLib/sprite_frag.glsl';
 import sprite_vert from './ShaderLib/sprite_vert.glsl';
 
+import matdither from './ShaderChunk/matdither.glsl';
+import matlighting from './ShaderChunk/matlighting.glsl';
+import matmicrofiber from './ShaderChunk/matmicrofiber.glsl';
+import matsampling from './ShaderChunk/matsampling.glsl';
+import matshadows from './ShaderChunk/matshadows.glsl';
+import matskin from './ShaderChunk/matskin.glsl';
+import matstrips from './ShaderChunk/matstrips.glsl';
+import alphaprepassfrag from './ShaderLib/alphaprepassfrag.glsl';
+import alphaprepassvert from './ShaderLib/alphaprepassvert.glsl';
+import bloom from './ShaderLib/bloom.glsl';
+import bloomshrink from './ShaderLib/bloomshrink.glsl';
+import fogfrag from './ShaderLib/fogfrag.glsl';
+import fogvert from './ShaderLib/fogvert.glsl';
+import matfrag from './ShaderLib/matfrag.glsl';
+import matvert from './ShaderLib/matvert.glsl';
+import postaa from './ShaderLib/postaa.glsl';
+import postfrag from './ShaderLib/postfrag.glsl';
+import postvert from './ShaderLib/postvert.glsl';
+import shadowfloorfrag from './ShaderLib/shadowfloorfrag.glsl';
+import shadowfloorvert from './ShaderLib/shadowfloorvert.glsl';
+import shadowfrag from './ShaderLib/shadowfrag.glsl';
+import shadowvert from './ShaderLib/shadowvert.glsl';
+import sky from './ShaderLib/sky.glsl';
+import skySH from './ShaderLib/skySH.glsl';
+import skyvert from './ShaderLib/skyvert.glsl';
+import wirefrag from './ShaderLib/wirefrag.glsl';
+import wirevert from './ShaderLib/wirevert.glsl';
+
 export var ShaderChunk = {
 	alphamap_fragment: alphamap_fragment,
 	alphamap_pars_fragment: alphamap_pars_fragment,
@@ -231,5 +259,33 @@ export var ShaderChunk = {
 	shadow_frag: shadow_frag,
 	shadow_vert: shadow_vert,
 	sprite_frag: sprite_frag,
-	sprite_vert: sprite_vert
+	sprite_vert: sprite_vert,
+
+	matdither:matdither,
+	matlighting:matlighting,
+	matmicrofiber:matmicrofiber,
+	matsampling:matsampling,
+	matshadows:matshadows,
+	matskin:matskin,
+	matstrips:matstrips,
+	alphaprepassfrag:alphaprepassfrag,
+	alphaprepassvert:alphaprepassvert,
+	bloom:bloom,
+	bloomshrink:bloomshrink,
+	fogfrag:fogfrag,
+	fogvert:fogvert,
+	matfrag:matfrag,
+	matvert:matvert,
+	postaa:postaa,
+	postfrag:postfrag,
+	postvert:postvert,
+	shadowfloorfrag:shadowfloorfrag,
+	shadowfloorvert:shadowfloorvert,
+	shadowfrag:shadowfrag,
+	shadowvert:shadowvert,
+	sky:sky,
+	skySH:skySH,
+	skyvert:skyvert,
+	wirefrag:wirefrag,
+	wirevert:wirevert
 };

+ 34 - 27
src/renderers/shaders/ShaderChunk/matshadows.glsl

@@ -1,42 +1,49 @@
 #ifdef SHADOW_COUNT
+
     #ifdef MOBILE
-    #define SHADOW_KERNEL (4.0/1536.0)
-#else
-    #define SHADOW_KERNEL (4.0/2048.0)
-#endif
+        #define SHADOW_KERNEL (4.0/1536.0)
+    #else
+        #define SHADOW_KERNEL (4.0/2048.0)
+    #endif
+
+    highp vec4 h(highp mat4 i,highp vec3 p){
+        return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
+    }
 
-highp vec4 h(highp mat4 i,highp vec3 p){
-    return i[0]*p.x+(i[1]*p.y+(i[2]*p.z+i[3]));
-}
+    uniform sampler2D tDepth0;
 
-uniform sampler2D tDepth0;
-#if SHADOW_COUNT > 1
-    uniform sampler2D tDepth1;
-    #if SHADOW_COUNT > 2
-        uniform sampler2D tDepth2;
+    #if SHADOW_COUNT > 1
+        uniform sampler2D tDepth1;
+        #if SHADOW_COUNT > 2
+            uniform sampler2D tDepth2;
+        #endif
     #endif
-#endif
-uniform highp vec2 uShadowKernelRotation;
-uniform highp vec2 uShadowMapSize;
-uniform highp mat4 uShadowMatrices[SHADOW_COUNT];
-uniform highp vec4 uShadowTexelPadProjections[SHADOW_COUNT];
-#ifndef MOBILE
-    uniform highp mat4 uInvShadowMatrices[SHADOW_COUNT];
-#endif
 
-highp float hJ(highp vec3 G){
-    #ifdef SHADOW_NATIVE_DEPTH
-        return G.x;
-    #else
-        return(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);
+    uniform highp vec2 uShadowKernelRotation;
+    uniform highp vec2 uShadowMapSize;
+    uniform highp mat4 uShadowMatrices[SHADOW_COUNT];
+    uniform highp vec4 uShadowTexelPadProjections[SHADOW_COUNT];
+
+    #ifndef MOBILE
+        uniform highp mat4 uInvShadowMatrices[SHADOW_COUNT];
     #endif
+
+    highp float hJ(highp vec3 G){
+        #ifdef SHADOW_NATIVE_DEPTH
+            return G.x;
+        #else
+            return(G.x+G.y*(1.0/255.0))+G.z*(1.0/65025.0);
+        #endif
     }
+
     #ifndef SHADOW_COMPARE
         #define SHADOW_COMPARE(a,b) ((a) < (b) ? 1.0 : 0.0)
     #endif
+
     #ifndef SHADOW_CLIP
         #define SHADOW_CLIP(c,v) v
     #endif
+
     float hK(sampler2D hL,highp vec2 hA,highp float H){
         #ifndef MOBILE
             highp vec2 c=hA*uShadowMapSize.x;
@@ -139,7 +146,7 @@ highp float hJ(highp vec3 G){
                 #ifdef MOBILE
                     hR*=.001+hO;
                 #else
-                hR*=.0005+0.5*hO;
+                    hR*=.0005+0.5*hO;
                 #endif
                 highp vec4 hS=h(uShadowMatrices[k],dv-hR*hu);
                 hV[k]=hS.xyz/hS.w;
@@ -163,5 +170,5 @@ highp float hJ(highp vec3 G){
             }
         }
     #endif
- #endif
+#endif