
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@downpourdigital/boxes-react-bridge
Advanced tools
Renderer-agnostic bindings for boxes — Create and compose boxes scenes with any react renderer.
yarn add @downpourdigital/boxes-react-bridge
npm i --save @downpourdigital/boxes-react-bridge
import {
BoxesRoot,
Renderable,
TransformNode,
UniformProvider,
PerspectiveWrapper,
MatchGlTransform,
usePxPerUnit,
} from '@downpourdigital/boxes-react-bridge';
boxes-react-bridge
only "renders" your elements into a container. This can be a boxes Scene
or anything living in the boxes scene graph.
What you do with the scene is then up to you – rendering, materials and geometries have to be done the "traditional", imperative way.
First, you'll have to specify a point from which to tap into the react tree. This could be the root of your app. E.g. with ReactDOM
:
const scene = new Scene();
ReactDOM.render(
<BoxesRoot container={scene}>
<App />
</BoxesRoot>,
document.getElementById( 'root' ),
);
All boxes related nodes inside <BoxesRoot>
will now be mounted into scene
.
For now, only Renderable
, TransformNode
and UniformProvider
are represented. The elements props closely match that of their imperative counterpart. Additionally, react ref
props can be used and transforms can be supplied as arrays.
() => {
const ref = useRef();
return (
<TransformNode
ref={ref}
translation={[1, 2, 3]}
>
</TransformNode>
);
}
boxes-react-bridge
can infer CSS transforms from boxes transforms to sync DOM content to WebGL. Right now, only PerspectiveCameras
are supported.
To get the correct CSS perspective, wrap your App in a <PerspectiveWrapper>
component. This'll create a <div>
with the necessary styles.
ReactDOM.render(
<BoxesRoot container={scene}>
<PerspectiveWrapper
// your canvas dimensions in pixels
width={1024}
height={1024}
// the camera from which you're projecting
camera={scene.activeCamera}
>
<App />
</PerspectiveWrapper>
</BoxesRoot>,
document.getElementById( 'root' ),
);
Now you can place a <MatchGlTransform>
component inside the element with which you want to sync transforms. This'll place a <div>
at the nodes origin. You may have to fight with CSS for a bit to get things looking right.
Use the usePxPerUnit
hook to convert from boxes units to pixels.
A 2x2u square on top of a Renderable
would look like this:
() => {
const scalar = usePxPerUnit();
return (
<Renderable
geometry={geometry}
material={material}
>
<MatchGlTransform>
<div style={{
transform: 'translate3d(-50%, 50%, 0)',
border: '1px solid red',
width: 2 * scalar,
height: 2 * scalar,
}}
>
SYNCED TRANSFORMS!
</div>
</MatchGlTransform>
</Renderable>
);
}
© 2020 DOWNPOUR DIGITAL, licensed under BSD-4-Clause
FAQs
Renderer agnostic react bindings for boxes
The npm package @downpourdigital/boxes-react-bridge receives a total of 180 weekly downloads. As such, @downpourdigital/boxes-react-bridge popularity was classified as not popular.
We found that @downpourdigital/boxes-react-bridge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.