kick.core.Project Class
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:
-
engine
kick.core.Engine
Example:
// load shader
var shader = engine.project.load(engine.project.ENGINE_SHADER_DIFFUSE);
Item Index
Methods
- addResourceDescriptor
- closeProject
- getEngineResourceDescriptorsByType
- getResourceDescriptor
- getResourceDescriptorsByName
- getResourceDescriptorsByType
- load
- loadByName
- loadProject
- loadProjectByURL
- newProject
- refreshResourceDescriptors
- registerObject
- removeCacheReference
- removeResourceDescriptor
- toJSON
Properties
- ENGINE_MATERIAL_DEFAULT static
- ENGINE_MESH_CUBE static
- ENGINE_MESH_CUBE static
- ENGINE_MESH_PLANE static
- ENGINE_MESH_TRIANGLE static
- ENGINE_MESH_UVSPHERE static
- ENGINE_SHADER___ERROR static
- ENGINE_SHADER___PICK static
- ENGINE_SHADER___PICK_NORMAL static
- ENGINE_SHADER___PICK_UV static
- ENGINE_SHADER___SHADOWMAP static
- ENGINE_SHADER___UNLIT_NO_DEPTH_TEST static
- ENGINE_SHADER_BUMPED_SPECULAR static
- ENGINE_SHADER_DEFAULT static
- ENGINE_SHADER_DIFFUSE static
- ENGINE_SHADER_PARTICLES static
- ENGINE_SHADER_SKYBOX static
- ENGINE_SHADER_SPECULAR static
- ENGINE_SHADER_TRANSPARENT_DIFFUSE static
- ENGINE_SHADER_TRANSPARENT_POINT_SPRITE static
- ENGINE_SHADER_TRANSPARENT_SPECULAR static
- ENGINE_SHADER_TRANSPARENT_UNLIT static
- ENGINE_SHADER_UNLIT static
- ENGINE_SHADER_UNLIT_VERTEX_COLOR static
- ENGINE_TEXTURE_BLACK static
- ENGINE_TEXTURE_CUBEMAP_WHITE static
- ENGINE_TEXTURE_DEFAULT_NORMAL static
- ENGINE_TEXTURE_GRAY static
- ENGINE_TEXTURE_LOGO static
- ENGINE_TEXTURE_WHITE static
- maxUID
- resourceDescriptorUIDs
Methods
addResourceDescriptor
-
resourceDescriptor
Parameters:
-
resourceDescriptor
kick.core.ResourceDescriptor | Object
Returns:
closeProject
()
Close all resources in the project and remove all resource descriptors
getEngineResourceDescriptorsByType
-
type
Returns the buildin engine resources
Parameters:
-
type
String
Returns:
getResourceDescriptor
-
uid
Parameters:
-
uid
Number
Returns:
resource descriptor (or null if not found)
getResourceDescriptorsByName
-
name
Parameters:
-
name
String
Returns:
getResourceDescriptorsByType
-
type
Parameters:
-
type
String
Returns:
load
-
uid
Load a resource from the project.
Parameters:
-
uid
String
loadByName
-
name
-
type=null
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
Stringlimit the search to a specific type
Returns:
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
FunctionFilter 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
FunctionFilter 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_LOGO
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