因此,我將我在Blender中製作的場景加載到Babylonjs中,並且它產生了一些有趣的效果。基本上,我試圖將重力等運用到場景中,將玩家移動到適當的位置,並使整個場景點亮並可見,但沒有任何效果。這是腳本:Babylonjs中的場景渲染奇怪
var BABYLON;
var canvas = document.getElementById('gamecanvas');
var engine = new BABYLON.Engine(canvas, true);
var player_height = 2;
var player_speed = 1;
var player_inertia = 0.9;
function INIT_GAME(){
BABYLON.SceneLoader.Load('Scenes/', 'zombie_map.babylon', engine, function(newScene){
var scene = newScene;
var light = new BABYLON.PointLight('light', new BABYLON.Vector3(0,0,10), scene);
var player = new BABYLON.FreeCamera('player', new BABYLON.Vector3(1,1,1), scene);
scene.activeCamera = player;
scene.activeCamera.attachControl(canvas, true);
scene.enablePhysics();
scene.setGravity(new BABYLON.Vector3(0, -10, 0));
player.ellipsoid = new BABYLON.Vector3(1, player_height, 1);
player.checkCollisions = true;
player.applyGravity = true;
player.keysUp = [87];
player.keysDown = [83];
player.keysLeft = [65];
player.keysRight = [68];
player.inertia = player_inertia;
player.speed = player_speed;
newScene.executeWhenReady(function(){
engine.runRenderLoop(function(){
newScene.render();
});
});
});
canvas.height = window.innerHeight;
canvas.width = window.innerWidth;
canvas.requestPointerLock = canvas.requestPointerLock || canvas.mozRequestPointerLock;
canvas.requestPointerLock();
window.addEventListener('resize', function(){
engine.resize();
});
}
我已經是問題:
- 我如何渲染距離更高,這樣我就可以查看 整個場景?
- 爲什麼我的場景屬性都不起作用(重力,移動等)?
對於第一個問題,您可以更改攝像頭的'position'財產。 – ConnorsFan
我已經嘗試過了,並沒有改變位置,增加了奇怪 –
你可以嘗試在巴比倫遊樂場(http://www.babylonjs-playground.com/)重現你的問題。如果您保存了測試,其他人可以訪問它並進行調試。你也可以諮詢他們的論壇(http://www.html5gamedevs.com/forum/16-babylonjs/)。 – ConnorsFan