kopia lustrzana https://github.com/backface/turtlestitch
use video pixel buffer for raycasting
rodzic
816186f17d
commit
9fcaf64300
|
@ -2104,19 +2104,12 @@ SpriteMorph.prototype.getImageData = function () {
|
|||
).data;
|
||||
this.imageData = {
|
||||
version : this.version,
|
||||
pixels : new Uint32Array(imageData.buffer.slice(0)),
|
||||
full : imageData // +++ get rid of this
|
||||
pixels : new Uint32Array(imageData.buffer.slice(0))
|
||||
};
|
||||
}
|
||||
return this.imageData.pixels;
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.getFullImageData = function () {
|
||||
// temporary hack for raycasting. // +++
|
||||
this.getImageData();
|
||||
return this.imageData.full;
|
||||
};
|
||||
|
||||
SpriteMorph.prototype.projectionSnap = function() {
|
||||
var stage = this.parentThatIsA(StageMorph),
|
||||
center = this.center().subtract(stage.position())
|
||||
|
|
|
@ -4933,13 +4933,13 @@ Process.prototype.reportDistanceFacing = function (name) {
|
|||
*/
|
||||
|
||||
width = Math.floor(targetBounds.width() / stage.scale); // +++
|
||||
imageData = thatObj.getFullImageData(); // +++
|
||||
imageData = thatObj.getImageData(); // +++
|
||||
|
||||
// scan the ray along the coordinates of a Bresenham line
|
||||
// for the first opaque pixel
|
||||
function alphaAt(imageData, width, x, y) {
|
||||
var idx = (y * width * 4) + x * 4;
|
||||
return imageData[idx + 3];
|
||||
var idx = y * width + x;
|
||||
return imageData[idx] && 0x000000FF; // alpha
|
||||
}
|
||||
|
||||
function isOpaque(x, y) {
|
||||
|
|
Ładowanie…
Reference in New Issue