// Start is called once at the start of the demo.
Start is called once at the start of the demo.
// Start is called once at the start of the demo .
func (t *PhysicsBasic) Start(a *app.App) {
	a.Subscribe(window.OnKeyRepeat, t.onKey)
	a.Subscribe(window.OnKeyDown, t.onKey)
	axes := helper.NewAxes(1)
	a.Scene().Add(axes)
	pl := light.NewPoint(math32.NewColor("white"), 1.0)
	pl.SetPosition(1, 0, 1)
	a.Scene().Add(pl)
	l2 := light.NewDirectional(&math32.Color{1, 1, 1}, 0.3)
	l2.SetPosition(0, 0.1, 0)
	a.Scene().Add(l2)
	t.sim = physics.NewSimulation(a.Scene())
	sphereGeom := geometry.NewSphere(0.1, 16, 8)
	mat := material.NewStandard(&math32.Color{1, 1, 1})
	mat.SetWireframe(true)
	sphere1 := graphic.NewMesh(sphereGeom, mat)
	a.Scene().Add(sphere1)
	t.rb = object.NewBody(sphere1)
	t.rb.SetShape(shape.NewSphere(0.1)) 
	t.sim.AddBody(t.rb, "Sphere1")
	sphere2 := graphic.NewMesh(sphereGeom, mat)
	sphere2.SetPosition(1, 0, 0)
	a.Scene().Add(sphere2)
	t.rb2 = object.NewBody(sphere2)
	t.rb2.SetShape(shape.NewSphere(0.1)) 
	t.sim.AddBody(t.rb2, "Sphere2")
	t.rb2.SetVelocity(math32.NewVector3(-0.5, 0, 0))
	t.rb2.SetAngularVelocity(math32.NewVector3(0, 0, 1))
}
func ( t * PhysicsBasic ) Start ( a * app . App ) { a . Subscribe ( window . OnKeyRepeat , t . onKey ) a . Subscribe ( window . OnKeyDown , t . onKey ) axes := helper . NewAxes ( 1 ) a . Scene ( ) . Add ( axes ) pl := light . NewPoint ( math32 . NewColor ( " " ) , 1.0 ) pl . SetPosition ( 1 , 0 , 1 ) a . Scene ( ) . Add ( pl ) l2 := light . NewDirectional ( & math32 . Color { 1 , 1 , 1 } , 0.3 ) l2 . SetPosition ( 0 , 0.1 , 0 ) a . Scene ( ) . Add ( l2 ) t . sim = physics . NewSimulation ( a . Scene ( ) ) sphereGeom := geometry . NewSphere ( 0.1 , 16 , 8 ) mat := material . NewStandard ( & math32 . Color { 1 , 1 , 1 } ) mat . SetWireframe ( true ) sphere1 := graphic . NewMesh ( sphereGeom , mat ) a . Scene ( ) . Add ( sphere1 ) t . rb = object . NewBody ( sphere1 ) t . rb . SetShape ( shape . NewSphere ( 0.1 ) ) t . sim . AddBody ( t . rb , " " ) sphere2 := graphic . NewMesh ( sphereGeom , mat ) sphere2 . SetPosition ( 1 , 0 , 0 ) a . Scene ( ) . Add ( sphere2 ) t . rb2 = object . NewBody ( sphere2 ) t . rb2 . SetShape ( shape . NewSphere ( 0.1 ) ) t . sim . AddBody ( t . rb2 , " " ) t . rb2 . SetVelocity ( math32 . NewVector3 ( - 0.5 , 0 , 0 ) ) t . rb2 . SetAngularVelocity ( math32 . NewVector3 ( 0 , 0 , 1 ) ) }
Start is called once at the start of the demo.
Start is called once at the start of the demo .
// Subscribe to key events // Create axes helper // Add directional green light from top //gravity := physics.NewConstantForceField(&math32.Vector3{0,-9.8,0}) // //gravity := physics.NewAttractorForceField(&math32.Vector3{0.1,1,0}, 1) //t.sim.AddForceField(gravity) // Creates sphere 1 // COMMENT THIS ON BOTH SPHERES TO TEST Convex-Convex collision! // COMMENT THIS ON BOTH SPHERES TO TEST Convex-Convex collision! //cubeGeom := geometry.NewCube(0.2) //cube1 := graphic.NewMesh(cubeGeom, mat) //a.Scene().Add(cube1) //t.rb3 = object.NewBody(cube1) //t.sim.AddBody(t.rb3, "Cube1")