我试图像这样在Threejs中加载OBJ
var objLoader = new THREE.OBJLoader();
objLoader.setPath(codepenAssetUrl1);
objLoader.load( 'wtc.obj', function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
let scale = 0.08;
let area = new THREE.Box3();
area.setFromObject( child );
let yOffset = (area.max.y * scale) / 2;
child.geometry.scale(scale,scale,scale);
rocketPoints = THREE.GeometryUtils.randomPointsInBufferGeometry(child.geometry, particleCount);
createVertices(rocketParticles, rocketPoints, yOffset, 2);
}
});
});
另一个是这个
var objLoader = new THREE.OBJLoader();
objLoader.setPath(codepenAssetUrl1);
objLoader.load( 'avap.obj', function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
let scale = 0.0021;
let area = new THREE.Box3();
area.setFromObject( child );
let yOffset = (area.max.y * scale) / 2;
const numberOfParticles1 = 3000000;
var particleCount1 = numberOfParticles1;
child.geometry.scale(scale,scale,scale);
spherePoints = THREE.GeometryUtils.randomPointsInBufferGeometry(child.geometry, particleCount1);
createVertices(sphereParticles, spherePoints, yOffset, 3);
}
});
},onProgress);
这是下一个
var objLoader = new THREE.OBJLoader();
objLoader.setPath(codepenAssetUrl1);
objLoader.load( '3.obj', function ( object ) {
object.traverse( function ( child ) {
if ( child instanceof THREE.Mesh ) {
let scale = 0.2;
let area = new THREE.Box3();
area.setFromObject( child );
let yOffset = (area.max.y * scale) / 2;
child.geometry.scale(scale,scale,scale);
spacemanPoints = THREE.GeometryUtils.randomPointsInBufferGeometry(child.geometry, particleCount*2);
createVertices(spacemanParticles, spacemanPoints, yOffset, 3);
}
});
});
总共我必须加载3个以上的obj,但现在3个obj导致浏览器崩溃 所以 问题是obj一次加载所有内容,这会导致浏览器崩溃。
所以我要如何一个接一个地装载。