我不知道有什么问题可以帮助我吗?
当我尝试将其加载到chrome上时,它只是白屏,代码使用在其自己的文件中,这将是当我发现有什么问题时,它只是加载了白页,我正在尝试通过帮助使多维数据集加载从jquery和three.js
<!DOCTYPE HTML>
<html>
<head>
<title>THREE</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript" src="js/three.js"></script>
<style>
body{
margins:0;
overflow:hidden;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
$(document).ready(function(){}
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth/window.innerHeight, .1, 500);
var renderer = new THREE.WebGLRenderer();
renderer.setColor(0xdddddd);
renderer.setSize(window.innerWidth, window.innerHeight);
var axis = new THREE.AxisHelper(10);
scene.add(axis);
var grid = new THREE.GridHelper(50, 5);
var color = new Color("rgb(255, 0, 0)");
grid.setColors(color, 0x000000);
//scene.add(grid);
var cubeGeo = new THREE.BoxGeometry(5, 5, 5);
var cubeMat = new THREE.MeshBasicMaterial({color:0xdddddd, wireframe:true});
var cube = new THREE.Mesh(cubeGeo, cubeMat);
cube.position.x = 0;
cube.position.y = 0;
cube.position.z = 0;
scene.add(cube);
camera.position.x = 40;
camera.position.y = 40;
camera.position.z = 40;
camera.lookAt(scene.position);
$("#container").append(renderer.domElement);
renderer.render(scene,camera);
});
</script>
</body>
</html>
最佳答案
从此处卸下右括号:
$(document).ready(function(){
删除此行,setColor似乎不是THREE.WebGLRenderer的方法:
renderer.setColor(0xdddddd);
更改:
var color = new Color("rgb(255, 0, 0)");
至:
var color = new THREE.Color("rgb(255, 0, 0)");
关于javascript - 我不知道jquery怎么了?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31036063/