Plugin Directory

Changeset 1137317


Ignore:
Timestamp:
04/17/2015 03:54:03 PM (11 years ago)
Author:
joergviola
Message:

OBJ Loader

Location:
3d-model-viewer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 3d-model-viewer/trunk/3d-model-viewer.php

    r1137308 r1137317  
    3636        return array_merge($mimes,array (
    3737            'dae' => 'model/vnd.collada+xml',
     38            'objmtl' => 'text/plain',
    3839            'obj' => 'text/plain',
    39             'mtl' => 'text/plain',
     40            'mtl' => 'text/plain',
    4041        ));
    4142    }
  • 3d-model-viewer/trunk/js/3d-model-viewer.js

    r1137308 r1137317  
    5050        else if (this.endsWith(model, '.obj'))
    5151            this.loadOBJ(model, options);
     52        else if (this.endsWith(model, '.objmtl'))
     53            this.loadOBJMTL(model, options);
    5254       
    5355        dirty = true;
     
    5961   
    6062    this.loadDAE = function(model, options) {
     63        console.log('loading DAE');
    6164        var loader = new THREE.ColladaLoader();
    6265        loader.options.convertUpAxis = true;
     
    7477    this.loadOBJ = function(model, options) {
    7578        console.log('loading OBJ');
     79        var loader = new THREE.OBJLoader();
     80        var loadScene = this.scene;
     81        loader.load( model, function ( object ) {
     82            object.position.set(options.modelPosition[0],options.modelPosition[1],options.modelPosition[2]);//x,z,y- if you think in blender dimensions ;)
     83            object.scale.set(options.modelScale[0],options.modelScale[1],options.modelScale[2]);
     84            loadScene.add( object );
     85        });
     86    }
     87
     88    this.loadOBJMTL = function(model, options) {
     89        console.log('loading OBJMTL');
    7690        var loader = new THREE.OBJMTLLoader();
    77         mtl = model.substring(0, model.length-3) + 'mtl';
     91        mtl = model.substring(0, model.length-6) + 'mtl';
    7892        var loadScene = this.scene;
    7993        loader.load( model, mtl, function ( object ) {
Note: See TracChangeset for help on using the changeset viewer.