SDK
Viewer API
Everything createViewer accepts, and every command of the viewer it returns.
createViewer options
The options createViewer takes. What the viewer shows can change afterwards through its commands.
containerDefaultRequiredkeyDefaultRequiredweaponDefaultNoneenvironmentDefaultshowroombackgroundDefaultenvironmenttype is environment (the environment's backdrop), none (your page shows behind the item) or custom, with the id of one of your backdrops, from your dashboard. A value the viewer cannot show leaves the environment's backdrop, which viewer.state.background then names.watermarkDefaultvskintype is vskin (the VSkin watermark tiled behind the item), custom, with the id of one of your watermarks, from your dashboard, or none (no watermark). A value the viewer cannot show leaves the VSkin watermark, which viewer.state.watermark then names.interactiveDefaulttruefalse turns off rotation and zoom by the visitor.autoplayDefaultOfftrue plays the inspect animation on load.localeDefaultenThe vskin-render-viewer element
The element takes the options of createViewer as these properties. One with an attribute beside it can also be written as that attribute. A boolean attribute turns its option on unless its value is false. An object goes through its property only.
viewerKeyviewer-keykey option of createViewer.weaponweapon option of createViewer, as a property only.environmentenvironmentenvironment option of createViewer.backgroundbackground option of createViewer, as a property only.watermarkwatermark option of createViewer, as a property only.interactiveinteractiveinteractive option of createViewer.autoplayautoplayautoplay option of createViewer.localelocalelocale option of createViewer.What the element gives back: the handle, and two events.
viewercreateViewer resolves with; null before, and once the element has left the page.vskin-render-readydetail.viewer. Sent again when the element comes back to the page with a new viewer.vskin-render-errordetail.error, the one createViewer rejects with, family and code of a refusal included.Weapon fields
Name a weapon with cert, or with defIndex and paintIndex plus the fields you need, as in the URL options. Gloves take cert, or defIndex, paintIndex, seed and float; an agent takes cert or defIndex.
certdefIndexpaintIndex0 for an agent or a weapon without a skin.seedfloatstattrakkillsnameCosmetic fields
The fields of the cosmetics that setStickers, setCharm and setPatches take. The ids are the ones the URL options use.
Sticker
idslotwearrotationoffsetXoffsetYCharm
idpatternwrappedStickeroffsetXoffsetYoffsetZPatch
idslotstate.patchSlots says how many the agent has.Every command except destroy returns a promise: it resolves once the viewer has applied it, and rejects with an error code when it cannot.
Items
setWeapon({ weapon })null. A new seed, wear or name tag on the same weapon updates it in place.setGloves({ gloves })null.setAgent({ agent })null.setSubject({ subject })Cosmetics
setStickers({ stickers })setCharm({ charm })null.setPatches({ patches })armPlacement({ target })null disarms.forwardPointer({ x, y, phase })clientX, clientY), so a drag that starts in your own HUD can land on the weapon. phase is start, move or end.View and camera
setView({ view })setFirstPersonSettings({ fov, offsetX, offsetY, offsetZ, handedness })viewmodel_fov), offsets (viewmodel_offset_x, _y, _z) and hand.setFacing({ facing })focus({ target })null flies back.resetCamera()focus with null.Scene, sound and language
setEnvironment({ environment })setBackground({ background })environment), your page behind the item (none), or one of your backdrops in place of any scenery, a map's included (custom, with its id). custom is refused with not_entitled without the Brand option, and with invalid_argument for an id that is not one of your backdrops.setWatermark({ watermark })vskin), one of your watermarks, covering the viewer from its center like a backdrop (custom, with its id), or removes it (none). It shows over a map's scenery too: set none when you switch to a map you want clear. custom is refused with not_entitled without the Brand option, and with invalid_argument for an id that is not one of your watermarks.setSound({ muted })setLocale({ locale })Animations
play()pause()playAnimation({ name })state.animations or state.agentAnimations.stopAnimation()setSilentReload({ held })startFire()stopFire.stopFire()Capture
capture()Lifecycle
destroy()Catalog
Lists to build your own pickers. Each resolves to an object with total and values, and needs the matching feature in your plan. The lists that take a query accept search, limit and offset.
catalog.weapons(query)catalog.stickers(query)catalog.charms(query)catalog.patches(query)catalog.agents(query)catalog.weaponModels()catalog.environments()setEnvironment takes.Inspect links
buildInspectLink turns a certificate into the item's in-game inspect link. It needs no viewer.
import { buildInspectLink } from '@vskin/sdk';
const link = buildInspectLink({
cert: '80907B511F0241819887A01389A886B089B87A101E7583C05683C880D081E29988819074BD9D76A89CBFAD8080CCC2BD90C5B43DC58004723AE29988839074BD9D8A57A3BFAD80805842BDFAB6EDBEC5B01E1FBCE29988839074BD9DE6E6A6BFAD8080CCC2BD0D1D0BBEC5802E003AE29988839074BD9D1A1999BFAD80807042BD5D8024BEC560F02DBCE29988829073BD9D2EC7A1BFAD8080F0C1BDD01ADDBEC580ABBABBE81C82F0882281978880908CBD3DF845C1C5A99536BECDCFC895C0D05A1C85110C776A',
});