Webaverse

Webaverse

    ›XRPackage

    Webaverse

    • Overview
    • SILK
    • NFTs
    • Avatars
    • Parcels
    • Seasons
    • Discord Bot
    • Twitter Bot
    • Guides

      • Getting Started In Webaverse

    Market

    • How To Get SILK
    • How To Buy And Sell NFTs
    • How To Trade

    Create

    • Overview
    • How To Mint NFTs
    • How To Mint NFTs in Discord
    • Season 0: Genesis

      • Submission Guide

      Avatars

      • Import From VRoid Studio

      3D Models

      • Import From Blender
      • Bake Physics For 3D Model
      • Export Multiple Animations

      Voxels

      • Import From MagicaVoxel

      XRPackage

      • What is XRPackage?
      • Create An XRPackage
      • Design Guidelines
      • Add Monetization
      • Examples

      API

      • Runtime API
      • Manifest API
      • Monetization API

    Add Monetization

    This guide will walk you through the basic steps for adding the ability to "unlock" features in your XRPackage when a user has web monetization enabled or when a user owns a NFT of your XRPackage.

    Note: This guide assumes you have read Creating Your First XRPackage or are familiar with what an XRPackage is.

    Prerequisites

    • Understand and be able to create an XRPackage.
    • Have an XRPackage you want to add the ability to unlock a feature when a user has web monetization enabled or own your XRPackage as an NFT.

    Add The Monetization Start Event Listener

    Let's say you have a lightsaber XRPackage made with Three.js. You control the "intensity" of the lightsaber by changing the variable particleIntensity, and you want users that unlock your XRPackage to have a more "intense" lightsaber.

    In order to know when a user unlocks your XRPackage, all you have to do is add an EventListener for monetizationstart on document.monetization as follows:

    document.monetization.addEventListener('monetizationstart', () => {
        particleIntensity = 0.1;
     })
    

    That's it! Inside of the event listener, you can change whatever you want to change for users who unlock your XRPackage.

    Last updated on 12/15/2020
    ← Design GuidelinesExamples →
    • Prerequisites
    • Add The Monetization Start Event Listener
    Docs
    OverviewCreate Overview
    Community
    DiscordTwitter
    More
    WebaverseGitHub
    © 2021 Webaverse