From c1bf227cf504b700c0b3e24e740bb76dec1cc276 Mon Sep 17 00:00:00 2001 From: ycw Date: Thu, 21 Sep 2023 16:14:29 +0800 Subject: [PATCH] AnimationUtils: Remove `arraySlice()`. (#26756) * use default * exclusive * rm arraySlice * rm test, rm docs --- docs/api/ar/animation/AnimationUtils.html | 5 ---- docs/api/en/animation/AnimationUtils.html | 5 ---- docs/api/fr/animation/AnimationUtils.html | 5 ---- docs/api/it/animation/AnimationUtils.html | 5 ---- docs/api/ko/animation/AnimationUtils.html | 5 ---- docs/api/pt-br/animation/AnimationUtils.html | 5 ---- docs/api/zh/animation/AnimationUtils.html | 5 ---- src/animation/AnimationUtils.js | 23 +++---------------- src/animation/KeyframeTrack.js | 16 ++++++------- .../src/animation/AnimationUtils.tests.js | 5 ---- 10 files changed, 11 insertions(+), 68 deletions(-) diff --git a/docs/api/ar/animation/AnimationUtils.html b/docs/api/ar/animation/AnimationUtils.html index 3e445b030fc437..6e3f53a7326640 100644 --- a/docs/api/ar/animation/AnimationUtils.html +++ b/docs/api/ar/animation/AnimationUtils.html @@ -17,11 +17,6 @@

[name]

الوظائف (Methods)

-

[method:Array arraySlice]( array, from, to )

-

- نفسه عمل Array.prototype.slice ، ولكنه يعمل أيضًا على المصفوفات المكتوبة. -

-

[method:Array convertArray]( array, type, forceClone )

يحول مصفوفة إلى نوع معين. diff --git a/docs/api/en/animation/AnimationUtils.html b/docs/api/en/animation/AnimationUtils.html index f29efdb7f6434e..7de9a9e8c7a80b 100644 --- a/docs/api/en/animation/AnimationUtils.html +++ b/docs/api/en/animation/AnimationUtils.html @@ -16,11 +16,6 @@

[name]

Methods

-

[method:Array arraySlice]( array, from, to )

-

- This is the same as Array.prototype.slice, but also works on typed arrays. -

-

[method:Array convertArray]( array, type, forceClone )

Converts an array to a specific type.

diff --git a/docs/api/fr/animation/AnimationUtils.html b/docs/api/fr/animation/AnimationUtils.html index 562e08b04fa4b4..905ea446afa9f1 100644 --- a/docs/api/fr/animation/AnimationUtils.html +++ b/docs/api/fr/animation/AnimationUtils.html @@ -17,11 +17,6 @@

[name]

Méthodes

-

[method:Array arraySlice]( array, from, to )

-

- Cette méthode est la même que Array.prototype.slice, mais fonctionne également sur les tableaux typés. -

-

[method:Array convertArray]( array, type, forceClone )

Convertis un tableau en un type spécifique. diff --git a/docs/api/it/animation/AnimationUtils.html b/docs/api/it/animation/AnimationUtils.html index 69afca9f9e87f7..47b394c0d482c3 100644 --- a/docs/api/it/animation/AnimationUtils.html +++ b/docs/api/it/animation/AnimationUtils.html @@ -17,11 +17,6 @@

[name]

Metodi

-

[method:Array arraySlice]( array, from, to )

-

- È lo stesso di Array.prototype.slice, ma funziona anche su array tipizzati. -

-

[method:Array convertArray]( array, type, forceClone )

Converte un array in un tipo specifico. diff --git a/docs/api/ko/animation/AnimationUtils.html b/docs/api/ko/animation/AnimationUtils.html index f318fa9a679fe7..10a92f732319ac 100644 --- a/docs/api/ko/animation/AnimationUtils.html +++ b/docs/api/ko/animation/AnimationUtils.html @@ -17,11 +17,6 @@

[name]

메서드

-

[method:Array arraySlice]( array, from, to )

-

- Array.prototype.slice와 동일하지만, 타입 배열에서도 작동합니다. -

-

[method:Array convertArray]( array, type, forceClone )

배열을 특정 타입으로 변환합니다. diff --git a/docs/api/pt-br/animation/AnimationUtils.html b/docs/api/pt-br/animation/AnimationUtils.html index 6ffc76fcb1339b..04002261794238 100644 --- a/docs/api/pt-br/animation/AnimationUtils.html +++ b/docs/api/pt-br/animation/AnimationUtils.html @@ -17,11 +17,6 @@

[name]

Métodos

-

[method:Array arraySlice]( array, from, to )

-

- É o mesmo que Array.prototype.slice, mas também funciona em arrays tipados. -

-

[method:Array convertArray]( array, type, forceClone )

Converte um array em um tipo específico. diff --git a/docs/api/zh/animation/AnimationUtils.html b/docs/api/zh/animation/AnimationUtils.html index dd68dc6ce9910b..75966937466c14 100644 --- a/docs/api/zh/animation/AnimationUtils.html +++ b/docs/api/zh/animation/AnimationUtils.html @@ -17,11 +17,6 @@

[name]

方法

-

[method:Array arraySlice]( array, from, to )

-

- 和Array.prototype.slice作用一样, 但也适用于类型化数组. -

-

[method:Array convertArray]( array, type, forceClone )

将数组转换为某种特定类型。 diff --git a/src/animation/AnimationUtils.js b/src/animation/AnimationUtils.js index 6cd6f5ba1ccb64..4b144c5370388f 100644 --- a/src/animation/AnimationUtils.js +++ b/src/animation/AnimationUtils.js @@ -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 ) { @@ -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 { @@ -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 ); } @@ -350,7 +335,6 @@ function makeClipAdditive( targetClip, referenceFrame = 0, referenceClip = targe } const AnimationUtils = { - arraySlice: arraySlice, convertArray: convertArray, isTypedArray: isTypedArray, getKeyframeOrder: getKeyframeOrder, @@ -361,7 +345,6 @@ const AnimationUtils = { }; export { - arraySlice, convertArray, isTypedArray, getKeyframeOrder, diff --git a/src/animation/KeyframeTrack.js b/src/animation/KeyframeTrack.js index 1a85cae1b3ea28..9da91c67f0991c 100644 --- a/src/animation/KeyframeTrack.js +++ b/src/animation/KeyframeTrack.js @@ -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 ); } @@ -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, @@ -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 { @@ -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 ); diff --git a/test/unit/src/animation/AnimationUtils.tests.js b/test/unit/src/animation/AnimationUtils.tests.js index f737ce677772ea..195f1e2d569a4f 100644 --- a/test/unit/src/animation/AnimationUtils.tests.js +++ b/test/unit/src/animation/AnimationUtils.tests.js @@ -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 ) => {