提交 03428eaa 编写于 作者: K Kai Salmen

RawObject did not correctly set the material reference. Adjusted logic of RawObject.finalize

上级 26416bd4
......@@ -15,7 +15,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
*/
THREE.OBJLoader2 = (function () {
var OBJLOADER2_VERSION = '1.4.0';
var OBJLOADER2_VERSION = '1.4.1';
function OBJLoader2( manager ) {
console.log( "Using THREE.OBJLoader2 version: " + OBJLOADER2_VERSION );
......@@ -476,7 +476,7 @@ THREE.OBJLoader2 = (function () {
*/
var RawObject = (function () {
function RawObject( objectName, groupName, mtllibName ) {
function RawObject( objectName, groupName, activeMtlName ) {
this.globalVertexOffset = 1;
this.globalUvOffset = 1;
this.globalNormalOffset = 1;
......@@ -487,10 +487,9 @@ THREE.OBJLoader2 = (function () {
this.uvs = [];
// faces are stored according combined index of group, material and smoothingGroup (0 or not)
this.mtllibName = Validator.verifyInput( mtllibName, '' );
this.activeMtlName = Validator.verifyInput( activeMtlName, '' );
this.objectName = Validator.verifyInput( objectName, '' );
this.groupName = Validator.verifyInput( groupName, '' );
this.activeMtlName = '';
this.activeSmoothingGroup = 1;
this.mtlCount = 0;
......@@ -508,7 +507,7 @@ THREE.OBJLoader2 = (function () {
};
RawObject.prototype.newInstanceFromObject = function ( objectName, groupName ) {
var newRawObject = new RawObject( objectName, groupName, this.mtllibName );
var newRawObject = new RawObject( objectName, groupName, this.activeMtlName );
// move indices forward
newRawObject.globalVertexOffset = this.globalVertexOffset + this.vertices.length / 3;
......@@ -519,7 +518,7 @@ THREE.OBJLoader2 = (function () {
};
RawObject.prototype.newInstanceFromGroup = function ( groupName ) {
var newRawObject = new RawObject( this.objectName, groupName, this.mtllibName );
var newRawObject = new RawObject( this.objectName, groupName, this.activeMtlName );
// keep current buffers and indices forward
newRawObject.vertices = this.vertices;
......@@ -618,7 +617,7 @@ THREE.OBJLoader2 = (function () {
}
// "f vertex/uv ..."
// "f vertex/uv ..."
} else if ( bufferLength === slashesCount * 2 ) {
for ( i = 3; i < bufferLength - 2; i += 2 ) {
......@@ -629,7 +628,7 @@ THREE.OBJLoader2 = (function () {
}
// "f vertex/uv/normal ..."
// "f vertex/uv/normal ..."
} else if ( bufferLength * 2 === slashesCount * 3 ) {
for ( i = 4; i < bufferLength - 3; i += 3 ) {
......@@ -640,7 +639,7 @@ THREE.OBJLoader2 = (function () {
}
// "f vertex//normal ..."
// "f vertex//normal ..."
} else {
for ( i = 3; i < bufferLength - 2; i += 2 ) {
......@@ -715,8 +714,7 @@ THREE.OBJLoader2 = (function () {
* Clear any empty rawObjectDescription and calculate absolute vertex, normal and uv counts
*/
RawObject.prototype.finalize = function ( meshCreator, inputObjectCount, debug ) {
var temp = this.rawObjectDescriptions;
this.rawObjectDescriptions = [];
var temp = [];
var rawObjectDescription;
var index = 0;
var absoluteVertexCount = 0;
......@@ -724,12 +722,12 @@ THREE.OBJLoader2 = (function () {
var absoluteNormalCount = 0;
var absoluteUvCount = 0;
for ( var name in temp ) {
for ( var name in this.rawObjectDescriptions ) {
rawObjectDescription = temp[ name ];
rawObjectDescription = this.rawObjectDescriptions[ name ];
if ( rawObjectDescription.vertices.length > 0 ) {
this.rawObjectDescriptions[ index++ ] = rawObjectDescription;
temp[ index++ ] = rawObjectDescription;
absoluteVertexCount += rawObjectDescription.vertices.length;
absoluteColorCount += rawObjectDescription.colors.length;
absoluteUvCount += rawObjectDescription.uvs.length;
......@@ -744,7 +742,7 @@ THREE.OBJLoader2 = (function () {
if ( debug ) this.createReport( inputObjectCount, true );
meshCreator.buildMesh(
this.rawObjectDescriptions,
temp,
inputObjectCount,
absoluteVertexCount,
absoluteColorCount,
......
......@@ -15,7 +15,7 @@ if ( THREE.OBJLoader2 === undefined ) { THREE.OBJLoader2 = {} }
*/
THREE.OBJLoader2.WWOBJLoader2 = (function () {
var WWOBJLOADER2_VERSION = '1.4.0';
var WWOBJLOADER2_VERSION = '1.4.1';
var Validator = THREE.OBJLoader2.prototype._getValidator();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册