Skip to content

Commit 1418c2b

Browse files
authored
Merge pull request #2 from mrdoob/dev
Merge with main repo
2 parents 3a13bf4 + 694c19e commit 1418c2b

File tree

64 files changed

+1519
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1519
-684
lines changed

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ As per the npm standard, ‘start’ is the place to begin the package.
2828

2929
This script will start a local server similar to [threejs.org](https://threejs.org/), but instead will be hosted on your local machine. Browse to http://localhost:8080/ to check it out. It also automatically creates the ‘build/three.js’ and ‘build/three.module.js’ scripts anytime there is a change within your three.js directory.
3030

31-
The next most important script runs all the appropriate testing.
31+
The next most important script runs all the appropriate testing. The E-2-E testing is intended to be run by github actions.
3232

3333
npm test
3434

build/three.js

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11106,23 +11106,26 @@
1110611106
function needsUpdate(geometry, index) {
1110711107
var cachedAttributes = currentState.attributes;
1110811108
var geometryAttributes = geometry.attributes;
11109-
if (Object.keys(cachedAttributes).length !== Object.keys(geometryAttributes).length) return true;
11109+
var attributesNum = 0;
1111011110

1111111111
for (var key in geometryAttributes) {
1111211112
var cachedAttribute = cachedAttributes[key];
1111311113
var geometryAttribute = geometryAttributes[key];
1111411114
if (cachedAttribute === undefined) return true;
1111511115
if (cachedAttribute.attribute !== geometryAttribute) return true;
1111611116
if (cachedAttribute.data !== geometryAttribute.data) return true;
11117+
attributesNum++;
1111711118
}
1111811119

11120+
if (currentState.attributesNum !== attributesNum) return true;
1111911121
if (currentState.index !== index) return true;
1112011122
return false;
1112111123
}
1112211124

1112311125
function saveCache(geometry, index) {
1112411126
var cache = {};
1112511127
var attributes = geometry.attributes;
11128+
var attributesNum = 0;
1112611129

1112711130
for (var key in attributes) {
1112811131
var attribute = attributes[key];
@@ -11134,9 +11137,11 @@
1113411137
}
1113511138

1113611139
cache[key] = data;
11140+
attributesNum++;
1113711141
}
1113811142

1113911143
currentState.attributes = cache;
11144+
currentState.attributesNum = attributesNum;
1114011145
currentState.index = index;
1114111146
}
1114211147

@@ -18327,7 +18332,7 @@
1832718332
var bones = skeleton.bones;
1832818333

1832918334
if (capabilities.floatVertexTextures) {
18330-
if (skeleton.boneTexture === undefined) {
18335+
if (skeleton.boneTexture === null) {
1833118336
// layout (1 matrix = 4 pixels)
1833218337
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
1833318338
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
@@ -19435,6 +19440,9 @@
1943519440
this.uuid = MathUtils.generateUUID();
1943619441
this.bones = bones.slice(0);
1943719442
this.boneInverses = boneInverses;
19443+
this.boneMatrices = null;
19444+
this.boneTexture = null;
19445+
this.boneTextureSize = 0;
1943819446
this.frame = -1;
1943919447
this.init();
1944019448
}
@@ -19514,7 +19522,7 @@
1951419522
_offsetMatrix.toArray(boneMatrices, i * 16);
1951519523
}
1951619524

19517-
if (boneTexture !== undefined) {
19525+
if (boneTexture !== null) {
1951819526
boneTexture.needsUpdate = true;
1951919527
}
1952019528
},
@@ -19533,9 +19541,9 @@
1953319541
return undefined;
1953419542
},
1953519543
dispose: function dispose() {
19536-
if (this.boneTexture) {
19544+
if (this.boneTexture !== null) {
1953719545
this.boneTexture.dispose();
19538-
this.boneTexture = undefined;
19546+
this.boneTexture = null;
1953919547
}
1954019548
},
1954119549
fromJSON: function fromJSON(json, bones) {
@@ -19607,12 +19615,8 @@
1960719615
this.count = source.count;
1960819616
return this;
1960919617
},
19610-
setColorAt: function setColorAt(index, color) {
19611-
if (this.instanceColor === null) {
19612-
this.instanceColor = new BufferAttribute(new Float32Array(this.count * 3), 3);
19613-
}
19614-
19615-
color.toArray(this.instanceColor.array, index * 3);
19618+
getColorAt: function getColorAt(index, color) {
19619+
color.fromArray(this.instanceColor.array, index * 3);
1961619620
},
1961719621
getMatrixAt: function getMatrixAt(index, matrix) {
1961819622
matrix.fromArray(this.instanceMatrix.array, index * 16);
@@ -19646,6 +19650,13 @@
1964619650
_instanceIntersects.length = 0;
1964719651
}
1964819652
},
19653+
setColorAt: function setColorAt(index, color) {
19654+
if (this.instanceColor === null) {
19655+
this.instanceColor = new BufferAttribute(new Float32Array(this.count * 3), 3);
19656+
}
19657+
19658+
color.toArray(this.instanceColor.array, index * 3);
19659+
},
1964919660
setMatrixAt: function setMatrixAt(index, matrix) {
1965019661
matrix.toArray(this.instanceMatrix.array, index * 16);
1965119662
},
@@ -20718,13 +20729,15 @@
2071820729
* Duplicated vertices are removed
2071920730
* and faces' vertices are updated.
2072020731
*/
20721-
mergeVertices: function mergeVertices() {
20732+
mergeVertices: function mergeVertices(precisionPoints) {
20733+
if (precisionPoints === void 0) {
20734+
precisionPoints = 4;
20735+
}
20736+
2072220737
var verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)
2072320738

2072420739
var unique = [],
2072520740
changes = [];
20726-
var precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001
20727-
2072820741
var precision = Math.pow(10, precisionPoints);
2072920742

2073020743
for (var i = 0, il = this.vertices.length; i < il; i++) {

build/three.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/three.module.js

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12763,7 +12763,7 @@ function WebGLAttributes( gl, capabilities ) {
1276312763

1276412764
if ( attribute.isGLBufferAttribute ) {
1276512765

12766-
var cached = buffers.get( attribute );
12766+
const cached = buffers.get( attribute );
1276712767

1276812768
if ( ! cached || cached.version < attribute.version ) {
1276912769

@@ -14189,7 +14189,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
1418914189
const cachedAttributes = currentState.attributes;
1419014190
const geometryAttributes = geometry.attributes;
1419114191

14192-
if ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;
14192+
let attributesNum = 0;
1419314193

1419414194
for ( const key in geometryAttributes ) {
1419514195

@@ -14202,8 +14202,12 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
1420214202

1420314203
if ( cachedAttribute.data !== geometryAttribute.data ) return true;
1420414204

14205+
attributesNum ++;
14206+
1420514207
}
1420614208

14209+
if ( currentState.attributesNum !== attributesNum ) return true;
14210+
1420714211
if ( currentState.index !== index ) return true;
1420814212

1420914213
return false;
@@ -14214,6 +14218,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
1421414218

1421514219
const cache = {};
1421614220
const attributes = geometry.attributes;
14221+
let attributesNum = 0;
1421714222

1421814223
for ( const key in attributes ) {
1421914224

@@ -14230,9 +14235,12 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
1423014235

1423114236
cache[ key ] = data;
1423214237

14238+
attributesNum ++;
14239+
1423314240
}
1423414241

1423514242
currentState.attributes = cache;
14243+
currentState.attributesNum = attributesNum;
1423614244

1423714245
currentState.index = index;
1423814246

@@ -24687,7 +24695,7 @@ function WebGLRenderer( parameters ) {
2468724695

2468824696
if ( capabilities.floatVertexTextures ) {
2468924697

24690-
if ( skeleton.boneTexture === undefined ) {
24698+
if ( skeleton.boneTexture === null ) {
2469124699

2469224700
// layout (1 matrix = 4 pixels)
2469324701
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
@@ -26229,6 +26237,10 @@ function Skeleton( bones = [], boneInverses = [] ) {
2622926237

2623026238
this.bones = bones.slice( 0 );
2623126239
this.boneInverses = boneInverses;
26240+
this.boneMatrices = null;
26241+
26242+
this.boneTexture = null;
26243+
this.boneTextureSize = 0;
2623226244

2623326245
this.frame = - 1;
2623426246

@@ -26356,7 +26368,7 @@ Object.assign( Skeleton.prototype, {
2635626368

2635726369
}
2635826370

26359-
if ( boneTexture !== undefined ) {
26371+
if ( boneTexture !== null ) {
2636026372

2636126373
boneTexture.needsUpdate = true;
2636226374

@@ -26390,11 +26402,11 @@ Object.assign( Skeleton.prototype, {
2639026402

2639126403
dispose: function ( ) {
2639226404

26393-
if ( this.boneTexture ) {
26405+
if ( this.boneTexture !== null ) {
2639426406

2639526407
this.boneTexture.dispose();
2639626408

26397-
this.boneTexture = undefined;
26409+
this.boneTexture = null;
2639826410

2639926411
}
2640026412

@@ -26497,15 +26509,9 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
2649726509

2649826510
},
2649926511

26500-
setColorAt: function ( index, color ) {
26501-
26502-
if ( this.instanceColor === null ) {
26503-
26504-
this.instanceColor = new BufferAttribute( new Float32Array( this.count * 3 ), 3 );
26512+
getColorAt: function ( index, color ) {
2650526513

26506-
}
26507-
26508-
color.toArray( this.instanceColor.array, index * 3 );
26514+
color.fromArray( this.instanceColor.array, index * 3 );
2650926515

2651026516
},
2651126517

@@ -26556,6 +26562,18 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
2655626562

2655726563
},
2655826564

26565+
setColorAt: function ( index, color ) {
26566+
26567+
if ( this.instanceColor === null ) {
26568+
26569+
this.instanceColor = new BufferAttribute( new Float32Array( this.count * 3 ), 3 );
26570+
26571+
}
26572+
26573+
color.toArray( this.instanceColor.array, index * 3 );
26574+
26575+
},
26576+
2655926577
setMatrixAt: function ( index, matrix ) {
2656026578

2656126579
matrix.toArray( this.instanceMatrix.array, index * 16 );
@@ -28108,12 +28126,11 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
2810828126
* and faces' vertices are updated.
2810928127
*/
2811028128

28111-
mergeVertices: function () {
28129+
mergeVertices: function ( precisionPoints = 4 ) {
2811228130

2811328131
const verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)
2811428132
const unique = [], changes = [];
2811528133

28116-
const precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001
2811728134
const precision = Math.pow( 10, precisionPoints );
2811828135

2811928136
for ( let i = 0, il = this.vertices.length; i < il; i ++ ) {

docs/api/en/math/MathUtils.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ <h3>[method:Float radToDeg]( [param:Float radians] )</h3>
7474
<p>Converts radians to degrees.</p>
7575

7676
<h3>[method:Float randFloat]( [param:Float low], [param:Float high] )</h3>
77-
<p>Random float in the interval [page:Float low] to [page:Float high].</p>
77+
<p>Random float in the interval [[page:Float low], [page:Float high]].</p>
7878

7979
<h3>[method:Float randFloatSpread]( [param:Float range] )</h3>
80-
<p>Random float in the interval *- [page:Float range] / 2* to *[page:Float range] / 2*.</p>
80+
<p>Random float in the interval [- [page:Float range] / 2, [page:Float range] / 2].</p>
8181

8282
<h3>[method:Integer randInt]( [param:Integer low], [param:Integer high] )</h3>
83-
<p>Random integer in the interval [page:Float low] to [page:Float high].</p>
83+
<p>Random integer in the interval [[page:Float low], [page:Float high]].</p>
8484

8585
<h3>[method:Float seededRandom]( [param:Integer seed] )</h3>
86-
<p>Deterministic pseudo-random float in the interval [ 0, 1 ]. The integer [page:Integer seed] is optional.</p>
86+
<p>Deterministic pseudo-random float in the interval [0, 1]. The integer [page:Integer seed] is optional.</p>
8787

8888
<h3>[method:Float smoothstep]( [param:Float x], [param:Float min], [param:Float max] )</h3>
8989
<p>

docs/api/en/objects/InstancedMesh.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ <h3>[property:Integer count]</h3>
5151
If you need more instances than the original count value, you have to create a new [name].
5252
</p>
5353

54+
<h3>[property:BufferAttribute instanceColor]</h3>
55+
<p>
56+
Represents the colors of all instances. *null* by default.
57+
You have to set its [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you modify instanced data via [page:.setColorAt]().
58+
</p>
59+
5460
<h3>[property:BufferAttribute instanceMatrix]</h3>
5561
<p>
5662
Represents the local transformation of all instances.
@@ -60,6 +66,17 @@ <h3>[property:BufferAttribute instanceMatrix]</h3>
6066
<h2>Methods</h2>
6167
<p>See the base [page:Mesh] class for common methods.</p>
6268

69+
<h3>[method:null getColorAt]( [param:Integer index], [param:Color color] )</h3>
70+
<p>
71+
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
72+
</p>
73+
<p>
74+
[page:Color color]: This color object will be set to the color of the defined instance.
75+
</p>
76+
<p>
77+
Get the color of the defined instance.
78+
</p>
79+
6380
<h3>[method:null getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
6481
<p>
6582
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
@@ -71,6 +88,18 @@ <h3>[method:null getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</
7188
Get the local transformation matrix of the defined instance.
7289
</p>
7390

91+
<h3>[method:null setColorAt]( [param:Integer index], [param:Color color] )</h3>
92+
<p>
93+
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
94+
</p>
95+
<p>
96+
[page:Color color]: The color of a single instance.
97+
</p>
98+
<p>
99+
Sets the given color to the defined instance.
100+
Make sure you set [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] to true after updating all the colors.
101+
</p>
102+
74103
<h3>[method:null setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
75104
<p>
76105
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].

docs/api/en/renderers/WebGLRenderer.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,13 @@ <h3>[property:Object info]</h3>
191191
</li>
192192
</ul>
193193
</p>
194-
<p>By default these data are reset at each render calls, but when using the composer or mirrors it can be preferred to reset them with a custom pattern :
194+
<p>By default these data are reset at each render call but when having multiple render passes per frame (e.g. when using post processing) it can be preferred to reset with a custom pattern.
195+
First, set *autoReset* to *false*.
195196
<code>
196197
renderer.info.autoReset = false;
198+
</code>
199+
Call *reset()* whenever you have finished to render a single frame.
200+
<code>
197201
renderer.info.reset();
198202
</code>
199203
</p>

docs/api/zh/math/MathUtils.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ <h3>[method:Float lerp]( [param:Float x], [param:Float y], [param:Float t] )</h3
4444
<p>
4545
[page:Float x] - 起始点。 <br />
4646
[page:Float y] - 终点。 <br />
47-
[page:Float t] - 封闭区间[0,1]内的插值因子。<br><br />
47+
[page:Float t] - 闭区间 [0,1] 内的插值因子。<br><br />
4848

4949
返回给定区间的线性插值[link:https://en.wikipedia.org/wiki/Linear_interpolation linearly interpolated]结果 - [page:Float t] = 0 将会返回 [page:Float x]
5050
如果 [page:Float t] = 1 将会返回 [page:Float y].
@@ -71,16 +71,16 @@ <h3>[method:Float radToDeg]( [param:Float radians] )</h3>
7171
<p>将弧度转换为角度。</p>
7272

7373
<h3>[method:Float randFloat]( [param:Float low], [param:Float high] )</h3>
74-
<p>在区间[page:Float low][page:Float high]随机一个浮点数</p>
74+
<p>在区间 [[page:Float low], [page:Float high]] 内随机一个浮点数</p>
7575

7676
<h3>[method:Float randFloatSpread]( [param:Float range] )</h3>
77-
<p>在区间*- [page:Float range] / 2* 到 *[page:Float range] / 2*随机一个浮点数</p>
77+
<p>在区间 [- [page:Float range] / 2, [page:Float range] / 2] 内随机一个浮点数</p>
7878

7979
<h3>[method:Integer randInt]( [param:Integer low], [param:Integer high] )</h3>
80-
<p>在区间[page:Float low][page:Float high]随机一个整数</p>
80+
<p>在区间 [[page:Float low], [page:Float high]] 内随机一个整数</p>
8181

8282
<h3>[method:Float seededRandom]( [param:Integer seed] )</h3>
83-
<p>Deterministic pseudo-random float in the interval [ 0, 1 ]. The integer [page:Integer seed] is optional.</p>
83+
<p>在区间 [0, 1] 中生成确定性的伪随机浮点数。 整数种子是可选的。</p>
8484

8585
<h3>[method:Float smoothstep]( [param:Float x], [param:Float min], [param:Float max] )</h3>
8686
<p>

0 commit comments

Comments
 (0)