Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Three.js代码在场景中没有显示任何内容?_Javascript_Three.js - Fatal编程技术网

Javascript Three.js代码在场景中没有显示任何内容?

Javascript Three.js代码在场景中没有显示任何内容?,javascript,three.js,Javascript,Three.js,我用Three.js创建了一个简单的示例,我以前用它构建过一些代码,但它没有组织成类, 问题是,在mof=违抗这样的代码之后,视图中没有显示任何内容 HTML文件 <!DOCTYPE html> <html> <head> <title> </title> </head> <body> <div id="scenecontainer"></div> <script src

我用Three.js创建了一个简单的示例,我以前用它构建过一些代码,但它没有组织成类, 问题是,在mof=违抗这样的代码之后,视图中没有显示任何内容

HTML文件

<!DOCTYPE html>
<html>
<head>
    <title> </title>
</head>
<body>

<div id="scenecontainer"></div>

<script src="../js/libs/three.js/three.js"></script>
<script src="../js/libs/Detector.js"></script>
<script src="../js/libs/stats.min.js"></script>
<script src="../js/libs/RequestAnimationFrame.js"></script>

<script src="../js/lab/common/CommonExperiment.js"></script>
<script src="../js/lab/common/commonMain.js"></script>
</body>
</html>
CommonExperience.js

function CommonExperiment(domElement, renderStatistics) {
    this.testMesh = undefined;

    this.scene = undefined;
    this.renderer = undefined;
    this.stats = undefined;
    this.camera = undefined;
    this.renderStatistics = ( renderStatistics != undefined ) ? renderStatistics : true;
    this.domElement = domElement;

    this.init();
}

CommonExperiment.prototype.init = function () {
    if (Detector.webgl) {
        this.renderer = new THREE.WebGLRenderer({
            antialias:true, // to get smoother output
            preserveDrawingBuffer:true
        });
    } else {
        Detector.addGetWebGLMessage();
        return;
    }


    this.renderer.setSize(window.innerWidth, window.innerHeight);
    this.domElement.appendChild(this.renderer.domElement);

    if (this.renderStatistics) {
        this.stats = new Stats();
        this.stats.domElement.style.position = 'absolute';
        this.stats.domElement.style.bottom = '0px';
        document.body.appendChild(this.stats.domElement);
    }

    // create a scene
    this.scene = new THREE.Scene();

    // put a camera in the scene
    this.camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
    this.camera.position.z = 1000;
    this.scene.add(this.camera);



};

CommonExperiment.prototype.animate = function () {
    requestAnimationFrame(this.animate.bind(this));

    this.render();
//    console.log("ahmed");

    if (this.stats) {
        this.stats.update();
    }
};

// just test donot use
CommonExperiment.prototype.addTestCube = function () {
    var geometry = new THREE.CubeGeometry(200, 200, 200);
    var material = new THREE.MeshBasicMaterial({ color:0xff0000, wireframe:true });
    this.testMesh = new THREE.Mesh(geometry, material);
    this.scene.add(this.testMesh);
};

// to be overide
CommonExperiment.prototype.render = function () {
    this.testMesh.rotation.x += 0.01;
    this.testMesh.rotation.y += 0.02;
};
有什么帮助吗? 我很感激:)。

对不起 我忘了加上

this.renderer.render(this.scene,this.camera);
在渲染循环的末尾


谢谢:)。

控制台中有javascript错误吗?@jbabey没有,先生,我已经检查了渲染循环是否正常运行,我被困在简单的示例中:)。
this.renderer.render(this.scene,this.camera);