threejs-model-loader
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -198,2 +198,3 @@ // Converts a datatransfer structer into an object with all paths and files | ||
// check if the end of file and url are the same | ||
// TODO: This does not account for `up directory` `../` tokens | ||
const len = Math.min( name.length, url.length ); | ||
@@ -200,0 +201,0 @@ return url.substr( url.length - len ) === name.substr( name.length - len ); |
@@ -108,2 +108,3 @@ // model-viewer element | ||
scene.add( dirLight ); | ||
scene.add( dirLight.target ); | ||
@@ -185,2 +186,3 @@ // Containers setup | ||
const bbox = new THREE.Box3().setFromObject( this._model ); | ||
const center = bbox.getCenter( new THREE.Vector3() ); | ||
const sphere = bbox.getBoundingSphere( new THREE.Sphere() ); | ||
@@ -191,8 +193,10 @@ const minmax = sphere.radius; | ||
cam.right = cam.top = minmax; | ||
// Update the camera to focus on the center of the model so the | ||
// shadow can encapsulate it | ||
const dirLight = this.directionalLight; | ||
const offset = dirLight.position.clone().sub( dirLight.target.position ); | ||
dirLight.target.position.copy( center ); | ||
dirLight.position.copy( center ).add( offset ); | ||
cam.updateProjectionMatrix(); | ||
// TODO: Position the camera about the center of the model | ||
// because it's possible that the model will be off center | ||
// and extend outside of the shadow camera bounds | ||
} | ||
@@ -424,4 +428,10 @@ | ||
// Can't use the `copy` function because the phong material expects | ||
// a specular color | ||
// https://github.com/mrdoob/three.js/issues/14401 | ||
const mat = new THREE.MeshPhongMaterial(); | ||
mat.copy( m ); | ||
Object.keys( m ) | ||
.filter( key => key in mat && m[ key ] && key != 'type' ) | ||
.forEach( key => mat[ key ] = m[ key ] ); | ||
mats[ i ] = mat; | ||
@@ -428,0 +438,0 @@ m = mat; |
{ | ||
"name": "threejs-model-loader", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "THREE.js Model Loader that delegates to the appropriate geometry loader", | ||
@@ -5,0 +5,0 @@ "main": "ModelLoader.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1857488
7309