Platinum Partner
architects,html5,javascript,tips and tricks

Combining three.js and KineticJS [update]

I wrote already how to combine three.js and Kinetic.js in the previous blog post. Since then, both libraries have evolved and the same code won’t work anymore so here is the update.

First, KineticJS is now initialized slightly differently. Instead of passing arguments, you pass a config object. The following code will construct a new KineticJS.Stage object:

stage = new Kinetic.Stage({
    container: "container",
    width: 700,
    height: 700
});

Three.js requires an HTML5 canvas element, not KineticJS wrapper around it. The correct way to initialize it is:

renderer = new THREE.CanvasRenderer({canvas: layer3D.getCanvas().getElement()});

Note: if you want to use WebGLRenderer instead of CanvasRenderer, the above code will not work. I will write a follow up post for that scenario soon.

You can see my new sample here.
Here is a jsfiddle version http://jsfiddle.net/hXw6D/3/.




Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}