Skip to content

Commit

Permalink
Merge pull request mrdoob#2 from mrdoob/dev
Browse files Browse the repository at this point in the history
Merge with main repo
  • Loading branch information
cabanier authored Nov 17, 2020
2 parents 3a13bf4 + 694c19e commit 1418c2b
Show file tree
Hide file tree
Showing 64 changed files with 1,519 additions and 684 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ As per the npm standard, ‘start’ is the place to begin the package.

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.

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

npm test

Expand Down
41 changes: 27 additions & 14 deletions build/three.js
Original file line number Diff line number Diff line change
Expand Up @@ -11106,23 +11106,26 @@
function needsUpdate(geometry, index) {
var cachedAttributes = currentState.attributes;
var geometryAttributes = geometry.attributes;
if (Object.keys(cachedAttributes).length !== Object.keys(geometryAttributes).length) return true;
var attributesNum = 0;

for (var key in geometryAttributes) {
var cachedAttribute = cachedAttributes[key];
var geometryAttribute = geometryAttributes[key];
if (cachedAttribute === undefined) return true;
if (cachedAttribute.attribute !== geometryAttribute) return true;
if (cachedAttribute.data !== geometryAttribute.data) return true;
attributesNum++;
}

if (currentState.attributesNum !== attributesNum) return true;
if (currentState.index !== index) return true;
return false;
}

function saveCache(geometry, index) {
var cache = {};
var attributes = geometry.attributes;
var attributesNum = 0;

for (var key in attributes) {
var attribute = attributes[key];
Expand All @@ -11134,9 +11137,11 @@
}

cache[key] = data;
attributesNum++;
}

currentState.attributes = cache;
currentState.attributesNum = attributesNum;
currentState.index = index;
}

Expand Down Expand Up @@ -18327,7 +18332,7 @@
var bones = skeleton.bones;

if (capabilities.floatVertexTextures) {
if (skeleton.boneTexture === undefined) {
if (skeleton.boneTexture === null) {
// layout (1 matrix = 4 pixels)
// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)
// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)
Expand Down Expand Up @@ -19435,6 +19440,9 @@
this.uuid = MathUtils.generateUUID();
this.bones = bones.slice(0);
this.boneInverses = boneInverses;
this.boneMatrices = null;
this.boneTexture = null;
this.boneTextureSize = 0;
this.frame = -1;
this.init();
}
Expand Down Expand Up @@ -19514,7 +19522,7 @@
_offsetMatrix.toArray(boneMatrices, i * 16);
}

if (boneTexture !== undefined) {
if (boneTexture !== null) {
boneTexture.needsUpdate = true;
}
},
Expand All @@ -19533,9 +19541,9 @@
return undefined;
},
dispose: function dispose() {
if (this.boneTexture) {
if (this.boneTexture !== null) {
this.boneTexture.dispose();
this.boneTexture = undefined;
this.boneTexture = null;
}
},
fromJSON: function fromJSON(json, bones) {
Expand Down Expand Up @@ -19607,12 +19615,8 @@
this.count = source.count;
return this;
},
setColorAt: function setColorAt(index, color) {
if (this.instanceColor === null) {
this.instanceColor = new BufferAttribute(new Float32Array(this.count * 3), 3);
}

color.toArray(this.instanceColor.array, index * 3);
getColorAt: function getColorAt(index, color) {
color.fromArray(this.instanceColor.array, index * 3);
},
getMatrixAt: function getMatrixAt(index, matrix) {
matrix.fromArray(this.instanceMatrix.array, index * 16);
Expand Down Expand Up @@ -19646,6 +19650,13 @@
_instanceIntersects.length = 0;
}
},
setColorAt: function setColorAt(index, color) {
if (this.instanceColor === null) {
this.instanceColor = new BufferAttribute(new Float32Array(this.count * 3), 3);
}

color.toArray(this.instanceColor.array, index * 3);
},
setMatrixAt: function setMatrixAt(index, matrix) {
matrix.toArray(this.instanceMatrix.array, index * 16);
},
Expand Down Expand Up @@ -20718,13 +20729,15 @@
* Duplicated vertices are removed
* and faces' vertices are updated.
*/
mergeVertices: function mergeVertices() {
mergeVertices: function mergeVertices(precisionPoints) {
if (precisionPoints === void 0) {
precisionPoints = 4;
}

var verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)

var unique = [],
changes = [];
var precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001

var precision = Math.pow(10, precisionPoints);

for (var i = 0, il = this.vertices.length; i < il; i++) {
Expand Down
2 changes: 1 addition & 1 deletion build/three.min.js

Large diffs are not rendered by default.

49 changes: 33 additions & 16 deletions build/three.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -12763,7 +12763,7 @@ function WebGLAttributes( gl, capabilities ) {

if ( attribute.isGLBufferAttribute ) {

var cached = buffers.get( attribute );
const cached = buffers.get( attribute );

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

Expand Down Expand Up @@ -14189,7 +14189,7 @@ function WebGLBindingStates( gl, extensions, attributes, capabilities ) {
const cachedAttributes = currentState.attributes;
const geometryAttributes = geometry.attributes;

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

for ( const key in geometryAttributes ) {

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

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

attributesNum ++;

}

if ( currentState.attributesNum !== attributesNum ) return true;

if ( currentState.index !== index ) return true;

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

const cache = {};
const attributes = geometry.attributes;
let attributesNum = 0;

for ( const key in attributes ) {

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

cache[ key ] = data;

attributesNum ++;

}

currentState.attributes = cache;
currentState.attributesNum = attributesNum;

currentState.index = index;

Expand Down Expand Up @@ -24687,7 +24695,7 @@ function WebGLRenderer( parameters ) {

if ( capabilities.floatVertexTextures ) {

if ( skeleton.boneTexture === undefined ) {
if ( skeleton.boneTexture === null ) {

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

this.bones = bones.slice( 0 );
this.boneInverses = boneInverses;
this.boneMatrices = null;

this.boneTexture = null;
this.boneTextureSize = 0;

this.frame = - 1;

Expand Down Expand Up @@ -26356,7 +26368,7 @@ Object.assign( Skeleton.prototype, {

}

if ( boneTexture !== undefined ) {
if ( boneTexture !== null ) {

boneTexture.needsUpdate = true;

Expand Down Expand Up @@ -26390,11 +26402,11 @@ Object.assign( Skeleton.prototype, {

dispose: function ( ) {

if ( this.boneTexture ) {
if ( this.boneTexture !== null ) {

this.boneTexture.dispose();

this.boneTexture = undefined;
this.boneTexture = null;

}

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

},

setColorAt: function ( index, color ) {

if ( this.instanceColor === null ) {

this.instanceColor = new BufferAttribute( new Float32Array( this.count * 3 ), 3 );
getColorAt: function ( index, color ) {

}

color.toArray( this.instanceColor.array, index * 3 );
color.fromArray( this.instanceColor.array, index * 3 );

},

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

},

setColorAt: function ( index, color ) {

if ( this.instanceColor === null ) {

this.instanceColor = new BufferAttribute( new Float32Array( this.count * 3 ), 3 );

}

color.toArray( this.instanceColor.array, index * 3 );

},

setMatrixAt: function ( index, matrix ) {

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

mergeVertices: function () {
mergeVertices: function ( precisionPoints = 4 ) {

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

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

for ( let i = 0, il = this.vertices.length; i < il; i ++ ) {
Expand Down
8 changes: 4 additions & 4 deletions docs/api/en/math/MathUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ <h3>[method:Float radToDeg]( [param:Float radians] )</h3>
<p>Converts radians to degrees.</p>

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

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

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

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

<h3>[method:Float smoothstep]( [param:Float x], [param:Float min], [param:Float max] )</h3>
<p>
Expand Down
29 changes: 29 additions & 0 deletions docs/api/en/objects/InstancedMesh.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ <h3>[property:Integer count]</h3>
If you need more instances than the original count value, you have to create a new [name].
</p>

<h3>[property:BufferAttribute instanceColor]</h3>
<p>
Represents the colors of all instances. *null* by default.
You have to set its [page:BufferAttribute.needsUpdate needsUpdate] flag to true if you modify instanced data via [page:.setColorAt]().
</p>

<h3>[property:BufferAttribute instanceMatrix]</h3>
<p>
Represents the local transformation of all instances.
Expand All @@ -60,6 +66,17 @@ <h3>[property:BufferAttribute instanceMatrix]</h3>
<h2>Methods</h2>
<p>See the base [page:Mesh] class for common methods.</p>

<h3>[method:null getColorAt]( [param:Integer index], [param:Color color] )</h3>
<p>
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
</p>
<p>
[page:Color color]: This color object will be set to the color of the defined instance.
</p>
<p>
Get the color of the defined instance.
</p>

<h3>[method:null getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
<p>
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
Expand All @@ -71,6 +88,18 @@ <h3>[method:null getMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</
Get the local transformation matrix of the defined instance.
</p>

<h3>[method:null setColorAt]( [param:Integer index], [param:Color color] )</h3>
<p>
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
</p>
<p>
[page:Color color]: The color of a single instance.
</p>
<p>
Sets the given color to the defined instance.
Make sure you set [page:.instanceColor][page:BufferAttribute.needsUpdate .needsUpdate] to true after updating all the colors.
</p>

<h3>[method:null setMatrixAt]( [param:Integer index], [param:Matrix4 matrix] )</h3>
<p>
[page:Integer index]: The index of an instance. Values have to be in the range [0, count].
Expand Down
6 changes: 5 additions & 1 deletion docs/api/en/renderers/WebGLRenderer.html
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,13 @@ <h3>[property:Object info]</h3>
</li>
</ul>
</p>
<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 :
<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.
First, set *autoReset* to *false*.
<code>
renderer.info.autoReset = false;
</code>
Call *reset()* whenever you have finished to render a single frame.
<code>
renderer.info.reset();
</code>
</p>
Expand Down
10 changes: 5 additions & 5 deletions docs/api/zh/math/MathUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h3>[method:Float lerp]( [param:Float x], [param:Float y], [param:Float t] )</h3
<p>
[page:Float x] - 起始点。 <br />
[page:Float y] - 终点。 <br />
[page:Float t] - 封闭区间[0,1]内的插值因子。<br><br />
[page:Float t] - 闭区间 [0,1] 内的插值因子。<br><br />

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

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

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

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

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

<h3>[method:Float smoothstep]( [param:Float x], [param:Float min], [param:Float max] )</h3>
<p>
Expand Down
Loading

0 comments on commit 1418c2b

Please sign in to comment.