Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
draft-n-draw
Advanced tools
Easily visualize bounding boxes, raycasts, points, lights and more in threejs. Fully typed, it can be used with vanilla JS or TypeScript and also has convenient React components for use in react-three-fiber.
npm install draft-n-draw
You begin by adding the DrafterProvider
component to the top level of your app.
import { Canvas } from '@react-three/fiber';
import { DrafterProvider } from '@draft-n-draw/react';
function App() {
return (
<Canvas>
<DrafterProvider>
<Game />
</DrafterProvider>
</Canvas>
);
}
And then we can access the drafter either inside a component with a hook or outside a component with a getter function.
import { getDrafter, useDrafter } from '@draft-n-draw/react';
// Outside a component.
const drafter = getDrafter();
// Inside a component.
function Component() {
const drafter2 = useDrafter();
//...
}
👉 Note: If you just want the React package you can install @draft-n-draw/react
.
npm install @draft-n-draw/react
You begin by creating a drafter for your scene.
import { Drafter } from '@draft-n-draw/vanilla';
const drafter = new Drafter(scene);
👉 Note: If you just want the vanilla JS package you can install @draft-n-draw/vanilla
.
npm install @draft-n-draw/vanilla
Then anywhere you are debugging request a draw.
drafter.drawBox3(myBox3);
drafter.drawRay({ origin, direction, distance });
By default, draws only last a single frame and are kept active by being called in a loop. This way you can safely inline them in functions you are debugging without worrying about spawning too many scene objects or cleaning them up when done — Draft-n-Draw will handle that for you.
If instead you want the draw to persist, you can specify it in the draw options.
drafter.drawSpotLight(mySpotLight, { persist: true });
👉 Note: This will cause a new draw to be persisted on screen each call, so be careful!
A persisted draw can be cleaned up using the dispose()
method with the object being visualized as the key.
drafter.dispose(mySpotLight);
Finally, there are additional draw options for controlling the visuals such as drawing on top and adjusting color or opacity.
drafter.drawWireSphere({ center, radius }, { color: 'yellow', alwaysOnTop: true, opacity: 0.5 });
The draw coverage is a work in progress. Our drafter is learning on the job!
First we have the generic draw()
method which can draw any custom visualization or helper. It has all the generic options discussed above.
Method | Object | Options |
---|---|---|
draw() | THREE.Object3D | { color: THREE.ColorRepresentation, alwaysOnTop: boolean, opacity: number, persist: boolean } |
And then we have draws for math objects. Unless stated otherwise all options are shared with draw()
.
Method | Object | Special options |
---|---|---|
drawBox3 | THREE.Box3 | None. |
drawRay | { origin: THREE.Vector3, direction: THREE.Vector3, distance: number } | None. |
drawPoint | THREE.Vector3 | radius: number |
drawWireTriangle | THREE.Triangle | None. |
drawTriangle | THREE.Triangle | winZFight: boolean |
drawWireSphere | { center: THREE.Vector3, radius: number } or THREE.Sphere | None. |
drawSphere | { center: THREE.Vector3, radius: number } or THREE.Sphere | None. |
And finally some draws for lights. Unless stated otherwise all options are shared with draw()
.
Method | Object | Special options |
---|---|---|
drawSpotlight | THREE.SpotLight | None. |
drawPointlight | THREE.PointLight | None. |
drawDirectionalLight | THREE.DirectionalLight | None. |
drawHemisphereLight | THREE.HemisphereLight | None. |
FAQs
### 🖍️ A utility for drawing debug visualizations in threejs.
We found that draft-n-draw 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.