Merged with latest changes in mrdoob's branch. All hex colors should be now without baked opacity.

This commit is contained in:
alteredq
2010-11-06 18:59:03 +01:00
34 changed files with 327 additions and 112 deletions
+2 -2
View File
@@ -16,7 +16,7 @@ Other similar projects: [pre3d](http://deanm.github.com/pre3d/), [pvjs](http://c
### Examples ###
[![large_mesh](http://mrdoob.github.com/three.js/assets/examples/12_large_mesh.png)](http://mrdoob.github.com/three.js/examples/geometry_large_mesh.html)
[![interactive_cubes](http://mrdoob.github.com/three.js/assets/examples/11_interactive.png)](http://mrdoob.github.com/three.js/examples/interactive_cubes.html)
[![interactive_voxelpainter](http://mrdoob.github.com/three.js/assets/examples/13_voxelpainter.png)](http://mrdoob.github.com/three.js/examples/interactive_voxelpainter.html)
[![camera_ortographic](http://mrdoob.github.com/three.js/assets/examples/10_orthographic.png)](http://mrdoob.github.com/three.js/examples/camera_orthographic.html)
[![lights_pointlights](http://mrdoob.github.com/three.js/assets/examples/09_walthead.png)](http://mrdoob.github.com/three.js/examples/lights_pointlights.html)
[![geometry_birds](http://mrdoob.github.com/three.js/assets/examples/08_birds.png)](http://mrdoob.github.com/three.js/examples/geometry_birds.html)
@@ -33,7 +33,7 @@ Other similar projects: [pre3d](http://deanm.github.com/pre3d/), [pvjs](http://c
[![The Wilderness Downtown](http://mrdoob.github.com/three.js/assets/projects/09_arcadefire.png)](http://thewildernessdowntown.com/)
[![CloudSCAD](http://mrdoob.github.com/three.js/assets/projects/08_cloudscad.png)](http://cloudscad.com/stl_viewer/)
[![Or so they say...](http://mrdoob.github.com/three.js/assets/projects/07_orsotheysay.png)](http://xplsv.com/prods/demos/online/xplsv_orsotheysay/)
[![Or so they say...](http://mrdoob.github.com/three.js/assets/projects/07_orsotheysay.png)](http://xplsv.com/prods/demos/xplsv_orsotheysay/)
[![Rat](http://mrdoob.github.com/three.js/assets/projects/06_rat.png)](http://tech.lab212.org/2010/07/export-textured-models-from-blender2-5-to-three-js/)
[![Failure](http://mrdoob.github.com/three.js/assets/projects/05_failure.png)](http://www.is-real.net/experiments/three/failure/)
[![Space Cannon 3D](http://mrdoob.github.com/three.js/assets/projects/02_spacecannon.png)](http://labs.brian-stoner.com/spacecannon/)
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -22,6 +22,7 @@
<script type="text/javascript" src="../src/core/Vector2.js"></script>
<script type="text/javascript" src="../src/core/Vector3.js"></script>
<script type="text/javascript" src="../src/core/Vector4.js"></script>
<script type="text/javascript" src="../src/core/Ray.js"></script>
<script type="text/javascript" src="../src/core/Rectangle.js"></script>
<script type="text/javascript" src="../src/core/Matrix3.js"></script>
<script type="text/javascript" src="../src/core/Matrix4.js"></script>
-1
View File
@@ -18,7 +18,6 @@
<script type="text/javascript" src="../build/Three.js"></script>
<script type="text/javascript" src="geometry/primitives/Cube.js"></script>
<script type="text/javascript" src="geometry/primitives/Plane.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
+227
View File
@@ -0,0 +1,227 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>three.js - interactive - voxel painter</title>
<meta charset="utf-8">
<style type="text/css">
body {
font-family: Monospace;
background-color: #f0f0f0;
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<script type="text/javascript" src="../build/Three.js"></script>
<script type="text/javascript" src="geometry/primitives/Cube.js"></script>
<script type="text/javascript" src="geometry/primitives/Plane.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
<script type="text/javascript">
var container, stats;
var camera, scene, renderer;
var projector, plane, cube;
var mouse2D, mouse3D, ray,
rollOveredFace, isShiftDown = false,
theta = 45, isCtrlDown = false;
init();
setInterval( loop, 1000 / 60 );
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
var info = document.createElement( 'div' );
info.style.position = 'absolute';
info.style.top = '10px';
info.style.width = '100%';
info.style.textAlign = 'center';
info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - voxel painter<br /><strong>click</strong>: add voxel, <strong>control + click</strong>: remove voxel, <strong>shift + click</strong>: rotate, <a href="javascript:save();return false;">save .png</a>';
container.appendChild( info );
camera = new THREE.Camera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.y = 800;
camera.target.position.y = 200;
scene = new THREE.Scene();
// Grid
var geometry = new THREE.Geometry();
geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( - 500, 0, 0 ) ) );
geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( 500, 0, 0 ) ) );
for ( var i = 0; i <= 20; i ++ ) {
var line = new THREE.Line( geometry, new THREE.LineColorMaterial( 0x000000, 0.2 ) );
line.position.z = ( i * 50 ) - 500;
scene.addObject( line );
var line = new THREE.Line( geometry, new THREE.LineColorMaterial( 0x000000, 0.2 ) );
line.position.x = ( i * 50 ) - 500;
line.rotation.y = 90 * Math.PI / 180;
scene.addObject( line );
}
projector = new THREE.Projector();
plane = new THREE.Mesh( new Plane( 1000, 1000, 20, 20 ), new THREE.MeshFaceMaterial() );
plane.rotation.x = - 90 * Math.PI / 180;
scene.addObject( plane );
mouse2D = new THREE.Vector3( 0, 10000, 0.5 );
ray = new THREE.Ray( camera.position, null );
// Lights
var ambientLight = new THREE.AmbientLight( 0x606060 );
scene.addLight( ambientLight );
var directionalLight = new THREE.DirectionalLight( 0xffffff );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.addLight( directionalLight );
var directionalLight = new THREE.DirectionalLight( 0x808080 );
directionalLight.position.x = Math.random() - 0.5;
directionalLight.position.y = Math.random() - 0.5;
directionalLight.position.z = Math.random() - 0.5;
directionalLight.position.normalize();
scene.addLight( directionalLight );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild(renderer.domElement);
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
document.addEventListener( 'keydown', onDocumentKeyDown, false );
document.addEventListener( 'keyup', onDocumentKeyUp, false );
}
function onDocumentMouseMove( event ) {
event.preventDefault();
mouse2D.x = ( event.clientX / window.innerWidth ) * 2 - 1;
mouse2D.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
}
function onDocumentMouseDown( event ) {
event.preventDefault();
var intersects = ray.intersectScene( scene );
if ( intersects.length > 0 ) {
if ( isCtrlDown ) {
if ( intersects[ 0 ].object != plane ) {
scene.removeObject( intersects[ 0 ].object );
}
} else {
var position = new THREE.Vector3().add( intersects[ 0 ].point, intersects[ 0 ].object.matrixRotation.transform( intersects[ 0 ].face.normal.clone() ) );
var voxel = new THREE.Mesh( new Cube( 50, 50, 50 ), [ new THREE.MeshColorFillMaterial( 0x00ff80, 1 ), new THREE.MeshFaceMaterial() ] );
voxel.position.x = Math.floor( position.x / 50 ) * 50 + 25;
voxel.position.y = Math.floor( position.y / 50 ) * 50 + 25;
voxel.position.z = Math.floor( position.z / 50 ) * 50 + 25;
voxel.overdraw = true;
scene.addObject( voxel );
}
}
}
function onDocumentKeyDown( event ) {
switch( event.keyCode ) {
case 16: isShiftDown = true; break;
case 17: isCtrlDown = true; break;
}
}
function onDocumentKeyUp( event ) {
switch( event.keyCode ) {
case 16: isShiftDown = false; break;
case 17: isCtrlDown = false; break;
}
}
function save() {
window.open( renderer.domElement.toDataURL('image/png'), 'mywindow' );
}
function loop() {
if ( isShiftDown ) {
theta += mouse2D.x * 3;
}
mouse3D = projector.unprojectVector( mouse2D.clone(), camera );
ray.direction = mouse3D.subSelf( camera.position ).normalize();
var intersects = ray.intersectScene( scene );
// console.log( intersects );
if ( intersects.length > 0 ) {
if ( intersects[ 0 ].face != rollOveredFace ) {
if ( rollOveredFace ) rollOveredFace.material = [];
rollOveredFace = intersects[ 0 ].face;
rollOveredFace.material = [ new THREE.MeshColorFillMaterial( 0xff0000, 0.5 ) ];
}
} else if ( rollOveredFace ) {
rollOveredFace.material = [];
rollOveredFace = null;
}
camera.position.x = 1400 * Math.sin( theta * Math.PI / 360 );
camera.position.z = 1400 * Math.cos( theta * Math.PI / 360 );
renderer.render( scene, camera );
stats.update();
}
</script>
</body>
</html>
+6 -6
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "_03_-_Default1noCulli__03_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -23,7 +23,7 @@ var model = {
},
{
"a_dbg_color" : 0xffee0000,
"a_dbg_color" : 0xee0000,
"a_dbg_index" : 1,
"a_dbg_name" : "_02_-_Default1noCulli__02_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -37,7 +37,7 @@ var model = {
},
{
"a_dbg_color" : 0xff00ee00,
"a_dbg_color" : 0x00ee00,
"a_dbg_index" : 2,
"a_dbg_name" : "FrontColorNoCullingID__02_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -51,7 +51,7 @@ var model = {
},
{
"a_dbg_color" : 0xff0000ee,
"a_dbg_color" : 0x0000ee,
"a_dbg_index" : 3,
"a_dbg_name" : "FrontColorNoCullingID__03_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -65,7 +65,7 @@ var model = {
},
{
"a_dbg_color" : 0xffeeee00,
"a_dbg_color" : 0xeeee00,
"a_dbg_index" : 4,
"a_dbg_name" : "_01_-_Default1noCulli__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -79,7 +79,7 @@ var model = {
},
{
"a_dbg_color" : 0xff00eeee,
"a_dbg_color" : 0x00eeee,
"a_dbg_index" : 5,
"a_dbg_name" : "FrontColorNoCullingID__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
+6 -6
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "_03_-_Default1noCulli__03_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -23,7 +23,7 @@ var model = {
},
{
"a_dbg_color" : 0xffee0000,
"a_dbg_color" : 0xee0000,
"a_dbg_index" : 1,
"a_dbg_name" : "_02_-_Default1noCulli__02_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -37,7 +37,7 @@ var model = {
},
{
"a_dbg_color" : 0xff00ee00,
"a_dbg_color" : 0x00ee00,
"a_dbg_index" : 2,
"a_dbg_name" : "FrontColorNoCullingID__02_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -51,7 +51,7 @@ var model = {
},
{
"a_dbg_color" : 0xff0000ee,
"a_dbg_color" : 0x0000ee,
"a_dbg_index" : 3,
"a_dbg_name" : "FrontColorNoCullingID__03_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -65,7 +65,7 @@ var model = {
},
{
"a_dbg_color" : 0xffeeee00,
"a_dbg_color" : 0xeeee00,
"a_dbg_index" : 4,
"a_dbg_name" : "_01_-_Default1noCulli__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -79,7 +79,7 @@ var model = {
},
{
"a_dbg_color" : 0xff00eeee,
"a_dbg_color" : 0x00eeee,
"a_dbg_index" : 5,
"a_dbg_name" : "FrontColorNoCullingID__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
+6 -6
View File
@@ -12,7 +12,7 @@ var Female02 = function ( urlbase ) {
THREE.Geometry.call(this);
var materials = [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "_03_-_Default1noCulli__03_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -26,7 +26,7 @@ var Female02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xffee0000,
"a_dbg_color" : 0xee0000,
"a_dbg_index" : 1,
"a_dbg_name" : "_02_-_Default1noCulli__02_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -40,7 +40,7 @@ var Female02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xff00ee00,
"a_dbg_color" : 0x00ee00,
"a_dbg_index" : 2,
"a_dbg_name" : "FrontColorNoCullingID__02_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -54,7 +54,7 @@ var Female02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xff0000ee,
"a_dbg_color" : 0x0000ee,
"a_dbg_index" : 3,
"a_dbg_name" : "FrontColorNoCullingID__03_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -68,7 +68,7 @@ var Female02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xffeeee00,
"a_dbg_color" : 0xeeee00,
"a_dbg_index" : 4,
"a_dbg_name" : "_01_-_Default1noCulli__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -82,7 +82,7 @@ var Female02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xff00eeee,
"a_dbg_color" : 0x00eeee,
"a_dbg_index" : 5,
"a_dbg_name" : "FrontColorNoCullingID__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
+1 -1
View File
@@ -12,7 +12,7 @@ var Lucy100k = function ( urlbase ) {
THREE.Geometry.call(this);
var materials = [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "default"
}];
+1 -1
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "default"
}],
+1 -1
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "default"
}],
+5 -5
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "male-02-1noCullingID_male-02-1noCulling.JP",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -23,7 +23,7 @@ var model = {
},
{
"a_dbg_color" : 0xffee0000,
"a_dbg_color" : 0xee0000,
"a_dbg_index" : 1,
"a_dbg_name" : "orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -37,7 +37,7 @@ var model = {
},
{
"a_dbg_color" : 0xff00ee00,
"a_dbg_color" : 0x00ee00,
"a_dbg_index" : 2,
"a_dbg_name" : "FrontColorNoCullingID_orig_02_-_Defaul1noCu",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -51,7 +51,7 @@ var model = {
},
{
"a_dbg_color" : 0xff0000ee,
"a_dbg_color" : 0x0000ee,
"a_dbg_index" : 3,
"a_dbg_name" : "_01_-_Default1noCulli__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -65,7 +65,7 @@ var model = {
},
{
"a_dbg_color" : 0xffeeee00,
"a_dbg_color" : 0xeeee00,
"a_dbg_index" : 4,
"a_dbg_name" : "FrontColorNoCullingID_male-02-1noCulling.JP",
"col_ambient" : [0.0, 0.0, 0.0],
+5 -5
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "male-02-1noCullingID_male-02-1noCulling.JP",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -23,7 +23,7 @@ var model = {
},
{
"a_dbg_color" : 0xffee0000,
"a_dbg_color" : 0xee0000,
"a_dbg_index" : 1,
"a_dbg_name" : "orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -37,7 +37,7 @@ var model = {
},
{
"a_dbg_color" : 0xff00ee00,
"a_dbg_color" : 0x00ee00,
"a_dbg_index" : 2,
"a_dbg_name" : "FrontColorNoCullingID_orig_02_-_Defaul1noCu",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -51,7 +51,7 @@ var model = {
},
{
"a_dbg_color" : 0xff0000ee,
"a_dbg_color" : 0x0000ee,
"a_dbg_index" : 3,
"a_dbg_name" : "_01_-_Default1noCulli__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -65,7 +65,7 @@ var model = {
},
{
"a_dbg_color" : 0xffeeee00,
"a_dbg_color" : 0xeeee00,
"a_dbg_index" : 4,
"a_dbg_name" : "FrontColorNoCullingID_male-02-1noCulling.JP",
"col_ambient" : [0.0, 0.0, 0.0],
+5 -5
View File
@@ -12,7 +12,7 @@ var Male02 = function ( urlbase ) {
THREE.Geometry.call(this);
var materials = [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "male-02-1noCullingID_male-02-1noCulling.JP",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -26,7 +26,7 @@ var Male02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xffee0000,
"a_dbg_color" : 0xee0000,
"a_dbg_index" : 1,
"a_dbg_name" : "orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -40,7 +40,7 @@ var Male02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xff00ee00,
"a_dbg_color" : 0x00ee00,
"a_dbg_index" : 2,
"a_dbg_name" : "FrontColorNoCullingID_orig_02_-_Defaul1noCu",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -54,7 +54,7 @@ var Male02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xff0000ee,
"a_dbg_color" : 0x0000ee,
"a_dbg_index" : 3,
"a_dbg_name" : "_01_-_Default1noCulli__01_-_Default1noCulli",
"col_ambient" : [0.0, 0.0, 0.0],
@@ -68,7 +68,7 @@ var Male02 = function ( urlbase ) {
},
{
"a_dbg_color" : 0xffeeee00,
"a_dbg_color" : 0xeeee00,
"a_dbg_index" : 4,
"a_dbg_name" : "FrontColorNoCullingID_male-02-1noCulling.JP",
"col_ambient" : [0.0, 0.0, 0.0],
+1 -1
View File
@@ -12,7 +12,7 @@ var Torus = function ( urlbase ) {
THREE.Geometry.call(this);
var materials = [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "(null)"
}];
+1 -1
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "(null)"
}],
+1 -1
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "(null)"
}],
+1 -1
View File
@@ -12,7 +12,7 @@ var WaltHead = function ( urlbase ) {
THREE.Geometry.call(this);
var materials = [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "lambert2SG.001",
"col_ambient" : [0.0, 0.0, 0.0],
+1 -1
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "lambert2SG.001",
"col_ambient" : [0.0, 0.0, 0.0],
+1 -1
View File
@@ -9,7 +9,7 @@
var model = {
'materials': [ {
"a_dbg_color" : 0xffeeeeee,
"a_dbg_color" : 0xeeeeee,
"a_dbg_index" : 0,
"a_dbg_name" : "lambert2SG.001",
"col_ambient" : [0.0, 0.0, 0.0],
+1 -1
View File
@@ -187,7 +187,7 @@
sphere = new Sphere( 100, 16, 8, 1 );
for (var i=0; i<10; i++) {
mesh = new THREE.Mesh( sphere, new THREE.MeshColorFillMaterial( 0xffdddddd ) );
mesh = new THREE.Mesh( sphere, new THREE.MeshColorFillMaterial( 0xdddddd ) );
mesh.position.x = 500 * (Math.random() - 0.5);
mesh.position.y = 300 * (Math.random() - 0) + FLOOR;
mesh.position.z = 100 * (Math.random() - 1);
+1 -7
View File
@@ -4,12 +4,6 @@
THREE.Color = function ( hex ) {
/*
this.r; this.g; this.b; this.a;
this.hex;
this.__styleString;
*/
this.autoUpdate = true;
this.setHex( hex );
@@ -73,7 +67,7 @@ THREE.Color.prototype = {
updateHex: function () {
this.hex = Math.floor( this.a * 255 ) << 24 | Math.floor( this.r * 255 ) << 16 | Math.floor( this.g * 255 ) << 8 | Math.floor( this.b * 255 );
this.hex = Math.floor( this.a * 255 ) << 24 ^ Math.floor( this.r * 255 ) << 16 ^ Math.floor( this.g * 255 ) << 8 ^ Math.floor( this.b * 255 );
},
+2 -2
View File
@@ -552,7 +552,7 @@ THREE.Loader.prototype = {
} else {
material = new THREE.MeshColorFillMaterial( 0xffeeeeee );
material = new THREE.MeshColorFillMaterial( 0xeeeeee );
}
@@ -848,7 +848,7 @@ THREE.Loader.prototype = {
} else {
material = new THREE.MeshColorFillMaterial( 0xffeeeeee );
material = new THREE.MeshColorFillMaterial( 0xeeeeee );
}
+1 -2
View File
@@ -5,8 +5,7 @@
THREE.LineColorMaterial = function ( hex, opacity, lineWidth ) {
this.lineWidth = lineWidth || 1;
this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
};
+4 -5
View File
@@ -4,11 +4,11 @@
THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
this.id = THREE.MeshBitmapMaterialCounter.value ++;
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 + ' )';
@@ -17,6 +17,5 @@ THREE.MeshBitmapMaterial = function ( bitmap, mode ) {
};
THREE.MeshBitmapMaterialCounter = { value:0 };
THREE.MeshBitmapMaterialCounter = { value: 0 };
THREE.MeshBitmapMaterialMode = { UVMAPPING: 0 };
+1 -1
View File
@@ -4,7 +4,7 @@
THREE.MeshColorFillMaterial = function ( hex, opacity ) {
this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
this.toString = function () {
+1 -1
View File
@@ -6,7 +6,7 @@ THREE.MeshColorStrokeMaterial = function ( hex, opacity, lineWidth ) {
this.lineWidth = lineWidth || 1;
this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
this.toString = function () {
+6 -5
View File
@@ -4,11 +4,12 @@
THREE.MeshPhongMaterial = function ( ambient, diffuse, specular, shininess, opacity ) {
this.ambient = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | ambient );
this.diffuse = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | diffuse );
this.specular = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | specular );
this.shininess = shininess;
this.opacity = opacity;
this.ambient = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ ambient );
this.diffuse = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ diffuse );
this.specular = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ specular );
this.shininess = shininess;
this.opacity = opacity;
this.toString = function () {
+1 -1
View File
@@ -4,7 +4,7 @@
THREE.ParticleCircleMaterial = function ( hex, opacity ) {
this.color = new THREE.Color( ( opacity >= 0 ? ( opacity * 0xff ) << 24 : 0xff000000 ) | hex );
this.color = new THREE.Color( ( opacity !== undefined ? opacity : 1 ) * 0xff << 24 ^ hex );
this.toString = function () {
+12 -11
View File
@@ -52,7 +52,7 @@ THREE.Mesh.prototype.sortFacesByMaterial = function () {
}
return hash_array.join("_");
return hash_array.join( '_' );
}
@@ -60,40 +60,41 @@ THREE.Mesh.prototype.sortFacesByMaterial = function () {
face = this.geometry.faces[ f ];
material = face.material;
mhash = materialHash( material );
if ( hash_map[ mhash ] == undefined ) {
hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 };
}
ghash = hash_map[ mhash ].hash + "_" + hash_map[ mhash ].counter;
ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
if ( this.materialFaceGroup[ ghash ] == undefined ) {
this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
}
vertices = face instanceof THREE.Face3 ? 3 : 4;
if ( this.materialFaceGroup[ ghash ].vertices + vertices > 65535 ) {
hash_map[ mhash ].counter += 1;
ghash = hash_map[ mhash ].hash + "_" + hash_map[ mhash ].counter;
ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
if ( this.materialFaceGroup[ ghash ] == undefined ) {
this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
}
}
this.materialFaceGroup[ ghash ].faces.push( f );
this.materialFaceGroup[ ghash ].vertices += vertices;
}
+6 -12
View File
@@ -15,14 +15,11 @@ THREE.Scene = function () {
this.removeObject = function ( object ) {
for ( var i = 0, l = this.objects.length; i < l; i++ ) {
var i = this.objects.indexOf( object );
if ( object == this.objects[ i ] ) {
if ( i !== -1 ) {
this.objects.splice( i, 1 );
return;
}
this.objects.splice( i, 1 );
}
@@ -36,14 +33,11 @@ THREE.Scene = function () {
this.removeLight = function ( light ) {
for ( var i = 0, l = this.lights.length; i < l; i++ ) {
var i = this.lights.indexOf( light );
if ( light == this.lights[ i ] ) {
if ( i !== -1 ) {
this.lights.splice( i, 1 );
return;
}
this.lights.splice( i, 1 );
}
+9 -9
View File
@@ -116,7 +116,7 @@ SHADING = "smooth" # flat smooth
# default colors for debugging (each material gets one distinct color):
# white, red, green, blue, yellow, cyan, magenta
COLORS = [0xffeeeeee, 0xffee0000, 0xff00ee00, 0xff0000ee, 0xffeeee00, 0xff00eeee, 0xffee00ee]
COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
# #####################################################
# Templates
@@ -425,22 +425,22 @@ def parse_mtl(fname):
# Diffuse color
# Kd 1.000 1.000 1.000
if chunks[0] == "Kd" and len(chunks) == 4:
if chunks[0] == "Kd" and len(chunks) == 4:
materials[identifier]["col_diffuse"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Ambient color
# Ka 1.000 1.000 1.000
if chunks[0] == "Ka" and len(chunks) == 4:
if chunks[0] == "Ka" and len(chunks) == 4:
materials[identifier]["col_ambient"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Specular color
# Ks 1.000 1.000 1.000
if chunks[0] == "Ks" and len(chunks) == 4:
if chunks[0] == "Ks" and len(chunks) == 4:
materials[identifier]["col_specular"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Specular coefficient
# Ns 154.000
if chunks[0] == "Ns" and len(chunks) == 2:
if chunks[0] == "Ns" and len(chunks) == 2:
materials[identifier]["specular_coef"] = float(chunks[1])
# Transparency
@@ -450,12 +450,12 @@ def parse_mtl(fname):
# Optical density
# Ni 1.0
if chunks[0] == "Ni" and len(chunks) == 2:
if chunks[0] == "Ni" and len(chunks) == 2:
materials[identifier]["optical_density"] = float(chunks[1])
# Diffuse texture
# map_Kd texture_diffuse.jpg
if chunks[0] == "map_Kd" and len(chunks) == 2:
if chunks[0] == "map_Kd" and len(chunks) == 2:
materials[identifier]["map_diffuse"] = chunks[1]
# Ambient texture
@@ -678,9 +678,9 @@ def generate_color(i):
"""
if i < len(COLORS):
return "0x%x" % COLORS[i]
return "0x%06x" % COLORS[i]
else:
return "0x%x" % (int(0xffffff * random.random()) + 0xff000000)
return "0x%06x" % int(0xffffff * random.random())
def value2string(v):
if type(v)==str and v[0] != "0":
+8 -8
View File
@@ -134,7 +134,7 @@ TYPE = "ascii" # ascii binary
# default colors for debugging (each material gets one distinct color):
# white, red, green, blue, yellow, cyan, magenta
COLORS = [0xffeeeeee, 0xffee0000, 0xff00ee00, 0xff0000ee, 0xffeeee00, 0xff00eeee, 0xffee00ee]
COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
# #####################################################
# Templates
@@ -336,27 +336,27 @@ def parse_mtl(fname):
# Diffuse color
# Kd 1.000 1.000 1.000
if chunks[0] == "Kd" and len(chunks) == 4:
if chunks[0] == "Kd" and len(chunks) == 4:
materials[identifier]["col_diffuse"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Ambient color
# Ka 1.000 1.000 1.000
if chunks[0] == "Ka" and len(chunks) == 4:
if chunks[0] == "Ka" and len(chunks) == 4:
materials[identifier]["col_ambient"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Specular color
# Ks 1.000 1.000 1.000
if chunks[0] == "Ks" and len(chunks) == 4:
if chunks[0] == "Ks" and len(chunks) == 4:
materials[identifier]["col_specular"] = [float(chunks[1]), float(chunks[2]), float(chunks[3])]
# Specular coefficient
# Ns 154.000
if chunks[0] == "Ns" and len(chunks) == 2:
if chunks[0] == "Ns" and len(chunks) == 2:
materials[identifier]["specular_coef"] = float(chunks[1])
# Transparency
# Tr 0.9 or d 0.9
if (chunks[0] == "Tr" or chunks[0] == "d") and len(chunks) == 2:
if (chunks[0] == "Tr" or chunks[0] == "d") and len(chunks) == 2:
materials[identifier]["transparency"] = float(chunks[1])
# Optical density
@@ -595,9 +595,9 @@ def generate_color(i):
"""
if i < len(COLORS):
return "0x%x" % COLORS[i]
return "0x%06x" % COLORS[i]
else:
return "0x%x" % (int(0xffffff * random.random()) + 0xff000000)
return "0x%06x" % int(0xffffff * random.random())
def value2string(v):
if type(v)==str and v[0] != "0":