Problems with triangle generation

I am trying to generate triangles from wedges and 3 points in euclidean space (think like 3d) and I am using this module from @EgoMoose

However when attempting to use the module I get an error saying that these dot products are basically nil

local abd, acd, bcd = ab:Dot(ab), ac:Dot(ac), bc:Dot(bc);

My main code is this

local triangleModule = require(script.GenerateTriangle)

triangleModule.draw3dTriangle(0, 1, 5, workspace)

Here is the place file Baseplate.rbxl (20.0 KB)

It expects Vector3s. Not numbers.

The error isn’t saying they’re nil. It’s saying you’re trying to call Dot() on a number.

How do I fix it then? I didn’t write the code I just got it from github

:Dot() is a method of Vector3, looking at the module’s code, ab, ac, and bc are the result of a series of subtractions between the first three inputted arguments. Meaning those three arguments should be vectors, not numbers, presumably representing the 3D position of each of the triangle’s vertices.

It’s better to read the article before blindly using the code, else use a documented module.

Could you link one with documentation?

I couldn’t find any, but you can look for yourself. If you end up not finding one, just go back to egomoose’s article, and try to understand what the a, b and c arguments need to be. Like I said, they’re probably the positions of vertices.

This is what you’re trying to do.

You gave the function a single number, which I imagine you thought was a 3D point. You clearly can’t draw a triangle with just that yellow dot above.

What you need to do is give it three points in 3D space like this.

image

local triangleModule = require(script.GenerateTriangle)

triangleModule.draw3dTriangle(Vector3.new(5,0,0), Vector3.new(0,5,0), Vector3.new(0,0,5), workspace)
1 Like