
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
@splinetool/react-spline
Advanced tools
A component to easily run Spline scenes in React apps.
yarn add @splinetool/react-spline @splinetool/runtime
or
npm install @splinetool/react-spline @splinetool/runtime
import { Spline } from '@splinetool/react-spline';
function App() {
return (
<main>
<Spline scene="[DRAFT OR PROD URL]" />
</main>
);
}
Create a wrapped component to be able to use ref.
import { Spline } from '@splinetool/react-spline';
import { Ref } from 'react';
export function WrappedSpline({ splineRef, ...props }) {
return <Spline ref={splineRef} {...props} />;
}
Use next/dynamic to import client-side component.
import dynamic from 'next/dynamic';
const WrappedSpline = dynamic(
() => import('./WrappedSpline').then((mod) => mod.WrappedSpline),
{
ssr: false,
}
);
const Spline = forwardRef((props, ref) => {
return <WrappedSpline {...props} splineRef={ref} />;
});
function App() {
return (
<main>
<Spline scene="[DRAFT OR PROD URL]" />
</main>
);
}
Spline is in charged of adding events and user just need to add handler function.
import { Spline } from '@splinetool/react-spline';
function App() {
function handleMouseDown(e) {
if (e.target.id === 'my-object-id') {
doSomething();
}
}
return (
<main>
<Spline scene="[DRAFT OR PROD URL]" onMouseDown={handleMouseDown} />
</main>
);
}
Option 1: Using emitEvent with event name and object id.
import { Spline } from '@splinetool/react-spline';
function App() {
const splineRef = useRef();
function handleTriggerButtonClick() {
splineRef.current.emitEvent('mouseHover', 'my-object-id');
}
return (
<main>
<Spline ref={splineRef} scene="[DRAFT OR PROD URL]"/>
<button type="button" onClick={handleTriggerButtonClick}/>
Trigger Button
</button>
</main>
)
}
Option 2: Querying object and trigger event using emitEvent object method.
import { Spline } from '@splinetool/react-spline';
function App() {
const splineRef = useRef();
const [myObj, setMyObj] = useState(null);
useEffect(() => {
const obj = splineRef.current.findObjectById('my-object-id')
setMyObj(obj)
}, [splineRef])
function handleTriggerButtonClick() {
myObj.emitEvent('mouseHover');
}
return (
<main>
<Spline ref={splineRef} scene="[DRAFT OR PROD URL]"/>
<button type="button" onClick={handleTriggerButtonClick}/>
Trigger Button
</button>
</main>
)
}
import { Spline } from '@splinetool/react-spline';
function App() {
const splineRef = useRef();
const [myObj, setMyObj] = useState(null);
useEffect(() => {
const obj = splineRef.current.findObjectById('my-object-id')
setMyObj(obj)
}, [splineRef])
function handleClick() {
console.log(myObj) // SPE Proxy Object => { name: 'my object', id: '8E8C2DDD-18B6-4C54-861D-7ED2519DE20E', ... }
}
return (
<main>
<Spline ref={splineRef} scene="[DRAFT OR PROD URL]"/>
<button type="button" onClick={handleClick}/>
Log {myObj.name} info
</button>
</main>
)
}
Name | Type | Description |
---|---|---|
scene | string | Scene file |
id? | string | Canvas id |
style? | string | CSS style |
className? | string | CSS classes |
onMouseDown? | (e: SplineEvent) => void | Function handler for Mouse Down events |
onMouseHover? | (e: SplineEvent) => void | Function handler for Mouse Hover events |
onMouseUp? | (e: SplineEvent) => void | Function handler for Mouse Up events |
onKeyDown? | (e: SplineEvent) => void | Function handler for Key Down events |
onKeyUp? | (e: SplineEvent) => void | Function handler for Key Up events |
onStart? | (e: SplineEvent) => void | Function handler for Start events |
onLookAt? | (e: SplineEvent) => void | Function handler for Look At events |
onFollow? | (e: SplineEvent) => void | Function handler for Mouse Up events |
Name | Type | Description |
---|---|---|
emitEvent | (eventName: string, uuid:string) => void | Triggers a Spline event associated to an object with provided uuid in reverse order. Starts from first state to last state. |
emitEventReverse | (eventName: string, uuid:string) => void | Triggers a Spline event associated to an object with provided uuid in reverse order. Starts from last state to first state. |
findObjectById | (uuid: string) => SPEObject | Searches through scene's children and returns the object with that uuid. |
findObjectByName | (name: string) => SPEObject | Searches through scene's children and returns the first object with that name |
We use yarn, install the dependencies like this:
yarn
For now, you need to use also:
yarn add link:path/to/runtime
in order to use the updated version that is merge in dev.yarn link
and then yarn link @splinetool/react-spline
.Serve the example
folder at localhost:3000
yarn dev
yarn build
yarn deploy
FAQs
Unknown package
The npm package @splinetool/react-spline receives a total of 22,337 weekly downloads. As such, @splinetool/react-spline popularity was classified as popular.
We found that @splinetool/react-spline demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.