Skip to content

Commit c1bf227

Browse files
authored
AnimationUtils: Remove arraySlice(). (mrdoob#26756)
* use default * exclusive * rm arraySlice * rm test, rm docs
1 parent ef417f0 commit c1bf227

File tree

10 files changed

+11
-68
lines changed

10 files changed

+11
-68
lines changed

docs/api/ar/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>[name]</h1>
1717
<h2>الوظائف (Methods)</h2>
1818

1919

20-
<h3>[method:Array arraySlice]( array, from, to )</h3>
21-
<p>
22-
نفسه عمل Array.prototype.slice ، ولكنه يعمل أيضًا على المصفوفات المكتوبة.
23-
</p>
24-
2520
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2621
<p>
2722
يحول مصفوفة إلى نوع معين.

docs/api/en/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ <h1>[name]</h1>
1616

1717
<h2>Methods</h2>
1818

19-
<h3>[method:Array arraySlice]( array, from, to )</h3>
20-
<p>
21-
This is the same as Array.prototype.slice, but also works on typed arrays.
22-
</p>
23-
2419
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2520
<p>Converts an array to a specific type.</p>
2621

docs/api/fr/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>[name]</h1>
1717
<h2>Méthodes</h2>
1818

1919

20-
<h3>[method:Array arraySlice]( array, from, to )</h3>
21-
<p>
22-
Cette méthode est la même que Array.prototype.slice, mais fonctionne également sur les tableaux typés.
23-
</p>
24-
2520
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2621
<p>
2722
Convertis un tableau en un type spécifique.

docs/api/it/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>[name]</h1>
1717
<h2>Metodi</h2>
1818

1919

20-
<h3>[method:Array arraySlice]( array, from, to )</h3>
21-
<p>
22-
È lo stesso di Array.prototype.slice, ma funziona anche su array tipizzati.
23-
</p>
24-
2520
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2621
<p>
2722
Converte un array in un tipo specifico.

docs/api/ko/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>[name]</h1>
1717
<h2>메서드</h2>
1818

1919

20-
<h3>[method:Array arraySlice]( array, from, to )</h3>
21-
<p>
22-
Array.prototype.slice와 동일하지만, 타입 배열에서도 작동합니다.
23-
</p>
24-
2520
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2621
<p>
2722
배열을 특정 타입으로 변환합니다.

docs/api/pt-br/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>[name]</h1>
1717
<h2>Métodos</h2>
1818

1919

20-
<h3>[method:Array arraySlice]( array, from, to )</h3>
21-
<p>
22-
É o mesmo que Array.prototype.slice, mas também funciona em arrays tipados.
23-
</p>
24-
2520
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2621
<p>
2722
Converte um array em um tipo específico.

docs/api/zh/animation/AnimationUtils.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ <h1>[name]</h1>
1717
<h2>方法</h2>
1818

1919

20-
<h3>[method:Array arraySlice]( array, from, to )</h3>
21-
<p>
22-
和Array.prototype.slice作用一样, 但也适用于类型化数组.
23-
</p>
24-
2520
<h3>[method:Array convertArray]( array, type, forceClone )</h3>
2621
<p>
2722
将数组转换为某种特定类型。

src/animation/AnimationUtils.js

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,6 @@
11
import { Quaternion } from '../math/Quaternion.js';
22
import { AdditiveAnimationBlendMode } from '../constants.js';
33

4-
// same as Array.prototype.slice, but also works on typed arrays
5-
function arraySlice( array, from, to ) {
6-
7-
if ( isTypedArray( array ) ) {
8-
9-
// in ios9 array.subarray(from, undefined) will return empty array
10-
// but array.subarray(from) or array.subarray(from, len) is correct
11-
return new array.constructor( array.subarray( from, to !== undefined ? to : array.length ) );
12-
13-
}
14-
15-
return array.slice( from, to );
16-
17-
}
18-
194
// converts an array to a specific type
205
function convertArray( array, type, forceClone ) {
216

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

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

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

291276
} else {
292277

@@ -295,7 +280,7 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
295280
const startIndex = referenceOffset;
296281
const endIndex = referenceValueSize - referenceOffset;
297282
interpolant.evaluate( referenceTime );
298-
referenceValue = arraySlice( interpolant.resultBuffer, startIndex, endIndex );
283+
referenceValue = interpolant.resultBuffer.slice( startIndex, endIndex );
299284

300285
}
301286

@@ -350,7 +335,6 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe
350335
}
351336

352337
const AnimationUtils = {
353-
arraySlice: arraySlice,
354338
convertArray: convertArray,
355339
isTypedArray: isTypedArray,
356340
getKeyframeOrder: getKeyframeOrder,
@@ -361,7 +345,6 @@ const AnimationUtils = {
361345
};
362346

363347
export {
364-
arraySlice,
365348
convertArray,
366349
isTypedArray,
367350
getKeyframeOrder,

src/animation/KeyframeTrack.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ class KeyframeTrack {
239239
}
240240

241241
const stride = this.getValueSize();
242-
this.times = AnimationUtils.arraySlice( times, from, to );
243-
this.values = AnimationUtils.arraySlice( this.values, from * stride, to * stride );
242+
this.times = times.slice( from, to );
243+
this.values = this.values.slice( from * stride, to * stride );
244244

245245
}
246246

@@ -330,8 +330,8 @@ class KeyframeTrack {
330330
optimize() {
331331

332332
// times or values may be shared with other tracks, so overwriting is unsafe
333-
const times = AnimationUtils.arraySlice( this.times ),
334-
values = AnimationUtils.arraySlice( this.values ),
333+
const times = this.times.slice(),
334+
values = this.values.slice(),
335335
stride = this.getValueSize(),
336336

337337
smoothInterpolation = this.getInterpolation() === InterpolateSmooth,
@@ -424,8 +424,8 @@ class KeyframeTrack {
424424

425425
if ( writeIndex !== times.length ) {
426426

427-
this.times = AnimationUtils.arraySlice( times, 0, writeIndex );
428-
this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride );
427+
this.times = times.slice( 0, writeIndex );
428+
this.values = values.slice( 0, writeIndex * stride );
429429

430430
} else {
431431

@@ -440,8 +440,8 @@ class KeyframeTrack {
440440

441441
clone() {
442442

443-
const times = AnimationUtils.arraySlice( this.times, 0 );
444-
const values = AnimationUtils.arraySlice( this.values, 0 );
443+
const times = this.times.slice();
444+
const values = this.values.slice();
445445

446446
const TypedKeyframeTrack = this.constructor;
447447
const track = new TypedKeyframeTrack( this.name, times, values );

test/unit/src/animation/AnimationUtils.tests.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ export default QUnit.module( 'Animation', () => {
77
QUnit.module( 'AnimationUtils', () => {
88

99
// PUBLIC
10-
QUnit.todo( 'arraySlice', ( assert ) => {
11-
12-
assert.ok( false, 'everything\'s gonna be alright' );
13-
14-
} );
1510

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

0 commit comments

Comments
 (0)