Skip to content

Commit

Permalink
Replace '.indexOf' with '.includes' where applicable
Browse files Browse the repository at this point in the history
  • Loading branch information
0x088730 committed Dec 10, 2021
1 parent f9dc840 commit 6324623
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/Canvas.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ This is a **svelthree** _Canvas_ Component.
$svelthreeStores[sti].useBVH = useBVH
//if (!BufferGeometry.prototype.hasOwnProperty("computeBoundsTree")) {
if (Object.keys(BufferGeometry.prototype).indexOf("computeBoundsTree") < 0) {
if (!Object.keys(BufferGeometry.prototype).includes("computeBoundsTree")) {
// backup original raycast function
originalThreeRaycastFunction = Mesh.prototype.raycast
Expand Down
2 changes: 1 addition & 1 deletion src/components/Mesh.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ This is a **svelthree** _Mesh_ Component.
// Using pre-made functions, see https://github.com/gkjohnson/three-mesh-bvh
console.warn("SVELTHREE > Mesh : BVH -> Using BVH!")
if (Object.keys(BufferGeometry.prototype).indexOf("computeBoundsTree") > -1) {
if (Object.keys(BufferGeometry.prototype).includes("computeBoundsTree")) {
if (verbose && log_dev) console.debug(...c_dev(c_name, "Using BVH, mesh.matrixWorld: ", mesh.matrixWorld))
// TOFIX TODO BVH needs more love and documentation!
Expand Down
2 changes: 1 addition & 1 deletion src/components/Points.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ This is a **svelthree** _Points_ Component.
console.warn("SVELTHREE > Points : (BVH) Using BVH!")
if (Object.keys(BufferGeometry.prototype).indexOf("computeBoundsTree") > -1) {
if (Object.keys(BufferGeometry.prototype).includes("computeBoundsTree")) {
if (verbose && log_dev)
console.debug(...c_dev(c_name, "Using BVH, points.matrixWorld: ", points.matrixWorld))
Expand Down
2 changes: 1 addition & 1 deletion src/components/SessionAR.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ This is a **svelthree** _SessionAR_ Component.
function updateHitTestMode(): void {
if (hitTestMode === XRDefaults.HITTEST_MODE_REALWORLD) {
if (requiredFeatures.indexOf("hit-test") > -1) {
if (requiredFeatures.includes("hit-test")) {
$svelthreeStores[sti].xr.hitTestMode = hitTestMode
} else {
console.warn(
Expand Down
4 changes: 2 additions & 2 deletions src/utils/SvelthreeLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ function log_prop_utils(obj: any): boolean {
return false
}
} else {
if (obj.type.indexOf("Camera") > -1 && obj.parent === null && !obj.userData.svelthreeComponent) {
if (obj.type.includes("Camera") && obj.parent === null && !obj.userData.svelthreeComponent) {
//console.warn("[ REMARK ] SvelthreeLogger > PropUtils is (most propbably) about to change change props of an internal Shadow-Camera (OrthographicCamera)...", obj)
if (obj.userData.log_dev) {
return obj.userData.log_dev.all || obj.userData.log_dev.prop_utils
} else {
return false
}
} else if (obj.type.indexOf("Material") > -1) {
} else if (obj.type.includes("Material")) {
console.warn(
"[ TODO ] SvelthreeLogger > Logging of Materials must be set manually by e.g. adding 'log_dev: { prop_utils: false }' to 'userData' ...",
obj
Expand Down
6 changes: 3 additions & 3 deletions src/xr/XRHandTouch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,13 +941,13 @@ export default class XRHandTouch {
handSpace.userData.jointsTouching = []
}

if (handSpace.userData.jointsTouching.indexOf(i) < 0) {
if (!handSpace.userData.jointsTouching.includes(i)) {
handSpace.userData.jointsTouching.push[i]
}
}

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

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

0 comments on commit 6324623

Please sign in to comment.