Skip to content

Commit 6324623

Browse files
author
0x088730
committed
Replace '.indexOf' with '.includes' where applicable
1 parent f9dc840 commit 6324623

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

src/components/Canvas.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ This is a **svelthree** _Canvas_ Component.
244244
$svelthreeStores[sti].useBVH = useBVH
245245
246246
//if (!BufferGeometry.prototype.hasOwnProperty("computeBoundsTree")) {
247-
if (Object.keys(BufferGeometry.prototype).indexOf("computeBoundsTree") < 0) {
247+
if (!Object.keys(BufferGeometry.prototype).includes("computeBoundsTree")) {
248248
// backup original raycast function
249249
originalThreeRaycastFunction = Mesh.prototype.raycast
250250

src/components/Mesh.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ This is a **svelthree** _Mesh_ Component.
298298
// Using pre-made functions, see https://github.com/gkjohnson/three-mesh-bvh
299299
console.warn("SVELTHREE > Mesh : BVH -> Using BVH!")
300300
301-
if (Object.keys(BufferGeometry.prototype).indexOf("computeBoundsTree") > -1) {
301+
if (Object.keys(BufferGeometry.prototype).includes("computeBoundsTree")) {
302302
if (verbose && log_dev) console.debug(...c_dev(c_name, "Using BVH, mesh.matrixWorld: ", mesh.matrixWorld))
303303
304304
// TOFIX TODO BVH needs more love and documentation!

src/components/Points.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ This is a **svelthree** _Points_ Component.
306306
307307
console.warn("SVELTHREE > Points : (BVH) Using BVH!")
308308
309-
if (Object.keys(BufferGeometry.prototype).indexOf("computeBoundsTree") > -1) {
309+
if (Object.keys(BufferGeometry.prototype).includes("computeBoundsTree")) {
310310
if (verbose && log_dev)
311311
console.debug(...c_dev(c_name, "Using BVH, points.matrixWorld: ", points.matrixWorld))
312312

src/components/SessionAR.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ This is a **svelthree** _SessionAR_ Component.
6868
6969
function updateHitTestMode(): void {
7070
if (hitTestMode === XRDefaults.HITTEST_MODE_REALWORLD) {
71-
if (requiredFeatures.indexOf("hit-test") > -1) {
71+
if (requiredFeatures.includes("hit-test")) {
7272
$svelthreeStores[sti].xr.hitTestMode = hitTestMode
7373
} else {
7474
console.warn(

src/utils/SvelthreeLogger.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ function log_prop_utils(obj: any): boolean {
3535
return false
3636
}
3737
} else {
38-
if (obj.type.indexOf("Camera") > -1 && obj.parent === null && !obj.userData.svelthreeComponent) {
38+
if (obj.type.includes("Camera") && obj.parent === null && !obj.userData.svelthreeComponent) {
3939
//console.warn("[ REMARK ] SvelthreeLogger > PropUtils is (most propbably) about to change change props of an internal Shadow-Camera (OrthographicCamera)...", obj)
4040
if (obj.userData.log_dev) {
4141
return obj.userData.log_dev.all || obj.userData.log_dev.prop_utils
4242
} else {
4343
return false
4444
}
45-
} else if (obj.type.indexOf("Material") > -1) {
45+
} else if (obj.type.includes("Material")) {
4646
console.warn(
4747
"[ TODO ] SvelthreeLogger > Logging of Materials must be set manually by e.g. adding 'log_dev: { prop_utils: false }' to 'userData' ...",
4848
obj

src/xr/XRHandTouch.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -941,13 +941,13 @@ export default class XRHandTouch {
941941
handSpace.userData.jointsTouching = []
942942
}
943943

944-
if (handSpace.userData.jointsTouching.indexOf(i) < 0) {
944+
if (!handSpace.userData.jointsTouching.includes(i)) {
945945
handSpace.userData.jointsTouching.push[i]
946946
}
947947
}
948948

949949
removeJointFromTouchingArray(handSpace: Group, i: number) {
950-
if (handSpace.userData.jointsTouching.indexOf(i) > 0) {
950+
if (handSpace.userData.jointsTouching.includes(i)) {
951951
handSpace.userData.jointsTouching.splice(handSpace.userData.jointsTouching.indexOf(i), 1)
952952
}
953953
}
@@ -969,7 +969,7 @@ export default class XRHandTouch {
969969
getJointOrigin(joint: Group, jointIndex: number, handProfile: string, handedness: string): Vector3 {
970970
let origin: Vector3 = new Vector3().setFromMatrixPosition(joint.matrixWorld)
971971

972-
if (handProfile === XRDefaults.HAND_PROFILE_OCULUS && XRHandJointIndices.TIP.indexOf(jointIndex) > -1) {
972+
if (handProfile === XRDefaults.HAND_PROFILE_OCULUS && XRHandJointIndices.TIP.includes(jointIndex)) {
973973
const tipOriginOffset: number = this.getTipOriginOffset(handedness)
974974
origin = new Vector3(tipOriginOffset, 0, 0).applyMatrix4(joint.matrixWorld)
975975
}

0 commit comments

Comments
 (0)