9
9
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.THREE = {}));
10
10
}(this, (function (exports) { 'use strict';
11
11
12
- const REVISION = '127dev ';
12
+ const REVISION = '127 ';
13
13
const MOUSE = {
14
14
LEFT: 0,
15
15
MIDDLE: 1,
303
303
mapLinear: function (x, a1, a2, b1, b2) {
304
304
return b1 + (x - a1) * (b2 - b1) / (a2 - a1);
305
305
},
306
+ // https://www.gamedev.net/tutorials/programming/general-and-gameplay-programming/inverse-lerp-a-super-useful-yet-often-overlooked-function-r5230/
307
+ inverseLerp: function (x, y, value) {
308
+ if (x !== y) {
309
+ return (value - x) / (y - x);
310
+ } else {
311
+ return 0;
312
+ }
313
+ },
306
314
// https://en.wikipedia.org/wiki/Linear_interpolation
307
315
lerp: function (x, y, t) {
308
316
return (1 - t) * x + t * y;
11840
11848
gl.uniform4fv(this.addr, v);
11841
11849
copyArray(cache, v);
11842
11850
}
11843
- } // Single matrix (from flat array or MatrixN)
11851
+ } // Single matrix (from flat array or THREE. MatrixN)
11844
11852
11845
11853
11846
11854
function setValueM2(gl, v) {
@@ -11889,22 +11897,70 @@
11889
11897
gl.uniformMatrix4fv(this.addr, false, mat4array);
11890
11898
copyArray(cache, elements);
11891
11899
}
11892
- } // Single texture (2D / Cube)
11900
+ } // Single integer / boolean
11893
11901
11894
11902
11895
- function setValueT1 (gl, v, textures ) {
11903
+ function setValueV1i (gl, v) {
11896
11904
const cache = this.cache;
11897
- const unit = textures.allocateTextureUnit();
11905
+ if (cache[0] === v) return;
11906
+ gl.uniform1i(this.addr, v);
11907
+ cache[0] = v;
11908
+ } // Single integer / boolean vector (from flat array)
11898
11909
11899
- if (cache[0] !== unit) {
11900
- gl.uniform1i(this.addr, unit);
11901
- cache[0] = unit;
11902
- }
11903
11910
11904
- textures.safeSetTexture2D(v || emptyTexture, unit);
11911
+ function setValueV2i(gl, v) {
11912
+ const cache = this.cache;
11913
+ if (arraysEqual(cache, v)) return;
11914
+ gl.uniform2iv(this.addr, v);
11915
+ copyArray(cache, v);
11905
11916
}
11906
11917
11907
- function setValueT2DArray1(gl, v, textures) {
11918
+ function setValueV3i(gl, v) {
11919
+ const cache = this.cache;
11920
+ if (arraysEqual(cache, v)) return;
11921
+ gl.uniform3iv(this.addr, v);
11922
+ copyArray(cache, v);
11923
+ }
11924
+
11925
+ function setValueV4i(gl, v) {
11926
+ const cache = this.cache;
11927
+ if (arraysEqual(cache, v)) return;
11928
+ gl.uniform4iv(this.addr, v);
11929
+ copyArray(cache, v);
11930
+ } // Single unsigned integer
11931
+
11932
+
11933
+ function setValueV1ui(gl, v) {
11934
+ const cache = this.cache;
11935
+ if (cache[0] === v) return;
11936
+ gl.uniform1ui(this.addr, v);
11937
+ cache[0] = v;
11938
+ } // Single unsigned integer vector (from flat array)
11939
+
11940
+
11941
+ function setValueV2ui(gl, v) {
11942
+ const cache = this.cache;
11943
+ if (arraysEqual(cache, v)) return;
11944
+ gl.uniform2uiv(this.addr, v);
11945
+ copyArray(cache, v);
11946
+ }
11947
+
11948
+ function setValueV3ui(gl, v) {
11949
+ const cache = this.cache;
11950
+ if (arraysEqual(cache, v)) return;
11951
+ gl.uniform3uiv(this.addr, v);
11952
+ copyArray(cache, v);
11953
+ }
11954
+
11955
+ function setValueV4ui(gl, v) {
11956
+ const cache = this.cache;
11957
+ if (arraysEqual(cache, v)) return;
11958
+ gl.uniform4uiv(this.addr, v);
11959
+ copyArray(cache, v);
11960
+ } // Single texture (2D / Cube)
11961
+
11962
+
11963
+ function setValueT1(gl, v, textures) {
11908
11964
const cache = this.cache;
11909
11965
const unit = textures.allocateTextureUnit();
11910
11966
11913
11969
cache[0] = unit;
11914
11970
}
11915
11971
11916
- textures.setTexture2DArray (v || emptyTexture2dArray , unit);
11972
+ textures.safeSetTexture2D (v || emptyTexture , unit);
11917
11973
}
11918
11974
11919
11975
function setValueT3D1(gl, v, textures) {
@@ -11938,43 +11994,18 @@
11938
11994
}
11939
11995
11940
11996
textures.safeSetTextureCube(v || emptyCubeTexture, unit);
11941
- } // Integer / Boolean vectors or arrays thereof (always flat arrays)
11942
-
11943
-
11944
- function setValueV1i(gl, v) {
11945
- const cache = this.cache;
11946
- if (cache[0] === v) return;
11947
- gl.uniform1i(this.addr, v);
11948
- cache[0] = v;
11949
- }
11950
-
11951
- function setValueV2i(gl, v) {
11952
- const cache = this.cache;
11953
- if (arraysEqual(cache, v)) return;
11954
- gl.uniform2iv(this.addr, v);
11955
- copyArray(cache, v);
11956
- }
11957
-
11958
- function setValueV3i(gl, v) {
11959
- const cache = this.cache;
11960
- if (arraysEqual(cache, v)) return;
11961
- gl.uniform3iv(this.addr, v);
11962
- copyArray(cache, v);
11963
11997
}
11964
11998
11965
- function setValueV4i (gl, v) {
11999
+ function setValueT2DArray1 (gl, v, textures ) {
11966
12000
const cache = this.cache;
11967
- if (arraysEqual(cache, v)) return;
11968
- gl.uniform4iv(this.addr, v);
11969
- copyArray(cache, v);
11970
- } // uint
12001
+ const unit = textures.allocateTextureUnit();
11971
12002
12003
+ if (cache[0] !== unit) {
12004
+ gl.uniform1i(this.addr, unit);
12005
+ cache[0] = unit;
12006
+ }
11972
12007
11973
- function setValueV1ui(gl, v) {
11974
- const cache = this.cache;
11975
- if (cache[0] === v) return;
11976
- gl.uniform1ui(this.addr, v);
11977
- cache[0] = v;
12008
+ textures.setTexture2DArray(v || emptyTexture2dArray, unit);
11978
12009
} // Helper to pick the right setter for the singular case
11979
12010
11980
12011
12032
12063
return setValueV1ui;
12033
12064
// UINT
12034
12065
12066
+ case 0x8dc6:
12067
+ return setValueV2ui;
12068
+ // _VEC2
12069
+
12070
+ case 0x8dc7:
12071
+ return setValueV3ui;
12072
+ // _VEC3
12073
+
12074
+ case 0x8dc8:
12075
+ return setValueV4ui;
12076
+ // _VEC4
12077
+
12035
12078
case 0x8b5e: // SAMPLER_2D
12036
12079
12037
12080
case 0x8d66: // SAMPLER_EXTERNAL_OES
12077
12120
12078
12121
function setValueV1fArray(gl, v) {
12079
12122
gl.uniform1fv(this.addr, v);
12080
- } // Integer / Boolean vectors or arrays thereof (always flat arrays)
12081
-
12082
-
12083
- function setValueV1iArray(gl, v) {
12084
- gl.uniform1iv(this.addr, v);
12085
- }
12086
-
12087
- function setValueV2iArray(gl, v) {
12088
- gl.uniform2iv(this.addr, v);
12089
- }
12090
-
12091
- function setValueV3iArray(gl, v) {
12092
- gl.uniform3iv(this.addr, v);
12093
- }
12094
-
12095
- function setValueV4iArray(gl, v) {
12096
- gl.uniform4iv(this.addr, v);
12097
- } // Array of vectors (flat or from THREE classes)
12123
+ } // Array of vectors (from flat array or array of THREE.VectorN)
12098
12124
12099
12125
12100
12126
function setValueV2fArray(gl, v) {
12110
12136
function setValueV4fArray(gl, v) {
12111
12137
const data = flatten(v, this.size, 4);
12112
12138
gl.uniform4fv(this.addr, data);
12113
- } // Array of matrices (flat or from THREE clases )
12139
+ } // Array of matrices (from flat array or array of THREE.MatrixN )
12114
12140
12115
12141
12116
12142
function setValueM2Array(gl, v) {
12126
12152
function setValueM4Array(gl, v) {
12127
12153
const data = flatten(v, this.size, 16);
12128
12154
gl.uniformMatrix4fv(this.addr, false, data);
12155
+ } // Array of integer / boolean
12156
+
12157
+
12158
+ function setValueV1iArray(gl, v) {
12159
+ gl.uniform1iv(this.addr, v);
12160
+ } // Array of integer / boolean vectors (from flat array)
12161
+
12162
+
12163
+ function setValueV2iArray(gl, v) {
12164
+ gl.uniform2iv(this.addr, v);
12165
+ }
12166
+
12167
+ function setValueV3iArray(gl, v) {
12168
+ gl.uniform3iv(this.addr, v);
12169
+ }
12170
+
12171
+ function setValueV4iArray(gl, v) {
12172
+ gl.uniform4iv(this.addr, v);
12173
+ } // Array of unsigned integer
12174
+
12175
+
12176
+ function setValueV1uiArray(gl, v) {
12177
+ gl.uniform1uiv(this.addr, v);
12178
+ } // Array of unsigned integer vectors (from flat array)
12179
+
12180
+
12181
+ function setValueV2uiArray(gl, v) {
12182
+ gl.uniform2uiv(this.addr, v);
12183
+ }
12184
+
12185
+ function setValueV3uiArray(gl, v) {
12186
+ gl.uniform3uiv(this.addr, v);
12187
+ }
12188
+
12189
+ function setValueV4uiArray(gl, v) {
12190
+ gl.uniform4uiv(this.addr, v);
12129
12191
} // Array of textures (2D / Cube)
12130
12192
12131
12193
12200
12262
return setValueV4iArray;
12201
12263
// _VEC4
12202
12264
12265
+ case 0x1405:
12266
+ return setValueV1uiArray;
12267
+ // UINT
12268
+
12269
+ case 0x8dc6:
12270
+ return setValueV2uiArray;
12271
+ // _VEC2
12272
+
12273
+ case 0x8dc7:
12274
+ return setValueV3uiArray;
12275
+ // _VEC3
12276
+
12277
+ case 0x8dc8:
12278
+ return setValueV4uiArray;
12279
+ // _VEC4
12280
+
12203
12281
case 0x8b5e: // SAMPLER_2D
12204
12282
12205
12283
case 0x8d66: // SAMPLER_EXTERNAL_OES
@@ -18319,10 +18397,10 @@
18319
18397
WebGL1Renderer.prototype.isWebGL1Renderer = true;
18320
18398
18321
18399
class FogExp2 {
18322
- constructor(color, density) {
18400
+ constructor(color, density = 0.00025 ) {
18323
18401
this.name = '';
18324
18402
this.color = new Color(color);
18325
- this.density = density !== undefined ? density : 0.00025 ;
18403
+ this.density = density;
18326
18404
}
18327
18405
18328
18406
clone() {
@@ -18344,11 +18422,11 @@
18344
18422
FogExp2.prototype.isFogExp2 = true;
18345
18423
18346
18424
class Fog {
18347
- constructor(color, near, far) {
18425
+ constructor(color, near = 1 , far = 1000 ) {
18348
18426
this.name = '';
18349
18427
this.color = new Color(color);
18350
- this.near = near !== undefined ? near : 1 ;
18351
- this.far = far !== undefined ? far : 1000 ;
18428
+ this.near = near;
18429
+ this.far = far;
18352
18430
}
18353
18431
18354
18432
clone() {
0 commit comments