Comments (9)
Thanks for posting! I'm on the road today, but will take a look at this tonight. Just curious what does this have to do with cocoon.js? It sounds like these are issues independent of cocoon, right?
from two.js.
The texts on the screenshot are maybe missleading. Android means running the code on Android through cocoonjs, and browser means running the very same code on desktop / latest chrome.
To the second issue: if i use mouse events:
var vmousedown = false;
var mouseX, mouseY;
var deltaX_old = 0;
var deltaY_old = 0;
var deltaX,deltaY;
elem.addEventListener("mousedown", function(ev)
{
vmousedown = true;
mouseX = ev.pageX;
mouseY = ev.pageY;
});
elem.addEventListener("mousemove", function(ev)
{
if (vmousedown === false)
return;
deltaX = ev.pageX - mouseX - deltaX_old;
deltaY = ev.pageY - mouseY - deltaY_old;
pan(deltaX,deltaY);
deltaX_old = ev.pageX - mouseX;
deltaY_old = ev.pageY - mouseY;
});
elem.addEventListener("mouseup", function(ev)
{
vmousedown = false;
deltaX_old = 0;
deltaY_old = 0;
});
on the desktop browser is everything ok, but running it on cocoonjs / android with the touch events causes that weird result.
One could think maybe it cocoonsjs's fault, but if i draw this primitives for instanse with pixi.js (2D webgl framework), then it works fine.
from two.js.
Interesting, thanks for further context. I won't have access to Android until tomorrow, but I will definitely try to run your example with the cocoon.js adk debug build. Until then, I added a fix so that you'll be probably able to request antialias
. Try this and let me know if this fixes the first problem:
var two = new Two({ type: Two.Types.webgl, antialias: true });
// Run code as usual
My guess is that when you're dragging or possibly at all times the gl context is getting confused on what to keep on screen and what if anything to clear. Keep you posted.
from two.js.
Thanks for the fix.
var two = new Two({ type: Two.Types.webgl, antialias: true });
console.log(two.antialias);
gave me false with the old build, with the patch its true, as expected. Unfortuneatly the cricle is still edgy on droid.
from two.js.
Cool thanks for the update. I'm digging into the ADK of cocoon.js today so hopefully I can help out with some answers or fixes!
from two.js.
Download the latest build of two.js — this should fix both your problems 👍
To note, the aliased effect was actually due to the buffer not being cleared. So, by default you shouldn't have to set antialias
to true in order to get smooth edges. Don't hesitate to let me know if there's anything else that comes up.
I also put up a test that I've been running to debug here: canvas • webgl
from two.js.
thank you!! That was quick;). The dragging works excellent, but unfortunetly i still have same aliased circle. Could you please post an android screenshot from the antialiased circle? What device do you use?
from two.js.
Ah, I see you're right. Here's a screenshot from my Nexus 7. Unfortunately this has to do with devicePixelRatio
. Two.js automatically tries to upsample your canvas for you based on hdpi, but it looks like Cocoon doesn't have those variables available for reading so it always defaults to 1
instead of what could be a higher ratio like 2
.
You can set the ratio yourself in two.js. I tried that and it doesn't seem to help as Cocoon doesn't resolve as expected. Typically when upsampling you would do something like this with your canvas:
// Where ratio can be equal to or larger than 1
canvas.width = x * ratio;
canvas.height = y * ratio;
canvas.style.width = x + 'px';
canvas.style.height = y + 'px';
This effectively stuffs more pixels per "pixel". When setting canvas.width
and canvas.height
Cocoon just makes the whole canvas that size...
from two.js.
According this : http://wiki.ludei.com/cocoonjs:releases they Added “window.devicePixelRatio” and “screenDensity” in version 1.4 Tomorrow im gonna continue to investigate this.
from two.js.
Related Issues (20)
- [Question] Woscope integration HOT 3
- How to animate millions of points on browser canvas using two.js HOT 12
- wrong type in getPointAT declaration in path class HOT 2
- "Dom-less" start for just generating result svg [Enhancement] HOT 1
- Can two handle thousands of svg path elements and hundreds of thousands of points? HOT 1
- [Enhancement] Add Path.Compound Static Method
- How to check if an object is currently being hovered by the mouse whilst taking rotation into account? HOT 3
- Two.Utils.read.path throws an error HOT 3
- Smooth out lines and Round Corners HOT 2
- [Bug] WebGL Renderer Blurry HOT 5
- Partial Ellipse HOT 6
- Text `BoundingClientRect` in nested groups HOT 2
- compile error typescript[Bug] HOT 2
- svg fill-opacity [Bug] HOT 12
- Issues with Zoom and ZUI when upgrading from version 8.1.1 to 8.11 (latest) HOT 3
- creating curve path using anchors and make path not working ! HOT 2
- [Question] Best way to render ~250k polygons HOT 6
- Text Baseline in SVG Backend HOT 5
- [Bug] Negative scale does not work, with webgl mode only HOT 1
- Can i add events to shapes if renderer is Two.CanvasRenderer HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from two.js.