Skip to content

Commit

Permalink
fix: remove remaining incompatible deps
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyJasonBennett committed Jan 4, 2025
1 parent e187dcd commit f9d9138
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@
"hls.js": "^1.5.17",
"maath": "^0.10.8",
"meshline": "^3.3.1",
"react-composer": "^5.0.3",
"stats-gl": "^2.2.8",
"stats.js": "^0.17.0",
"suspend-react": "^0.1.3",
"three-mesh-bvh": "^0.7.8",
"three-stdlib": "^2.34.0",
"troika-three-text": "^0.52.0",
"tunnel-rat": "^0.1.2",
"use-sync-external-store": "^1.4.0",
"utility-types": "^3.11.0",
"uuid": "^9.0.1",
"zustand": "^5.0.1"
Expand Down
52 changes: 26 additions & 26 deletions src/core/Instances.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as THREE from 'three'
import * as React from 'react'
import { ThreeElement, ThreeElements, extend, useFrame } from '@react-three/fiber'
import Composer from 'react-composer'
import { ForwardRefComponent } from '../helpers/ts-utils'
import { setUpdateRange } from '../helpers/deprecated'

Expand Down Expand Up @@ -224,32 +223,33 @@ export interface MergedProps extends InstancesProps {
children: React.ReactNode
}

export const Merged: ForwardRefComponent<any, THREE.Group> = /* @__PURE__ */ React.forwardRef<THREE.Group, any>(
function Merged({ meshes, children, ...props }, ref) {
const isArray = Array.isArray(meshes)
// Filter out meshes from collections, which may contain non-meshes
if (!isArray) for (const key of Object.keys(meshes)) if (!meshes[key].isMesh) delete meshes[key]
return (
<group ref={ref}>
<Composer
components={(isArray ? meshes : Object.values(meshes)).map(({ geometry, material }) => (
<Instances key={geometry.uuid} geometry={geometry} material={material} {...props} />
))}
>
{(args) =>
isArray
? children(...args)
: children(
Object.keys(meshes)
.filter((key) => meshes[key].isMesh)
.reduce((acc, key, i) => ({ ...acc, [key]: args[i] }), {})
)
}
</Composer>
</group>
)
export const Merged: ForwardRefComponent<any, THREE.Group> = React.forwardRef<THREE.Group, any>(function Merged(
{ meshes, children, ...rest },
ref
) {
const instances: React.FC[] = []

if (Array.isArray(meshes)) {
for (const mesh of meshes) {
if (mesh?.isMesh) {
instances.push((props) => (
<Instances key={mesh.geometry.uuid} geometry={mesh.geometry} material={mesh.material} {...rest} {...props} />
))
}
}
} else if (meshes != null && typeof meshes === 'object') {
for (const key in meshes) {
const mesh = meshes[key]
if (mesh?.isMesh) {
instances.push((props) => (
<Instances key={mesh.geometry.uuid} geometry={mesh.geometry} material={mesh.material} {...rest} {...props} />
))
}
}
}
)

return <group ref={ref}>{children(instances)}</group>
})

/** Idea and implementation for global instances and instanced attributes by
/* Matias Gonzalez Fernandez https://x.com/matiNotFound
Expand Down
14 changes: 6 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6783,7 +6783,7 @@ promzard@^2.0.0:
dependencies:
read "^4.0.0"

prop-types@^15.6.0, prop-types@^15.8.1:
prop-types@^15.8.1:
version "15.8.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
Expand Down Expand Up @@ -6834,13 +6834,6 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.8:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

react-composer@^5.0.3:
version "5.0.3"
resolved "https://registry.yarnpkg.com/react-composer/-/react-composer-5.0.3.tgz#7beb9513da5e8687f4f434ea1333ef36a4f3091b"
integrity sha512-1uWd07EME6XZvMfapwZmc7NgCZqDemcvicRi3wMJzXsQLvZ3L7fTHVyPy1bZdnWXM4iPjYuNE+uJ41MLKeTtnA==
dependencies:
prop-types "^15.6.0"

react-confetti@^6.1.0:
version "6.2.2"
resolved "https://registry.yarnpkg.com/react-confetti/-/react-confetti-6.2.2.tgz#b72888889b10b6707a91adca919dd35c653f4bb2"
Expand Down Expand Up @@ -8283,6 +8276,11 @@ use-sync-external-store@1.2.2:
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.2.2.tgz#c3b6390f3a30eba13200d2302dcdf1e7b57b2ef9"
integrity sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==

use-sync-external-store@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/use-sync-external-store/-/use-sync-external-store-1.4.0.tgz#adbc795d8eeb47029963016cefdf89dc799fcebc"
integrity sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==

util-deprecate@^1.0.2, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
Expand Down

0 comments on commit f9d9138

Please sign in to comment.