Skip to content

Commit

Permalink
AnimationUtils: Remove arraySlice(). (mrdoob#26756)
Browse files Browse the repository at this point in the history
* use default

* exclusive

* rm arraySlice

* rm test, rm docs
  • Loading branch information
ycw committed Sep 21, 2023
1 parent ef417f0 commit c1bf227
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 68 deletions.
5 changes: 0 additions & 5 deletions docs/api/ar/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ <h1>[name]</h1>
<h2>الوظائف (Methods)</h2>


<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
نفسه عمل Array.prototype.slice ، ولكنه يعمل أيضًا على المصفوفات المكتوبة.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>
يحول مصفوفة إلى نوع معين.
Expand Down
5 changes: 0 additions & 5 deletions docs/api/en/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ <h1>[name]</h1>

<h2>Methods</h2>

<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
This is the same as Array.prototype.slice, but also works on typed arrays.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>Converts an array to a specific type.</p>

Expand Down
5 changes: 0 additions & 5 deletions docs/api/fr/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ <h1>[name]</h1>
<h2>Méthodes</h2>


<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
Cette méthode est la même que Array.prototype.slice, mais fonctionne également sur les tableaux typés.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>
Convertis un tableau en un type spécifique.
Expand Down
5 changes: 0 additions & 5 deletions docs/api/it/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ <h1>[name]</h1>
<h2>Metodi</h2>


<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
È lo stesso di Array.prototype.slice, ma funziona anche su array tipizzati.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>
Converte un array in un tipo specifico.
Expand Down
5 changes: 0 additions & 5 deletions docs/api/ko/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ <h1>[name]</h1>
<h2>메서드</h2>


<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
Array.prototype.slice와 동일하지만, 타입 배열에서도 작동합니다.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>
배열을 특정 타입으로 변환합니다.
Expand Down
5 changes: 0 additions & 5 deletions docs/api/pt-br/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ <h1>[name]</h1>
<h2>Métodos</h2>


<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
É o mesmo que Array.prototype.slice, mas também funciona em arrays tipados.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>
Converte um array em um tipo específico.
Expand Down
5 changes: 0 additions & 5 deletions docs/api/zh/animation/AnimationUtils.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ <h1>[name]</h1>
<h2>方法</h2>


<h3>[method:Array arraySlice]( array, from, to )</h3>
<p>
和Array.prototype.slice作用一样, 但也适用于类型化数组.
</p>

<h3>[method:Array convertArray]( array, type, forceClone )</h3>
<p>
将数组转换为某种特定类型。
Expand Down
23 changes: 3 additions & 20 deletions src/animation/AnimationUtils.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
import { Quaternion } from '../math/Quaternion.js';
import { AdditiveAnimationBlendMode } from '../constants.js';

// same as Array.prototype.slice, but also works on typed arrays
function arraySlice( array, from, to ) {

if ( isTypedArray( array ) ) {

// in ios9 array.subarray(from, undefined) will return empty array
// but array.subarray(from) or array.subarray(from, len) is correct
return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) );

}

return array.slice( from, to );

}

// converts an array to a specific type
function convertArray( array, type, forceClone ) {

Expand Down Expand Up @@ -279,14 +264,14 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
// Reference frame is earlier than the first keyframe, so just use the first keyframe
const startIndex = referenceOffset;
const endIndex = referenceValueSize - referenceOffset;
referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex );
referenceValue = referenceTrack.values.slice( startIndex, endIndex );

} else if ( referenceTime >= referenceTrack.times[ lastIndex ] ) {

// Reference frame is after the last keyframe, so just use the last keyframe
const startIndex = lastIndex * referenceValueSize + referenceOffset;
const endIndex = startIndex + referenceValueSize - referenceOffset;
referenceValue = arraySlice( referenceTrack.values, startIndex, endIndex );
referenceValue = referenceTrack.values.slice( startIndex, endIndex );

} else {

Expand All @@ -295,7 +280,7 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
const startIndex = referenceOffset;
const endIndex = referenceValueSize - referenceOffset;
interpolant.evaluate( referenceTime );
referenceValue = arraySlice( interpolant.resultBuffer, startIndex, endIndex );
referenceValue = interpolant.resultBuffer.slice( startIndex, endIndex );

}

Expand Down Expand Up @@ -350,7 +335,6 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
}

const AnimationUtils = {
arraySlice: arraySlice,
convertArray: convertArray,
isTypedArray: isTypedArray,
getKeyframeOrder: getKeyframeOrder,
Expand All @@ -361,7 +345,6 @@ const AnimationUtils = {
};

export {
arraySlice,
convertArray,
isTypedArray,
getKeyframeOrder,
Expand Down
16 changes: 8 additions & 8 deletions src/animation/KeyframeTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ class KeyframeTrack {
}

const stride = this.getValueSize();
this.times = AnimationUtils.arraySlice( times, from, to );
this.values = AnimationUtils.arraySlice( this.values, from * stride, to * stride );
this.times = times.slice( from, to );
this.values = this.values.slice( from * stride, to * stride );

}

Expand Down Expand Up @@ -330,8 +330,8 @@ class KeyframeTrack {
optimize() {

// times or values may be shared with other tracks, so overwriting is unsafe
const times = AnimationUtils.arraySlice( this.times ),
values = AnimationUtils.arraySlice( this.values ),
const times = this.times.slice(),
values = this.values.slice(),
stride = this.getValueSize(),

smoothInterpolation = this.getInterpolation() === InterpolateSmooth,
Expand Down Expand Up @@ -424,8 +424,8 @@ class KeyframeTrack {

if ( writeIndex !== times.length ) {

this.times = AnimationUtils.arraySlice( times, 0, writeIndex );
this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride );
this.times = times.slice( 0, writeIndex );
this.values = values.slice( 0, writeIndex * stride );

} else {

Expand All @@ -440,8 +440,8 @@ class KeyframeTrack {

clone() {

const times = AnimationUtils.arraySlice( this.times, 0 );
const values = AnimationUtils.arraySlice( this.values, 0 );
const times = this.times.slice();
const values = this.values.slice();

const TypedKeyframeTrack = this.constructor;
const track = new TypedKeyframeTrack( this.name, times, values );
Expand Down
5 changes: 0 additions & 5 deletions test/unit/src/animation/AnimationUtils.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ export default QUnit.module( 'Animation', () => {
QUnit.module( 'AnimationUtils', () => {

// PUBLIC
QUnit.todo( 'arraySlice', ( assert ) => {

assert.ok( false, 'everything\'s gonna be alright' );

} );

QUnit.todo( 'convertArray', ( assert ) => {

Expand Down

0 comments on commit c1bf227

Please sign in to comment.