API Docs for: 0.5.5
Show:

kick.core.Project Class

Module: kick.core

A project is a container of all resources and assets used in a game.

When a project is loaded then all it's assets are initialized (except for built-in assets with uid less than 0, which are lazy-loaded).

All assets initialized should be registered in the project. This is done by calling Project.registerObject() (Note for built-in kickjs assets, this happens automatically when the objects are constructed).

Constructor

kick.core.Project

(
  • engine
)

Parameters:

Example:

 // load shader
 var shader = engine.project.load(engine.project.ENGINE_SHADER_DIFFUSE);

Methods

addResourceDescriptor

(
  • resourceDescriptor
)
kick.core.ResourceDescriptor

Parameters:

closeProject

()

Close all resources in the project and remove all resource descriptors

getEngineResourceDescriptorsByType

(
  • type
)
Array_kick.core.ResourceDescriptor

Returns the buildin engine resources

Parameters:

  • type String

Returns:

Array_kick.core.ResourceDescriptor:

getResourceDescriptor

(
  • uid
)
kick.core.ResourceDescriptor

Parameters:

  • uid Number

Returns:

kick.core.ResourceDescriptor:

resource descriptor (or null if not found)

getResourceDescriptorsByName

(
  • name
)
Array_kick.core.ResourceDescriptor

Parameters:

  • name String

Returns:

Array_kick.core.ResourceDescriptor:

getResourceDescriptorsByType

(
  • type
)
Array_kick.core.ResourceDescriptor

Parameters:

  • type String

Returns:

Array_kick.core.ResourceDescriptor:

load

(
  • uid
)

Load a resource from the project.

Parameters:

  • uid String

loadByName

(
  • name
  • type=null
)
kick.core.ProjectAsset

Load a resource from the configuration (or cache). Also increases the resource reference counter. If more objects exist with the same name, the first object is returned

Parameters:

  • name String
  • type=null String

    limit the search to a specific type

Returns:

kick.core.ProjectAsset:

resource or null if resource is not found

loadProject

(
  • config
  • onSuccess
  • [onFail=null]
)

Load a project of the form {maxUID:number,resourceDescriptors:[kick.core.ResourceDescriptor],activeScene:number}

Parameters:

  • config Object
  • onSuccess Function
  • [onFail=null] Function optional

loadProjectByURL

(
  • url
  • onSuccess
  • onFail
)

Loads a project by URL. This call is asynchronous, and onSuccess or onFail will be called when the loading is complete.

Parameters:

  • url String
  • onSuccess Function
  • onFail Function

newProject

()

Creates a new empty project.

refreshResourceDescriptors

(
  • filter=null
)

Updates the resourceDescriptors with data from the initialized objects

Parameters:

  • filter=null Function

    Filter with function(object): return boolean, where true means include in export.

registerObject

(
  • object
  • type
)

Registers an asset in a Project.

Parameters:

  • object Object
  • type String

removeCacheReference

(
  • uid
)

Remove cache references to an object. Next time load(uid) is called a new object is initialized from the resource config

Parameters:

  • uid Number

removeResourceDescriptor

(
  • uid
)

Remove resource descriptor and destroy the resource if already allocated.

Parameters:

  • uid Number

toJSON

(
  • filter=null
)

Parameters:

  • filter=null Function

    Filter with function(object): return boolean, where true means include in export.

Returns:

Object

Properties

ENGINE_MATERIAL_DEFAULT

Number static

Default material is using ENGINE_SHADER_UNLIT and is white

ENGINE_MESH_CUBE

Number static

ENGINE_MESH_CUBE

Number static

ENGINE_MESH_PLANE

Number static

ENGINE_MESH_TRIANGLE

Number static

ENGINE_MESH_UVSPHERE

Number static

ENGINE_SHADER___ERROR

Number protected static

ENGINE_SHADER___PICK

Number static

ENGINE_SHADER___PICK_NORMAL

Number protected static

ENGINE_SHADER___PICK_UV

Number protected static

ENGINE_SHADER___SHADOWMAP

Number static

ENGINE_SHADER___UNLIT_NO_DEPTH_TEST

Number protected static

ENGINE_SHADER_BUMPED_SPECULAR

Number static

ENGINE_SHADER_DEFAULT

Number static

ENGINE_SHADER_DIFFUSE

Number static

ENGINE_SHADER_PARTICLES

Number static

ENGINE_SHADER_SKYBOX

Number static

ENGINE_SHADER_SPECULAR

Number static

ENGINE_SHADER_TRANSPARENT_DIFFUSE

Number static

ENGINE_SHADER_TRANSPARENT_POINT_SPRITE

Number static

ENGINE_SHADER_TRANSPARENT_SPECULAR

Number static

ENGINE_SHADER_TRANSPARENT_UNLIT

Number static

ENGINE_SHADER_UNLIT

Number static

ENGINE_SHADER_UNLIT_VERTEX_COLOR

Number static

ENGINE_TEXTURE_BLACK

Number static

ENGINE_TEXTURE_CUBEMAP_WHITE

Number static

ENGINE_TEXTURE_DEFAULT_NORMAL

Number static

ENGINE_TEXTURE_GRAY

Number static

ENGINE_TEXTURE_WHITE

Number static

maxUID

Number

The maximum UID used in the project

resourceDescriptorUIDs

Array_Number

List the asset uids of project