Added meshes and scene for Mario 64

This commit is contained in:
Thomas FORGIONE 2015-04-14 16:58:39 +02:00
parent 848587f11b
commit 0c5676cfaf
60 changed files with 6536 additions and 101 deletions

Binary file not shown.

BIN
data/castle/154B175A_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/16CBEF1C_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/1916F8C5_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/19D5421D_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/1D0CA178_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/1FEE462_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/20EF7F7C_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/3AB7B2BC_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/3C6851DA_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/49254A53_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/5EDC83BD_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/castle/60A64656_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/61BE951F_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/6AE21407_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/6DAF90F6_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/7EB1C6A1_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/Castle.zip Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/castle/Masks/Thumbs.db Normal file

Binary file not shown.

5
data/castle/Readme.txt Normal file
View File

@ -0,0 +1,5 @@
This is the complete set of the castle, i have the model, the textures, the masks used
by the textures and as an added bonus, the peices of the sky texture, enjoy!
if you use this could you give credit to Alec Pike, or at least try to remember my name?
if you have any comments or complaints or need help with the model
or something e-mail me at alec.pike@gmail.com

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

View File

@ -0,0 +1,172 @@
# Blender3D MTL File: princess peaches castle (outside).blend
# Material Count: 16
newmtl Material.136_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.101_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.612500 0.612500 0.650000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.104_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.453125 0.453125 0.515625
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.096
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.662500 0.000000 0.000000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.105_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.126_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.100
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.318750 0.000000 0.000000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.135_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.099
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.556250 0.000000 0.000000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.102_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.487500 0.487500 0.543750
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.103_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.106_princess_peaches_cast
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd princess peaches castle (outside)_grp.png
newmtl Material.098
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.778125 0.000000 0.000000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.104
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.453125 0.453125 0.515625
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 1FEE462_c.bmp
newmtl Material.095
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.662500 0.662500 0.662500
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
newmtl Material.097
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.753125 0.000000 0.000000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

BIN
data/first/3C96C6A_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/first/48F5B267_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/first/5C3492AB_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

BIN
data/first/6B88A261_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/first/6E3E7EFA_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

BIN
data/first/777F0E0B_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
data/first/77928504_c.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
data/first/7A7501A5_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
data/first/7F0DBBD7_c.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

211
data/first/Floor 1.mtl Normal file
View File

@ -0,0 +1,211 @@
# Blender3D MTL File: Floor 1.blend
# Material Count: 19
newmtl Material.009_48F5B267_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.193750 0.193750 0.193750
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd Sky_grp.png
newmtl Material.055_77928504_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 77928504_c.png
newmtl Material.007_7F0DBBD7_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.265625 0.265625 0.265625
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 7F0DBBD7_c.bmp
newmtl Material.008_7A7501A5_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 7A7501A5_c.bmp
newmtl Material.017_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.296875 0.296875 0.296875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.008_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.015_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.675000 0.675000 0.675000
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.018_7F0DBBD7_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 7F0DBBD7_c.bmp
newmtl Material.011_48F5B267_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.296875 0.296875 0.296875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd Sky_grp.png
newmtl Material.061_5C3492AB_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.490625 0.490625 0.490625
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 5C3492AB_c.png
newmtl Material.014_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.540625 0.540625 0.540625
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.012_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.334375 0.334375 0.334375
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.010_48F5B267_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.346875 0.346875 0.346875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd Sky_grp.png
newmtl Material.008_6B88A261_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6B88A261_c.bmp
newmtl Material.054_777F0E0B_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 777F0E0B_c.png
newmtl Material.013_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.406250 0.406250 0.406250
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.008_3C96C6A_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 3C96C6A_c.bmp
newmtl Material.016_6E3E7EFA_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.793750 0.793750 0.793750
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 6E3E7EFA_c.bmp
newmtl Material.008_7F0DBBD7_c.bmp
Ns 0.000000
Ka 0.000000 0.000000 0.000000
Kd 0.796875 0.796875 0.796875
Ks 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2
map_Kd 7F0DBBD7_c.bmp

3016
data/first/Floor 1.obj Normal file

File diff suppressed because it is too large Load Diff

BIN
data/first/Sky_grp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

4
data/first/readme.txt Normal file
View File

@ -0,0 +1,4 @@
here is the first floor of peaches castle,ripped by me
if you use this please give credit to alec pike
if you have any comments, complaints or compliments
please contact me at alec.pike@gmail.com

BIN
data/first/toto.zip Normal file

Binary file not shown.

View File

@ -37,13 +37,8 @@ var Plane = function(size1, size2, style) {
this.geometry = new THREE.PlaneBufferGeometry(size1, size2); this.geometry = new THREE.PlaneBufferGeometry(size1, size2);
this.material = new THREE.MeshLambertMaterial(style); this.material = new THREE.MeshLambertMaterial(style);
this.material.side = THREE.FrontSide; this.material.side = THREE.DoubleSide;
this.materialBack = new THREE.MeshLambertMaterial(style);
this.materialBack.side = THREE.BackSide;
this.mesh = new THREE.Mesh(this.geometry, this.material); this.mesh = new THREE.Mesh(this.geometry, this.material);
this.meshBack = new THREE.Mesh(this.geometry, this.materialBack);
this.mesh.receiveShadow = true; this.mesh.receiveShadow = true;
} }
@ -52,5 +47,4 @@ Plane.prototype.constructor = Plane;
Plane.prototype.addToScene = function(scene) { Plane.prototype.addToScene = function(scene) {
scene.add(this.mesh); scene.add(this.mesh);
scene.add(this.meshBack);
} }

View File

@ -23,7 +23,7 @@ var PointerCamera = function() {
this.position = new THREE.Vector3(); this.position = new THREE.Vector3();
this.forward = new THREE.Vector3(); this.forward = new THREE.Vector3();
this.left = new THREE.Vector3(); this.left = new THREE.Vector3();
this.up = new THREE.Vector3(0,0,1); // this.up = new THREE.Vector3(0,0,1);
this.target = new THREE.Vector3(0,1,0); this.target = new THREE.Vector3(0,1,0);
// Stuff for events // Stuff for events
@ -104,11 +104,11 @@ PointerCamera.prototype.update = function() {
var delta = 0.1; var delta = 0.1;
// Update direction // Update direction
this.forward.z = Math.sin(this.phi); this.forward.y = Math.sin(this.phi);
var cos = Math.cos(this.phi); var cos = Math.cos(this.phi);
this.forward.x = cos * Math.cos(this.theta); this.forward.z = cos * Math.cos(this.theta);
this.forward.y = cos * Math.sin(this.theta); this.forward.x = cos * Math.sin(this.theta);
this.forward.normalize(); this.forward.normalize();
// Update // Update

365
js/three/OBJMTLLoader.js Normal file
View File

@ -0,0 +1,365 @@
/**
* Loads a Wavefront .obj file with materials
*
* @author mrdoob / http://mrdoob.com/
* @author angelxuanchang
*/
THREE.OBJMTLLoader = function ( manager ) {
this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager;
};
THREE.OBJMTLLoader.prototype = {
constructor: THREE.OBJMTLLoader,
load: function ( url, mtlurl, onLoad, onProgress, onError ) {
var scope = this;
var mtlLoader = new THREE.MTLLoader( url.substr( 0, url.lastIndexOf( "/" ) + 1 ) );
mtlLoader.crossOrigin = scope.crossOrigin;
mtlLoader.load( mtlurl, function ( materials ) {
var materialsCreator = materials;
materialsCreator.preload();
var loader = new THREE.XHRLoader( scope.manager );
loader.setCrossOrigin( scope.crossOrigin );
loader.load( url, function ( text ) {
var object = scope.parse( text );
object.traverse( function ( object ) {
if ( object instanceof THREE.Mesh ) {
if ( object.material.name ) {
var material = materialsCreator.create( object.material.name );
if ( material ) object.material = material;
}
}
} );
onLoad( object );
}, onProgress, onError );
}, onProgress, onError );
},
/**
* Parses loaded .obj file
* @param data - content of .obj file
* @param mtllibCallback - callback to handle mtllib declaration (optional)
* @return {THREE.Object3D} - Object3D (with default material)
*/
parse: function ( data, mtllibCallback ) {
function vector( x, y, z ) {
return new THREE.Vector3( x, y, z );
}
function uv( u, v ) {
return new THREE.Vector2( u, v );
}
function face3( a, b, c, normals ) {
return new THREE.Face3( a, b, c, normals );
}
var face_offset = 0;
function meshN( meshName, materialName ) {
if ( vertices.length > 0 ) {
geometry.vertices = vertices;
geometry.mergeVertices();
geometry.computeFaceNormals();
geometry.computeBoundingSphere();
object.add( mesh );
geometry = new THREE.Geometry();
mesh = new THREE.Mesh( geometry, material );
}
if ( meshName !== undefined ) mesh.name = meshName;
if ( materialName !== undefined ) {
material = new THREE.MeshLambertMaterial();
material.name = materialName;
mesh.material = material;
}
}
var group = new THREE.Group();
var object = group;
var geometry = new THREE.Geometry();
var material = new THREE.MeshLambertMaterial();
var mesh = new THREE.Mesh( geometry, material );
var vertices = [];
var normals = [];
var uvs = [];
function add_face( a, b, c, normals_inds ) {
if ( normals_inds === undefined ) {
geometry.faces.push( face3(
parseInt( a ) - (face_offset + 1),
parseInt( b ) - (face_offset + 1),
parseInt( c ) - (face_offset + 1)
) );
} else {
geometry.faces.push( face3(
parseInt( a ) - (face_offset + 1),
parseInt( b ) - (face_offset + 1),
parseInt( c ) - (face_offset + 1),
[
normals[ parseInt( normals_inds[ 0 ] ) - 1 ].clone(),
normals[ parseInt( normals_inds[ 1 ] ) - 1 ].clone(),
normals[ parseInt( normals_inds[ 2 ] ) - 1 ].clone()
]
) );
}
}
function add_uvs( a, b, c ) {
geometry.faceVertexUvs[ 0 ].push( [
uvs[ parseInt( a ) - 1 ].clone(),
uvs[ parseInt( b ) - 1 ].clone(),
uvs[ parseInt( c ) - 1 ].clone()
] );
}
function handle_face_line(faces, uvs, normals_inds) {
if ( faces[ 3 ] === undefined ) {
add_face( faces[ 0 ], faces[ 1 ], faces[ 2 ], normals_inds );
if (!(uvs === undefined) && uvs.length > 0) {
add_uvs( uvs[ 0 ], uvs[ 1 ], uvs[ 2 ] );
}
} else {
if (!(normals_inds === undefined) && normals_inds.length > 0) {
add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ], [ normals_inds[ 0 ], normals_inds[ 1 ], normals_inds[ 3 ] ]);
add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ], [ normals_inds[ 1 ], normals_inds[ 2 ], normals_inds[ 3 ] ]);
} else {
add_face( faces[ 0 ], faces[ 1 ], faces[ 3 ]);
add_face( faces[ 1 ], faces[ 2 ], faces[ 3 ]);
}
if (!(uvs === undefined) && uvs.length > 0) {
add_uvs( uvs[ 0 ], uvs[ 1 ], uvs[ 3 ] );
add_uvs( uvs[ 1 ], uvs[ 2 ], uvs[ 3 ] );
}
}
}
// v float float float
var vertex_pattern = /v( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/;
// vn float float float
var normal_pattern = /vn( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/;
// vt float float
var uv_pattern = /vt( +[\d|\.|\+|\-|e]+)( +[\d|\.|\+|\-|e]+)/;
// f vertex vertex vertex ...
var face_pattern1 = /f( +\d+)( +\d+)( +\d+)( +\d+)?/;
// f vertex/uv vertex/uv vertex/uv ...
var face_pattern2 = /f( +(\d+)\/(\d+))( +(\d+)\/(\d+))( +(\d+)\/(\d+))( +(\d+)\/(\d+))?/;
// f vertex/uv/normal vertex/uv/normal vertex/uv/normal ...
var face_pattern3 = /f( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))( +(\d+)\/(\d+)\/(\d+))?/;
// f vertex//normal vertex//normal vertex//normal ...
var face_pattern4 = /f( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))( +(\d+)\/\/(\d+))?/
//
var lines = data.split( "\n" );
for ( var i = 0; i < lines.length; i ++ ) {
var line = lines[ i ];
line = line.trim();
var result;
if ( line.length === 0 || line.charAt( 0 ) === '#' ) {
continue;
} else if ( ( result = vertex_pattern.exec( line ) ) !== null ) {
// ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
vertices.push( vector(
parseFloat( result[ 1 ] ),
parseFloat( result[ 2 ] ),
parseFloat( result[ 3 ] )
) );
} else if ( ( result = normal_pattern.exec( line ) ) !== null ) {
// ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
normals.push( vector(
parseFloat( result[ 1 ] ),
parseFloat( result[ 2 ] ),
parseFloat( result[ 3 ] )
) );
} else if ( ( result = uv_pattern.exec( line ) ) !== null ) {
// ["vt 0.1 0.2", "0.1", "0.2"]
uvs.push( uv(
parseFloat( result[ 1 ] ),
parseFloat( result[ 2 ] )
) );
} else if ( ( result = face_pattern1.exec( line ) ) !== null ) {
// ["f 1 2 3", "1", "2", "3", undefined]
handle_face_line([ result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ] ]);
} else if ( ( result = face_pattern2.exec( line ) ) !== null ) {
// ["f 1/1 2/2 3/3", " 1/1", "1", "1", " 2/2", "2", "2", " 3/3", "3", "3", undefined, undefined, undefined]
handle_face_line(
[ result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ] ], //faces
[ result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ] ] //uv
);
} else if ( ( result = face_pattern3.exec( line ) ) !== null ) {
// ["f 1/1/1 2/2/2 3/3/3", " 1/1/1", "1", "1", "1", " 2/2/2", "2", "2", "2", " 3/3/3", "3", "3", "3", undefined, undefined, undefined, undefined]
handle_face_line(
[ result[ 2 ], result[ 6 ], result[ 10 ], result[ 14 ] ], //faces
[ result[ 3 ], result[ 7 ], result[ 11 ], result[ 15 ] ], //uv
[ result[ 4 ], result[ 8 ], result[ 12 ], result[ 16 ] ] //normal
);
} else if ( ( result = face_pattern4.exec( line ) ) !== null ) {
// ["f 1//1 2//2 3//3", " 1//1", "1", "1", " 2//2", "2", "2", " 3//3", "3", "3", undefined, undefined, undefined]
handle_face_line(
[ result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ] ], //faces
[ ], //uv
[ result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ] ] //normal
);
} else if ( /^o /.test( line ) ) {
// object
meshN();
face_offset = face_offset + vertices.length;
vertices = [];
object = new THREE.Object3D();
object.name = line.substring( 2 ).trim();
group.add( object );
} else if ( /^g /.test( line ) ) {
// group
meshN( line.substring( 2 ).trim(), undefined );
} else if ( /^usemtl /.test( line ) ) {
// material
meshN( undefined, line.substring( 7 ).trim() );
} else if ( /^mtllib /.test( line ) ) {
// mtl file
if ( mtllibCallback ) {
var mtlfile = line.substring( 7 );
mtlfile = mtlfile.trim();
mtllibCallback( mtlfile );
}
} else if ( /^s /.test( line ) ) {
// Smooth shading
} else {
console.log( "THREE.OBJMTLLoader: Unhandled line " + line );
}
}
//Add last object
meshN(undefined, undefined);
return group;
}
};
THREE.EventDispatcher.prototype.apply( THREE.OBJMTLLoader.prototype );

148
prototype/js/main.js vendored
View File

@ -23,7 +23,7 @@ function init() {
renderer = new THREE.WebGLRenderer({alpha:true}); renderer = new THREE.WebGLRenderer({alpha:true});
renderer.setSize(container_size.width, container_size.height); renderer.setSize(container_size.width, container_size.height);
renderer.shadowMapEnabled = true; renderer.shadowMapEnabled = true;
// renderer.setClearColor(0x000000); renderer.setClearColor(0x000000);
// on initialise la scène // on initialise la scène
scene = new THREE.Scene(); scene = new THREE.Scene();
@ -39,47 +39,70 @@ function init() {
container.appendChild(renderer.domElement); container.appendChild(renderer.domElement);
// init light // init light
var directional_light = new THREE.DirectionalLight(0x999999); // var directional_light = new THREE.DirectionalLight(0x999999);
directional_light.position.set(1, 0.5, 1).normalize(); // directional_light.position.set(1, 0.5, 1).normalize();
directional_light.castShadow = true; // directional_light.castShadow = true;
scene.add(directional_light); // scene.add(directional_light);
var ambient_light = new THREE.AmbientLight(0x333333); var ambient_light = new THREE.AmbientLight(0xffffff);
scene.add(ambient_light); scene.add(ambient_light);
// on initialise la camera que lon place ensuite sur la scène // on initialise la camera que lon place ensuite sur la scène
var camera1 = new PointerCamera(50, container_size.width / container_size.height, 1, 100000, container); var camera1 = new PointerCamera(50, container_size.width / container_size.height, 0.01, 100000, container);
camera1.speed = 0.001;
var camera2 = new FixedCamera(50,
container_size.width / container_size.height,
1, 100000,
new THREE.Vector3(707,-247,603),
new THREE.Vector3(683,-269,580)
);
var camera3 = new FixedCamera(50,
container_size.width / container_size.height,
1, 100000,
new THREE.Vector3(727,165,310),
new THREE.Vector3(693,173,291)
);
var camera4 = new FixedCamera(50,
container_size.width / container_size.height,
1, 100000,
new THREE.Vector3(-67,-105,306),
new THREE.Vector3(-103,-120,314)
);
scene.add(camera1); scene.add(camera1);
cameras.push(camera1); cameras.push(camera1);
cameras.push(camera2);
cameras.push(camera3);
cameras.push(camera4);
camera2.addToScene(scene); var loader = new THREE.OBJMTLLoader();
camera3.addToScene(scene);
camera4.addToScene(scene); var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round(percentComplete, 2) + '% downloaded' );
}
};
var onError = function ( xhr ) {
};
// THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
var loader = new THREE.OBJMTLLoader();
// loader.load( '/data/castle/princess peaches castle (outside).obj',
// '/data/castle/princess peaches castle (outside).mtl',
loader.load( '/data/first/Floor 1.obj',
'/data/first/Floor 1.mtl',
function ( object ) {
object.position.z -= 10.9;
object.position.y += 0.555;
object.position.x += 3.23;
var theta = 0.27;
// object.rotation.x = -Math.PI/2;
object.rotation.y = Math.PI - theta;
// object.rotation.z = - Math.PI/2;
object.up = new THREE.Vector3(0,0,1);
scene.add(object);
object.traverse(function (object) {
if (object instanceof THREE.Material){
object.material.transparent = true;
}
});
}, onProgress, onError );
loader.load( '/data/castle/princess peaches castle (outside).obj',
'/data/castle/princess peaches castle (outside).mtl',
function ( object ) {
// object.rotation.y = Math.PI/2;
// object.rotation.z = Math.PI/2;
object.up = new THREE.Vector3(0,0,1);
scene.add(object);
object.traverse(function (object) {
if (object instanceof THREE.Material){
object.material.transparent = true;
}
});
}, onProgress, onError );
// var camera3 = new FixedCamera( // var camera3 = new FixedCamera(
// 50, // 50,
@ -100,66 +123,11 @@ function init() {
// Load the scene // Load the scene
loadScene(); loadScene();
plane = new Plane(1000,1000);
plane.translate(0,0,-100);
plane.addToScene(scene);
} }
function loadScene() { function loadScene() {
var positions = [
new THREE.Vector3(139.4026786273838,135.5184946130355,398.44068539970607),
new THREE.Vector3(-435.43466612542625,-213.42817928744614,357.9683852860272),
new THREE.Vector3(331.55730402813379,-554.75051838788778,327.9545043861335),
new THREE.Vector3(337.83563114154583,494.02776032947725,91.40149126173162),
new THREE.Vector3(-483.7218395537484,26.07460345877575,16.1503626453437)
];
var colors = [
0x5bf9ef,
0xec5e15,
0xcac518,
0x39c8d6,
0x04da72
];
var seen_by = [
[],
[3],
[1],
[2],
[2]
];
var mesh_number = positions.length;
loader = new THREE.OBJLoader();
for (var i = 0; i < mesh_number; i++) {
// Capture of i
// I am pretty good
(function(i) {
var new_id;
loader.load('/data/spheres/' + (2*i+2) + '.obj', function (object) {
object.traverse(function (child) {
if (child instanceof THREE.Mesh ) {
child.material.color.setHex(colors[i]);
child.up = new THREE.Vector3(0,0,1);
child.translateX(positions[i].x);
child.translateY(positions[i].y);
child.translateZ(positions[i].z);
new_id = child.id;
child.geometry = Converter.toGeometry(child.geometry);
child.geometry.mergeVertices();
child.geometry.computeFaceNormals();
child.geometry.computeVertexNormals();
}
});
spheres[i] = object;
scene.add(object);
objects.push({obj: object, seen_by: seen_by[i], id: new_id});
});
})(i);
}
} }
function animate() { function animate() {

View File

@ -3,6 +3,7 @@
<script src="/js/three/DDSLoader.js"></script> <script src="/js/three/DDSLoader.js"></script>
<script src="/js/three/MTLLoader.js"></script> <script src="/js/three/MTLLoader.js"></script>
<script src="/js/three/OBJLoader.js"></script> <script src="/js/three/OBJLoader.js"></script>
<script src="/js/three/OBJMTLLoader.js"></script>
<script src="/js/three/OrbitControls.js"></script> <script src="/js/three/OrbitControls.js"></script>
<script src="/js/Cube.js"></script> <script src="/js/Cube.js"></script>
<script src="/js/ProgressiveSphere.js"></script> <script src="/js/ProgressiveSphere.js"></script>