Preparing search index...

    Class VectorRenderer

    Draws a vector composite into a caller-owned render-target Texture. A VectorRenderer is stateless — one renderer can draw many assets into many targets, and VectorRenderer#render is cheap to call every frame because it replays the asset's already-tessellated geometry.

    The destination is a standard Studio render-target Texture: create one at runtime with Scene#createRenderTargetTexture (then size it through its RenderTargetProvider control), or author one in Studio (an @input Asset.Texture Render Target, or Camera.renderTarget). Sampling that same Texture (a material baseTex, a screen image, a post effect) reflects the vector output through the normal render-graph consumption path.

    Lens Scripting Version 368

    //@input Asset.VectorComposite mySvg
    //@input Component.Image image
    var renderer = new VectorRenderer();
    var target = null;
    // `request` is required; a fresh RenderRequest carries the defaults (whole
    // target, full source, cleared first). Construct it once and reuse it.
    var req = new VectorComposite.RenderRequest();
    script.mySvg.ready().then(function () {
    // Size the target to the source's intrinsic size so the composite fills
    // it (the default viewport covers the whole target).
    var size = script.mySvg.intrinsicSize;
    target = scene.createRenderTargetTexture();
    target.control.outputResolution = RenderTargetProvider.OutputResolution.Custom;
    target.control.resolution = new vec2(size.x, size.y);
    script.image.mainMaterial.mainPass.baseTex = target;
    });
    // render() is cheap (it replays the retained geometry), so draw every frame.
    script.createEvent("UpdateEvent").bind(function () {
    if (target) { renderer.render(target, script.mySvg, req); }
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    • Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

      Returns string

      Lens Scripting Version 368

    • Returns true if the object matches or derives from the passed in type.

      Parameters

      • type: string

      Returns boolean

    • Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

      Parameters

      Returns boolean

    • Draws asset into the caller-owned render target target. The composite is drawn directly into the RenderTargetProvider backing that Texture; that same Texture can then be used directly on a Material (e.g. as baseTex) — there is no separate publish step.

      target must be a Render Target Texture — created in Lens Studio, or at runtime with Scene#createRenderTargetTexture (or Camera.renderTarget).

      Clearing is controlled by RenderRequest#clear (default: clear first); the render target's own clear-color options do not affect this draw.

      Edge anti-aliasing follows the render target's authored RenderTargetProvider#antialiasingMode and RenderTargetProvider#antialiasingQuality: Disabled draws single-sample (edges alias); any other mode draws the composite with MSAA at the quality's sample count (Low is 2x; Medium/High/Ultra are 4x), clamped to what the device supports. Temporal and post-process modes need a camera, so TAA, FXAA and SMAA also map to MSAA here; MSAAStrategy does not apply.

      Pass a RenderRequest to place, clip, or select a source sub-region of asset, or a fresh one for the defaults (whole target, full source, cleared first). request is required — pass null to take the defaults. Executes on the render thread; asset must be ready (asset.isReady). Throws if target or asset is null, asset is not ready, or target is not a Render Target Texture.

      Parameters

      • target: Texture

        The caller-owned render destination: a Render Target Texture.

      • asset: VectorComposite

        The vector asset to draw (must be ready).

      • request: RenderRequest

        Draw options as a RenderRequest, or null for the default placement, region, and clear behavior. Required.

      Returns void

      Lens Scripting Version 368

      //@input Asset.VectorComposite mySvg
      //@input Asset.Texture rt // a Render Target Texture created in Lens Studio, also used on an Image's Material
      var renderer = new VectorRenderer();
      // `request` is required; a fresh RenderRequest carries the defaults.
      var req = new VectorComposite.RenderRequest();
      script.mySvg.ready().then(function () {
      script.createEvent("UpdateEvent").bind(function () {
      // The vector output appears wherever `rt` is sampled.
      renderer.render(script.rt, script.mySvg, req);
      });
      });