【发布时间】:2022-01-05 23:28:06
【问题描述】:
我是 JS 的新手,我尝试使用库 three.js 做一些动画。
我试着理解指令: const scene = new THREE.Scene();
我不明白为什么我们必须把 THREE(在 THREE.Scene 中),我们不能简单地写 const scene = new Scene(); ?
图书馆本身的“三”从何而来?
这是我的 html 文件:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="./three.js"></script>
<script src="./script.js"></script>
</body>
</html>
我的 JS 文件只包含 console.log(THREE),它返回一个对象(在控制台日志中)。
谁能更好地解释我从哪里来?
感谢您的帮助。
【问题讨论】:
-
将
THREE视为存储所有对象on the left column 的文件夹。以这种方式组织数百个对象有助于保持代码整洁。例如,您可以使用变量名Camera,因为它与THREE.Camera不冲突。如果该对象不在THREE中,那么变量名称Camera将被占用,您将花费大量时间遇到此类问题。
标签: javascript three.js scene