Trying to create lines; must be doing something dumb :<

  for (var i = 0; i < 10; i++) {
    var playerBoidLine = [];
    playerBoidLine.push(; //likely a vector3
      models[i].getBoundingInfo() //returns a vector3 for sure
    var lines = BABYLON.MeshBuilder.CreateLines("lines", {points: playerBoidLine}, scene);

I believe that the xr.baseExperience etc. is a vector3
I know that the models[i] etc. is vector3
So, why can’t I make a line?
I’m trying to create a helper f(x) in my vr world so that all players can see which robots are owned by all other players (a little white line, maybe dashed, will connect them).

Here’s my error:

TypeError: this._scene.getUniqueId is not a function
at t.e (babylon.js:16)
at t [as constructor] (babylon.js:16)
at t [as constructor] (babylon.js:16)
at t [as constructor] (babylon.js:16)
at new t (babylon.js:16)
at Function.e.CreateLineSystem (babylon.js:16)
at Function.e.CreateLines (babylon.js:16)
at Function.e.CreateLines (babylon.js:16)
at (index):1551
at t._renderFrame (babylon.js:16)
XRSession$1..onDeviceFrame @ VM2080:1284
requestAnimationFrame (async)
requestAnimationFrame @ VM2080:36505
XRSession$1..startDeviceFrameLoop @ VM2080:1293
XRSession$1 @ VM2080:1367
requestSession @ VM2080:944
async function (async)
requestSession @ VM2080:943
CustomWebXRPolyfill.XRSystem.requestSession @ VM2080:37020
e.initializeSessionAsync @ babylon.js:16
e.enterXRAsync @ babylon.js:16
(anonymous) @ babylon.js:16
(anonymous) @ babylon.js:16
(anonymous) @ babylon.js:16
(anonymous) @ babylon.js:16
s @ babylon.js:16
Promise.all.then.e.forEach.o._buttons..element.onclick @ babylon.js:16

also, making lines every call of the draw loop is probably a bad way to do this, right?
shouldn’t I create this in the setup code
then update all these positions in update f(x) (aka draw loop)

My guess would be that you’re still suffering from the problem outlined by ubercordes, but it would be nice if your code was in a Playground so we could make sure. (Just taking a shot in the dark) If you console out your scene right before this for loop, is it a Promise or an actual Scene object?

it’s a promise, not a scene object, but I don’t understand… what the deal is with all that? I fixed everything on that other post by totally rearchitecting my code; I think that’s not called for here, there just might be something I don’t understand, and maybe it’s what you’re pointing to…

now that you’ve said this, I think what I’m supposed to do is move this code to the setup f(x) and then update it in the draw loop; I think that babylon hates that I’m trying to create a billion lines every draw… I recollect that last time, I was trying to draw a new mesh ever loop of the update f(x) and it was like no don’t do that…

Yeah. Your problem is definitely that you don’t have an actual Scene object. Without seeing your code, I can only guess that your function for setting up the Scene is async and that you’re not awaiting on it. You should read a bit about Promises, async, and await.

I will do that!

1 Like

@Vampiro OK it’s working; I need to make a post it note about this and slap it on my monitor (slaps forehead with palm).

Haha, nice work!