第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Three.js 錯誤 --> THREE.Scene 不是構(gòu)造函數(shù)

Three.js 錯誤 --> THREE.Scene 不是構(gòu)造函數(shù)

回首憶惘然 2022-06-16 17:20:45
由于此錯誤,我無法執(zhí)行我的代碼:TypeError: THREE.Scene is not a constructor我使用來自官方 github 存儲庫的 three.js 文件,這是我的文件:索引.html<html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <link rel="stylesheet" href="../style.css">    <title>First three.js</title></head><body>    <script type="module" src="../frontend/tetrahedrons_render.js"></script></body></html>四面體渲染.jsimport * as THREE from '../lib/three.js';// Create the sceneconst scene = new THREE.Scene();scene.background = new THREE.Color(0x2d3436);// Set up the cameraconst camera = new THREE.PerspectiveCamera(100, window.innerWidth / window.innerHeight, 0.1, 1000);// Set up the renderconst renderer = new THREE.WebGLRenderer();renderer.setSize(window.innerWidth, window.innerHeight);renderer.setPixelRatio(window.devicePixelRatio);document.body.appendChild(renderer.domElement);// Create n random tetrahedronsconst n = Math.floor(Math.random() * 7) + 2;const tetrahedrons = [];const positions = [];let x, y;for (let i = 0; i < n; i++) {  do {    x = Math.floor(Math.random() * 10) - 5;    y = Math.floor(Math.random() * 10) - 5;  } while ([x, y] in positions);  positions.push([x, y]);  tetrahedrons.push(createTetrahedron(x * 2.5, y * 2.5));}// Color one random tetrahedron in black and another in whiteconst i = Math.floor(Math.random() * tetrahedrons.length);let i2;do {  i2 = Math.floor(Math.random() * tetrahedrons.length);} while (i2 === i);tetrahedrons[i].geometry.faces.forEach((face) => {  face.color = new THREE.Color('black');});tetrahedrons[i2].geometry.faces.forEach((face) => {  face.color = new THREE.Color('white');});camera.position.z = 15;function animate() {  requestAnimationFrame(animate);  // Rotation  tetrahedrons.forEach((tetrahedron) => {    tetrahedron.rotation.x += 0.03;    tetrahedron.rotation.y -= 0.03;  });  renderer.render(scene, camera);}這是所有代碼,但我認為問題必須在第一行導(dǎo)入。我看到很多帖子都有類似的錯誤,但我找不到適合我的解決方案。
查看完整描述

1 回答

?
暮色呼如

TA貢獻1853條經(jīng)驗 獲得超9個贊

Three.js 有三個輸出文件:

  • 三.js

    • three.js 源代碼的未損壞包

  • 三分鐘.js

    • 捆綁的 three.js 源代碼的損壞/縮?。ㄝ^?。┌姹?/p>

  • 三.module.js

    • three.js 包的 JavaScript 模塊版本

您需要引用最后一個以導(dǎo)入 three.js 導(dǎo)出。復(fù)制three.module.js到您的lib文件夾中,然后:

import * as THREE from '../lib/three.module.js';


查看完整回答
反對 回復(fù) 2022-06-16
  • 1 回答
  • 0 關(guān)注
  • 707 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號