我正在使用 Angular 7,我想在我的项目中添加三个 JS Thee JS,但结果并不是真的很有效。我不确定我做对了。请给我指路
这是我的代码
ngAfterViewInit(): void {
let script = this._renderer2.createElement('script');
script.type = `text/javascript`;
script.text = `
{
$(document).ready(function () {
var SEPARATION = 100, AMOUNTX = 50, AMOUNTY = 50;
var container, stats;
var camera, scene, renderer;
var particles, count = 0;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
mouseX = 635 - windowHalfX;
mouseY = 27 - windowHalfY;
init();
animate();
function init() {
container = document.createElement('div');
document.body.appendChild(container);
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 1, 10000);
camera.position.z = 1000;
scene = new THREE.Scene();
//
var numParticles = AMOUNTX * AMOUNTY;
var positions = new Float32Array(numParticles * 3);
var scales = new Float32Array(numParticles);
var i = 0, j = 0;
for (var ix = 0; ix < AMOUNTX; ix++) {
for (var iy = 0; iy < AMOUNTY; iy++) {
positions[i] = ix * SEPARATION - ((AMOUNTX * SEPARATION) / 2); // x
positions[i + 1] = 0; // y
positions[i + 2] = iy * SEPARATION - ((AMOUNTY * SEPARATION) / 2); // z
scales[j] = 1;
i += 3;
j++;
}
}
我已经导入了所需的模块,但仍然无法正常工作,并且显示错误,例如“三个不是函数”或其他内容。
Qyouu
侃侃尔雅
相关分类