The history object for this entity.
The entity in the 3D viewport of the Editor.
Adds a component to this Entity
The component name
Default component data. Defaults values will be used for any missing fields. For details on component properties see Entity.
Adds a script to the script component of this entity. If a script component does not exist, this method will add the script component as well.
The name of the script.
Options
The values of attributes. Each key is the name of the attributes and each value is the value for that attribute. Leave undefined to let the Editor set default values depending on the attribute types.
Whether to add a history action. Defaults to true.
The desired index in the entity's scripts order to add this script.
A promise
Duplicates entity under the same parent
Optional
options: { history?: boolean; rename?: boolean; select?: boolean } = {}Options
Optional
history?: booleanWhether to record a history action. Defaults to true.
Optional
rename?: booleanWhether to rename the duplicated entity. Defaults to false.
Optional
select?: booleanWhether to select the new entity. Defaults to false.
The new entity
Gets value at path. See Entity for a list of properties.
The path
The value
Checks if path exists. See Entity for a list of properties.
The path
True if path exists
Inserts value in array at path, at specified index. See Entity for a list of properties.
The path
The value
The index (if undefined the value will be inserted in the end)
Whether the value was inserted
Finds all entities with specified tags
The tags. If multiple tags are specified then entities that contain ANY of the specified tags will be included. If an argument is an array of tags then entities that contain ALL of the tags in the array will be included.
The entities
// entities that have the following tag
const entities = editor.entities.root.listByTag('tag');
// entities that have any of the following tags
const entities = editor.entities.root.listByTag('tag', 'tag2');
// entities that have all of the following tags
const entities = editor.entities.root.listByTag(['tag', 'tag2']);
Remove value from array at path. See Entity for a list of properties.
The path
The value
Whether the value was removed
Reparents entity under new parent
The new parent
The desired index. If undefined the entity will be added at the end of the parent's children.
Options
Whether to record a history action. Defaults to true.
Whether to preserve the original transform after reparenting
Sets value at path. See Entity for a list of properties.
The path
The value
Whether the value was set
Unsets value at path. See Entity for a list of properties.
The path
Whether the value was unset
Represents an Entity.
What follows is a reference for all possible asset paths that can be passed to functions such as Entity#get and Entity#set.
Common Entity Properties:
children
Array<string>
resource_id
's of the entity's children.[]
enabled
boolean
true
name
string
parent
string
resource_id
of the parent entity.position
Array<number>
[0,0,0]
resource_id
string
rotation
Array<number>
[0,0,0]
scale
Array<number>
[1,1,1]
tags
Array<string>
[]
template_ent_ids
object
resource_id
,resource_id
> pairs that maps the entity (and its children) to the respective Entities in the template asset.template_id
number
id
of the Template asset that this entity is linked to.components
object
Anim Component Properties:
components.anim
object
components.anim.activate
boolean
true
components.anim.animationAssets
object
{}
components.anim.animationAssets.*.asset
number
id
of the animation asset.null
components.anim.enabled
boolean
true
components.anim.masks
object
{}
components.anim.masks.*.mask
object
{}
components.anim.masks.*.mask.*.children
boolean
components.anim.masks.*.mask.*.value
boolean
components.anim.rootBone
string
resource_id
of the entity that this anim component should use as the root of the animation hierarchy.null
components.anim.speed
number
1
Animation Component Properties:
components.animation
object
components.animation.activate
boolean
true
components.animation.assets
Array<number>
id
's.[]
components.animation.enabled
boolean
true
components.animation.loop
boolean
true
components.animation.speed
number
1
AudioListener Component Properties:
components.audiolistener
object
components.audiolistener.enabled
boolean
true
Button Component Properties:
components.button
object
components.button.active
boolean
true
components.button.enabled
boolean
true
components.button.fadeDuration
number
0
components.button.hitPadding
Array<number>
[0,0,0,0]
components.button.hoverSpriteAsset
number
id
of the sprite asset to be used as the button image when the user hovers over it.null
components.button.hoverSpriteFrame
number
0
components.button.hoverTint
Array<number>
[1,1,1,1]
components.button.imageEntity
string
resource_id
of the entity to be used as the button background. Must have an element component of typeimage
.null
components.button.inactiveSpriteAsset
number
id
of the sprite asset to be used as the button image when the button is not interactive.null
components.button.inactiveSpriteFrame
number
0
components.button.inactiveTint
Array<number>
[1,1,1,1]
components.button.pressedSpriteAsset
number
id
of the sprite asset to be used as the button image when the user presses it.null
components.button.pressedSpriteFrame
number
0
components.button.pressedTint
Array<number>
[1,1,1,1]
components.button.transitionMode
number
0
Camera Component Properties:
components.camera
object
components.camera.clearColor
Array<number>
[0.118,0.118,0.118,1]
components.camera.clearColorBuffer
boolean
true
components.camera.clearDepthBuffer
boolean
true
components.camera.enabled
boolean
true
components.camera.farClip
number
1000
components.camera.fov
number
45
components.camera.frustumCulling
boolean
true
components.camera.layers
Array<number>
[0,1,2,3,4]
components.camera.nearClip
number
0.1
components.camera.orthoHeight
number
4
components.camera.priority
number
0
components.camera.projection
number
pc.PROJECTION_PERSPECTIVE
orpc.PROJECTION_ORTHOGRAPHIC
.0
components.camera.rect
Array<number>
[0,0,1,1]
Collision Component Properties:
components.collision
object
components.collision.asset
number
id
of the model asset that will be used as a source for the triangle-based collision mesh.null
components.collision.axis
number
1
components.collision.enabled
boolean
true
components.collision.halfExtents
Array<number>
[0.5,0.5,0.5]
components.collision.height
number
2
components.collision.radius
number
0.5
components.collision.renderAsset
number
id
of the render asset that will be used as a source for the triangle-based collision mesh.null
components.collision.type
string
"box"
Element Component Properties:
components.element
object
components.element.alignment
Array<number>
[0.5,0.5]
components.element.anchor
Array<number>
[0.5,0.5,0.5,0.5]
components.element.autoFitHeight
boolean
false
components.element.autoFitWidth
boolean
false
components.element.autoHeight
boolean
false
components.element.autoWidth
boolean
false
components.element.batchGroupId
number
null
components.element.color
Array<number>
[1,1,1]
components.element.enableMarkup
boolean
false
components.element.enabled
boolean
true
components.element.fontAsset
number
id
of the font asset used by the element.null
components.element.fontSize
number
32
components.element.height
number
32
components.element.key
string
null
components.element.layers
Array<number>
[4]
components.element.lineHeight
number
32
components.element.margin
Array<number>
[-16,-16,-16,-16]
components.element.mask
boolean
false
components.element.materialAsset
number
id
of the material asset used by this element.null
components.element.maxFontSize
number
autoFitWidth
orautoFitHeight
.32
components.element.maxLines
number
null
components.element.minFontSize
number
autoFitWidth
orautoFitHeight
.8
components.element.opacity
number
1
components.element.outlineColor
Array<number>
[0,0,0,1]
components.element.outlineThickness
number
0
components.element.pivot
Array<number>
[0.5,0.5]
components.element.pixelsPerUnit
number
null
components.element.rect
Array<number>
[0,0,1,1]
components.element.shadowColor
Array<number>
[0,0,0,1]
components.element.shadowOffset
Array<number>
[0,0]
components.element.spacing
number
1
components.element.spriteAsset
number
id
of the sprite asset to be used by the element.null
components.element.spriteFrame
number
0
components.element.text
string
""
components.element.textureAsset
number
id
of the texture asset to be used by the element.null
components.element.type
string
pc.ELEMENTTYPE_GROUP
,pc.ELEMENTTYPE_IMAGE
,pc.ELEMENTTYPE_TEXT
."text"
components.element.useInput
boolean
false
components.element.width
number
32
components.element.wrapLines
boolean
true
LayoutChild Component Properties:
components.layoutchild
object
components.layoutchild.enabled
boolean
true
components.layoutchild.excludeFromLayout
boolean
false
components.layoutchild.fitHeightProportion
number
0
components.layoutchild.fitWidthProportion
number
0
components.layoutchild.maxHeight
number
null
components.layoutchild.maxWidth
number
null
components.layoutchild.minHeight
number
0
components.layoutchild.minWidth
number
0
LayoutGroup Component Properties:
components.layoutgroup
object
components.layoutgroup.alignment
Array<number>
[0,1]
components.layoutgroup.enabled
boolean
true
components.layoutgroup.heightFitting
number
0
components.layoutgroup.orientation
number
0
components.layoutgroup.padding
Array<number>
[0,0,0,0]
components.layoutgroup.reverseX
boolean
false
components.layoutgroup.reverseY
boolean
true
components.layoutgroup.spacing
Array<number>
[0,0]
components.layoutgroup.widthFitting
number
0
components.layoutgroup.wrap
boolean
false
Light Component Properties:
components.light
object
components.light.affectDynamic
boolean
true
components.light.affectLightmapped
boolean
false
components.light.bake
boolean
false
components.light.bakeDir
boolean
bake
is true, the light's direction will contribute to directional lightmaps.true
components.light.cascadeDistribution
number
0.5
components.light.castShadows
boolean
false
components.light.color
Array<number>
[1,1,1]
components.light.cookie
number
components.light.cookieAngle
number
0
components.light.cookieAsset
number
null
components.light.cookieChannel
string
"rgb"
components.light.cookieFalloff
boolean
true
components.light.cookieIntensity
number
1
components.light.cookieOffset
Array<number>
[0,0]
components.light.cookieScale
Array<number>
[1,1]
components.light.enabled
boolean
true
components.light.falloffMode
number
0
components.light.innerConeAngle
number
40
components.light.intensity
number
1
components.light.isStatic
boolean
false
components.light.layers
Array<number>
[0]
components.light.normalOffsetBias
number
0.05
components.light.numCascades
number
1
components.light.outerConeAngle
number
45
components.light.range
number
Model Component Properties:
components.model
object
components.model.aabbCenter
Array<number>
components.model.aabbHalfExtents
Array<number>
components.model.asset
number
id
of the model asset rendered by this model component.null
components.model.batchGroupId
number
null
components.model.castShadows
boolean
true
components.model.castShadowsLightmap
boolean
true
components.model.enabled
boolean
true
components.model.isStatic
boolean
false
components.model.layers
Array<number>
[0]
components.model.lightmapSizeMultiplier
number
1
components.model.lightmapped
boolean
false
components.model.mapping
object
id
.components.model.materialAsset
number
id
of the material asset that will be used to render the model (only applies to primitives).null
components.model.receiveShadows
boolean
true
components.model.type
string
"asset"
ParticleSystem Component Properties:
components.particlesystem
object
components.particlesystem.alignToMotion
boolean
false
components.particlesystem.alphaGraph
object
alphaGraph2
is specified, the opacity will be a random lerp between both curves.{"type":1,"keys":[0,1],"betweenCurves":false}
components.particlesystem.alphaGraph2
object
{"type":1,"keys":[0,1]}
components.particlesystem.animIndex
number
0
components.particlesystem.animLoop
boolean
true
components.particlesystem.animNumAnimations
number
1
components.particlesystem.animNumFrames
number
1
components.particlesystem.animSpeed
number
1
components.particlesystem.animStartFrame
number
0
components.particlesystem.animTilesX
number
1
components.particlesystem.animTilesY
number
1
components.particlesystem.autoPlay
boolean
true
components.particlesystem.blendType
number
2
components.particlesystem.colorGraph
object
{"type":4,"keys":[[0,1],[0,1],[0,1]],"betweenCurves":false}
components.particlesystem.colorMapAsset
number
id
of the color map texture asset to apply to all particles in the system. If no texture asset is assigned, a default spot texture is used.null
components.particlesystem.depthSoftening
number
0
components.particlesystem.depthWrite
boolean
false
components.particlesystem.emitterExtents
Array<number>
[0,0,0]
components.particlesystem.emitterRadius
number
0
components.particlesystem.emitterShape
number
pc.EMITTERSHAPE_BOX
,pc.EMITTERSHAPE_SPHERE
.0
components.particlesystem.enabled
boolean
true
components.particlesystem.halfLambert
boolean
false
components.particlesystem.intensity
number
1
components.particlesystem.layers
Array<number>
[0]
components.particlesystem.lighting
boolean
false
components.particlesystem.loop
boolean
numParticles
property and then stop.true
components.particlesystem.mesh
number
null
components.particlesystem.normalMapAsset
number
id
of the normal map texture asset to apply to all particles in the system.null
components.particlesystem.numParticles
number
30
components.particlesystem.orientation
number
0
components.particlesystem.particleNormal
Array<number>
[0,1,0]
components.particlesystem.preWarm
boolean
false
components.particlesystem.radialSpeedGraph
object
{"type":1,"keys":[0,0],"betweenCurves":false}
components.particlesystem.rotationSpeedGraph
object
{"type":1,"keys":[0,0],"betweenCurves":false}
components.particlesystem.scaleGraph
object
{"type":1,"keys":[0,0.1],"betweenCurves":false}
components.particlesystem.screenSpace
boolean
false
components.particlesystem.sort
number
0
components.particlesystem.startAngle
number
0
components.particlesystem.velocityGraph
object
{"type":1,"keys":[[0,-1],[0,-1],[0,-1]],"betweenCurves":true}
components.particlesystem.wrap
boolean
false
components.particlesystem.wrapBounds
Array<number>
[0,0,0]
Render Component Properties:
components.render
object
components.render.aabbCenter
Array<number>
components.render.aabbHalfExtents
Array<number>
components.render.asset
number
id
of the render asset for the render component (only applies to type "asset").null
components.render.batchGroupId
number
null
components.render.castShadows
boolean
true
components.render.castShadowsLightmap
boolean
true
components.render.enabled
boolean
true
components.render.isStatic
boolean
false
components.render.layers
Array<number>
[0]
components.render.lightmapSizeMultiplier
number
1
components.render.lightmapped
boolean
false
components.render.materialAssets
Array<number>
id
's that will be used to render the meshes. Each material corresponds to the respective mesh instance.[]
components.render.receiveShadows
boolean
true
components.render.rootBone
string
resource_id
of the entity to be used as the root bone for any skinned meshes that are rendered by this component.null
components.render.type
string
"asset"
RigidBody Component Properties:
components.rigidbody
object
components.rigidbody.angularDamping
number
0
components.rigidbody.angularFactor
Array<number>
[1,1,1]
components.rigidbody.enabled
boolean
true
components.rigidbody.friction
number
0.5
components.rigidbody.linearDamping
number
0
components.rigidbody.linearFactor
Array<number>
[1,1,1]
components.rigidbody.mass
number
1
components.rigidbody.restitution
number
0.5
components.rigidbody.type
string
"static"
Screen Component Properties:
components.screen
object
components.screen.enabled
boolean
true
components.screen.referenceResolution
Array<number>
scaleMode
.[1280,720]
components.screen.resolution
Array<number>
[1280,720]
components.screen.scaleBlend
number
0.5
components.screen.scaleMode
string
pc.SCALEMODE_BLEND
for adjusting to window resolution orpc.SCALEMODE_NONE
."blend"
components.screen.screenSpace
boolean
true
Script Component Properties:
components.script
object
components.script.enabled
boolean
true
components.script.order
Array<string>
[]
components.script.scripts
object
{}
components.script.scripts.*.attributes
object
components.script.scripts.*.enabled
boolean
Scrollbar Component Properties:
components.scrollbar
object
components.scrollbar.enabled
boolean
true
components.scrollbar.handleEntity
string
resource_id
of the entity used as the scrollbar handle. Must have a scrollbar component.null
components.scrollbar.handleSize
number
0.5
components.scrollbar.orientation
number
0
components.scrollbar.value
number
0
Scrollview Component Properties:
components.scrollview
object
components.scrollview.bounceAmount
number
0.1
components.scrollview.contentEntity
string
resource_id
of the entity containing the scrolling content. Must have an element component.null
components.scrollview.enabled
boolean
true
components.scrollview.friction
number
0.05
components.scrollview.horizontal
boolean
true
components.scrollview.horizontalScrollbarEntity
string
resource_id
of the entity used as the horizontal scrollbar. Must have a scrollbar component.null
components.scrollview.horizontalScrollbarVisibility
number
1
components.scrollview.mouseWheelSensitivity
Array<number>
[1,1]
components.scrollview.scrollMode
number
1
components.scrollview.useMouseWheel
boolean
true
components.scrollview.vertical
boolean
true
components.scrollview.verticalScrollbarEntity
string
resource_id
of the entity used as the vertical scrollbar. Must have a scrollbar component.null
components.scrollview.verticalScrollbarVisibility
number
1
components.scrollview.viewportEntity
string
resource_id
of the entity used as the viewport area, within which content scrolls. Must have an element component of typegroup
.null
Sound Component Properties:
components.sound
object
components.sound.distanceModel
string
"linear"
components.sound.enabled
boolean
true
components.sound.maxDistance
number
10000
components.sound.pitch
number
1
components.sound.positional
boolean
true
components.sound.refDistance
number
1
components.sound.rollOffFactor
number
1
components.sound.slots
object
components.sound.slots.*.asset
number
id
of the audio asset in this sound slot.components.sound.slots.*.autoPlay
boolean
components.sound.slots.*.duration
number
components.sound.slots.*.loop
boolean
components.sound.slots.*.name
string
components.sound.slots.*.overlap
boolean
components.sound.slots.*.pitch
number
components.sound.slots.*.startTime
number
components.sound.slots.*.volume
number
components.sound.volume
number
1
Sprite Component Properties:
components.sprite
object
components.sprite.autoPlayClip
string
name
of the sprite animation clip to play automatically when the component is enabled.null
components.sprite.batchGroupId
number
null
components.sprite.clips
object
{}
components.sprite.clips.*.autoPlay
boolean
components.sprite.clips.*.fps
number
components.sprite.clips.*.loop
boolean
components.sprite.clips.*.name
string
components.sprite.clips.*.spriteAsset
number
id
of the sprite asset containing all frames for this animation clip.components.sprite.color
Array<number>
[1,1,1]
components.sprite.drawOrder
number
0
components.sprite.enabled
boolean
true
components.sprite.flipX
boolean
false
components.sprite.flipY
boolean
false
components.sprite.frame
number
0
components.sprite.height
number
1
components.sprite.layers
Array<number>
[0]
components.sprite.opacity
number
1
components.sprite.speed
number
1
components.sprite.spriteAsset
number
id
of the sprite asset used by the component.null
components.sprite.type
string
pc.SPRITETYPE_SIMPLE
orpc.SPRITETYPE_ANIMATED
."simple"
components.sprite.width
number
1