// Put several scene objects on the same Layer as an orthographic camera so // that camera renders them. A SceneObject is only drawn by a camera when // their layer sets intersect — make sure the target camera's renderLayer // includes the layer used here, otherwise the objects will not be visible. constmodel = this.pluginSystem.findInterface(Editor.Model.IModel) asEditor.Model.IModel; constscene = model.project.scene;
// Orthographic camera. Its renderLayer starts at the default set that // covers Editor.Model.LayerId.Default. constcamObj = scene.createSceneObject('OrthoCamera'); constcamera = camObj.addComponent('Camera') asEditor.Components.Camera; camera.cameraType = Editor.Components.CameraType.Orthographic;
// Build a matching LayerSet from the id the camera uses, then assign it // to each new object so the ortho camera will include them in rendering. constlayerId = Editor.Model.LayerId.Default; consttargetSet = Editor.Model.LayerSet.fromId(layerId); camera.renderLayer = targetSet;
constobjects = [ scene.createSceneObject('UiPanel'), scene.createSceneObject('UiButton'), scene.createSceneObject('UiLabel'), ]; for (constoofobjects) { o.layers = targetSet; } console.log(`Placed ${objects.length} objects on the same layer as the ortho camera.`);
The layers within a Editor.Model.LayerSet.
Example