提交 79ab4bf2 编写于 作者: A alteredq

Merged with mrdoob's branch. Got WebGLRenderer working again :)

Changed OBJ -> Three.js converter to use new materials system (eventual old models need to be reconverted).

Limitations:

  - one use case is now much slower
    - when a mesh has each face with different color (e.g. polyfield in examples/test.html)
    - before this used FaceColorFill material and in WebGLRenderer it was rendered fast with color attribute array
    - now when FaceColorFill material is gone, each face gets own VBO :(

  - material sorting uses Materials "toString" methods for hashing, so it's very important to keep these in a good shape
此差异已折叠。
此差异已折叠。
...@@ -39,11 +39,10 @@ ...@@ -39,11 +39,10 @@
<script type="text/javascript" src="../src/objects/Particle.js"></script> <script type="text/javascript" src="../src/objects/Particle.js"></script>
<script type="text/javascript" src="../src/objects/Line.js"></script> <script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
......
此差异已折叠。
...@@ -74,10 +74,10 @@ ...@@ -74,10 +74,10 @@
for (var i = 0; i < geometry.faces.length; i++) { for (var i = 0; i < geometry.faces.length; i++) {
geometry.faces[i].color.setRGBA( Math.random() * 0.5, Math.random() * 0.5 + 0.5, Math.random() * 0.5 + 0.5, 1 ); geometry.faces[i].material = [ new THREE.MeshColorFillMaterial( Math.random() * 0xffffff, 1 ) ];
} }
cube = new THREE.Mesh(geometry, new THREE.MeshFaceColorFillMaterial() ); cube = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial() );
cube.position.y = 150; cube.position.y = 150;
scene.addObject( cube ); scene.addObject( cube );
......
...@@ -98,7 +98,7 @@ ...@@ -98,7 +98,7 @@
canvas.width = 32; canvas.width = 32;
canvas.height = 32; canvas.height = 32;
var material = new THREE.MeshBitmapUVMappingMaterial( canvas ); var material = new THREE.MeshBitmapMaterial( canvas );
var image = new Image(); var image = new Image();
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
var heightMap = height( 1024, 1024 ); var heightMap = height( 1024, 1024 );
var textureMap = shadow( heightMap ); var textureMap = shadow( heightMap );
var material = new THREE.MeshBitmapUVMappingMaterial( textureMap ); var material = new THREE.MeshBitmapMaterial( textureMap );
var quality = 20; var quality = 20;
var quality1 = quality + 1; var quality1 = quality + 1;
......
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
function loadTexture( path ) { function loadTexture( path ) {
var material = new THREE.MeshBitmapUVMappingMaterial( texture_placeholder ); var material = new THREE.MeshBitmapMaterial( texture_placeholder );
var texture = new Image(); var texture = new Image();
......
...@@ -37,11 +37,10 @@ ...@@ -37,11 +37,10 @@
<script type="text/javascript" src="../src/lights/AmbientLight.js"></script> <script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script> <script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
...@@ -115,33 +114,33 @@ ...@@ -115,33 +114,33 @@
geometry = new ClickCube( 200, 200, 200, geometry = new ClickCube( 200, 200, 200,
function ( s, c, o, f, p ) { function ( s, c, o, f, p ) {
f.color.setRGBA( Math.random() * 0.5, Math.random() * 0.5, Math.random() * 0.5, opacity ); f.material = [ new THREE.MeshColorFillMaterial( Math.random() * 0xffffff, opacity ) ];
document.getElementById( "msg" ).innerHTML = "Click detected at " + p; document.getElementById( "msg" ).innerHTML = "Click detected at " + p;
}); });
for (var i = 0; i < geometry.faces.length; i++) { for (var i = 0; i < geometry.faces.length; i++) {
geometry.faces[i].color.setRGBA( Math.random() * 0.5, Math.random() * 0.5, Math.random() * 0.5, opacity ); geometry.faces[i].material = [ new THREE.MeshColorFillMaterial( Math.random() * 0xffffff, opacity ) ];
} }
cube = new THREE.Mesh( geometry, new THREE.MeshFaceColorFillMaterial() ); cube = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
cube.position.y = 150; cube.position.y = 150;
scene.addObject(cube); scene.addObject(cube);
geometry2 = new ClickCube( 100, 100, 100, geometry2 = new ClickCube( 100, 100, 100,
function ( s, c, o, f, p ) { function ( s, c, o, f, p ) {
f.color.setRGBA( Math.random() * 0.5, Math.random() * 0.5, Math.random() * 0.5, opacity ); f.material = [ new THREE.MeshColorFillMaterial( Math.random() * 0xffffff, opacity ) ];
document.getElementById( "msg" ).innerHTML = "Click detected at " + p; document.getElementById( "msg" ).innerHTML = "Click detected at " + p;
}); });
for (var i = 0; i < geometry2.faces.length; i++) { for (var i = 0; i < geometry2.faces.length; i++) {
geometry2.faces[i].color.setRGBA( Math.random() * 0.5, Math.random() * 0.5, Math.random() * 0.5, opacity ); geometry2.faces[i].material = [ new THREE.MeshColorFillMaterial( Math.random() * 0xffffff, opacity ) ];
} }
cube2 = new THREE.Mesh( geometry2, new THREE.MeshFaceColorFillMaterial() ); cube2 = new THREE.Mesh( geometry2, new THREE.MeshFaceMaterial() );
cube2.position.y = 150; cube2.position.y = 150;
cube2.position.z = 200; cube2.position.z = 200;
scene.addObject(cube2); scene.addObject(cube2);
// Plane // Plane
renderer = new THREE.CanvasRenderer(); renderer = new THREE.CanvasRenderer();
renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT); renderer.setSize(SCREEN_WIDTH, SCREEN_HEIGHT);
......
...@@ -39,11 +39,10 @@ ...@@ -39,11 +39,10 @@
<div id="log"></div> <div id="log"></div>
<script type="text/javascript" src="../build/Three.js"></script>
<!-- <!--
<script type="text/javascript" src="../build/Three.js"></script>
--> -->
<!--
<script type="text/javascript" src="../src/Three.js"></script> <script type="text/javascript" src="../src/Three.js"></script>
<script type="text/javascript" src="../src/core/Color.js"></script> <script type="text/javascript" src="../src/core/Color.js"></script>
<script type="text/javascript" src="../src/core/Vector2.js"></script> <script type="text/javascript" src="../src/core/Vector2.js"></script>
...@@ -67,11 +66,10 @@ ...@@ -67,11 +66,10 @@
<script type="text/javascript" src="../src/objects/Line.js"></script> <script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
...@@ -83,6 +81,7 @@ ...@@ -83,6 +81,7 @@
<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script> <script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script> <script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script> <script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
<!--
--> -->
<script type="text/javascript" src="geometry/primitives/Sphere.js"></script> <script type="text/javascript" src="geometry/primitives/Sphere.js"></script>
......
...@@ -69,11 +69,10 @@ ...@@ -69,11 +69,10 @@
<script type="text/javascript" src="../src/objects/Line.js"></script> <script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
...@@ -221,14 +220,6 @@ ...@@ -221,14 +220,6 @@
geometry = new Female02( "obj/female02" ); geometry = new Female02( "obj/female02" );
// full-mesh wireframe overlay
//geometry.materials.push ( new THREE.MeshColorStrokeMaterial(0xff0000, 1, 1.5) );
// full-mesh color overlay
var colorOverlay = new THREE.MeshColorFillMaterial(0xff0000, 0.5)
colorOverlay.decalIndex = 4;
geometry.materials.push ( colorOverlay );
// PROCEDURAL TEXTURES (decals) // PROCEDURAL TEXTURES (decals)
var x1 = document.createElement( "canvas" ); var x1 = document.createElement( "canvas" );
...@@ -258,18 +249,26 @@ ...@@ -258,18 +249,26 @@
xc2.fillRect(i*4, 5, 2, 54); xc2.fillRect(i*4, 5, 2, 54);
} }
var xm1 = new THREE.MeshBitmapUVMappingMaterial( x1 ); var xm1 = new THREE.MeshBitmapMaterial( x1 );
xm1.loaded = 1; xm1.loaded = 1; // this is procedurally generated texture
xm1.decalIndex = 0; // index of the original UV mapped material
var xm2 = new THREE.MeshBitmapUVMappingMaterial( x2 ); var xm2 = new THREE.MeshBitmapMaterial( x2 );
xm2.loaded = 1; xm2.loaded = 1; // this is procedurally generated texture
xm2.decalIndex = 1; // index of the original UV mapped material
geometry.materials[0].push ( xm1 ); // goes to faces with material 0
geometry.materials[1].push ( xm2 ); // goes to faces with material 1
geometry.materials.push ( xm1 ); geometry.materials[4].push ( new THREE.MeshColorFillMaterial(0xff0000, 0.5) );
geometry.materials.push ( xm2 );
zmesh = new THREE.Mesh( geometry, geometry.materials, 1 ); var materials = [ new THREE.MeshFaceMaterial() ];
// full-mesh wireframe overlay
//materials.push( new THREE.MeshColorStrokeMaterial(0xff0000, 1, 1.5) );
// full-mesh color overlay
//materials.push( new THREE.MeshColorFillMaterial(0xff0000, 0.5) );
zmesh = new THREE.Mesh( geometry, materials, 1 );
zmesh.position.x = -80; zmesh.position.x = -80;
zmesh.position.z = 50; zmesh.position.z = 50;
zmesh.position.y = FLOOR; zmesh.position.y = FLOOR;
...@@ -321,7 +320,7 @@ ...@@ -321,7 +320,7 @@
xc.font = "50pt arial bold"; xc.font = "50pt arial bold";
xc.fillText(i, 10, 64); xc.fillText(i, 10, 64);
var xm = new THREE.MeshBitmapUVMappingMaterial( x ); var xm = new THREE.MeshBitmapMaterial( x );
xm.loaded = 1; xm.loaded = 1;
mesh = new THREE.Mesh( new Plane( size, size ), xm ); mesh = new THREE.Mesh( new Plane( size, size ), xm );
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
textureContext.fillStyle = '#000000'; textureContext.fillStyle = '#000000';
textureContext.fillRect( 0, 0, 480, 204 ); textureContext.fillRect( 0, 0, 480, 204 );
var material = new THREE.MeshBitmapUVMappingMaterial( texture ); var material = new THREE.MeshBitmapMaterial( texture );
textureReflection = document.createElement( 'canvas' ); textureReflection = document.createElement( 'canvas' );
textureReflection.width = 480; textureReflection.width = 480;
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
textureReflectionGradient.addColorStop( 0.2, 'rgba(240, 240, 240, 1)' ); textureReflectionGradient.addColorStop( 0.2, 'rgba(240, 240, 240, 1)' );
textureReflectionGradient.addColorStop( 1, 'rgba(240, 240, 240, 0.8)' ); textureReflectionGradient.addColorStop( 1, 'rgba(240, 240, 240, 0.8)' );
var materialReflection = new THREE.MeshBitmapUVMappingMaterial( textureReflection ); var materialReflection = new THREE.MeshBitmapMaterial( textureReflection );
// //
......
...@@ -15859,18 +15859,18 @@ var Female02 = function ( urlbase ) { ...@@ -15859,18 +15859,18 @@ var Female02 = function ( urlbase ) {
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
} }
function f3( a, b, c, material ) { function f3( a, b, c, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face3( a, b, c, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face3( a, b, c, null, material ) );
} }
function f4( a, b, c, d, material ) { function f4( a, b, c, d, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face4( a, b, c, d, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face4( a, b, c, d, null, material ) );
} }
function f3n( a, b, c, material, n1, n2, n3 ) { function f3n( a, b, c, mi, n1, n2, n3 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -15882,11 +15882,11 @@ var Female02 = function ( urlbase ) { ...@@ -15882,11 +15882,11 @@ var Female02 = function ( urlbase ) {
var n3z = normals[n3][2]; var n3z = normals[n3][2];
scope.faces.push( new THREE.Face3( a, b, c, scope.faces.push( new THREE.Face3( a, b, c,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )],
new THREE.Color(color), material ) ); material ) );
} }
function f4n( a, b, c, d, material, n1, n2, n3, n4 ) { function f4n( a, b, c, d, mi, n1, n2, n3, n4 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -15901,7 +15901,7 @@ var Female02 = function ( urlbase ) { ...@@ -15901,7 +15901,7 @@ var Female02 = function ( urlbase ) {
var n4z = normals[n4][2]; var n4z = normals[n4][2];
scope.faces.push( new THREE.Face4( a, b, c, d, scope.faces.push( new THREE.Face4( a, b, c, d,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )],
new THREE.Color(color), material ) ); material ) );
} }
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) { function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
...@@ -15916,7 +15916,7 @@ var Female02 = function ( urlbase ) { ...@@ -15916,7 +15916,7 @@ var Female02 = function ( urlbase ) {
function init_materials() { function init_materials() {
scope.materials = []; scope.materials = [];
for(var i=0; i<materials.length; ++i) { for(var i=0; i<materials.length; ++i) {
scope.materials[i] = create_material( materials[i], urlbase ); scope.materials[i] = [ create_material( materials[i], urlbase ) ];
} }
} }
...@@ -15936,7 +15936,7 @@ var Female02 = function ( urlbase ) { ...@@ -15936,7 +15936,7 @@ var Female02 = function ( urlbase ) {
if( m.map_diffuse && urlbase ) { if( m.map_diffuse && urlbase ) {
var texture = document.createElement( 'canvas' ); var texture = document.createElement( 'canvas' );
material = new THREE.MeshBitmapUVMappingMaterial( texture ); material = new THREE.MeshBitmapMaterial( texture );
var image = new Image(); var image = new Image();
image.onload = function () { image.onload = function () {
...@@ -15965,7 +15965,7 @@ var Female02 = function ( urlbase ) { ...@@ -15965,7 +15965,7 @@ var Female02 = function ( urlbase ) {
material = new THREE.MeshColorFillMaterial( m.a_dbg_color ); material = new THREE.MeshColorFillMaterial( m.a_dbg_color );
} }
else { else {
material = new THREE.MeshFaceColorFillMaterial( ); material = new THREE.MeshColorFillMaterial( 0xffeeeeee );
} }
return material; return material;
......
...@@ -12859,18 +12859,18 @@ var Male02 = function ( urlbase ) { ...@@ -12859,18 +12859,18 @@ var Male02 = function ( urlbase ) {
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
} }
function f3( a, b, c, material ) { function f3( a, b, c, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face3( a, b, c, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face3( a, b, c, null, material ) );
} }
function f4( a, b, c, d, material ) { function f4( a, b, c, d, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face4( a, b, c, d, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face4( a, b, c, d, null, material ) );
} }
function f3n( a, b, c, material, n1, n2, n3 ) { function f3n( a, b, c, mi, n1, n2, n3 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -12882,11 +12882,11 @@ var Male02 = function ( urlbase ) { ...@@ -12882,11 +12882,11 @@ var Male02 = function ( urlbase ) {
var n3z = normals[n3][2]; var n3z = normals[n3][2];
scope.faces.push( new THREE.Face3( a, b, c, scope.faces.push( new THREE.Face3( a, b, c,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )],
new THREE.Color(color), material ) ); material ) );
} }
function f4n( a, b, c, d, material, n1, n2, n3, n4 ) { function f4n( a, b, c, d, mi, n1, n2, n3, n4 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -12901,7 +12901,7 @@ var Male02 = function ( urlbase ) { ...@@ -12901,7 +12901,7 @@ var Male02 = function ( urlbase ) {
var n4z = normals[n4][2]; var n4z = normals[n4][2];
scope.faces.push( new THREE.Face4( a, b, c, d, scope.faces.push( new THREE.Face4( a, b, c, d,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )],
new THREE.Color(color), material ) ); material ) );
} }
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) { function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
...@@ -12916,7 +12916,7 @@ var Male02 = function ( urlbase ) { ...@@ -12916,7 +12916,7 @@ var Male02 = function ( urlbase ) {
function init_materials() { function init_materials() {
scope.materials = []; scope.materials = [];
for(var i=0; i<materials.length; ++i) { for(var i=0; i<materials.length; ++i) {
scope.materials[i] = create_material( materials[i], urlbase ); scope.materials[i] = [ create_material( materials[i], urlbase ) ];
} }
} }
...@@ -12936,7 +12936,7 @@ var Male02 = function ( urlbase ) { ...@@ -12936,7 +12936,7 @@ var Male02 = function ( urlbase ) {
if( m.map_diffuse && urlbase ) { if( m.map_diffuse && urlbase ) {
var texture = document.createElement( 'canvas' ); var texture = document.createElement( 'canvas' );
material = new THREE.MeshBitmapUVMappingMaterial( texture ); material = new THREE.MeshBitmapMaterial( texture );
var image = new Image(); var image = new Image();
image.onload = function () { image.onload = function () {
...@@ -12965,7 +12965,7 @@ var Male02 = function ( urlbase ) { ...@@ -12965,7 +12965,7 @@ var Male02 = function ( urlbase ) {
material = new THREE.MeshColorFillMaterial( m.a_dbg_color ); material = new THREE.MeshColorFillMaterial( m.a_dbg_color );
} }
else { else {
material = new THREE.MeshFaceColorFillMaterial( ); material = new THREE.MeshColorFillMaterial( 0xffeeeeee );
} }
return material; return material;
......
...@@ -1194,18 +1194,18 @@ var Torus = function ( urlbase ) { ...@@ -1194,18 +1194,18 @@ var Torus = function ( urlbase ) {
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
} }
function f3( a, b, c, material ) { function f3( a, b, c, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face3( a, b, c, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face3( a, b, c, null, material ) );
} }
function f4( a, b, c, d, material ) { function f4( a, b, c, d, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face4( a, b, c, d, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face4( a, b, c, d, null, material ) );
} }
function f3n( a, b, c, material, n1, n2, n3 ) { function f3n( a, b, c, mi, n1, n2, n3 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -1217,11 +1217,11 @@ var Torus = function ( urlbase ) { ...@@ -1217,11 +1217,11 @@ var Torus = function ( urlbase ) {
var n3z = normals[n3][2]; var n3z = normals[n3][2];
scope.faces.push( new THREE.Face3( a, b, c, scope.faces.push( new THREE.Face3( a, b, c,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )],
new THREE.Color(color), material ) ); material ) );
} }
function f4n( a, b, c, d, material, n1, n2, n3, n4 ) { function f4n( a, b, c, d, mi, n1, n2, n3, n4 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -1236,7 +1236,7 @@ var Torus = function ( urlbase ) { ...@@ -1236,7 +1236,7 @@ var Torus = function ( urlbase ) {
var n4z = normals[n4][2]; var n4z = normals[n4][2];
scope.faces.push( new THREE.Face4( a, b, c, d, scope.faces.push( new THREE.Face4( a, b, c, d,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )],
new THREE.Color(color), material ) ); material ) );
} }
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) { function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
...@@ -1251,7 +1251,7 @@ var Torus = function ( urlbase ) { ...@@ -1251,7 +1251,7 @@ var Torus = function ( urlbase ) {
function init_materials() { function init_materials() {
scope.materials = []; scope.materials = [];
for(var i=0; i<materials.length; ++i) { for(var i=0; i<materials.length; ++i) {
scope.materials[i] = create_material( materials[i], urlbase ); scope.materials[i] = [ create_material( materials[i], urlbase ) ];
} }
} }
...@@ -1271,7 +1271,7 @@ var Torus = function ( urlbase ) { ...@@ -1271,7 +1271,7 @@ var Torus = function ( urlbase ) {
if( m.map_diffuse && urlbase ) { if( m.map_diffuse && urlbase ) {
var texture = document.createElement( 'canvas' ); var texture = document.createElement( 'canvas' );
material = new THREE.MeshBitmapUVMappingMaterial( texture ); material = new THREE.MeshBitmapMaterial( texture );
var image = new Image(); var image = new Image();
image.onload = function () { image.onload = function () {
...@@ -1300,7 +1300,7 @@ var Torus = function ( urlbase ) { ...@@ -1300,7 +1300,7 @@ var Torus = function ( urlbase ) {
material = new THREE.MeshColorFillMaterial( m.a_dbg_color ); material = new THREE.MeshColorFillMaterial( m.a_dbg_color );
} }
else { else {
material = new THREE.MeshFaceColorFillMaterial( ); material = new THREE.MeshColorFillMaterial( 0xffeeeeee );
} }
return material; return material;
......
...@@ -42,11 +42,10 @@ ...@@ -42,11 +42,10 @@
<div id="log"></div> <div id="log"></div>
<script type="text/javascript" src="../build/Three.js"></script>
<!-- <!--
<script type="text/javascript" src="../build/Three.js"></script>
--> -->
<!--
<script type="text/javascript" src="../src/Three.js"></script> <script type="text/javascript" src="../src/Three.js"></script>
<script type="text/javascript" src="../src/core/Color.js"></script> <script type="text/javascript" src="../src/core/Color.js"></script>
<script type="text/javascript" src="../src/core/Vector2.js"></script> <script type="text/javascript" src="../src/core/Vector2.js"></script>
...@@ -70,11 +69,10 @@ ...@@ -70,11 +69,10 @@
<script type="text/javascript" src="../src/objects/Line.js"></script> <script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
...@@ -86,6 +84,7 @@ ...@@ -86,6 +84,7 @@
<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script> <script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script> <script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script> <script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
<!--
--> -->
...@@ -161,7 +160,7 @@ ...@@ -161,7 +160,7 @@
xc.fillStyle = "#555"; xc.fillStyle = "#555";
xc.fillRect(96, 96, 32, 32); xc.fillRect(96, 96, 32, 32);
var xm = new THREE.MeshBitmapUVMappingMaterial( x ); var xm = new THREE.MeshBitmapMaterial( x );
xm.loaded = 1; xm.loaded = 1;
geometry = new Plane( 100, 100, 15, 10 ); geometry = new Plane( 100, 100, 15, 10 );
...@@ -245,7 +244,7 @@ ...@@ -245,7 +244,7 @@
// MESH // MESH
geometry = new Male02( "obj/male02" ); geometry = new Male02( "obj/male02" );
zmesh = new THREE.Mesh( geometry, geometry.materials, 1 ); zmesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial(), 1 );
zmesh.position.x = 90; zmesh.position.x = 90;
zmesh.position.z = 50; zmesh.position.z = 50;
zmesh.position.y = FLOOR; zmesh.position.y = FLOOR;
...@@ -264,7 +263,7 @@ ...@@ -264,7 +263,7 @@
// MESH // MESH
geometry = new Female02( "obj/female02" ); geometry = new Female02( "obj/female02" );
zmesh = new THREE.Mesh( geometry, geometry.materials, 1 ); zmesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial(), 1 );
zmesh.position.x = -80; zmesh.position.x = -80;
zmesh.position.z = 50; zmesh.position.z = 50;
zmesh.position.y = FLOOR; zmesh.position.y = FLOOR;
...@@ -317,7 +316,7 @@ ...@@ -317,7 +316,7 @@
xc.font = "50pt arial bold"; xc.font = "50pt arial bold";
xc.fillText(i, 10, 64); xc.fillText(i, 10, 64);
var xm = new THREE.MeshBitmapUVMappingMaterial( x ); var xm = new THREE.MeshBitmapMaterial( x );
xm.loaded = 1; xm.loaded = 1;
mesh = new THREE.Mesh( new Plane( size, size ), xm ); mesh = new THREE.Mesh( new Plane( size, size ), xm );
......
...@@ -69,11 +69,10 @@ ...@@ -69,11 +69,10 @@
<script type="text/javascript" src="../src/objects/Line.js"></script> <script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
......
...@@ -33,16 +33,15 @@ ...@@ -33,16 +33,15 @@
<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script> <script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
<script type="text/javascript" src="../src/lights/PointLight.js"></script> <script type="text/javascript" src="../src/lights/PointLight.js"></script>
<script type="text/javascript" src="../src/objects/Object3D.js"></script> <script type="text/javascript" src="../src/objects/Object3D.js"></script>
<script type="text/javascript" src="../src/objects/Mesh.js"></script>
<script type="text/javascript" src="../src/objects/Particle.js"></script> <script type="text/javascript" src="../src/objects/Particle.js"></script>
<script type="text/javascript" src="../src/objects/Line.js"></script> <script type="text/javascript" src="../src/objects/Line.js"></script>
<script type="text/javascript" src="../src/objects/Mesh.js"></script>
<script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script> <script type="text/javascript" src="../src/materials/LineColorMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshBitmapUVMappingMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorFillMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorFillMaterial.js"></script> <script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
<script type="text/javascript" src="../src/materials/MeshFaceColorStrokeMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
<script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script> <script type="text/javascript" src="../src/materials/ParticleBitmapMaterial.js"></script>
<script type="text/javascript" src="../src/scenes/Scene.js"></script> <script type="text/javascript" src="../src/scenes/Scene.js"></script>
...@@ -105,7 +104,7 @@ ...@@ -105,7 +104,7 @@
// QRCODE // QRCODE
qrcode = mesh = new THREE.Mesh(new Qrcode(), new THREE.MeshFaceColorFillMaterial()); qrcode = mesh = new THREE.Mesh( new Qrcode(), new THREE.MeshFaceMaterial() );
mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2;
mesh.updateMatrix(); mesh.updateMatrix();
scene.add(mesh); scene.add(mesh);
...@@ -156,22 +155,22 @@ ...@@ -156,22 +155,22 @@
var v = new THREE.Vector3( Math.random() * 1000 - 500, Math.random() * 1000 - 500, Math.random() * 1000 - 500 ); var v = new THREE.Vector3( Math.random() * 1000 - 500, Math.random() * 1000 - 500, Math.random() * 1000 - 500 );
var v0 = new THREE.Vertex( new THREE.Vector3(Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 ) ); var v0 = new THREE.Vertex( new THREE.Vector3( Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 ) );
var v1 = new THREE.Vertex( new THREE.Vector3(Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 ) ); var v1 = new THREE.Vertex( new THREE.Vector3( Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 ) );
var v2 = new THREE.Vertex( new THREE.Vector3(Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 ) ); var v2 = new THREE.Vertex( new THREE.Vector3( Math.random() * 100 - 50, Math.random() * 100 - 50, Math.random() * 100 - 50 ) );
v0.position.addSelf( v ); v0.position.addSelf( v );
v1.position.addSelf( v ); v1.position.addSelf( v );
v2.position.addSelf( v ); v2.position.addSelf( v );
var face = new THREE.Face3( geometry.vertices.push( v0 ) - 1, geometry.vertices.push( v1 ) - 1, geometry.vertices.push( v2 ) - 1 ); var face = new THREE.Face3( geometry.vertices.push( v0 ) - 1, geometry.vertices.push( v1 ) - 1, geometry.vertices.push( v2 ) - 1, null, new THREE.MeshColorFillMaterial( Math.random() * 0xffffff ) );
face.color.setRGBA( Math.random(), Math.random(), Math.random(), 1 );
geometry.faces.push( face ); geometry.faces.push( face );
} }
geometry.computeNormals(); geometry.computeNormals();
mesh = new THREE.Mesh( geometry, new THREE.MeshFaceColorFillMaterial() ); mesh = new THREE.Mesh( geometry, [ new THREE.MeshFaceMaterial(), new THREE.MeshColorStrokeMaterial( 0xff0000, 0.5, 10 ) ] );
mesh.doubleSided = true; mesh.doubleSided = true;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2;
scene.add(mesh); scene.add(mesh);
......
...@@ -2,32 +2,22 @@ ...@@ -2,32 +2,22 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.Face3 = function ( a, b, c, normal, color, material ) { THREE.Face3 = function ( a, b, c, normal, material ) {
this.a = a; this.a = a;
this.b = b; this.b = b;
this.c = c; this.c = c;
this.centroid = new THREE.Vector3(); this.centroid = new THREE.Vector3();
this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3(); this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
this.vertexNormals = normal instanceof Array ? normal : [];
this.color = color || new THREE.Color( 0xff000000 );
this.vertexNormals = normal instanceof Array ? normal : []; this.material = material instanceof Array ? material : [ material ];
this.material = material || 0;
}; };
THREE.Face3.prototype = { THREE.Face3.prototype = {
// TODO: Dupe? (Geometry/computeCentroid)
getCenter : function(){
return this.a.clone().addSelf( this.b ).addSelf( this.c ).divideScalar( 3 );
},
toString: function () { toString: function () {
return 'THREE.Face3 ( ' + this.a + ', ' + this.b + ', ' + this.c + ' )'; return 'THREE.Face3 ( ' + this.a + ', ' + this.b + ', ' + this.c + ' )';
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.Face4 = function ( a, b, c, d, normal, color, material ) { THREE.Face4 = function ( a, b, c, d, normal, material ) {
this.a = a; this.a = a;
this.b = b; this.b = b;
...@@ -11,25 +11,15 @@ THREE.Face4 = function ( a, b, c, d, normal, color, material ) { ...@@ -11,25 +11,15 @@ THREE.Face4 = function ( a, b, c, d, normal, color, material ) {
this.centroid = new THREE.Vector3(); this.centroid = new THREE.Vector3();
this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3(); this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
this.vertexNormals = normal instanceof Array ? normal : [];
this.color = color || new THREE.Color( 0xff000000 ); this.material = material instanceof Array ? material : [ material ];
this.vertexNormals = normal instanceof Array ? normal : [];
this.material = material || 0;
}; };
THREE.Face4.prototype = { THREE.Face4.prototype = {
// TODO: Dupe? (Geometry/computeCentroid)
getCenter : function(){
return this.a.clone().addSelf( this.b ).addSelf( this.c ).addSelf( this.d ).divideScalar( 4 );
},
toString: function () { toString: function () {
return 'THREE.Face4 ( ' + this.a + ', ' + this.b + ', ' + this.c + ' ' + this.d + ' )'; return 'THREE.Face4 ( ' + this.a + ', ' + this.b + ', ' + this.c + ' ' + this.d + ' )';
......
...@@ -58,86 +58,97 @@ THREE.Geometry.prototype = { ...@@ -58,86 +58,97 @@ THREE.Geometry.prototype = {
face = this.faces[ f ]; face = this.faces[ f ];
if ( useVertexNormals && face.vertexNormals.length ) { if ( useVertexNormals && face.vertexNormals.length ) {
// set face normal to average of vertex normals
cb.set( 0, 0, 0 );
for ( n = 0, nl = face.normal.length; n < nl; n++ ) { cb.set( 0, 0, 0 );
cb.x += face.vertexNormals[n].x;
cb.y += face.vertexNormals[n].y;
cb.z += face.vertexNormals[n].z;
}
cb.x /= 3; for ( n = 0, nl = face.normal.length; n < nl; n++ ) {
cb.y /= 3;
cb.z /= 3;
if ( !cb.isZero() ) { cd.addSelf( face.vertexNormals[n] );
cb.normalize(); }
} cb.divideScalar( 3 );
face.normal.copy( cb ); if ( ! cb.isZero() ) {
}
else {
vA = this.vertices[ face.a ];
vB = this.vertices[ face.b ];
vC = this.vertices[ face.c ];
cb.sub( vC.position, vB.position ); cb.normalize();
ab.sub( vA.position, vB.position );
cb.crossSelf( ab );
if ( !cb.isZero() ) { }
cb.normalize(); face.normal.copy( cb );
} } else {
face.normal.copy( cb ); vA = this.vertices[ face.a ];
} vB = this.vertices[ face.b ];
vC = this.vertices[ face.c ];
cb.sub( vC.position, vB.position );
ab.sub( vA.position, vB.position );
cb.crossSelf( ab );
if ( !cb.isZero() ) {
cb.normalize();
}
face.normal.copy( cb );
}
}
},
computeBoundingBox: function ( ) {
if ( this.vertices.length > 0 ) {
this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
'y': [ this.vertices[ 0 ].position.y, this.vertices[ 0 ].position.y ],
'z': [ this.vertices[ 0 ].position.z, this.vertices[ 0 ].position.z ] };
for ( var v = 1, vl = this.vertices.length; v < vl; v++ ) {
vertex = this.vertices[ v ];
if ( vertex.position.x < this.bbox.x[ 0 ] ) {
this.bbox.x[ 0 ] = vertex.position.x;
} else if ( vertex.position.x > this.bbox.x[ 1 ] ) {
this.bbox.x[ 1 ] = vertex.position.x;
}
if ( vertex.position.y < this.bbox.y[ 0 ] ) {
this.bbox.y[ 0 ] = vertex.position.y;
} else if ( vertex.position.y > this.bbox.y[ 1 ] ) {
this.bbox.y[ 1 ] = vertex.position.y;
}
if ( vertex.position.z < this.bbox.z[ 0 ] ) {
this.bbox.z[ 0 ] = vertex.position.z;
} else if ( vertex.position.z > this.bbox.z[ 1 ] ) {
this.bbox.z[ 1 ] = vertex.position.z;
}
}
} }
}, },
computeBoundingBox: function ( ) {
if ( this.vertices.length > 0 ) {
this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
'y': [ this.vertices[ 0 ].position.y, this.vertices[ 0 ].position.y ],
'z': [ this.vertices[ 0 ].position.z, this.vertices[ 0 ].position.z ] };
var v, vl;
for ( v = 1, vl = this.vertices.length; v < vl; v++ ) {
vertex = this.vertices[ v ];
if ( vertex.position.x < this.bbox.x[ 0 ] )
this.bbox.x[ 0 ] = vertex.position.x;
else if ( vertex.position.x > this.bbox.x[ 1 ] )
this.bbox.x[ 1 ] = vertex.position.x;
if ( vertex.position.y < this.bbox.y[ 0 ] )
this.bbox.y[ 0 ] = vertex.position.y;
else if ( vertex.position.y > this.bbox.y[ 1 ] )
this.bbox.y[ 1 ] = vertex.position.y;
if ( vertex.position.z < this.bbox.z[ 0 ] )
this.bbox.z[ 0 ] = vertex.position.z;
else if ( vertex.position.z > this.bbox.z[ 1 ] )
this.bbox.z[ 1 ] = vertex.position.z;
}
}
},
toString: function () { toString: function () {
......
/**
* @author mr.doob / http://mrdoob.com/
*/
THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
this.bitmap = bitmap;
this.mode = mode || THREE.MeshBitmapMaterialMode.UVMAPPING;
this.id = THREE.MeshBitmapMaterialCounter.value++;
this.toString = function () {
return 'THREE.MeshBitmapMaterial ( bitmap: ' + this.bitmap + ', mode: ' + this.mode + ', id: ' + this.id + ' )';
};
};
THREE.MeshBitmapMaterialCounter = { value:0 };
THREE.MeshBitmapMaterialMode = { UVMAPPING: 0 };
/**
* @author mr.doob / http://mrdoob.com/
*/
THREE.MeshBitmapUVMappingMaterial = function ( bitmap ) {
this.bitmap = bitmap;
this.loaded = 0;
this.decalIndex = -1;
this.toString = function () {
return 'THREE.MeshBitmapUVMappingMaterial ( bitmap: ' + this.bitmap + ' )';
};
};
/**
* @author mr.doob / http://mrdoob.com/
*/
THREE.MeshFaceColorStrokeMaterial = function ( lineWidth ) {
this.lineWidth = lineWidth || 1;
this.toString = function () {
return 'THREE.MeshFaceColorStrokeMaterial ( lineWidth: ' + this.lineWidth + ' )';
};
};
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* @author mr.doob / http://mrdoob.com/ * @author mr.doob / http://mrdoob.com/
*/ */
THREE.MeshFaceColorFillMaterial = function () { THREE.MeshFaceMaterial = function () {
this.toString = function () { this.toString = function () {
return 'THREE.MeshFaceColorFillMaterial ( )'; return 'THREE.MeshFaceMaterial';
}; };
......
...@@ -14,7 +14,7 @@ THREE.Mesh = function ( geometry, material, normUVs ) { ...@@ -14,7 +14,7 @@ THREE.Mesh = function ( geometry, material, normUVs ) {
this.overdraw = false; this.overdraw = false;
this.materialFaces = {}; this.materialFaceGroup = {};
this.sortFacesByMaterial(); this.sortFacesByMaterial();
if( normUVs ) this.normalizeUVs(); if( normUVs ) this.normalizeUVs();
...@@ -28,20 +28,50 @@ THREE.Mesh.prototype.constructor = THREE.Mesh; ...@@ -28,20 +28,50 @@ THREE.Mesh.prototype.constructor = THREE.Mesh;
THREE.Mesh.prototype.sortFacesByMaterial = function () { THREE.Mesh.prototype.sortFacesByMaterial = function () {
var f, fl, face, material; // TODO
// Should optimize by grouping faces with ColorFill / ColorStroke materials
// which could then use vertex color attributes instead of each being
// in its separate VBO
for ( f = 0, fl = this.geometry.faces.length; f < fl; f++ ) { function materialHash( material ) {
var i, l, hash_array = [];
for ( i = 0, l = material.length; i<l; i++ ) {
if ( material[i] == undefined ) {
hash_array.push( "undefined" );
} else {
hash_array.push( material[i].toString() );
}
}
return hash_array.join("_");
}
var i, f, fl, face, material;
for ( f = 0, fl = this.geometry.faces.length; f < fl; f++ ) {
face = this.geometry.faces[ f ]; face = this.geometry.faces[ f ];
material = face.material; material = face.material;
hash = materialHash( material);
if ( this.materialFaceGroup[ hash ] == undefined ) {
this.materialFaceGroup[ hash ] = { 'faces': [], 'material': material };
}
if ( this.materialFaces[material] == undefined ) this.materialFaceGroup[ hash ].faces.push( f );
this.materialFaces[material] = { 'faces': [] };
this.materialFaces[material].faces.push( f );
} }
} }
THREE.Mesh.prototype.normalizeUVs = function () { THREE.Mesh.prototype.normalizeUVs = function () {
......
此差异已折叠。
...@@ -96,9 +96,8 @@ THREE.Projector = function() { ...@@ -96,9 +96,8 @@ THREE.Projector = function() {
_face3.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, v3.positionScreen.z ) ); _face3.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, v3.positionScreen.z ) );
//_face3.material = [ object.material[face.material] ]; _face3.meshMaterial = object.material;
_face3.material = object.material; _face3.faceMaterial = face.material;
_face3.materialIndex = face.material;
_face3.overdraw = object.overdraw; _face3.overdraw = object.overdraw;
_face3.uvs = object.geometry.uvs[ f ]; _face3.uvs = object.geometry.uvs[ f ];
_face3.color = face.color; _face3.color = face.color;
...@@ -137,9 +136,8 @@ THREE.Projector = function() { ...@@ -137,9 +136,8 @@ THREE.Projector = function() {
_face4.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, Math.max( v3.positionScreen.z, v4.positionScreen.z ) ) ); _face4.z = Math.max( v1.positionScreen.z, Math.max( v2.positionScreen.z, Math.max( v3.positionScreen.z, v4.positionScreen.z ) ) );
//_face4.material = [ object.material[face.material] ]; _face4.meshMaterial = object.material;
_face4.material = object.material; _face4.faceMaterial = face.material;
_face4.materialIndex = face.material;
_face4.overdraw = object.overdraw; _face4.overdraw = object.overdraw;
_face4.uvs = object.geometry.uvs[ f ]; _face4.uvs = object.geometry.uvs[ f ];
_face4.color = face.color; _face4.color = face.color;
......
...@@ -19,6 +19,7 @@ THREE.SVGRenderer = function () { ...@@ -19,6 +19,7 @@ THREE.SVGRenderer = function () {
_vector3 = new THREE.Vector3(), // Needed for PointLight _vector3 = new THREE.Vector3(), // Needed for PointLight
_svgPathPool = [], _svgCirclePool = [], _svgPathPool = [], _svgCirclePool = [],
_svgNode, _pathCount, _circleCount,
_quality = 1; _quality = 1;
this.domElement = _svg; this.domElement = _svg;
...@@ -60,8 +61,7 @@ THREE.SVGRenderer = function () { ...@@ -60,8 +61,7 @@ THREE.SVGRenderer = function () {
this.render = function ( scene, camera ) { this.render = function ( scene, camera ) {
var e, el, m, ml, element, material, var e, el, m, ml, fm, fml, element, material,
pathCount = 0, circleCount = 0, svgNode,
v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y,
size; size;
...@@ -73,6 +73,8 @@ THREE.SVGRenderer = function () { ...@@ -73,6 +73,8 @@ THREE.SVGRenderer = function () {
_renderList = _projector.projectScene( scene, camera ); _renderList = _projector.projectScene( scene, camera );
_pathCount = 0; _circleCount = 0;
_enableLighting = scene.lights.length > 0; _enableLighting = scene.lights.length > 0;
if ( _enableLighting ) { if ( _enableLighting ) {
...@@ -85,155 +87,110 @@ THREE.SVGRenderer = function () { ...@@ -85,155 +87,110 @@ THREE.SVGRenderer = function () {
element = _renderList[ e ]; element = _renderList[ e ];
for ( m = 0, ml = element.material.length; m < ml; m++ ) { _bboxRect.empty();
material = element.material[ m ];
_bboxRect.empty();
if ( element instanceof THREE.RenderableParticle ) {
v1x = element.x * _widthHalf; v1y = element.y * -_heightHalf; if ( element instanceof THREE.RenderableParticle ) {
size = element.size * _widthHalf;
_bboxRect.set( v1x - size, v1y - size, v1x + size, v1y + size ); v1x = element.x * _widthHalf; v1y = element.y * -_heightHalf;
if ( !_clipRect.instersects( _bboxRect ) ) { for ( m = 0, ml = element.material.length; m < ml; m++ ) {
continue;
}
svgNode = getCircleNode( circleCount++ ); material = element.material[ m ];
svgNode.setAttribute( 'cx', v1x );
svgNode.setAttribute( 'cy', v1y );
svgNode.setAttribute( 'r', size );
} else if ( element instanceof THREE.RenderableFace3 ) { renderParticle( v1x, v1y, element, material, scene );
v1x = element.v1.x * _widthHalf; v1y = element.v1.y * -_heightHalf;
v2x = element.v2.x * _widthHalf; v2y = element.v2.y * -_heightHalf;
v3x = element.v3.x * _widthHalf; v3y = element.v3.y * -_heightHalf;
_bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
if ( !_clipRect.instersects( _bboxRect ) ) {
continue;
}
svgNode = getPathNode( pathCount++ ); }
svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + 'z' );
} else if ( element instanceof THREE.RenderableFace4 ) { } else if ( element instanceof THREE.RenderableLine ) {
v1x = element.v1.x * _widthHalf; v1y = element.v1.y * -_heightHalf;
v2x = element.v2.x * _widthHalf; v2y = element.v2.y * -_heightHalf;
v3x = element.v3.x * _widthHalf; v3y = element.v3.y * -_heightHalf;
v4x = element.v4.x * _widthHalf; v4y = element.v4.y * -_heightHalf;
_bboxRect.addPoint( v1x, v1y ); } else if ( element instanceof THREE.RenderableFace3 ) {
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
_bboxRect.addPoint( v4x, v4y );
if ( !_clipRect.instersects( _bboxRect) ) { v1x = element.v1.x * _widthHalf; v1y = element.v1.y * -_heightHalf;
v2x = element.v2.x * _widthHalf; v2y = element.v2.y * -_heightHalf;
v3x = element.v3.x * _widthHalf; v3y = element.v3.y * -_heightHalf;
continue; _bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
} if ( !_clipRect.instersects( _bboxRect ) ) {
svgNode = getPathNode( pathCount++ ); continue;
svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + ' L ' + v4x + ',' + v4y + 'z' );
} }
m = 0; ml = element.meshMaterial.length;
// TODO: Move out of materials loop while ( m < ml ) {
if ( material instanceof THREE.MeshColorFillMaterial ) {
if ( _enableLighting ) { material = element.meshMaterial[ m ++ ];
_light.copyRGB( _ambientLight ); if ( material instanceof THREE.MeshFaceMaterial ) {
calculateFaceLight( scene, element, _light );
_color.copyRGBA( material.color ); fm = 0; fml = element.faceMaterial.length;
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else { while ( fm < fml ) {
_color = material.color;
}
svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString ); material = element.faceMaterial[ fm ++ ];
} else if ( material instanceof THREE.MeshFaceColorFillMaterial ) { renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
if ( _enableLighting ) { }
_light.copyRGB( _ambientLight ); continue;
calculateFaceLight( scene, element, _light );
_color.copyRGBA( element.color ); }
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else { renderFace3( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene );
_color = element.color; }
} } else if ( element instanceof THREE.RenderableFace4 ) {
svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString ); v1x = element.v1.x * _widthHalf; v1y = element.v1.y * -_heightHalf;
v2x = element.v2.x * _widthHalf; v2y = element.v2.y * -_heightHalf;
v3x = element.v3.x * _widthHalf; v3y = element.v3.y * -_heightHalf;
v4x = element.v4.x * _widthHalf; v4y = element.v4.y * -_heightHalf;
} else if ( material instanceof THREE.MeshColorStrokeMaterial ) { _bboxRect.addPoint( v1x, v1y );
_bboxRect.addPoint( v2x, v2y );
_bboxRect.addPoint( v3x, v3y );
_bboxRect.addPoint( v4x, v4y );
if ( _enableLighting ) { if ( !_clipRect.instersects( _bboxRect) ) {
_light.copyRGB( _ambientLight ); continue;
calculateFaceLight( scene, element, _light );
_color.copyRGBA( material.color ); }
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else { m = 0; ml = element.meshMaterial.length;
_color = material.color; while ( m < ml ) {
} material = element.meshMaterial[ m ++ ];
svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.lineWidth + '; stroke-linecap: round; stroke-linejoin: round' ); if ( material instanceof THREE.MeshFaceMaterial ) {
} else if ( material instanceof THREE.MeshFaceColorStrokeMaterial ) { fm = 0; fml = element.faceMaterial.length;
if ( _enableLighting ) { while ( fm < fml ) {
_light.copyRGB( _ambientLight ); material = element.faceMaterial[ fm ++ ];
calculateFaceLight( scene, element, _light );
_color.copyRGBA( element.color ); renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else { }
_color = element.color; continue;
} }
svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.lineWidth + '; stroke-linecap: round; stroke-linejoin: round' ); renderFace4( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene );
} }
_svg.appendChild( svgNode );
} }
} }
...@@ -262,6 +219,32 @@ THREE.SVGRenderer = function () { ...@@ -262,6 +219,32 @@ THREE.SVGRenderer = function () {
} }
function calculateLight( scene, element, color ) {
var l, ll, light;
for ( l = 0, ll = scene.lights.length; l < ll; l++ ) {
light = scene.lights[ l ];
if ( light instanceof THREE.DirectionalLight ) {
color.r += light.color.r;
color.g += light.color.g;
color.b += light.color.b;
} else if ( light instanceof THREE.PointLight ) {
color.r += light.color.r;
color.g += light.color.g;
color.b += light.color.b;
}
}
}
function calculateFaceLight( scene, element, color ) { function calculateFaceLight( scene, element, color ) {
var l, ll, light, amount; var l, ll, light, amount;
...@@ -303,7 +286,143 @@ THREE.SVGRenderer = function () { ...@@ -303,7 +286,143 @@ THREE.SVGRenderer = function () {
} }
function getPathNode( id ) { function renderParticle ( v1x, v1y, element, material, scene ) {
_svgNode = getCircleNode( _circleCount++ );
_svgNode.setAttribute( 'cx', v1x );
_svgNode.setAttribute( 'cy', v1y );
_svgNode.setAttribute( 'r', element.scale.x * _widthHalf );
if ( material instanceof THREE.ParticleCircleMaterial ) {
if ( _enableLighting ) {
_light.copyRGB( _ambientLight );
calculateLight( scene, element, _light );
_color.copyRGBA( material.color );
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else {
_color = material.color;
}
_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString );
}
_svg.appendChild( _svgNode );
}
function renderLine ( ) {
}
function renderFace3 ( v1x, v1y, v2x, v2y, v3x, v3y, element, material, scene ) {
_svgNode = getPathNode( _pathCount ++ );
_svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + 'z' );
if ( material instanceof THREE.MeshColorFillMaterial ) {
if ( _enableLighting ) {
_light.copyRGB( _ambientLight );
calculateFaceLight( scene, element, _light );
_color.copyRGBA( material.color );
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else {
_color = material.color;
}
_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString );
} else if ( material instanceof THREE.MeshColorStrokeMaterial ) {
if ( _enableLighting ) {
_light.copyRGB( _ambientLight );
calculateFaceLight( scene, element, _light );
_color.copyRGBA( material.color );
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else {
_color = material.color;
}
_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.lineWidth + '; stroke-linecap: round; stroke-linejoin: round' );
}
_svg.appendChild( _svgNode );
}
function renderFace4 ( v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, element, material, scene ) {
_svgNode = getPathNode( _pathCount ++ );
_svgNode.setAttribute( 'd', 'M ' + v1x + ' ' + v1y + ' L ' + v2x + ' ' + v2y + ' L ' + v3x + ',' + v3y + ' L ' + v4x + ',' + v4y + 'z' );
if ( material instanceof THREE.MeshColorFillMaterial ) {
if ( _enableLighting ) {
_light.copyRGB( _ambientLight );
calculateFaceLight( scene, element, _light );
_color.copyRGBA( material.color );
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else {
_color = material.color;
}
_svgNode.setAttribute( 'style', 'fill: ' + _color.__styleString );
} else if ( material instanceof THREE.MeshColorStrokeMaterial ) {
if ( _enableLighting ) {
_light.copyRGB( _ambientLight );
calculateFaceLight( scene, element, _light );
_color.copyRGBA( material.color );
_color.multiplySelfRGB( _light );
_color.updateStyleString();
} else {
_color = material.color;
}
_svgNode.setAttribute( 'style', 'fill: none; stroke: ' + _color.__styleString + '; stroke-width: ' + material.lineWidth + '; stroke-linecap: round; stroke-linejoin: round' );
}
_svg.appendChild( _svgNode );
}
function getPathNode ( id ) {
if ( _svgPathPool[ id ] == null ) { if ( _svgPathPool[ id ] == null ) {
...@@ -323,7 +442,7 @@ THREE.SVGRenderer = function () { ...@@ -323,7 +442,7 @@ THREE.SVGRenderer = function () {
} }
function getCircleNode( id ) { function getCircleNode ( id ) {
if ( _svgCirclePool[id] == null ) { if ( _svgCirclePool[id] == null ) {
......
此差异已折叠。
...@@ -29,11 +29,10 @@ files.append('objects/Line.js') ...@@ -29,11 +29,10 @@ files.append('objects/Line.js')
files.append('objects/Mesh.js') files.append('objects/Mesh.js')
files.append('materials/LineColorMaterial.js') files.append('materials/LineColorMaterial.js')
files.append('materials/MeshPhongMaterial.js') files.append('materials/MeshPhongMaterial.js')
files.append('materials/MeshBitmapUVMappingMaterial.js') files.append('materials/MeshBitmapMaterial.js')
files.append('materials/MeshColorFillMaterial.js') files.append('materials/MeshColorFillMaterial.js')
files.append('materials/MeshColorStrokeMaterial.js') files.append('materials/MeshColorStrokeMaterial.js')
files.append('materials/MeshFaceColorFillMaterial.js') files.append('materials/MeshFaceMaterial.js')
files.append('materials/MeshFaceColorStrokeMaterial.js')
files.append('materials/ParticleBitmapMaterial.js') files.append('materials/ParticleBitmapMaterial.js')
files.append('materials/ParticleCircleMaterial.js') files.append('materials/ParticleCircleMaterial.js')
files.append('materials/ParticleDOMMaterial.js') files.append('materials/ParticleDOMMaterial.js')
......
...@@ -29,11 +29,10 @@ files.append('objects/Line.js') ...@@ -29,11 +29,10 @@ files.append('objects/Line.js')
files.append('objects/Mesh.js') files.append('objects/Mesh.js')
files.append('materials/LineColorMaterial.js') files.append('materials/LineColorMaterial.js')
files.append('materials/MeshPhongMaterial.js') files.append('materials/MeshPhongMaterial.js')
files.append('materials/MeshBitmapUVMappingMaterial.js') files.append('materials/MeshBitmapMaterial.js')
files.append('materials/MeshColorFillMaterial.js') files.append('materials/MeshColorFillMaterial.js')
files.append('materials/MeshColorStrokeMaterial.js') files.append('materials/MeshColorStrokeMaterial.js')
files.append('materials/MeshFaceColorFillMaterial.js') files.append('materials/MeshFaceMaterial.js')
files.append('materials/MeshFaceColorStrokeMaterial.js')
files.append('materials/ParticleBitmapMaterial.js') files.append('materials/ParticleBitmapMaterial.js')
files.append('materials/ParticleCircleMaterial.js') files.append('materials/ParticleCircleMaterial.js')
files.append('scenes/Scene.js') files.append('scenes/Scene.js')
......
...@@ -29,11 +29,10 @@ files.append('objects/Line.js') ...@@ -29,11 +29,10 @@ files.append('objects/Line.js')
files.append('objects/Mesh.js') files.append('objects/Mesh.js')
files.append('materials/LineColorMaterial.js') files.append('materials/LineColorMaterial.js')
files.append('materials/MeshPhongMaterial.js') files.append('materials/MeshPhongMaterial.js')
files.append('materials/MeshBitmapUVMappingMaterial.js') files.append('materials/MeshBitmapMaterial.js')
files.append('materials/MeshColorFillMaterial.js') files.append('materials/MeshColorFillMaterial.js')
files.append('materials/MeshColorStrokeMaterial.js') files.append('materials/MeshColorStrokeMaterial.js')
files.append('materials/MeshFaceColorFillMaterial.js') files.append('materials/MeshFaceMaterial.js')
files.append('materials/MeshFaceColorStrokeMaterial.js')
files.append('materials/ParticleBitmapMaterial.js') files.append('materials/ParticleBitmapMaterial.js')
files.append('materials/ParticleCircleMaterial.js') files.append('materials/ParticleCircleMaterial.js')
files.append('materials/ParticleDOMMaterial.js') files.append('materials/ParticleDOMMaterial.js')
......
...@@ -27,11 +27,11 @@ files.append('objects/Object3D.js') ...@@ -27,11 +27,11 @@ files.append('objects/Object3D.js')
files.append('objects/Particle.js') files.append('objects/Particle.js')
files.append('objects/Line.js') files.append('objects/Line.js')
files.append('objects/Mesh.js') files.append('objects/Mesh.js')
files.append('materials/MeshBitmapUVMappingMaterial.js') files.append('materials/LineColorMaterial.js')
files.append('materials/MeshBitmapMaterial.js')
files.append('materials/MeshColorFillMaterial.js') files.append('materials/MeshColorFillMaterial.js')
files.append('materials/MeshColorStrokeMaterial.js') files.append('materials/MeshColorStrokeMaterial.js')
files.append('materials/MeshFaceColorFillMaterial.js') files.append('materials/MeshFaceMaterial.js')
files.append('materials/MeshFaceColorStrokeMaterial.js')
files.append('materials/ParticleBitmapMaterial.js') files.append('materials/ParticleBitmapMaterial.js')
files.append('materials/ParticleCircleMaterial.js') files.append('materials/ParticleCircleMaterial.js')
files.append('scenes/Scene.js') files.append('scenes/Scene.js')
......
...@@ -29,11 +29,10 @@ files.append('objects/Line.js') ...@@ -29,11 +29,10 @@ files.append('objects/Line.js')
files.append('objects/Mesh.js') files.append('objects/Mesh.js')
files.append('materials/LineColorMaterial.js') files.append('materials/LineColorMaterial.js')
files.append('materials/MeshPhongMaterial.js') files.append('materials/MeshPhongMaterial.js')
files.append('materials/MeshBitmapUVMappingMaterial.js') files.append('materials/MeshBitmapMaterial.js')
files.append('materials/MeshColorFillMaterial.js') files.append('materials/MeshColorFillMaterial.js')
files.append('materials/MeshColorStrokeMaterial.js') files.append('materials/MeshColorStrokeMaterial.js')
files.append('materials/MeshFaceColorFillMaterial.js') files.append('materials/MeshFaceMaterial.js')
files.append('materials/MeshFaceColorStrokeMaterial.js')
files.append('materials/ParticleBitmapMaterial.js') files.append('materials/ParticleBitmapMaterial.js')
files.append('materials/ParticleCircleMaterial.js') files.append('materials/ParticleCircleMaterial.js')
files.append('scenes/Scene.js') files.append('scenes/Scene.js')
......
...@@ -163,18 +163,18 @@ var %(name)s = function ( urlbase ) { ...@@ -163,18 +163,18 @@ var %(name)s = function ( urlbase ) {
scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
} }
function f3( a, b, c, material ) { function f3( a, b, c, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face3( a, b, c, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face3( a, b, c, null, material ) );
} }
function f4( a, b, c, d, material ) { function f4( a, b, c, d, mi ) {
var color = material_color(material); var material = scope.materials[ mi ];
scope.faces.push( new THREE.Face4( a, b, c, d, null, new THREE.Color(color), material ) ); scope.faces.push( new THREE.Face4( a, b, c, d, null, material ) );
} }
function f3n( a, b, c, material, n1, n2, n3 ) { function f3n( a, b, c, mi, n1, n2, n3 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -186,11 +186,11 @@ var %(name)s = function ( urlbase ) { ...@@ -186,11 +186,11 @@ var %(name)s = function ( urlbase ) {
var n3z = normals[n3][2]; var n3z = normals[n3][2];
scope.faces.push( new THREE.Face3( a, b, c, scope.faces.push( new THREE.Face3( a, b, c,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z )],
new THREE.Color(color), material ) ); material ) );
} }
function f4n( a, b, c, d, material, n1, n2, n3, n4 ) { function f4n( a, b, c, d, mi, n1, n2, n3, n4 ) {
var color = material_color(material); var material = scope.materials[ mi ];
var n1x = normals[n1][0]; var n1x = normals[n1][0];
var n1y = normals[n1][1]; var n1y = normals[n1][1];
var n1z = normals[n1][2]; var n1z = normals[n1][2];
...@@ -205,7 +205,7 @@ var %(name)s = function ( urlbase ) { ...@@ -205,7 +205,7 @@ var %(name)s = function ( urlbase ) {
var n4z = normals[n4][2]; var n4z = normals[n4][2];
scope.faces.push( new THREE.Face4( a, b, c, d, scope.faces.push( new THREE.Face4( a, b, c, d,
[new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )], [new THREE.Vector3( n1x, n1y, n1z ), new THREE.Vector3( n2x, n2y, n2z ), new THREE.Vector3( n3x, n3y, n3z ), new THREE.Vector3( n4x, n4y, n4z )],
new THREE.Color(color), material ) ); material ) );
} }
function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) { function uv( u1, v1, u2, v2, u3, v3, u4, v4 ) {
...@@ -220,7 +220,7 @@ var %(name)s = function ( urlbase ) { ...@@ -220,7 +220,7 @@ var %(name)s = function ( urlbase ) {
function init_materials() { function init_materials() {
scope.materials = []; scope.materials = [];
for(var i=0; i<materials.length; ++i) { for(var i=0; i<materials.length; ++i) {
scope.materials[i] = create_material( materials[i], urlbase ); scope.materials[i] = [ create_material( materials[i], urlbase ) ];
} }
} }
...@@ -240,7 +240,7 @@ var %(name)s = function ( urlbase ) { ...@@ -240,7 +240,7 @@ var %(name)s = function ( urlbase ) {
if( m.map_diffuse && urlbase ) { if( m.map_diffuse && urlbase ) {
var texture = document.createElement( 'canvas' ); var texture = document.createElement( 'canvas' );
material = new THREE.MeshBitmapUVMappingMaterial( texture ); material = new THREE.MeshBitmapMaterial( texture );
var image = new Image(); var image = new Image();
image.onload = function () { image.onload = function () {
...@@ -269,7 +269,7 @@ var %(name)s = function ( urlbase ) { ...@@ -269,7 +269,7 @@ var %(name)s = function ( urlbase ) {
material = new THREE.MeshColorFillMaterial( m.a_dbg_color ); material = new THREE.MeshColorFillMaterial( m.a_dbg_color );
} }
else { else {
material = new THREE.MeshFaceColorFillMaterial( ); material = new THREE.MeshColorFillMaterial( 0xffeeeeee );
} }
return material; return material;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册