ProgressiveLoader seems finished... I don't like the perfs :s
This commit is contained in:
parent
c6062e6a50
commit
21321a6ff7
|
@ -253,7 +253,6 @@ mesh.Face.prototype.toString = function() {
|
|||
mesh.Material = function() {
|
||||
var split = arguments[0].replace(/\s+/g, ' ').trim().split(' ');
|
||||
this.name = split[1];
|
||||
console.log(this.name);
|
||||
}
|
||||
|
||||
mesh.Material.prototype.toString = function() {
|
||||
|
|
|
@ -94,6 +94,13 @@ geo.MeshStreamer.prototype.loadFromFile = function(path, callback) {
|
|||
|
||||
}
|
||||
|
||||
if (currentMesh.faces.length * 3 * 3 > 60000) {
|
||||
var previousMesh = currentMesh;
|
||||
currentMesh = new mesh.Mesh();
|
||||
self.meshes.push(currentMesh);
|
||||
currentMesh.material = previousMesh.material;
|
||||
}
|
||||
|
||||
} else if (line[0] === 'u') {
|
||||
|
||||
// usemtl
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
var _parseList = function(arr) {
|
||||
|
||||
// For example
|
||||
// arr = [ 'f', 0, 0, 1, 2];
|
||||
// type index first second third
|
||||
|
||||
var ret = {};
|
||||
ret.index = arr[1];
|
||||
|
||||
|
@ -104,6 +100,10 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
|||
this.socket.on('usemtl', function(materialName, verticesNumber, facesNumber, texCoordsExist, normalsExist) {
|
||||
|
||||
// console.log("New mesh arrived : " + materialName);
|
||||
if (self.currentMesh !== undefined && self.currentMesh.visible === false) {
|
||||
self.currentMesh.geometry.computeBoundingSphere();
|
||||
self.currentMesh.visible = true;
|
||||
}
|
||||
|
||||
// Create mesh material
|
||||
var material;
|
||||
|
@ -160,6 +160,7 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
|||
|
||||
self.currentMesh = mesh;
|
||||
self.obj.add(mesh);
|
||||
mesh.visible = false;
|
||||
|
||||
if (typeof self.callback === 'function') {
|
||||
self.callback(mesh);
|
||||
|
@ -236,16 +237,17 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
|||
|
||||
if (elt.aTexture !== undefined) {
|
||||
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 9 ] = self.texCoords[elt.aTexture][0];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 9 + 1] = self.texCoords[elt.aTexture][1];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 6 ] = self.texCoords[elt.aTexture][0];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 6 + 1] = self.texCoords[elt.aTexture][1];
|
||||
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 9 + 2] = self.texCoords[elt.bTexture][0];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 9 + 3] = self.texCoords[elt.bTexture][1];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 6 + 2] = self.texCoords[elt.bTexture][0];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 6 + 3] = self.texCoords[elt.bTexture][1];
|
||||
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 9 + 4] = self.texCoords[elt.cTexture][0];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 9 + 5] = self.texCoords[elt.cTexture][1];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 6 + 4] = self.texCoords[elt.cTexture][0];
|
||||
self.currentMesh.geometry.attributes.uv.array[elt.index * 6 + 5] = self.texCoords[elt.cTexture][1];
|
||||
|
||||
self.currentMesh.geometry.attributes.uv.needsUpdate = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,10 +13,10 @@ function addLight(scene) {
|
|||
|
||||
function initPeachCastle(scene, collidableObjects, loader, static_path) {
|
||||
|
||||
ProgressiveLoader(
|
||||
'/static/data/castle/princess peaches castle (outside).obj',
|
||||
var loader = new ProgressiveLoader(
|
||||
'static/data/castle/princess peaches castle (outside).obj',
|
||||
scene,
|
||||
function(object, container) {
|
||||
function(object) {
|
||||
collidableObjects.push(object);
|
||||
object.raycastable = true;
|
||||
if (object.material.name === 'Material.103_princess_peaches_cast') {
|
||||
|
@ -30,6 +30,7 @@ function initPeachCastle(scene, collidableObjects, loader, static_path) {
|
|||
}
|
||||
}
|
||||
);
|
||||
loader.load();
|
||||
|
||||
}
|
||||
|
||||
|
@ -600,7 +601,17 @@ function initMountain(camera, scene, static_path, coins) {
|
|||
|
||||
function initSponzaScene(scene, collidableObjects, loader, static_path) {
|
||||
|
||||
var loader = new ProgressiveLoader('static/data/sponza/sponza.obj', scene);
|
||||
var loader = new ProgressiveLoader('static/data/sponza/sponza.obj', scene, function(obj) {
|
||||
if (obj.material.name === 'chain' ||
|
||||
obj.material.name === 'leaf' ||
|
||||
obj.material.name === 'Material__57') {
|
||||
|
||||
THREEx.Transparency.push(obj);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
loader.load();
|
||||
glob = loader.obj;
|
||||
loader.obj.scale.set(0.1,0.1,0.1);
|
||||
|
|
|
@ -78,8 +78,8 @@ function init() {
|
|||
// Initialize pointer camera
|
||||
var camera1 = new PointerCamera(50, container_size.width() / container_size.height(), 0.01, 100000, renderer, container);
|
||||
|
||||
cameras = initMainScene(camera1, scene, static_path, coins);
|
||||
// cameras = initPeach(camera1, scene, static_path, coins);
|
||||
// cameras = initMainScene(camera1, scene, static_path, coins);
|
||||
cameras = initPeach(camera1, scene, static_path, coins);
|
||||
// cameras = initBobomb(camera1, scene, static_path, coins);
|
||||
// cameras = initWhomp(camera1, scene, static_path, coins);
|
||||
// cameras = initMountain(camera1, scene, static_path, coins);
|
||||
|
|
Loading…
Reference in New Issue