Question: How do I apply an arcball (using quaternions) along with mouse events, to allow the user to look around the screen using the [o3d WebGL framework](http://code.google.com/p/o3d/)?

[This sample](http://code.google.com/p/o3d/source/browse/trunk/samples_webgl/o3d-webgl-samples/simpleviewer/simpleviewer.html?r=215) uses the arcball for rotating the transform of an "object," but rather than apply this to a transform, I would like to apply the rotation to the camera's target, to create a first person style ability to look around the scene, as if the camera is inside the centre of the arcball instead of rotating from the outside.

The code that is used in this sample is

```
var rotationQuat = g_aball.drag([e.x, e.y]);
var rot_mat = g_quaternions.quaternionToRotation(rotationQuat);
g_thisRot = g_math.matrix4.mul(g_lastRot, rot_mat);

```

The code that I am using which doesn't work

```
var rotationQuat = g_aball.drag([e.x, e.y]);
var rot_mat = g_quaternions.quaternionToRotation(rotationQuat);
g_thisRot = g_math.matrix4.mul(g_lastRot, rot_mat);

var cameraRotationMatrix4 = g_math.matrix4.lookAt(
  g_eye, g_target, [g_up[0], g_up[1] * -1, g_up[2]]
);
var cameraRotation = g_math.matrix4.setUpper3x3(
  cameraRotationMatrix4, g_thisRot
);
g_target = g_math.addVector(cameraRotation, g_target);

```

where am I going wrong?

Answer: 
See the paper: [Automatic making of Sokoban problems](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.47.2303)

From the abstract:

> 
> This paper describes our program that makes Sokoban problems automatically. Sokoban is one of one-person puzzles invented in Japan. The program consists of three stages: generation, checking and evaluation. First, candidates for problems are generated randomly by a prototype and three templates . Second, unsolvable candidates are removed by the Sokoban solver. Finally trivial or uninteresting candidates are removed by the evaluator. The problems that the program made are judged good by human experts. Creation of art by computer is an important target of Artificial Intelligence. Our work can be characterized one of the attempts to create some arts by computers.
> 
> 
>
For solvable puzzles, it's often easy to just play the game in reverse, starting from a solved state and un-making moves either planned or at random (or in an editor.)

Sokoban fits this approach very well, and will be much easier to implement than an exclude-and-solve strategy.