Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QBJS in 3D
#7
Update #2

I've added support for a number of the three.js "Primitives".  These are basic 3D shapes that can be used as building blocks in a 3D scene. You can preview them here:
It's pretty neat to see how quickly you can put together a simple 3D scene using these primitives.

For example, we could build a simple tree using just the cylinder and cone shapes.  Start by drawing a brown cylinder for the base:
   
Code: (Select All)
Function CreateTree
    Dim As Object material, geometry, opts, tree, mesh
   
    ' Create a cylinder trunk
    geometry = THREE.CylinderGeometry(1, 1, 3)
    opts.color = &H663300
    material = THREE.MeshPhongMaterial(opts)
    tree = THREE.Mesh(geometry, material)
    tree.position.y = 1.5

    CreateTree = tree
End Sub

Then add a green cone on top:
   
Code: (Select All)
Function CreateTree
    Dim As Object material, geometry, opts, tree, mesh
   
    ' Create a cylinder trunk
    geometry = THREE.CylinderGeometry(1, 1, 3)
    opts.color = &H663300
    material = THREE.MeshPhongMaterial(opts)
    tree = THREE.Mesh(geometry, material)
    tree.position.y = 1.5
   
    ' Create a cone for the branches
    geometry = THREE.ConeGeometry(4, 8)
    opts.color = &H336600
    material = THREE.MeshPhongMaterial(opts)
    mesh = THREE.Mesh(geometry, material)
    THREE.Add tree, mesh
    mesh.position.y = 5
   
    CreateTree = tree
End Function

Then we can use the Clone function to copy the green cone a couple of times and stack them on top by changing the position:
   
Code: (Select All)
Function CreateTree
    Dim As Object material, geometry, opts, tree, mesh
   
    ' Create a cylinder trunk
    geometry = THREE.CylinderGeometry(1, 1, 3)
    opts.color = &H663300
    material = THREE.MeshPhongMaterial(opts)
    tree = THREE.Mesh(geometry, material)
    tree.position.y = 1.5
   
    ' Create 3 stacked cones for the branches
    geometry = THREE.ConeGeometry(4, 8)
    opts.color = &H336600
    material = THREE.MeshPhongMaterial(opts)
    mesh = THREE.Mesh(geometry, material)
    THREE.Add tree, mesh
    mesh.position.y = 5
   
    mesh = THREE.Clone(mesh)
    THREE.Add tree, mesh
    THREE.Set mesh.scale, .8, .8, .8
    mesh.position.y = 7
   
    mesh = THREE.Clone(mesh)
    THREE.Add tree, mesh
    THREE.Set mesh.scale, .6, .6, .6
    mesh.position.y = 9
   
    CreateTree = tree
End Function

Finally, you could use the Clone function again and some RNG to generate a whole forest:
   
Reply


Messages In This Thread
QBJS in 3D - by dbox - 02-23-2026, 08:15 PM
RE: QBJS in 3D - by NakedApe - 02-23-2026, 09:16 PM
RE: QBJS in 3D - by Sprezzo - 02-24-2026, 01:44 AM
RE: QBJS in 3D - by vince - 02-25-2026, 12:35 PM
RE: QBJS in 3D - by grymmjack - 03-01-2026, 04:22 PM
RE: QBJS in 3D - by dbox - 03-02-2026, 12:07 AM
RE: QBJS in 3D - by dbox - 03-02-2026, 05:29 PM
RE: QBJS in 3D - by bplus - 03-02-2026, 06:29 PM
RE: QBJS in 3D - by dbox - 03-02-2026, 08:42 PM
RE: QBJS in 3D - by bplus - 03-03-2026, 02:52 PM

Forum Jump:


Users browsing this thread: