API Reference

Class List

pc.ModelHandler

Resource handler used for loading pc.Model resources

Summary

Methods

addParserAdd a parser that converts raw data into a pc.Model Default parser is for JSON models
loadFetch model data from a remote url
openProcess data in deserialized format into a pc.

Details

Constructor

ModelHandler(device, defaultMaterial)

Parameters

devicepc.GraphicsDeviceThe graphics device that will be rendering
defaultMaterialpc.StandardMaterialThe shared default material that is used in any place that a material is not specified

Methods

addParser(parser, decider)

Add a parser that converts raw data into a pc.Model Default parser is for JSON models

Parameters

parserObjectSee JsonModelParser for example
deciderpc.callbacks.AddParserFunction that decides on which parser to use. Function should take (url, data) arguments and return true if this parser should be used to parse the data into a pc.Model. The first parser to return true is used.

load(url, callback)

Fetch model data from a remote url

Parameters

urlStringThe URL of the model data.
callbackpc.callbacks.ResourceHandlerCallback function called when the load completes. The callback is of the form fn(err, response), where err is a String error message in the case where the load fails, and response is the model data that has been successfully loaded.

open(url, data)

Process data in deserialized format into a pc.Model object.

Parameters

urlStringThe URL of the model data.
dataObjectThe data from model file deserialized into a JavaScript Object.

Returns

pc.Model The loaded model.