API Reference

Class List

ContainerResource

Summary

Methods

instantiateModelEntity

Instantiates an entity with a model component.

instantiateRenderEntity

Instantiates an entity with a render component.

Details

Constructor

ContainerResource()

Container for a list of animations, textures, materials, renders and a model.

Methods

instantiateModelEntity([options])

Instantiates an entity with a model component.

// load a glb file and instantiate an entity with a model component based on it
app.assets.loadFromUrl("statue.glb", "container", function (err, asset) {
    var entity = asset.resource.instantiateModelEntity({
        castShadows: true
    });
    app.root.addChild(entity);
});

Parameters

optionsobject

The initialization data for the model component type ModelComponent.

Returns

Entity

A single entity with a model component. Model component internally contains a hierarchy based on GraphNode.

instantiateRenderEntity([options])

Instantiates an entity with a render component.

// load a glb file and instantiate an entity with a render component based on it
app.assets.loadFromUrl("statue.glb", "container", function (err, asset) {
    var entity = asset.resource.instantiateRenderEntity({
        castShadows: true
    });
    app.root.addChild(entity);

    // find all render components containing mesh instances, and change blend mode on their materials
    var renders = entity.findComponents("render");
    renders.forEach(function (render) {
        render.meshInstances.forEach(function (meshInstance) {
            meshInstance.material.blendType = pc.BLEND_MULTIPLICATIVE;
            meshInstance.material.update();
        });
    });
});

Parameters

optionsobject

The initialization data for the render component type RenderComponent.

Returns

Entity

A hierarchy of entities with render components on entities containing renderable geometry.