Skip to content

Commit 91d9af8

Browse files
committed
Merge branch 'dev' of git@github.com:mrdoob/three.js.git into texture_encoding
# Conflicts: # src/renderers/shaders/ShaderLib.js
2 parents 653a278 + 5b55178 commit 91d9af8

19 files changed

Lines changed: 1896 additions & 1324 deletions

build/three.js

Lines changed: 494 additions & 390 deletions
Large diffs are not rendered by default.

build/three.min.js

Lines changed: 281 additions & 300 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/js/Ocean.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@
1212

1313
this.scene = new THREE.Scene();
1414

15-
// Enable necessary extensions
16-
this.renderer.context.getExtension( 'OES_texture_float' );
17-
this.renderer.context.getExtension( 'OES_texture_float_linear' );
18-
1915
// Assign optional parameters as variables and object properties
2016
function optionalParameter( value, defaultValue ) {
2117

examples/js/exporters/STLBinaryExporter.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@ THREE.STLBinaryExporter.prototype = {
1717

1818
return function parse( scene ) {
1919

20+
// We collect objects first, as we may need to convert from BufferGeometry to Geometry
21+
var objects = [];
2022
var triangles = 0;
2123
scene.traverse( function ( object ) {
2224

2325
if ( ! ( object instanceof THREE.Mesh ) ) return;
24-
triangles += object.geometry.faces.length;
26+
27+
var geometry = object.geometry;
28+
if ( geometry instanceof THREE.BufferGeometry ) {
29+
30+
geometry = new THREE.Geometry().fromBufferGeometry( geometry );
31+
32+
}
33+
34+
if ( ! ( geometry instanceof THREE.Geometry ) ) return;
35+
triangles += geometry.faces.length;
36+
37+
objects.push( {
38+
39+
geometry: geometry,
40+
matrix: object.matrixWorld
41+
42+
} );
2543

2644
} );
2745

@@ -31,25 +49,13 @@ THREE.STLBinaryExporter.prototype = {
3149
var output = new DataView( arrayBuffer );
3250
output.setUint32( offset, triangles, true ); offset += 4;
3351

34-
scene.traverse( function ( object ) {
35-
36-
if ( ! ( object instanceof THREE.Mesh ) ) return;
37-
38-
var geometry = object.geometry;
39-
if ( geometry instanceof THREE.BufferGeometry ) {
40-
41-
geometry = new THREE.Geometry().fromBufferGeometry( geometry );
42-
43-
}
44-
45-
if ( ! ( geometry instanceof THREE.Geometry ) ) return;
46-
47-
var matrixWorld = object.matrixWorld;
52+
// Traversing our collected objects
53+
objects.forEach( function ( object ) {
4854

49-
var vertices = geometry.vertices;
50-
var faces = geometry.faces;
55+
var vertices = object.geometry.vertices;
56+
var faces = object.geometry.faces;
5157

52-
normalMatrixWorld.getNormalMatrix( matrixWorld );
58+
normalMatrixWorld.getNormalMatrix( object.matrix );
5359

5460
for ( var i = 0, l = faces.length; i < l; i ++ ) {
5561

@@ -65,7 +71,7 @@ THREE.STLBinaryExporter.prototype = {
6571

6672
for ( var j = 0; j < 3; j ++ ) {
6773

68-
vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( matrixWorld );
74+
vector.copy( vertices[ indices[ j ] ] ).applyMatrix4( object.matrix );
6975

7076
output.setFloat32( offset, vector.x, true ); offset += 4; // vertices
7177
output.setFloat32( offset, vector.y, true ); offset += 4;

examples/js/loaders/ColladaLoader2.js

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,87 @@ THREE.ColladaLoader.prototype = {
420420
break;
421421

422422
case 'texture':
423-
data[ child.nodeName ] = child.getAttribute( 'texture' );
423+
data[ child.nodeName ] = { id: child.getAttribute( 'texture' ), extra: parseEffectParameterTexture( child ) };
424+
break;
425+
426+
}
427+
428+
}
429+
430+
return data;
431+
432+
}
433+
434+
function parseEffectParameterTexture( xml ) {
435+
436+
var data = {};
437+
438+
for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
439+
440+
var child = xml.childNodes[ i ];
441+
442+
if ( child.nodeType !== 1 ) continue;
443+
444+
switch ( child.nodeName ) {
445+
446+
case 'extra':
447+
data = parseEffectParameterTextureExtra( child );
448+
break;
449+
450+
}
451+
452+
}
453+
454+
return data;
455+
456+
}
457+
458+
function parseEffectParameterTextureExtra( xml ) {
459+
460+
var data = {};
461+
462+
for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
463+
464+
var child = xml.childNodes[ i ];
465+
466+
if ( child.nodeType !== 1 ) continue;
467+
468+
switch ( child.nodeName ) {
469+
470+
case 'technique':
471+
data[ child.nodeName ] = parseEffectParameterTextureExtraTechnique( child );
472+
break;
473+
474+
}
475+
476+
}
477+
478+
return data;
479+
480+
}
481+
482+
function parseEffectParameterTextureExtraTechnique( xml ) {
483+
484+
var data = {};
485+
486+
for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) {
487+
488+
var child = xml.childNodes[ i ];
489+
490+
if ( child.nodeType !== 1 ) continue;
491+
492+
switch ( child.nodeName ) {
493+
494+
case 'repeatU':
495+
case 'repeatV':
496+
case 'offsetU':
497+
case 'offsetV':
498+
data[ child.nodeName ] = parseFloat( child.textContent );
499+
break;
500+
501+
case 'wrapU':
502+
case 'wrapV':
503+
data[ child.nodeName ] = parseInt( child.textContent );
424504
break;
425505

426506
}
@@ -497,24 +577,37 @@ THREE.ColladaLoader.prototype = {
497577

498578
material.name = data.name;
499579

500-
function getTexture( sid ) {
580+
function getTexture( textureObject ) {
501581

502-
var sampler = effect.profile.samplers[ sid ];
582+
var sampler = effect.profile.samplers[ textureObject.id ];
503583

504584
if ( sampler !== undefined ) {
505585

506586
var surface = effect.profile.surfaces[ sampler.source ];
507587

508588
var texture = new THREE.Texture( getImage( surface.init_from ) );
509-
texture.wrapS = THREE.RepeatWrapping;
510-
texture.wrapT = THREE.RepeatWrapping;
589+
590+
var extra = textureObject.extra;
591+
592+
if ( extra !== undefined && extra.technique !== undefined ) {
593+
594+
var technique = extra.technique;
595+
596+
texture.wrapS = technique.wrapU ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
597+
texture.wrapT = technique.wrapV ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping;
598+
599+
texture.offset.set( technique.offsetU, technique.offsetV );
600+
texture.repeat.set( technique.repeatU, technique.repeatV );
601+
602+
}
603+
511604
texture.needsUpdate = true;
512605

513606
return texture;
514607

515608
}
516609

517-
console.error( 'ColladaLoder: Undefined sampler', sid );
610+
console.error( 'ColladaLoder: Undefined sampler', textureObject.id );
518611

519612
return null;
520613

0 commit comments

Comments
 (0)