Jump to content

Three JS Conversion


Pryme8
 Share

Recommended Posts

I am working on converting:
https://github.com/spacejack/poaceae/blob/master/ts/grass.ts

to a playground.

I have gotten to this part:

const geo = new THREE.InstancedBufferGeometry()
	// Make a giant bounding sphere so the mesh never goes out of view.
	// Also, because there are no position vertices, we must create our own bounding sphere.
	geo.boundingSphere = new THREE.Sphere(
		new THREE.Vector3(0,0,0), Math.sqrt(opts.radius * opts.radius * 2.0) * 10000.0
	)
	geo.addAttribute('vindex', new THREE.BufferAttribute(buffers.vindex, 1))
	geo.addAttribute('shape', new THREE.InstancedBufferAttribute(buffers.shape, 4))
	geo.addAttribute('offset', new THREE.InstancedBufferAttribute(buffers.offset, 4))
	geo.setIndex(new THREE.BufferAttribute(buffers.index, 1))

and am trying to figure out the BJS equivalent.
http://www.babylonjs-playground.com/#JPJVL4#1
Approx Line 49 is where this section would need to go.

Link to comment
Share on other sites

http://www.babylonjs-playground.com/#JPJVL4#6

So is this correct now?

I noticed that I prolly needed to change:

var vIndexBuffer = new BABYLON.Buffer(engine, new Float32Array(args.BLADE_VERTS * 2 * 1), false, 2);
var shapeBuffer = new BABYLON.Buffer(engine, new Float32Array(4 * args.numBlades), false, 4, false, true)

to:

var vIndexBuffer = new BABYLON.Buffer(engine, this.buffers.vID, false, 2);
var shapeBuffer = new BABYLON.Buffer(engine, this.buffers.shape, false, 4, false, true);


otherwise the data I built wont be included if I'm not mistaken?

Then what, is this on the mesh as a VBO?
 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...