相关疑难解决方法(0)

使用SVGRenderer(或以其他方式渲染球体)将图像渲染为Three.js中的节点

<circle>在SVG文档中有一个元素,我将其<radialGradient>应用于给出幻觉它是一个球体:

<svg version="1.1" id="sphere_svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="640px" height="640px" viewBox="0 0 640 640" enable-background="new 0 0 640 640" xml:space="preserve">
    <defs>
        <radialGradient id="sphere_gradient" cx="292.3262" cy="287.4077" r="249.2454" fx="147.7949" fy="274.5532" gradientTransform="matrix(1.0729 0 0 1.0729 -23.3359 -23.3359)" gradientUnits="userSpaceOnUse">
            <stop id="sphere_gradient_0" offset="0" style="stop-color:#F37D7F"/>
            <stop id="sphere_gradient_1" offset="0.4847" style="stop-color:#ED1F24"/>
            <stop id="sphere_gradient_2" offset="1" style="stop-color:#7E1416"/>
        </radialGradient>
    </defs>
    <circle fill="url(#sphere_gradient)" cx="320" cy="320" r="320"/>
</svg>
Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

红球

的jsfiddle

我可以WebGLRenderer使用Gabe Lerner的canvg在three.js 容器中渲染它:

/* sphere_asset is a div containing the svg element */ …
Run Code Online (Sandbox Code Playgroud)

javascript svg webgl three.js

12
推荐指数
1
解决办法
1916
查看次数

标签 统计

javascript ×1

svg ×1

three.js ×1

webgl ×1