Threejs帆布背景黑色 [英] Threejs canvas background black

查看:522
本文介绍了Threejs帆布背景黑色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用threejs的基本场景进行了试验,但我无法理解为什么画布背景是完全黑色的。

I made a trial with basic scene of threejs but I can't understand why the canvas background is completely black.

<html>
<head>
    <title>My first Three.js app</title>
    <style>
        body { margin: 0; }
        canvas { width: 100%; height: 100%;background-color: white; }
    </style>
</head>
<body>
    <script src="Stereos/threejs/three.js"></script>
    <script>
        var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
    </script>
  </body>
</html>

编辑:

felpone.netsons.org上的代码

Code at felpone.netsons.org

推荐答案

画布背景的颜色不是由CSS值决定的但使用 renderer.setClearColor(0xff0000,1);

The color of the background of the canvas is not determined by the CSS value but using renderer.setClearColor (0xff0000, 1);

这篇关于Threejs帆布背景黑色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆