0

这很奇怪。。

我在我的目录'brick'中下载了three.js:

git 克隆https://github.com/mrdoob/three.js.git

这会产生一个子目录:

brick/three.js/

当我去

brick/three.js/examples

并在 Firefox 中打开文件

brick/three.js/examples/webgl_geometry_cube.html

一个漂亮的旋转立方体出现了。然后当我将它(即brick/three.js/examples/webgl_geometry_cube.html)复制到目录'brick'并相应地更改新brick/webgl_geometry_cube.html中的three.min.js引用时,brick/webgl_geometry_cube。 html 不起作用 - 当我在 Firefox 中打开它时,没有立方体出现。

让我更具体地说明 webgl_geometry_cube.html 中的three.min.js 引用。brick/three.js/examples/webgl_geometry_cube.html 的顶部如下所示:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>three.js webgl - geometry - cube</title>
        <meta charset="utf-8">
        <style>
            body {
                margin: 0px;
                background-color: #000000;
                overflow: hidden;
            }
        </style>
    </head>
    <body>

        <script src="../build/three.min.js"></script>

        <script>

            var camera, scene, renderer;
            var mesh;

当我将它复制到

brick/webgl_geometry_cube.html

我换行

<script src="../build/three.min.js"></script>

到:

<script src="three.js/build/three.min.js"></script>

我通过打开来验证这个新参考确实有效

brick/webgl_geometry_cube.html

在 Firefox 中,选择“查看源代码”,并在源代码中遵循对 three.min.js 的引用。如果我看到three.min.js(我就是)的源代码,我很高兴。

但是为什么在 Firefox 中打开移动的文件时没有立方体旋转呢?我很困惑。webgl_geometry_cube.html 中似乎没有任何其他依赖于路径的引用。webgl_geometry_cube.html 的完整源代码可以在这里看到:

Github 上的 webgl_geometry_cube.html

另外,我该如何调试呢?我可以对代码进行某种单步执行,以查看两个文件在执行过程中的不同之处吗?

4

2 回答 2

0

原来在 webgl_geometry_cube.html 中还有一个我没有发现的引用:文件 crate.gif 在第 34 行被引用,当然这个引用也应该更新以反映 crate.gif 的新相对位置:

three.js/examples/textures/crate.gif

此解决方案由用户maenu 提供。谢谢你,兄弟..

于 2012-08-19T13:30:28.177 回答
0

该示例使用纹理,因此您还需要textures/crate.gif在 JavaScript 中调整路径,否则找不到纹理。

于 2012-08-19T20:31:36.980 回答