In a series of articles on my site, I’m building some simple moving objects in Codea Craft. I’ve been attaching a class to the entity. Those elements do get an
update callback, but they do not get a
draw callback. Normally, this is fine, because all the 3d stuff is in the entity anyway. But one might want to display some 2D text or the like, and one has to jump through some hoops to do that, saving globals or the like.
Here are some thoughts I’ve had on addressing this:
- Craft should call draw on any attached class instances.
- Apps should keep a global collection of objects wanting callbacks and add a loop to the main draw event to do the callbacks.
- Trek through
Scene to find the entity collection and trek through that to find objects and call them. (Seems like a very bad idea.)
I don’t like globals much but #2 would work, and might provide possibilities for handling other events. I’m not sure how
touch is handled with Craft, if in fact it is. I bet it’s hard to know what got touched.
Advise me, please.
@RonJeffries Where is your site at. Maybe I can look at what you’re trying to do and give some pointers. Or maybe you can post a small example of what you’re trying to do.
Found your site, there’s a lot there to look at. Is there some place to copy the code to run it instead of just chunks here and there. I didn’t look thru everything, so if you do have everything together, let me know.
@RonJeffries - just found you website, scanned your posts on Craft. I struggled to use it effectively, largely because I don’t have a good understanding of the fundamentals. I will be working through your posts to see if I can climb that mountain and will follow your thread here - I will post back if I can help.
@RonJeffries Heres some code for 2D text on 3D. Every now and then I’ll play with the app 3DC.io to create 3D objects including 3D text.
assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")
scene = craft.scene()
skyMaterial.sky=color(148, 148, 223, 255)
skyMaterial.horizon=color(183, 223, 159, 255)
v=scene.camera:add(OrbitViewer,vec3(0,0,0), 100, 0, 1000)
t.model = craft.model.plane(vec2(20,10))
t.material = craft.material("Materials:Specular")
t.material.map = img
t.material.blendMode = NORMAL
@RonJeffries I just read your 6 articles about Craft. I found them quite interesting. As I mentioned above, it would be nice if at the end of each article you would have all the code in one spot so it could be copied to a Codea project and run without trying to put chunks together.
@RonJeffries found your website and enjoyed reading your Codea articles. Keep up the good work! I really should start using working copy. You should link them in the Codea wiki so beginners can easily find them.
good idea on showing all the code. i used to do that and will do so again, thanks. as you’ve seen, i’m working thru simple stuff from scratch. john millard’s examples ARE great, of course. and large.
(Terrible typo, got aren’t. They ARE great! Sorry, John!)
@dave1707 text example is lovely, i had no idea you could do that! thanks!
@RonJeffries A draw callback would be cool but unfortunately it doesn’t really work in the context of the Craft scene graph drawing system. I think a better solution might be a
craft.text renderer component you could attach to an entity and then place it in the scene somewhere.
yes, john, i understand, and dave showed me how to do the text thing. thanks!