@aidinabedi/playcanvas
Version:
PlayCanvas WebGL game engine
673 lines (625 loc) • 45 kB
HTML
<html lang="en">
<head>
<title>pc.Layer | PlayCanvas API Reference</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/playcanvas-favicon.png">
<link href="styles/styles.css" rel="stylesheet">
<link href="styles/playcanvas-theme.css" rel="stylesheet">
<script src="scripts/interface.js"></script>
<script src="scripts/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<header>
<nav class="header-width">
<a href="/" class="header-title"><img src="images/playcanvas-manual.png"></a>
<ul class="header-menu">
<li class="user-manual"><a href="https://developer.playcanvas.com/en/user-manual/">User Manual</a></li>
<li class="tutorials"><a href="https://developer.playcanvas.com/en/tutorials">Tutorials</a></li>
<li class="forum"><a href="https://forum.playcanvas.com/" target="_blank">Forum</a></li>
<li class="api active"><a href="/api/">API Reference</a></li>
</ul>
</nav>
<div class="header-content header-page header-width">
<h1><span class="font-icon"></span>API Reference</h1>
<input id="search" class="search" type="text" placeholder="Search"></input>
</div>
</header>
<div class="container content-width">
<nav class="sidebar">
<div class="sidebarFilter">
<input id="filter-input" type="text" placeholder="Filter">
</div>
<ul>
<li id="nav-pc"><a href="pc.html">pc</a></li>
<li id="nav-pc.callbacks"><a href="pc.callbacks.html">pc.callbacks</a></li>
<li id="nav-pc.guid"><a href="pc.guid.html">pc.guid</a></li>
<li id="nav-pc.math"><a href="pc.math.html">pc.math</a></li>
<li id="nav-pc.path"><a href="pc.path.html">pc.path</a></li>
<li id="nav-pc.platform"><a href="pc.platform.html">pc.platform</a></li>
<li id="nav-pc.script"><a href="pc.script.html">pc.script</a></li>
<li id="nav-pc.string"><a href="pc.string.html">pc.string</a></li>
<li id="nav-pc.Animation"><a href="pc.Animation.html">Animation</a></li>
<li id="nav-pc.AnimationComponent"><a href="pc.AnimationComponent.html">AnimationComponent</a></li>
<li id="nav-pc.AnimationComponentSystem"><a href="pc.AnimationComponentSystem.html">AnimationComponentSystem</a></li>
<li id="nav-pc.AnimationHandler"><a href="pc.AnimationHandler.html">AnimationHandler</a></li>
<li id="nav-pc.AnimCache"><a href="pc.AnimCache.html">AnimCache</a></li>
<li id="nav-pc.AnimClip"><a href="pc.AnimClip.html">AnimClip</a></li>
<li id="nav-pc.AnimController"><a href="pc.AnimController.html">AnimController</a></li>
<li id="nav-pc.AnimCurve"><a href="pc.AnimCurve.html">AnimCurve</a></li>
<li id="nav-pc.AnimData"><a href="pc.AnimData.html">AnimData</a></li>
<li id="nav-pc.AnimSnapshot"><a href="pc.AnimSnapshot.html">AnimSnapshot</a></li>
<li id="nav-pc.AnimTarget"><a href="pc.AnimTarget.html">AnimTarget</a></li>
<li id="nav-pc.AnimTrack"><a href="pc.AnimTrack.html">AnimTrack</a></li>
<li id="nav-pc.Application"><a href="pc.Application.html">Application</a></li>
<li id="nav-pc.Asset"><a href="pc.Asset.html">Asset</a></li>
<li id="nav-pc.AssetReference"><a href="pc.AssetReference.html">AssetReference</a></li>
<li id="nav-pc.AssetRegistry"><a href="pc.AssetRegistry.html">AssetRegistry</a></li>
<li id="nav-pc.AudioHandler"><a href="pc.AudioHandler.html">AudioHandler</a></li>
<li id="nav-pc.AudioListenerComponent"><a href="pc.AudioListenerComponent.html">AudioListenerComponent</a></li>
<li id="nav-pc.AudioListenerComponentSystem"><a href="pc.AudioListenerComponentSystem.html">AudioListenerComponentSystem</a></li>
<li id="nav-pc.BasicMaterial"><a href="pc.BasicMaterial.html">BasicMaterial</a></li>
<li id="nav-pc.Batch"><a href="pc.Batch.html">Batch</a></li>
<li id="nav-pc.BatchGroup"><a href="pc.BatchGroup.html">BatchGroup</a></li>
<li id="nav-pc.BatchManager"><a href="pc.BatchManager.html">BatchManager</a></li>
<li id="nav-pc.BoundingBox"><a href="pc.BoundingBox.html">BoundingBox</a></li>
<li id="nav-pc.BoundingSphere"><a href="pc.BoundingSphere.html">BoundingSphere</a></li>
<li id="nav-pc.ButtonComponent"><a href="pc.ButtonComponent.html">ButtonComponent</a></li>
<li id="nav-pc.ButtonComponentSystem"><a href="pc.ButtonComponentSystem.html">ButtonComponentSystem</a></li>
<li id="nav-pc.CameraComponent"><a href="pc.CameraComponent.html">CameraComponent</a></li>
<li id="nav-pc.CameraComponentSystem"><a href="pc.CameraComponentSystem.html">CameraComponentSystem</a></li>
<li id="nav-pc.CollisionComponent"><a href="pc.CollisionComponent.html">CollisionComponent</a></li>
<li id="nav-pc.CollisionComponentSystem"><a href="pc.CollisionComponentSystem.html">CollisionComponentSystem</a></li>
<li id="nav-pc.Color"><a href="pc.Color.html">Color</a></li>
<li id="nav-pc.Component"><a href="pc.Component.html">Component</a></li>
<li id="nav-pc.ComponentSystem"><a href="pc.ComponentSystem.html">ComponentSystem</a></li>
<li id="nav-pc.ComponentSystemRegistry"><a href="pc.ComponentSystemRegistry.html">ComponentSystemRegistry</a></li>
<li id="nav-pc.ContactPoint"><a href="pc.ContactPoint.html">ContactPoint</a></li>
<li id="nav-pc.ContactResult"><a href="pc.ContactResult.html">ContactResult</a></li>
<li id="nav-pc.ContainerHandler"><a href="pc.ContainerHandler.html">ContainerHandler</a></li>
<li id="nav-pc.ContainerResource"><a href="pc.ContainerResource.html">ContainerResource</a></li>
<li id="nav-pc.Controller"><a href="pc.Controller.html">Controller</a></li>
<li id="nav-pc.CubemapHandler"><a href="pc.CubemapHandler.html">CubemapHandler</a></li>
<li id="nav-pc.Curve"><a href="pc.Curve.html">Curve</a></li>
<li id="nav-pc.CurveSet"><a href="pc.CurveSet.html">CurveSet</a></li>
<li id="nav-pc.ElementComponent"><a href="pc.ElementComponent.html">ElementComponent</a></li>
<li id="nav-pc.ElementComponentSystem"><a href="pc.ElementComponentSystem.html">ElementComponentSystem</a></li>
<li id="nav-pc.ElementDragHelper"><a href="pc.ElementDragHelper.html">ElementDragHelper</a></li>
<li id="nav-pc.ElementInput"><a href="pc.ElementInput.html">ElementInput</a></li>
<li id="nav-pc.ElementInputEvent"><a href="pc.ElementInputEvent.html">ElementInputEvent</a></li>
<li id="nav-pc.ElementMouseEvent"><a href="pc.ElementMouseEvent.html">ElementMouseEvent</a></li>
<li id="nav-pc.ElementTouchEvent"><a href="pc.ElementTouchEvent.html">ElementTouchEvent</a></li>
<li id="nav-pc.Entity"><a href="pc.Entity.html">Entity</a></li>
<li id="nav-pc.EventHandler"><a href="pc.EventHandler.html">EventHandler</a></li>
<li id="nav-pc.Font"><a href="pc.Font.html">Font</a></li>
<li id="nav-pc.FontHandler"><a href="pc.FontHandler.html">FontHandler</a></li>
<li id="nav-pc.ForwardRenderer"><a href="pc.ForwardRenderer.html">ForwardRenderer</a></li>
<li id="nav-pc.Frustum"><a href="pc.Frustum.html">Frustum</a></li>
<li id="nav-pc.GamePads"><a href="pc.GamePads.html">GamePads</a></li>
<li id="nav-pc.GraphicsDevice"><a href="pc.GraphicsDevice.html">GraphicsDevice</a></li>
<li id="nav-pc.GraphNode"><a href="pc.GraphNode.html">GraphNode</a></li>
<li id="nav-pc.Http"><a href="pc.Http.html">Http</a></li>
<li id="nav-pc.I18n"><a href="pc.I18n.html">I18n</a></li>
<li id="nav-pc.IndexBuffer"><a href="pc.IndexBuffer.html">IndexBuffer</a></li>
<li id="nav-pc.Keyboard"><a href="pc.Keyboard.html">Keyboard</a></li>
<li id="nav-pc.KeyboardEvent"><a href="pc.KeyboardEvent.html">KeyboardEvent</a></li>
<li id="nav-pc.Layer"><a href="pc.Layer.html">Layer</a></li>
<li id="nav-pc.LayerComposition"><a href="pc.LayerComposition.html">LayerComposition</a></li>
<li id="nav-pc.LayoutChildComponent"><a href="pc.LayoutChildComponent.html">LayoutChildComponent</a></li>
<li id="nav-pc.LayoutChildComponentSystem"><a href="pc.LayoutChildComponentSystem.html">LayoutChildComponentSystem</a></li>
<li id="nav-pc.LayoutGroupComponent"><a href="pc.LayoutGroupComponent.html">LayoutGroupComponent</a></li>
<li id="nav-pc.LayoutGroupComponentSystem"><a href="pc.LayoutGroupComponentSystem.html">LayoutGroupComponentSystem</a></li>
<li id="nav-pc.LightComponent"><a href="pc.LightComponent.html">LightComponent</a></li>
<li id="nav-pc.LightComponentSystem"><a href="pc.LightComponentSystem.html">LightComponentSystem</a></li>
<li id="nav-pc.Lightmapper"><a href="pc.Lightmapper.html">Lightmapper</a></li>
<li id="nav-pc.Mat3"><a href="pc.Mat3.html">Mat3</a></li>
<li id="nav-pc.Mat4"><a href="pc.Mat4.html">Mat4</a></li>
<li id="nav-pc.Material"><a href="pc.Material.html">Material</a></li>
<li id="nav-pc.MaterialHandler"><a href="pc.MaterialHandler.html">MaterialHandler</a></li>
<li id="nav-pc.Mesh"><a href="pc.Mesh.html">Mesh</a></li>
<li id="nav-pc.MeshInstance"><a href="pc.MeshInstance.html">MeshInstance</a></li>
<li id="nav-pc.Model"><a href="pc.Model.html">Model</a></li>
<li id="nav-pc.ModelComponent"><a href="pc.ModelComponent.html">ModelComponent</a></li>
<li id="nav-pc.ModelComponentSystem"><a href="pc.ModelComponentSystem.html">ModelComponentSystem</a></li>
<li id="nav-pc.ModelHandler"><a href="pc.ModelHandler.html">ModelHandler</a></li>
<li id="nav-pc.Morph"><a href="pc.Morph.html">Morph</a></li>
<li id="nav-pc.MorphInstance"><a href="pc.MorphInstance.html">MorphInstance</a></li>
<li id="nav-pc.MorphTarget"><a href="pc.MorphTarget.html">MorphTarget</a></li>
<li id="nav-pc.Mouse"><a href="pc.Mouse.html">Mouse</a></li>
<li id="nav-pc.MouseEvent"><a href="pc.MouseEvent.html">MouseEvent</a></li>
<li id="nav-pc.Node"><a href="pc.Node.html">Node</a></li>
<li id="nav-pc.OrientedBox"><a href="pc.OrientedBox.html">OrientedBox</a></li>
<li id="nav-pc.ParticleSystemComponent"><a href="pc.ParticleSystemComponent.html">ParticleSystemComponent</a></li>
<li id="nav-pc.ParticleSystemComponentSystem"><a href="pc.ParticleSystemComponentSystem.html">ParticleSystemComponentSystem</a></li>
<li id="nav-pc.Picker"><a href="pc.Picker.html">Picker</a></li>
<li id="nav-pc.PostEffect"><a href="pc.PostEffect.html">PostEffect</a></li>
<li id="nav-pc.PostEffectQueue"><a href="pc.PostEffectQueue.html">PostEffectQueue</a></li>
<li id="nav-pc.Quat"><a href="pc.Quat.html">Quat</a></li>
<li id="nav-pc.Ray"><a href="pc.Ray.html">Ray</a></li>
<li id="nav-pc.RaycastResult"><a href="pc.RaycastResult.html">RaycastResult</a></li>
<li id="nav-pc.RenderTarget"><a href="pc.RenderTarget.html">RenderTarget</a></li>
<li id="nav-pc.ResourceHandler"><a href="pc.ResourceHandler.html">ResourceHandler</a></li>
<li id="nav-pc.ResourceLoader"><a href="pc.ResourceLoader.html">ResourceLoader</a></li>
<li id="nav-pc.RigidBodyComponent"><a href="pc.RigidBodyComponent.html">RigidBodyComponent</a></li>
<li id="nav-pc.RigidBodyComponentSystem"><a href="pc.RigidBodyComponentSystem.html">RigidBodyComponentSystem</a></li>
<li id="nav-pc.Scene"><a href="pc.Scene.html">Scene</a></li>
<li id="nav-pc.SceneHandler"><a href="pc.SceneHandler.html">SceneHandler</a></li>
<li id="nav-pc.ScopeId"><a href="pc.ScopeId.html">ScopeId</a></li>
<li id="nav-pc.ScopeSpace"><a href="pc.ScopeSpace.html">ScopeSpace</a></li>
<li id="nav-pc.ScreenComponent"><a href="pc.ScreenComponent.html">ScreenComponent</a></li>
<li id="nav-pc.ScreenComponentSystem"><a href="pc.ScreenComponentSystem.html">ScreenComponentSystem</a></li>
<li id="nav-pc.ScriptAttributes"><a href="pc.ScriptAttributes.html">ScriptAttributes</a></li>
<li id="nav-pc.ScriptComponent"><a href="pc.ScriptComponent.html">ScriptComponent</a></li>
<li id="nav-pc.ScriptComponentSystem"><a href="pc.ScriptComponentSystem.html">ScriptComponentSystem</a></li>
<li id="nav-pc.ScriptHandler"><a href="pc.ScriptHandler.html">ScriptHandler</a></li>
<li id="nav-pc.ScriptRegistry"><a href="pc.ScriptRegistry.html">ScriptRegistry</a></li>
<li id="nav-pc.ScriptType"><a href="pc.ScriptType.html">ScriptType</a></li>
<li id="nav-pc.ScrollbarComponent"><a href="pc.ScrollbarComponent.html">ScrollbarComponent</a></li>
<li id="nav-pc.ScrollbarComponentSystem"><a href="pc.ScrollbarComponentSystem.html">ScrollbarComponentSystem</a></li>
<li id="nav-pc.ScrollViewComponent"><a href="pc.ScrollViewComponent.html">ScrollViewComponent</a></li>
<li id="nav-pc.ScrollViewComponentSystem"><a href="pc.ScrollViewComponentSystem.html">ScrollViewComponentSystem</a></li>
<li id="nav-pc.Shader"><a href="pc.Shader.html">Shader</a></li>
<li id="nav-pc.SingleContactResult"><a href="pc.SingleContactResult.html">SingleContactResult</a></li>
<li id="nav-pc.Skeleton"><a href="pc.Skeleton.html">Skeleton</a></li>
<li id="nav-pc.Skin"><a href="pc.Skin.html">Skin</a></li>
<li id="nav-pc.SkinInstance"><a href="pc.SkinInstance.html">SkinInstance</a></li>
<li id="nav-pc.Sound"><a href="pc.Sound.html">Sound</a></li>
<li id="nav-pc.SoundComponent"><a href="pc.SoundComponent.html">SoundComponent</a></li>
<li id="nav-pc.SoundComponentSystem"><a href="pc.SoundComponentSystem.html">SoundComponentSystem</a></li>
<li id="nav-pc.SoundInstance"><a href="pc.SoundInstance.html">SoundInstance</a></li>
<li id="nav-pc.SoundInstance3d"><a href="pc.SoundInstance3d.html">SoundInstance3d</a></li>
<li id="nav-pc.SoundManager"><a href="pc.SoundManager.html">SoundManager</a></li>
<li id="nav-pc.SoundSlot"><a href="pc.SoundSlot.html">SoundSlot</a></li>
<li id="nav-pc.Sprite"><a href="pc.Sprite.html">Sprite</a></li>
<li id="nav-pc.SpriteAnimationClip"><a href="pc.SpriteAnimationClip.html">SpriteAnimationClip</a></li>
<li id="nav-pc.SpriteComponent"><a href="pc.SpriteComponent.html">SpriteComponent</a></li>
<li id="nav-pc.SpriteComponentSystem"><a href="pc.SpriteComponentSystem.html">SpriteComponentSystem</a></li>
<li id="nav-pc.SpriteHandler"><a href="pc.SpriteHandler.html">SpriteHandler</a></li>
<li id="nav-pc.StandardMaterial"><a href="pc.StandardMaterial.html">StandardMaterial</a></li>
<li id="nav-pc.StencilParameters"><a href="pc.StencilParameters.html">StencilParameters</a></li>
<li id="nav-pc.Tags"><a href="pc.Tags.html">Tags</a></li>
<li id="nav-pc.Texture"><a href="pc.Texture.html">Texture</a></li>
<li id="nav-pc.TextureAtlas"><a href="pc.TextureAtlas.html">TextureAtlas</a></li>
<li id="nav-pc.TextureAtlasHandler"><a href="pc.TextureAtlasHandler.html">TextureAtlasHandler</a></li>
<li id="nav-pc.TextureHandler"><a href="pc.TextureHandler.html">TextureHandler</a></li>
<li id="nav-pc.Touch"><a href="pc.Touch.html">Touch</a></li>
<li id="nav-pc.TouchDevice"><a href="pc.TouchDevice.html">TouchDevice</a></li>
<li id="nav-pc.TouchEvent"><a href="pc.TouchEvent.html">TouchEvent</a></li>
<li id="nav-pc.TransformFeedback"><a href="pc.TransformFeedback.html">TransformFeedback</a></li>
<li id="nav-pc.Vec2"><a href="pc.Vec2.html">Vec2</a></li>
<li id="nav-pc.Vec3"><a href="pc.Vec3.html">Vec3</a></li>
<li id="nav-pc.Vec4"><a href="pc.Vec4.html">Vec4</a></li>
<li id="nav-pc.VertexAttributeDescription"><a href="pc.VertexAttributeDescription.html">VertexAttributeDescription</a></li>
<li id="nav-pc.VertexAttributeElement"><a href="pc.VertexAttributeElement.html">VertexAttributeElement</a></li>
<li id="nav-pc.VertexBuffer"><a href="pc.VertexBuffer.html">VertexBuffer</a></li>
<li id="nav-pc.VertexFormat"><a href="pc.VertexFormat.html">VertexFormat</a></li>
<li id="nav-pc.VertexIterator"><a href="pc.VertexIterator.html">VertexIterator</a></li>
<li id="nav-pc.VertexIteratorAccessor"><a href="pc.VertexIteratorAccessor.html">VertexIteratorAccessor</a></li>
<li id="nav-pc.XrInput"><a href="pc.XrInput.html">XrInput</a></li>
<li id="nav-pc.XrInputSource"><a href="pc.XrInputSource.html">XrInputSource</a></li>
<li id="nav-pc.XrManager"><a href="pc.XrManager.html">XrManager</a></li>
</ul>
</nav>
<div class='sidebarToggle'><span></span>Class List</div>
<main class="cls">
<h1>pc.Layer</h1>
<p><p>Layer represents a renderable subset of the scene. It can contain a list of mesh instances, lights and cameras,
their render settings and also defines custom callbacks before, after or during rendering.
Layers are organized inside <a href="pc.LayerComposition.html">pc.LayerComposition</a> in a desired order.</p></p>
<!-- summary -->
<h1>Summary</h1>
<!--type definitions-->
<!--static properties-->
<!--static methods-->
<!--properties-->
<h3>Properties</h3>
<table class="properties">
<tr>
<td><a href="#clearColor">clearColor</a></td><td><p>The color used to clear the canvas to before each camera starts to render.</td>
</tr>
<tr>
<td><a href="#clearColorBuffer">clearColorBuffer</a></td><td><p>If true cameras will clear the color buffer to the color set in clearColor.</td>
</tr>
<tr>
<td><a href="#clearDepthBuffer">clearDepthBuffer</a></td><td><p>If true cameras will clear the depth buffer.</td>
</tr>
<tr>
<td><a href="#clearStencilBuffer">clearStencilBuffer</a></td><td><p>If true cameras will clear the stencil buffer.</td>
</tr>
<tr>
<td><a href="#cullingMask">cullingMask</a></td><td><p>Visibility mask that interacts with <a href="pc.MeshInstance.html#mask">pc.MeshInstance#mask</a>.</td>
</tr>
<tr>
<td><a href="#enabled">enabled</a></td><td><p>Enable the layer.</td>
</tr>
<tr>
<td><a href="#id">id</a></td><td><p>A unique ID of the layer.</td>
</tr>
<tr>
<td><a href="#layerReference">layerReference</a></td><td><p>Make this layer render the same mesh instances that another layer does instead of having its own mesh instance list.</td>
</tr>
<tr>
<td><a href="#name">name</a></td><td><p>Name of the layer.</td>
</tr>
<tr>
<td><a href="#onDisable">onDisable</a></td><td><p>Custom function that is called after the layer has been disabled.</td>
</tr>
<tr>
<td><a href="#onDrawCall">onDrawCall</a></td><td><p>Custom function that is called before every mesh instance in this layer is rendered.</td>
</tr>
<tr>
<td><a href="#onEnable">onEnable</a></td><td><p>Custom function that is called after the layer has been enabled.</td>
</tr>
<tr>
<td><a href="#onPostCull">onPostCull</a></td><td><p>Custom function that is called after visibiliy culling is performed for this layer.</td>
</tr>
<tr>
<td><a href="#onPostRender">onPostRender</a></td><td><p>Custom function that is called after this layer is rendered.</td>
</tr>
<tr>
<td><a href="#onPostRenderOpaque">onPostRenderOpaque</a></td><td><p>Custom function that is called after opaque mesh instances (not semi-transparent) in this layer are rendered.</td>
</tr>
<tr>
<td><a href="#onPostRenderTransparent">onPostRenderTransparent</a></td><td><p>Custom function that is called after semi-transparent mesh instances in this layer are rendered.</td>
</tr>
<tr>
<td><a href="#onPreCull">onPreCull</a></td><td><p>Custom function that is called before visibility culling is performed for this layer.</td>
</tr>
<tr>
<td><a href="#onPreRender">onPreRender</a></td><td><p>Custom function that is called before this layer is rendered.</td>
</tr>
<tr>
<td><a href="#onPreRenderOpaque">onPreRenderOpaque</a></td><td><p>Custom function that is called before opaque mesh instances (not semi-transparent) in this layer are rendered.</td>
</tr>
<tr>
<td><a href="#onPreRenderTransparent">onPreRenderTransparent</a></td><td><p>Custom function that is called before semi-transparent mesh instances in this layer are rendered.</td>
</tr>
<tr>
<td><a href="#opaqueSortMode">opaqueSortMode</a></td><td><p>Defines the method used for sorting opaque (that is, not semi-transparent) mesh instances before rendering.</td>
</tr>
<tr>
<td><a href="#overrideClear">overrideClear</a></td><td><p>Defines if layer should use camera clear parameters (true) or ignore them and use pc.Layer#clearColor, pc.Layer#clearColorBuffer,
pc.Layer#clearDepthBuffer and pc.Layer#clearStencilBuffer.</td>
</tr>
<tr>
<td><a href="#passThrough">passThrough</a></td><td><p>Tells that this layer is simple and needs to just render a bunch of mesh instances without lighting, skinning and morphing (faster).</td>
</tr>
<tr>
<td><a href="#renderTarget">renderTarget</a></td><td><p>Render target to which rendering is performed.</td>
</tr>
<tr>
<td><a href="#shaderPass">shaderPass</a></td><td><p>A type of shader to use during rendering.</td>
</tr>
<tr>
<td><a href="#transparentSortMode">transparentSortMode</a></td><td><p>Defines the method used for sorting semi-transparent mesh instances before rendering.</td>
</tr>
</table>
<!--methods-->
<h3>Methods</h3>
<table class="properties">
<tr>
<td><a href="#addCamera">addCamera</a></td><td><p>Adds a camera to this layer.</td>
</tr>
<tr>
<td><a href="#addLight">addLight</a></td><td><p>Adds a light to this layer.</td>
</tr>
<tr>
<td><a href="#addMeshInstances">addMeshInstances</a></td><td><p>Adds an array of mesh instances to this layer.</td>
</tr>
<tr>
<td><a href="#addShadowCasters">addShadowCasters</a></td><td><p>Adds an array of mesh instances to this layer, but only as shadow casters (they will not be rendered anywhere, but only cast shadows on other objects).</td>
</tr>
<tr>
<td><a href="#clearCameras">clearCameras</a></td><td><p>Removes all cameras from this layer.</td>
</tr>
<tr>
<td><a href="#clearLights">clearLights</a></td><td><p>Removes all lights from this layer.</td>
</tr>
<tr>
<td><a href="#clearMeshInstances">clearMeshInstances</a></td><td><p>Removes all mesh instances from this layer.</td>
</tr>
<tr>
<td><a href="#removeCamera">removeCamera</a></td><td><p>Removes a camera from this layer.</td>
</tr>
<tr>
<td><a href="#removeLight">removeLight</a></td><td><p>Removes a light from this layer.</td>
</tr>
<tr>
<td><a href="#removeMeshInstances">removeMeshInstances</a></td><td><p>Removes multiple mesh instances from this layer.</td>
</tr>
<tr>
<td><a href="#removeShadowCasters">removeShadowCasters</a></td><td><p>Removes multiple mesh instances from the shadow casters list of this layer, meaning they will stop casting shadows.</td>
</tr>
</table>
<!--events-->
<h1>Details</h1>
<!--type definitions-->
<!--static members-->
<!--static methods-->
<h2>Constructor</h2>
<!-- Constructor -->
<div id="Layer">
<h3 class="methodname">Layer(options) <a class="font-icon" href="#Layer"></a></h3>
<p><p>Create a new layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>options</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object">object</a></td><td><p>Object for passing optional arguments. These arguments are the same as properties of the Layer.</p></td>
</tr>
</table>
</div>
<!--properties-->
<h2>Properties</h2>
<div id="clearColor">
<span class="property"><a href="pc.Color.html">pc.Color</a></span><span class="property">clearColor <a class="font-icon" href="#clearColor"></a></span>
<p><p>The color used to clear the canvas to before each camera starts to render.</p></p>
</div>
<div id="clearColorBuffer">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">clearColorBuffer <a class="font-icon" href="#clearColorBuffer"></a></span>
<p><p>If true cameras will clear the color buffer to the color set in clearColor.</p></p>
</div>
<div id="clearDepthBuffer">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">clearDepthBuffer <a class="font-icon" href="#clearDepthBuffer"></a></span>
<p><p>If true cameras will clear the depth buffer.</p></p>
</div>
<div id="clearStencilBuffer">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">clearStencilBuffer <a class="font-icon" href="#clearStencilBuffer"></a></span>
<p><p>If true cameras will clear the stencil buffer.</p></p>
</div>
<div id="cullingMask">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">cullingMask <a class="font-icon" href="#cullingMask"></a></span>
<p><p>Visibility mask that interacts with <a href="pc.MeshInstance.html#mask">pc.MeshInstance#mask</a>.</p></p>
</div>
<div id="enabled">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">enabled <a class="font-icon" href="#enabled"></a></span>
<p><p>Enable the layer. Disabled layers are skipped. Defaults to true.</p></p>
</div>
<div id="id">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">id <a class="font-icon" href="#id"></a></span>
<p><p>A unique ID of the layer.
Layer IDs are stored inside pc.ModelComponent#layers, pc.CameraComponent#layers, pc.LightComponent#layers and pc.ElementComponent#layers instead of names.
Can be used in <a href="pc.LayerComposition.html#getLayerById">pc.LayerComposition#getLayerById</a>.</p></p>
</div>
<div id="layerReference">
<span class="property"><a href="pc.Layer.html">pc.Layer</a></span><span class="property">layerReference <a class="font-icon" href="#layerReference"></a></span>
<p><p>Make this layer render the same mesh instances that another layer does instead of having its own mesh instance list.
Both layers must share cameras. Frustum culling is only performed for one layer.</p></p>
</div>
<div id="name">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">string</a></span><span class="property">name <a class="font-icon" href="#name"></a></span>
<p><p>Name of the layer. Can be used in <a href="pc.LayerComposition.html#getLayerByName">pc.LayerComposition#getLayerByName</a>.</p></p>
</div>
<div id="onDisable">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onDisable <a class="font-icon" href="#onDisable"></a></span>
<p><p>Custom function that is called after the layer has been disabled.
This happens when:</p>
<ul>
<li>pc.Layer#enabled was changed from true to false</li>
<li><a href="pc.Layer.html#decrementCounter">pc.Layer#decrementCounter</a> was called and set the counter to zero.</li>
</ul></p>
</div>
<div id="onDrawCall">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onDrawCall <a class="font-icon" href="#onDrawCall"></a></span>
<p><p>Custom function that is called before every mesh instance in this layer is rendered.
It is not recommended to set this function when rendering many objects every frame due to performance reasons.</p></p>
</div>
<div id="onEnable">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onEnable <a class="font-icon" href="#onEnable"></a></span>
<p><p>Custom function that is called after the layer has been enabled.
This happens when:</p>
<ul>
<li>The layer is created with pc.Layer#enabled set to true (which is the default value).</li>
<li>pc.Layer#enabled was changed from false to true</li>
<li><a href="pc.Layer.html#incrementCounter">pc.Layer#incrementCounter</a> was called and incremented the counter above zero.</li>
</ul>
<p>Useful for allocating resources this layer will use (e.g. creating render targets).</p></p>
</div>
<div id="onPostCull">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPostCull <a class="font-icon" href="#onPostCull"></a></span>
<p><p>Custom function that is called after visibiliy culling is performed for this layer.
Useful for reverting changes done in pc.Layer#onPreCull and determining final mesh instance visibility (see pc.MeshInstance#visibleThisFrame).
This function will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPostRender">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPostRender <a class="font-icon" href="#onPostRender"></a></span>
<p><p>Custom function that is called after this layer is rendered.
Useful to revert changes made in pc.Layer#onPreRender or performing some processing on pc.Layer#renderTarget.
This function is called after the last occurrence of this layer in <a href="pc.LayerComposition.html">pc.LayerComposition</a>.
It will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPostRenderOpaque">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPostRenderOpaque <a class="font-icon" href="#onPostRenderOpaque"></a></span>
<p><p>Custom function that is called after opaque mesh instances (not semi-transparent) in this layer are rendered.
This function will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPostRenderTransparent">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPostRenderTransparent <a class="font-icon" href="#onPostRenderTransparent"></a></span>
<p><p>Custom function that is called after semi-transparent mesh instances in this layer are rendered.
This function will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPreCull">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPreCull <a class="font-icon" href="#onPreCull"></a></span>
<p><p>Custom function that is called before visibility culling is performed for this layer.
Useful, for example, if you want to modify camera projection while still using the same camera and make frustum culling work correctly with it
(see pc.CameraComponent#calculateTransform and pc.CameraComponent#calculateProjection).
This function will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPreRender">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPreRender <a class="font-icon" href="#onPreRender"></a></span>
<p><p>Custom function that is called before this layer is rendered.
Useful, for example, for reacting on screen size changes.
This function is called before the first occurrence of this layer in <a href="pc.LayerComposition.html">pc.LayerComposition</a>.
It will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPreRenderOpaque">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPreRenderOpaque <a class="font-icon" href="#onPreRenderOpaque"></a></span>
<p><p>Custom function that is called before opaque mesh instances (not semi-transparent) in this layer are rendered.
This function will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="onPreRenderTransparent">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function">function</a></span><span class="property">onPreRenderTransparent <a class="font-icon" href="#onPreRenderTransparent"></a></span>
<p><p>Custom function that is called before semi-transparent mesh instances in this layer are rendered.
This function will receive camera index as the only argument. You can get the actual camera being used by looking up pc.LayerComposition#cameras with this index.</p></p>
</div>
<div id="opaqueSortMode">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">opaqueSortMode <a class="font-icon" href="#opaqueSortMode"></a></span>
<p><p>Defines the method used for sorting opaque (that is, not semi-transparent) mesh instances before rendering.
Possible values are:</p>
<ul>
<li><a href="pc.html#SORTMODE_NONE">pc.SORTMODE_NONE</a></li>
<li><a href="pc.html#SORTMODE_MANUAL">pc.SORTMODE_MANUAL</a></li>
<li><a href="pc.html#SORTMODE_MATERIALMESH">pc.SORTMODE_MATERIALMESH</a></li>
<li><a href="pc.html#SORTMODE_BACK2FRONT">pc.SORTMODE_BACK2FRONT</a></li>
<li><a href="pc.html#SORTMODE_FRONT2BACK">pc.SORTMODE_FRONT2BACK</a></li>
</ul>
<p>Defaults to pc.SORTMODE_MATERIALMESH.</p></p>
</div>
<div id="overrideClear">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">overrideClear <a class="font-icon" href="#overrideClear"></a></span>
<p><p>Defines if layer should use camera clear parameters (true) or ignore them and use pc.Layer#clearColor, pc.Layer#clearColorBuffer,
pc.Layer#clearDepthBuffer and pc.Layer#clearStencilBuffer.</p></p>
</div>
<div id="passThrough">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></span><span class="property">passThrough <a class="font-icon" href="#passThrough"></a></span>
<p><p>Tells that this layer is simple and needs to just render a bunch of mesh instances without lighting, skinning and morphing (faster).</p></p>
</div>
<div id="renderTarget">
<span class="property"><a href="pc.RenderTarget.html">pc.RenderTarget</a></span><span class="property">renderTarget <a class="font-icon" href="#renderTarget"></a></span>
<p><p>Render target to which rendering is performed. If not set, will render simply to the screen.</p></p>
</div>
<div id="shaderPass">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">shaderPass <a class="font-icon" href="#shaderPass"></a></span>
<p><p>A type of shader to use during rendering. Possible values are:</p>
<ul>
<li><a href="pc.html#SHADER_FORWARD">pc.SHADER_FORWARD</a></li>
<li><a href="pc.html#SHADER_FORWARDHDR">pc.SHADER_FORWARDHDR</a></li>
<li><a href="pc.html#SHADER_DEPTH">pc.SHADER_DEPTH</a></li>
<li>Your own custom value. Should be in 19 - 31 range. Use pc.StandardMaterial#onUpdateShader to apply shader modifications based on this value.</li>
</ul>
<p>Defaults to pc.SHADER_FORWARD.</p></p>
</div>
<div id="transparentSortMode">
<span class="property"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number">number</a></span><span class="property">transparentSortMode <a class="font-icon" href="#transparentSortMode"></a></span>
<p><p>Defines the method used for sorting semi-transparent mesh instances before rendering.
Possible values are:</p>
<ul>
<li><a href="pc.html#SORTMODE_NONE">pc.SORTMODE_NONE</a></li>
<li><a href="pc.html#SORTMODE_MANUAL">pc.SORTMODE_MANUAL</a></li>
<li><a href="pc.html#SORTMODE_MATERIALMESH">pc.SORTMODE_MATERIALMESH</a></li>
<li><a href="pc.html#SORTMODE_BACK2FRONT">pc.SORTMODE_BACK2FRONT</a></li>
<li><a href="pc.html#SORTMODE_FRONT2BACK">pc.SORTMODE_FRONT2BACK</a></li>
</ul>
<p>Defaults to pc.SORTMODE_BACK2FRONT.</p></p>
</div>
<!--methods-->
<h2>Methods</h2>
<div id="addCamera">
<h3 class="methodname">addCamera(camera) <a class="font-icon" href="#addCamera"></a></h3>
<p><p>Adds a camera to this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>camera</td><td><a href="pc.CameraComponent.html">pc.CameraComponent</a></td><td><p>A <a href="pc.CameraComponent.html">pc.CameraComponent</a>.</p></td>
</tr>
</table>
</div>
<div id="addLight">
<h3 class="methodname">addLight(light) <a class="font-icon" href="#addLight"></a></h3>
<p><p>Adds a light to this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>light</td><td><a href="pc.LightComponent.html">pc.LightComponent</a></td><td><p>A <a href="pc.LightComponent.html">pc.LightComponent</a>.</p></td>
</tr>
</table>
</div>
<div id="addMeshInstances">
<h3 class="methodname">addMeshInstances(meshInstances, [skipShadowCasters]) <a class="font-icon" href="#addMeshInstances"></a></h3>
<p><p>Adds an array of mesh instances to this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>meshInstances</td><td><a href="pc.MeshInstance.html">pc.MeshInstance[]</a></td><td><p>Array of <a href="pc.MeshInstance.html">pc.MeshInstance</a>.</p></td>
</tr>
<tr>
<td>skipShadowCasters</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Set it to true if you don't want these mesh instances to cast shadows in this layer.</p></td>
</tr>
</table>
</div>
<div id="addShadowCasters">
<h3 class="methodname">addShadowCasters(meshInstances) <a class="font-icon" href="#addShadowCasters"></a></h3>
<p><p>Adds an array of mesh instances to this layer, but only as shadow casters (they will not be rendered anywhere, but only cast shadows on other objects).</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>meshInstances</td><td><a href="pc.MeshInstance.html">pc.MeshInstance[]</a></td><td><p>Array of <a href="pc.MeshInstance.html">pc.MeshInstance</a>.</p></td>
</tr>
</table>
</div>
<div id="clearCameras">
<h3 class="methodname">clearCameras() <a class="font-icon" href="#clearCameras"></a></h3>
<p><p>Removes all cameras from this layer.</p></p>
</div>
<div id="clearLights">
<h3 class="methodname">clearLights() <a class="font-icon" href="#clearLights"></a></h3>
<p><p>Removes all lights from this layer.</p></p>
</div>
<div id="clearMeshInstances">
<h3 class="methodname">clearMeshInstances([skipShadowCasters]) <a class="font-icon" href="#clearMeshInstances"></a></h3>
<p><p>Removes all mesh instances from this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>skipShadowCasters</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Set it to true if you want to still cast shadows from removed mesh instances or if they never did cast shadows before.</p></td>
</tr>
</table>
</div>
<div id="removeCamera">
<h3 class="methodname">removeCamera(camera) <a class="font-icon" href="#removeCamera"></a></h3>
<p><p>Removes a camera from this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>camera</td><td><a href="pc.CameraComponent.html">pc.CameraComponent</a></td><td><p>A <a href="pc.CameraComponent.html">pc.CameraComponent</a>.</p></td>
</tr>
</table>
</div>
<div id="removeLight">
<h3 class="methodname">removeLight(light) <a class="font-icon" href="#removeLight"></a></h3>
<p><p>Removes a light from this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>light</td><td><a href="pc.LightComponent.html">pc.LightComponent</a></td><td><p>A <a href="pc.LightComponent.html">pc.LightComponent</a>.</p></td>
</tr>
</table>
</div>
<div id="removeMeshInstances">
<h3 class="methodname">removeMeshInstances(meshInstances, [skipShadowCasters]) <a class="font-icon" href="#removeMeshInstances"></a></h3>
<p><p>Removes multiple mesh instances from this layer.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>meshInstances</td><td><a href="pc.MeshInstance.html">pc.MeshInstance[]</a></td><td><p>Array of <a href="pc.MeshInstance.html">pc.MeshInstance</a>. If they were added to this layer, they will be removed.</p></td>
</tr>
<tr>
<td>skipShadowCasters</td><td><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean">boolean</a></td><td><p>Set it to true if you want to still cast shadows from removed mesh instances or if they never did cast shadows before.</p></td>
</tr>
</table>
</div>
<div id="removeShadowCasters">
<h3 class="methodname">removeShadowCasters(meshInstances) <a class="font-icon" href="#removeShadowCasters"></a></h3>
<p><p>Removes multiple mesh instances from the shadow casters list of this layer, meaning they will stop casting shadows.</p></p>
<h4>Parameters</h4>
<table>
<tr>
<td>meshInstances</td><td><a href="pc.MeshInstance.html">pc.MeshInstance[]</a></td><td><p>Array of <a href="pc.MeshInstance.html">pc.MeshInstance</a>. If they were added to this layer, they will be removed.</p></td>
</tr>
</table>
</div>
<!--events-->
</main>
</div>
</body>
</html>