-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to represent irregular polygon as sprite? #38
Comments
@wadehenning thanks for reaching out. You can set any custom geometries for the nodes, using the Here's an example with custom geometries: |
Thank you for focusing me on the nodeThreeObject. I think I am close to being able to plot a 2D curve (ignoring the Sprite part for now), but I am getting an error: TypeError: shape.extractPoints is not a function. Any thoughts? My component code: My shape: |
I think I'm doing something wrong with sending the shape to the component |
I have been working to get a simple custom shape plotted and I am getting the error: TypeError: Cannot read property 'extractPoints' of undefined. Does my simple code look correct? import React, { Component } from 'react'; export default class FocusGraph extends React.Component { My shape looks like this: Thanks |
I'm sure I'll figure it out. |
I have been able to get all of your examples working, and I have been able to add custom shapes. But I am still having trouble with custom sprites of shapes. My sprite code seems to generate sprites, but I get an error message: I hope that my code is close enough for your review. First I have a simple React Component, followed by short code to make my sprite. export default class SpriteCurves extends React.Component { SPRITE CODE: export function generatesprite(shape){ |
Hi @wadehenning could you make an example online, on CodePen or similar so that it's easier to debug? For now, I'd check whether:
|
Hi @vasturiano .
I'm working on a codesandbox. |
Hi @vasturiano.
|
@wadehenning the signature of
In your code above, you're not unpacking the function signature correctly, it should be Also you should do some drawing operations on the context, otherwise Here's an example of using the |
@vasturiano in the line below, I don't understand where the values for the input parameters come from. What is the value of ctx and where is it coming from? Where are id, x,, y coming from when you don't call
If I simply add my |
The The
The |
Hi @vasturiano
|
@wadehenning you should create a new canvas context as part of the operation of generating a THREE object. Remember that this canvas is not attached to the DOM, it serves only the purpose of the sprite construction, so you don't need to get it from or link it with the 3d graph itself. |
Hi @vasturiano Here is a link to a code sandbox where the preview does not work. I think this is related to the force-graph package (it did preview intermittently when I first copied in the example Custom Node Geometries code) , and maybe you have some experience getting these things to render better in these environments. |
@vasturiano , I'm sorry that you've had to walk me through this sprite example-- this is the first time I have ever worked with three.js or canvas. What I have learned here has helped me in other components that require canvas, and I appreciate your time. I don't know if you have had a chance to look at the code sandbox I put up- even though the preview does not work, at least the code is all on one page and it is a trivial example. Here is what my output looks like. It is making some sort of tiny sprite node, but does not include my circles. |
Thank you for this beautiful repo. How do I replace the 3D Text nodes with irregular shapes? For example, my shapes might look something California in this example.
https://threejs.org/examples/#webgl_geometry_shapes
EDIT/ SOLUTION: @vasturiano was extremely patient and helpful as I got up to speed on
canvas
andthree.js
; the rest of this post is my journey. Here is my bare-bones solution to my original question:The text was updated successfully, but these errors were encountered: