我正在尝试向 Kinetic JS 画布添加 3D 立方体以显示 x、y、z 旋转。我找到了这篇文章http://www.tonicodes.net/blog/combining- Three-js-and-kineticjs http://www.tonicodes.net/blog/combining-three-js-and-kineticjs。我使用的是 3.8 版本,当我尝试使用 Kinetic JS 版本 4 来遵循该示例时,我收到了此错误,
Unable to get property 'appendChild'
任何建议,解决它或更好的方法在画布中包含 3D 立方体。
完整的项目http://jsfiddle.net/user373721/hXw6D/1/ http://jsfiddle.net/user373721/hXw6D/1/
我找到了这个完美的例子http://html5example.net/entry/html5-canvas/html5-canvas-pre3d-rotating-cube http://html5example.net/entry/html5-canvas/html5-canvas-pre3d-rotating-cube,不幸的是它是基于 pre3d.js 的,我不知道如何与 Kinetic JS canvas 集成。
因此,我设法修复了链接博客文章中的示例,请在此处查看结果:http://tonicodes.net/sandbox/html5/k Three/index.htm http://tonicodes.net/sandbox/html5/kthree/index.htm.
与我上一篇文章相比,有几件事发生了变化:
现在动力学初始化的方式有所不同:
stage = new Kinetic.Stage({
container: "container",
width: 700,
height: 700
});
另外,您应该提供canvas
HTML5 提供的元素,而不是 Kinetic 包裹的元素:
renderer = new THREE.CanvasRenderer({canvas: layer3D.getCanvas().getElement()});
我还修复了你的 jsFiddle:http://jsfiddle.net/hXw6D/3/ http://jsfiddle.net/hXw6D/3/, 一探究竟。您忘记添加另一个div
带有 id 的元素容器.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)