Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
three-render-objects
Advanced tools
Easy way to render ThreeJS objects with built-in interaction defaults
This module offers a convenient way to render ThreeJS objects onto a WebGL canvas, with built-in interaction capabilities:
All the renderer/scene/camera scaffolding is already included and any instance of Object3D can be rendered with minimal setup.
import ThreeRenderObjects from 'three-render-objects';
or
var ThreeRenderObjects = require('three-render-objects');
or even
<script src="//unpkg.com/three-render-objects"></script>
then
const myCanvas = ThreeRenderObjects();
myCanvas(<myDOMElement>)
.objects(<myData>);
Method | Description | Default |
---|---|---|
objects([array]) | Getter/setter for the list of objects to render. Each object should be an instance of Object3D. | [] |
Method | Description | Default |
---|---|---|
width([px]) | Getter/setter for the canvas width. | <window width> |
height([px]) | Getter/setter for the canvas height. | <window height> |
backgroundColor([str]) | Getter/setter for the canvas background color. | #000011 |
showNavInfo([boolean]) | Getter/setter for whether to show the navigation controls footer info. | true |
Method | Description | Default |
---|---|---|
tick() | Re-render all the objects on the canvas. Essentially this method should be called at every frame, and can be used to control the animation ticks. | |
cameraPosition([{x,y,z}], [lookAt], [ms]) | Getter/setter for the camera position, in terms of x , y , z coordinates. Each of the coordinates is optional, allowing for motion in just some dimensions. The optional second argument can be used to define the direction that the camera should aim at, in terms of an {x,y,z} point in the 3D space at the distance of 1000 away from the camera. The 3rd optional argument defines the duration of the transition (in ms) to animate the camera motion. A value of 0 (default) moves the camera immediately to the final position. | By default the camera will face the center of the graph at a z distance of 1000 . |
renderer() | Access the WebGL renderer object. | |
camera() | Access the perspective camera object. | |
scene() | Access the Scene object. | |
tbControls() | Access the Trackball Controls object. |
Method | Description | Default |
---|---|---|
onClick(fn) | Callback function for object clicks. The object is included as single argument onClick(object) . | - |
onHover(fn) | Callback function for object mouse over events. The object (or null if there's no node under the mouse line of sight) is included as the first argument, and the previous hovered object (or null) as second argument: onHover(obj, prevObj) . | - |
hoverOrderComparator([fn]) | Getter/setter for the comparator function to use when hovering over multiple objects under the same line of sight. This function can be used to prioritize hovering some objects over others. | By default, hovering priority is based solely on camera proximity (closes object wins). |
lineHoverPrecision([int]) | Getter/setter for the precision to use when detecting hover events over Line objects. | 1 |
tooltipContent([str or fn]) | Object accessor function or attribute for label (shown in tooltip). Supports plain text or HTML content. | |
enablePointerInteraction([boolean]) | Getter/setter for whether to enable the mouse tracking events. This activates an internal tracker of the canvas mouse position and enables the functionality of object hover/click and tooltip labels, at the cost of performance. If you're looking for maximum gain in your render performance it's recommended to switch off this property. | true |
FAQs
Easy way to render ThreeJS objects with built-in interaction defaults
The npm package three-render-objects receives a total of 24,527 weekly downloads. As such, three-render-objects popularity was classified as popular.
We found that three-render-objects 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.