The plane has the canvas and the mouse drags are recalculated to properties that ordinary animation-xml uses to rotate and translate objects.

The nasal code:

- Code: Select all
`# create a new canvas...`

var c = canvas.new({

"name": "BTEST",

"size": [128, 128],

"view": [128, 128],

"mipmapping": 1

});

# ... and place it on the object called Plane_Btest

c.addPlacement({"node": "Plane_Btest", "capture-events": 1});

c.addEventListener("drag", func(e) { mouseDrag(e.clientX, e.clientY, e.deltaX, e.deltaY); });

setprop("tmp/wheel", 0);

setprop("tmp/slider", 0);

setprop("tmp/knob", 0);

var mouseDrag= func(x, y, dx, dy) {

if (x>23 and x<80 and y>80 and y<87) {

setprop("tmp/wheel", getprop("tmp/wheel")+dx*1.62);

} else if (x>46+getprop("tmp/slider")*64 and x<54+getprop("tmp/slider")*64 and y>105 and y<116) {

setprop("tmp/slider", (x-50)/64);

} else if ((x-50)*(x-50) + (y-40)*(y-40) <600) {

dv=math.atan2((x-50),(y-40))-math.atan2((x-dx-50),(y-dy-40));

setprop("tmp/knob", getprop("tmp/knob")+dv*57.3);

}

print(x ~" , " ~y);

}