kopia lustrzana https://github.com/backface/turtlestitch
fix mouse sensing function (#12)
rodzic
3d3e0f5e61
commit
2328386de9
|
|
@ -35,6 +35,7 @@
|
|||
<!-- turtlestitch additions -->
|
||||
<script type="text/javascript" src="stitchcode/turtleShepherd.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/blocks.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/threads.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/objects.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/gui.js"></script>
|
||||
<script type="text/javascript" src="stitchcode/gui-cloud.js"></script>
|
||||
|
|
|
|||
|
|
@ -716,6 +716,25 @@ StageMorph.prototype.mouseLeave = function () {
|
|||
this.referencePos = null;
|
||||
};
|
||||
|
||||
// StageMorph Mouse Coordinates
|
||||
|
||||
StageMorph.prototype.reportMouseX = function () {
|
||||
var world = this.world();
|
||||
if (world) {
|
||||
return ((world.hand.position().x - this.center().x) / this.scale) / this.camera.zoomFactor * 2 + this.controls.center.x;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
StageMorph.prototype.reportMouseY = function () {
|
||||
var world = this.world();
|
||||
if (world) {
|
||||
return ((this.center().y - world.hand.position().y) / this.scale) / this.camera.zoomFactor * 2 + this.controls.center.y;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
StageMorph.prototype.originalAdd = StageMorph.prototype.add;
|
||||
StageMorph.prototype.add = function (morph) {
|
||||
this.originalAdd(morph);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
Process.prototype.reportMouseX = function () {
|
||||
var stage, world;
|
||||
if (this.homeContext.receiver) {
|
||||
stage = this.homeContext.receiver.parentThatIsA(StageMorph);
|
||||
if (stage) {
|
||||
world = stage.world();
|
||||
if (world) {
|
||||
var factor = stage.renderer.isParallelProjection ? 65 / stage.camera.zoomFactor : stage.controls.object.position.length() / 10;
|
||||
return ((world.hand.position().x - stage.center().x)
|
||||
/ stage.scale) / stage.camera.zoomFactor * 2 + stage.controls.center.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
Process.prototype.reportMouseY = function () {
|
||||
var stage, world;
|
||||
if (this.homeContext.receiver) {
|
||||
stage = this.homeContext.receiver.parentThatIsA(StageMorph);
|
||||
if (stage) {
|
||||
world = stage.world();
|
||||
if (world) {
|
||||
var factor = stage.renderer.isParallelProjection ? 65 / stage.camera.zoomFactor : stage.controls.object.position.length() / 10;
|
||||
return ((stage.center().y - world.hand.position().y)
|
||||
/ stage.scale) / stage.camera.zoomFactor * 2 + stage.controls.center.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
Ładowanie…
Reference in New Issue