Skip to content

Commit

Permalink
- Scene.add > Scene.addObject
Browse files Browse the repository at this point in the history
- Enabled Scene.removeObject
- Removed computeNormals() from Geometry
  • Loading branch information
mrdoob committed Jul 3, 2010
1 parent fbad38c commit 4d0fdbb
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 61 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Other similar projects: [pre3d](http://deanm.github.com/pre3d/), [pvjs](http://c
[![particles_wave](http://github.com/mrdoob/three.js/raw/master/assets/examples/01_waves.png)](http://mrdoob.com/projects/three.js/examples/particles_waves.html)
[![particles_floor](http://github.com/mrdoob/three.js/raw/master/assets/examples/00_floor.png)](http://mrdoob.com/projects/three.js/examples/particles_floor.html)

[![Rat](http://github.com/mrdoob/three.js/raw/master/assets/projects/06_rat.png)](http://tech.lab212.org/2010/07/export-textured-models-from-blender2-5-to-three-js/)
[![Failure](http://github.com/mrdoob/three.js/raw/master/assets/projects/05_failure.png)](http://www.is-real.net/experiments/three/failure/)
[![Space Cannon 3D](http://github.com/mrdoob/three.js/raw/master/assets/projects/02_spacecannon.png)](http://labs.brian-stoner.com/spacecannon/)
[![Alocasia](http://github.com/mrdoob/three.js/raw/master/assets/projects/04_alocasia.png)](http://arithmetric.com/projects/alocasia/)
[![DDD](http://github.com/mrdoob/three.js/raw/master/assets/projects/01_ddd.png)](http://the389.com/works/three/)
Expand Down Expand Up @@ -58,7 +60,7 @@ This code creates a camera, then creates a scene object, adds a bunch of random
particle.position.x = Math.random() * 2000 - 1000;
particle.position.y = Math.random() * 2000 - 1000;
particle.position.z = Math.random() * 2000 - 1000;
scene.add( particle );
scene.addObject( particle );

}

Expand Down Expand Up @@ -119,6 +121,14 @@ Thanks to the power of the internets (and github <3) these people have kindly he

### Change Log ###

2010 07 03 - **r11** (23.541 kb)

* Blender 2.5 exporter (utils/export_threejs.py) now exports UV and normals (Thx [kikko](http://github.com/kikko))
* Scene.add > Scene.addObject
* Enabled Scene.removeObject
* Removed computeNormals() from Geometry


2010 06 22 - **r10** (23.959 kb)

* Changed Camera system. (Thx [Paul Brunt](http://github.com/supereggbert))
Expand Down
4 changes: 2 additions & 2 deletions build/three.js

Large diffs are not rendered by default.

46 changes: 0 additions & 46 deletions src/core/Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,50 +9,4 @@ THREE.Geometry = function () {
this.faces = [];
this.uvs = [];

this.computeNormals = function () {

var v, f, vA, vB, vC, cb, ab, normal;

for( v = 0; v < this.vertices.length; v++ ) {

this.vertices[v].normal.set(0,0,0);

}

for( f = 0; f < this.faces.length; f++ ) {

vA = this.vertices[ this.faces[f].a ];
vB = this.vertices[ this.faces[f].b ];
vC = this.vertices[ this.faces[f].c ];

cb = new THREE.Vector3();
ab = new THREE.Vector3();
normal = new THREE.Vector3();

cb.sub(vC.position,vB.position);
ab.sub(vA.position,vB.position);
cb.cross(ab);

if ( !cb.isZero() ) {

cb.normalize();

}

this.faces[f].normal = cb;

vA.normal.addSelf( normal );
vB.normal.addSelf( normal );
vC.normal.addSelf( normal );

if ( this.faces[f] instanceof THREE.Face4 ) {

this.vertices[ this.faces[f].d ].normal.addSelf( normal );

}

}

};

};
22 changes: 14 additions & 8 deletions src/scenes/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,33 @@
THREE.Scene = function () {

this.objects = [];
// this.lights = [];

this.add = function (object) {
this.addObject = function ( object ) {

this.objects.push(object);

};

/*
this.remove = function (object) {
this.removeObject = function ( object ) {

var nrObjects = this.objects.length;
for ( var i = 0, l = this.objects.length; i < l; i++ ) {

for(var i = 0; i < nrObjects; i++) {
if ( object == this.objects[ i ] ) {

if(object == this.objects[i]) {
this.objects.splice( i, 1 );
return;

alert("yay");
}
}
}
*/

// Deprecated
this.add = function ( object ) {

this.addObject( object );

};

this.toString = function () {

Expand Down
2 changes: 1 addition & 1 deletion utils/deployer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# MERGER

rev = 10;
rev = 11;

files = [];
files.append('Three.js');
Expand Down
6 changes: 3 additions & 3 deletions utils/export_threejs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__author__ = "Mr.doob"
__url__ = ("http://mrdoob.com")
__author__ = "Mr.doob, Kikko"
__url__ = ['http://mrdoob.com', 'http://github.com/kikko']
__version__ = "1"
__bpydoc__ = """\
This script exports the selected object for the three.js engine.
Expand Down Expand Up @@ -209,4 +209,4 @@ def unregister():
bpy.types.INFO_MT_file_export.remove(menu_func)

if __name__ == "__main__":
register()
register()

0 comments on commit 4d0fdbb

Please sign in to comment.