|
@@ -53,7 +53,7 @@ THREE.MMDLoader = ( function () {
|
|
|
crossOrigin: 'anonymous',
|
|
|
|
|
|
/**
|
|
|
- * @param {string} value
|
|
|
+ * @param {string} crossOrigin
|
|
|
* @return {THREE.MMDLoader}
|
|
|
*/
|
|
|
setCrossOrigin: function ( crossOrigin ) {
|
|
@@ -63,6 +63,39 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * @param {string} animationPath
|
|
|
+ * @return {THREE.MMDLoader}
|
|
|
+ */
|
|
|
+ setAnimationPath: function ( animationPath ) {
|
|
|
+
|
|
|
+ this.animationPath = animationPath;
|
|
|
+ return this;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param {string} path
|
|
|
+ * @return {THREE.MMDLoader}
|
|
|
+ */
|
|
|
+ setPath: function ( path ) {
|
|
|
+
|
|
|
+ this.path = path;
|
|
|
+ return this;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param {string} resourcePath
|
|
|
+ * @return {THREE.MMDLoader}
|
|
|
+ */
|
|
|
+ setResoucePath: function ( resourcePath ) {
|
|
|
+
|
|
|
+ this.resourcePath = resourcePath;
|
|
|
+ return this;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
// Load MMD assets as Three.js Object
|
|
|
|
|
|
/**
|
|
@@ -77,7 +110,24 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
var builder = this.meshBuilder.setCrossOrigin( this.crossOrigin );
|
|
|
|
|
|
- var texturePath = THREE.LoaderUtils.extractUrlBase( url );
|
|
|
+ // resource path
|
|
|
+
|
|
|
+ var resourcePath;
|
|
|
+
|
|
|
+ if ( this.resourcePath !== undefined ) {
|
|
|
+
|
|
|
+ resourcePath = this.resourcePath;
|
|
|
+
|
|
|
+ } else if ( this.path !== undefined ) {
|
|
|
+
|
|
|
+ resourcePath = this.path;
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ resourcePath = THREE.LoaderUtils.extractUrlBase( url );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
var modelExtension = this._extractExtension( url ).toLowerCase();
|
|
|
|
|
|
// Should I detect by seeing header?
|
|
@@ -91,7 +141,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
this[ modelExtension === 'pmd' ? 'loadPMD' : 'loadPMX' ]( url, function ( data ) {
|
|
|
|
|
|
- onLoad( builder.build( data, texturePath, onProgress, onError ) );
|
|
|
+ onLoad( builder.build( data, resourcePath, onProgress, onError ) );
|
|
|
|
|
|
}, onProgress, onError );
|
|
|
|
|
@@ -167,6 +217,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
this.loader
|
|
|
.setMimeType( undefined )
|
|
|
+ .setPath( this.path )
|
|
|
.setResponseType( 'arraybuffer' )
|
|
|
.load( url, function ( buffer ) {
|
|
|
|
|
@@ -190,6 +241,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
this.loader
|
|
|
.setMimeType( undefined )
|
|
|
+ .setPath( this.path )
|
|
|
.setResponseType( 'arraybuffer' )
|
|
|
.load( url, function ( buffer ) {
|
|
|
|
|
@@ -219,6 +271,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
this.loader
|
|
|
.setMimeType( undefined )
|
|
|
+ .setPath( this.animationPath )
|
|
|
.setResponseType( 'arraybuffer' );
|
|
|
|
|
|
for ( var i = 0, il = urls.length; i < il; i ++ ) {
|
|
@@ -250,6 +303,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
this.loader
|
|
|
.setMimeType( isUnicode ? undefined : 'text/plain; charset=shift_jis' )
|
|
|
+ .setPath( this.animationPath )
|
|
|
.setResponseType( 'text' )
|
|
|
.load( url, function ( text ) {
|
|
|
|
|
@@ -340,17 +394,17 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
/**
|
|
|
* @param {Object} data - parsed PMD/PMX data
|
|
|
- * @param {string} texturePath
|
|
|
+ * @param {string} resourcePath
|
|
|
* @param {function} onProgress
|
|
|
* @param {function} onError
|
|
|
* @return {THREE.SkinnedMesh}
|
|
|
*/
|
|
|
- build: function ( data, texturePath, onProgress, onError ) {
|
|
|
+ build: function ( data, resourcePath, onProgress, onError ) {
|
|
|
|
|
|
var geometry = this.geometryBuilder.build( data );
|
|
|
var material = this.materialBuilder
|
|
|
.setCrossOrigin( this.crossOrigin )
|
|
|
- .setTexturePath( texturePath )
|
|
|
+ .setResourcePath( resourcePath )
|
|
|
.build( data, geometry, onProgress, onError );
|
|
|
|
|
|
var mesh = new THREE.SkinnedMesh( geometry, material );
|
|
@@ -941,7 +995,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
crossOrigin: 'anonymous',
|
|
|
|
|
|
- texturePath: undefined,
|
|
|
+ resourcePath: undefined,
|
|
|
|
|
|
/**
|
|
|
* @param {string} crossOrigin
|
|
@@ -955,12 +1009,12 @@ THREE.MMDLoader = ( function () {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * @param {string} texturePath
|
|
|
+ * @param {string} resourcePath
|
|
|
* @return {MaterialBuilder}
|
|
|
*/
|
|
|
- setTexturePath: function ( texturePath ) {
|
|
|
+ setResourcePath: function ( resourcePath ) {
|
|
|
|
|
|
- this.texturePath = texturePath;
|
|
|
+ this.resourcePath = resourcePath;
|
|
|
return this;
|
|
|
|
|
|
},
|
|
@@ -1280,7 +1334,7 @@ THREE.MMDLoader = ( function () {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- fullPath = this.texturePath + filePath;
|
|
|
+ fullPath = this.resourcePath + filePath;
|
|
|
|
|
|
}
|
|
|
|