-
Notifications
You must be signed in to change notification settings - Fork 5
Debugging
Oğuz Eroğlu edited this page Jul 29, 2020
·
7 revisions
DebugHelper class helps programmers to visually debug their Kompute worlds. This class expects a three.js constructor for 3D rendering.
To visualise entities, their look direciton and speed:
// create a DebugHelper instance
var debugHelper = new Kompute.DebugHelper(
world, // refers to a Kompute.World instance in which we add our elements
threeInstance, // refers to a THREE instance
scene // refers to a THREE.Scene instance to do the rendering on
);
// actiave the debugHelper
debugHelper.activate();To visualise Paths:
// create an instance of DebugHelper
var debugHelper = new Kompute.DebugHelper(world, threeInstance, scene);
// create a Path
var path = new Kompute.Path();
path.addWaypoint(new Kompute.Vector3D(100, 200, 300));
// visualise the Path using debugHelper
debugHelper.visualisePath(path);
// or to specify the size of the waypoint visualisation (default size is 5 units)
// debugHelper.visualisePath(path, 15); // this visualises the waypoints with 15 units of size.Paths generated by AStar may be dynamically visualised via visualiseAStar API.
// we assume graph is an instance of Kompute.Graph
// create an instance of AStar
var aStar = new Kompute.AStar(graph);
debugHelper.visualiseAStar(aStar);
// The path visualisation will now be automatically updated everytime AStar constructs a new path with `findShortestPath` API.To visualise Graphs:
// create an instance of DebugHelper
var debugHelper = new Kompute.DebugHelper(world, threeInstance, scene);
// create a Graph
var graph = new Kompute.Graph();
var v1 = new Kompute.Vector3D(10, 20, 30);
var v2 = new Kompute.Vector3D(30, 40, 50);
graph.addVertex(v1);
graph.addVertex(v2);
graph.addEdge(v1, v2);
// visualise the Graph
debugHelper.visualiseGraph(graph);To visualise JumpDescriptors:
// create an instance of JumpDescriptor
var jumpDescriptor = new Kompute.JumpDescriptor({
takeoffPosition: new Kompute.Vector3D(100, 0, 0),
landingPosition: new Kompute.Vector3D(150, 100, 0),
runupSatisfactionRadius: 50,
takeoffPositionSatisfactionRadius: 35,
takeoffVelocitySatisfactionRadius: 20
});
// visualise the JumpDescriptor. This renders a 3D Bezier curve.
debugHelper.visualiseJumpDescriptor(jumpDescriptor);Deactivating DebugHelper:
debugHelper.deactivate();logger module logs the internal states of behaviors to console when activated. Note that this module is a singleton and does not need to be constructed.
Usage:
// to enable
Kompute.logger.enable();
// to disable
Kompute.logger.disable();- Core
- Path
-
Steering Behaviors
- AlignBehavior
- ArriveBehavior
- AvoidBehavior
- BlendedSteeringBehavior
- CohesionBehavior
- EvadeBehavior
- FleeBehavior
- HideBehavior
- JumpBehavior
- LookWhereYouAreGoingBehavior
- PathFollowingBehavior
- PrioritySteeringBehavior
- PursueBehavior
- RandomPathBehavior
- RandomWaypointBehavior
- SeekBehavior
- SeparationBehavior
- Wander2DBehavior
- Wander3DBehavior
- Math
- Extra