English
Appearance
English
Appearance
For the full reference and method lists, refer directly to:
The scene advanced API lets the host page directly manipulate scene content inside the iframe.
The collection advanced API lets the host page control the collection-level flow inside the iframe, including opening and closing scenes, but it cannot directly manipulate scene content.
If you want to manipulate scene content inside a collection, wait until a scene is open and then use that scene's advanced API.
You can use it to:
Watermark Note
If you call any advanced API and the current plugin domain is not authorized, a developer watermark will appear.
iframe.addEventListener("ready", (event) => {
const { detail } = event;
const { api } = detail;
console.log(api);
});detail.api is the advanced API object. Scenes and collections use the same access pattern here.
To get the scene advanced API from within a collection:
iframe.addEventListener("sceneReady", (event) => {
const { detail } = event;
const { api } = detail;
console.log(api);
});Because communication across the iframe boundary is inherently asynchronous, all API calls, getters, and setters are asynchronous.
So in real development, you should await every API call unless you truly do not care about the result.
const image = await api.getObject("object-name");
await api.setPosition(image, 1, 0, 0);You can think of them as pointers. They are object references without local properties or methods, and you cannot control them directly.
const image = await api.getObject("object-name");
image.position.set(1, 0, 0); // ❌ wrong
await api.setPosition(image, 1, 0, 0); // ✅ correctSo you cannot directly mutate image.position.x; you must go through methods such as api.setPosition().
Difference from the Mini Program Plugin
At the moment, detail.api exposes relatively low-level APIs, so the usage is less direct.
Higher-level object-style properties and APIs similar to the Mini Program plugin will be added later.
That is also why the current event.detail gives you detail.api rather than a view object, unlike the Mini Program plugin.
We support building base content in the scene editor and then using advanced APIs to add, remove, or modify content at runtime.
When adding content, the file can be passed in several forms: ArrayBuffer, Blob, File, or URL.
If you pass a URL into the plugin, the hosting server must allow cross-origin access from https://www.kivicube.com.
URL Format
Only absolute URLs are supported: complete URLs that include the protocol, domain, and path, for example: https://your.domain.com/path/to/image.jpg.
Relative URLs are not supported: paths relative to the current page location, for example: /path/to/image.jpg or ../image.jpg.
If you want to use a relative URL, convert it to an absolute URL with new URL('../image.jpg', location.href).href.
For example:
const image = await api.createImage("https://your.domain.com/path/to/image.jpg");
await api.add(image);In this case, the server at your.domain.com must allow CORS access from the Kivicube domain.
server {
# Directory that stores asset files
location /path/to {
add_header Access-Control-Allow-Origin "https://www.kivicube.com" always;
}
}The core requirement is that the response header includes:
Access-Control-Allow-Origin: https://www.kivicube.comIf you pass ArrayBuffer, Blob, or File instead, you can usually ignore CORS configuration because the file is downloaded on your own side first.
const response = await fetch("https://your.domain.com/path/to/image.jpg");
if (response.ok) {
const imageAb = await response.arrayBuffer();
const image = await api.createImage(imageAb);
await api.add(image);
}Reference: Scene API / Start Now Button
getStartButtonRect()setStartButtonRect(rect)Reference: Scene API / Object Query and Basic Properties
getObject(name)getAllObjects()getObjectName() / setObjectName()getObjectVisible() / setObjectVisible()getRenderOrder() / setRenderOrder()getDisableClick() / setDisableClick()getSize()lookAt()getPosition() / setPosition()getRotation() / setRotation()getQuaternion() / setQuaternion()getScale() / setScale()Reference: Scene API / Object Hierarchy and Lifecycle
addChild() / removeChild()getChildren() / getChildByProperty()add()remove()destroyObject()clear()Reference: Scene API / Dynamic Content Creation
createImage()createAnimatedImage()createGltfModel()createVideo()createAlphaVideo()createKeyingVideo()createPanorama()createGroup()createAmbientLight()createDirectionalLight()createEnvMapByHDR()getAnimatedImagePaused() / playAnimatedImage() / pauseAnimatedImage() / stopAnimatedImage()getVideoDuration() / getVideoPaused() / getVideoCurrentTime() / setVideoCurrentTime() / getVideoLoop() / setVideoLoop() / playVideo() / pauseVideo() / stopVideo() / playbackVideo()getAudioDuration() / getAudioPaused() / getAudioCurrentTime() / setAudioCurrentTime() / getAudioLoop() / setAudioLoop() / playAudio() / pauseAudio() / stopAudio() / playbackAudio()playAnimation() / pauseAnimation() / stopAnimation() / playbackAnimation() / getAnimationNames() / isAnimationLoop() / getAnimationIsRunningNames()Reference: Scene API / Rendering and Materials, Scene API / Lighting
setEnableMask() / setDisableMask()setGLState()setAnisotropy()setObjectAlpha()getDefaultAmbientLight()getDefaultDirectionalLightLeft() / getDefaultDirectionalLightRight()getDirectionalLightTarget()setLightColor() / setLightIntensity()setToneMapping()useEnvMapForObj()Reference: Scene API / Camera and Photo Capture
getDefaultCamera()getCameraFov() / setCameraFov()getCameraAspect() / setCameraAspect()getCameraNear() / setCameraNear()getCameraFar() / setCameraFar()updateCameraProjectionMatrix()getCameraWorldDirection()dispatchTouchEvent(x, y)switchCamera(position)takePhoto()skipCloudar()Reference: Scene API / Event Listeners
on(eventName, callback, target?)off(eventName, callback, target?)Reference: Collection API / Start Now Button
getStartButtonRect()setStartButtonRect(rect)Reference: Collection API / Scene Management
backToScan()openScene(sceneId)closeCurrentScene()Reference: Collection API / Cloud Recognition
startCloudar(collectionId, sceneIdList)stopCloudar()Reference: Collection API / Photo Capture
takePhoto()Note: currently supported only by the scene advanced API
The currently available api.on() / api.off() patterns are:
target: currently only objectClick, which listens once for clicks on any objecttarget: click - clickedplay - audio / video / animation / animated-image playback startspause - audio / video / animation / animated-image playback pausesended - audio / video / animation / animated-image playback finishes naturallyreplay - video / animation / animated-image playback restartsExample:
const model = await api.getObject('rabbit');
function handleClick(payload) {
console.log('Object clicked', payload);
}
await api.on('click', handleClick, model);The following pages explain each capability in more detail: