
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
threejs-model-loader
Advanced tools
THREE.js Model Loader that delegates to the appropriate geometry loader
THREE.js Model Loader for delegating to the appropriate geometry loader. Uses the file's extension to determine which THREE geometry loader to use.
var loader = new THREE.ModelLoader();
// overriding the getLoader function so loaders can be
// loaded as-needed
loader.getLoader = function( loaderName, manager, loadercb ) {
function createLoader() {
return new THREE[ loaderName ]( manager );
}
if ( THREE[ loaderName ] == null ) {
// fetch the loader script from the server and run it
// if it's not already on the page
fetch(`.../node_modules/three/examples/js/loaders/${ loaderName }.js`)
.then(res => res.text())
.then(tex => {
eval( text );
loadercb( createLoader() );
});
} else {
loadercb( createLoader() );
}
}
loader.load( '.../model.ply', res => {
// res.model
// res.originalResult
// res.extension
} );
A function signature that mirrors all the THREE.js geometry loaders. An appriopriate loader is selected based on the file name.
If extOverride
is set, then that extension is used to select the loader.
onLoad
is passed an object with values
{
model, // THREE.js Object3D, Group, or Mesh that was loaded
extension, // The extension of the model that was loaded
originalResult // The original result that the loader returned
}
Takes the data
to parse into geometry and the associated file extension in ext
.
The model is returned asynchronously in onLoad
to support async fetching of the loaders.
See load
for documentation on what the onLoad
function is passed.
Function used to return an instance of a particular loader. Once the loader has been created, pass it into loadercb
. See above code snippet for an example.
Object with a map of loader name to loader class to instantiate. Used only for the default implementation of the getLoader
function. Defaults to the available THREE
object where loaders are typically available.
List of extension
to loaderName
, used to select the loader for each extension. The list can be modified by adding and removing keys from the list. Every loader is expected to be found on the THREE
object.
loader.loadMap[ 'obj' ] = 'OBJLoader';
delete loader.loadMap[ 'stl' ];
<!-- Register the Element -->
<script href=".../model-viewer-element.js" />
<script>customElements.define('model-viewer', ModelViewer)</script>
<body>
<model-viewer src=".../path/to/model.ply" display-shadow ambient-color="red"></model-viewer>
</body>
The url of the model to display.
Whether or not the render the shadow under the robot.
The color of the ambient light specified with css colors.
Show a grid underneath the model.
Automatically redraw the model every frame instead of waiting to be dirtied.
Dirty the renderer so the element will redraw next frame.
Fires when a model is going to load.
Fires when all the geometry has been fully loaded.
Fires when there's a problem loading the model.
Install Node.js and NPM.
Run npm install
.
Run npm run server
.
Visit localhost:9080/example/
to view the page.
[0.1.0] - 2018-10-29
src
folder.umd
folder.FAQs
THREE.js Model Loader that delegates to the appropriate geometry loader
The npm package threejs-model-loader receives a total of 3 weekly downloads. As such, threejs-model-loader popularity was classified as not popular.
We found that threejs-model-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.