如何使用 three.js 加载 VRML 模型 (wrl)

How to load VRML models (wrl) with three.js

我正在尝试使用 three.js 加载 VRML 模型,但我的代码似乎无法正常工作,而且我无法在网页上显示 3D 模型。我的代码有问题吗?

var loader = new THREE.VRMLLoader();
loader.load('./Bluegg/Bluegg/Bluegg.wrl', function(object){
    alert(object);
    scene.add(object);
});

错误信息说 无法加载 file:///C:/Users/ninom/Desktop/takahiro_note/3DJS/Bluegg/Bluegg/Bluegg.wrl: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. 这条消息是什么意思?感谢您抽出宝贵时间。

来自 how to run things locally -

的文档部分

If you load models or textures from external files, due to browsers' same origin policy security restrictions, loading from a file system will fail with a security exception.

如果您的页面使用的是 file:// URL,那么它将如上所述从文件系统加载。要解决此问题,您需要 运行 本地服务器。文档中提到的有很多快速方法可以做到这一点。我喜欢的安装了 Node.js v6+ 的是:

# first time only
npm install -g serve

# start a local server "hosting" the current directory
serve .