如何在 React (Next) 中添加这三个 js 代码?

时间:2021-05-16 18:08:24

标签: reactjs three.js next.js

如何在 react 组件中制作带有动画的背景,例如跟随链接?

https://codepen.io/deathfang/pen/WxNVoq

function init() {
    container = document.createElement('div');
    document.body.appendChild(container);
 
    camera = new THREE.PerspectiveCamera(120, window.innerWidth / window.innerHeight, 1, 10000);
    camera.position.z = 1000;
 
    scene = new THREE.Scene();
 
    particles = new Array();
 
    var PI2 = Math.PI * 2;
    var material = new THREE.ParticleCanvasMaterial({
        color: 0xe1e1e1,
        program: function(context) {
            context.beginPath();
            context.arc(0, 0, .6, 0, PI2, true);
            context.fill();
        }
    });
}

0 个答案:

没有答案