我遇到的一个问题似乎是众所周知的:我的“边界”对象不会与“地板”凹面网格碰撞。
我已经读过这个问题可能是由于在与模型一起缩放凹面网格时发生的错误引起的,因此我按需要导出了我的地板模型,并在应用了凹面网格后(如下所示),但是它不起作用。
我对此表示红色:https : //github.com/chandlerprall/Physijs/issues/102以及与此主题相关的许多其他信息(Physijs负载模型three.js冲突不起作用,并且类似),我编写了以下代码但无事可做:(
我真的不明白为什么“界限”贯穿整个地板。
这是我的代码:
Physijs.scripts.worker = './libs/chandlerprall-Physijs-7e3837b/physijs_worker.js';
Physijs.scripts.ammo = './examples/js/ammo.js';
var gravityVector = new THREE.Vector3( 0, -100, 0 );
//renderer
var renderer = new THREE.WebGLRenderer({antialias:true});
renderer.setClearColor(0xffffff, 0);
renderer.setSize( window.innerWidth, window.innerHeight );
//canvas
var canvas = renderer.domElement;
canvas.setAttribute("width", window.innerWidth);
canvas.setAttribute("height", window.innerHeight);
document.body.appendChild( canvas );
var perspectiveCamera = new THREE.PerspectiveCamera(45,window.innerWidth/window.innerHeight, 1, 200000);
//scene
var rttScene = new Physijs.Scene();
var bounding = new Physijs.SphereMesh(new THREE.SphereGeometry(100, 100, 100),
Physijs.createMaterial(
new THREE.MeshBasicMaterial({color: '#ff0000'}),
1.0, // friction
0.0 // …Run Code Online (Sandbox Code Playgroud) 我一直在寻找一段时间以获得结论,但我似乎无法找到任何解决方案.
我正在尝试使用THREE.JS和PHYSI.JS创建一个简单的场景来获得一个小平台动作.我有一个质量为0的扁平盒子作为我的工作,还有一个盒子网格作为我的角色.Physijs的网站似乎建议我将__dirtyPosition变量设置为true.这里的问题是:__dirtyPosition与物理混淆.当我将角色从水平边缘移开时,他并没有摔倒.事实上,当它发生碰撞时,它似乎会停在世界立方体的中间位置.
当我尝试更新位置而不应用时__dirtyPosition,立方体会被放回原位.它有点颤抖,好像它有一个小小的癫痫发作,就是这样.如果我可以同时使用物理和运动,那就太棒了,使用Physi进行碰撞就像是过度使用它.这是我现在的表现,显然是错误的方式:
level1.generateScene = function()
{
level1.camera = new THREE.PerspectiveCamera(75, this.cameraWidth / this.cameraHeight, 0.1, 1000);
level1.material = new AdapterEngine.createBasicMaterial({color: 0x00ff00}); //Threejs basic material
level1.ground = new AdapterEngine.createBoxMesh(5, 0.1, 5, level1.material, 0); //Physijs box mesh with a mass of 0
level1.playerMaterial = new AdapterEngine.createBasicMaterial({color:0x0000ff}, 0.6, 0.3); //Physijs basic material with a fruction of 0.6, and a restitution of 0.3
level1.player = new AdapterEngine.createBoxMesh(0.3, 0.3, 0.3, level1.playerMaterial, 0.1); //Physijs box mesh with a mass of …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 physi.js 库 ()。我遵循了给出的所有步骤:
https://github.com/chandlerprall/Physijs/wiki/Basic-Setup
但是,我得到了错误:
Uncaught SecurityError: Failed to construct 'Worker': Script at 'file://172.16.159.200/js/physijs_worker.js' cannot be accessed from origin 'null'.
Run Code Online (Sandbox Code Playgroud)
我试图更深入,并看到该行的问题:
this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );
Run Code Online (Sandbox Code Playgroud)
是什么导致了这个问题?浏览器是谷歌浏览器。我检查过,文件“physijs_worker.js”出现在正确的位置。