EditorConstructor
It is the main component of the library, allows you to visualize the scene
🎛 EditorConstructor Props
| Prop | Type | Description |
|---|---|---|
type | "model" | "material" | "scene" | "texture" | Select the type of asset that will be displayed in the 3D scene. The type must match the asset that you specify in the assetId field. |
assetId | number | string | Asset/Product ID taken from the Amaspace platform |
apiKey | string | API key taken from the Amaspace platform |
presetConfig | object | Editor settings |
🎛 presetConfig Props
| Prop | Default | Type | Description |
|---|---|---|---|
mode | "VIEWER" | "EDITOR" | "TRYON" | Defines the operating mode of the customizer/editor. Untitled | |
applyProductRules | false | boolean | allows you to enable/disable the application of product option rules |
controls | AMAControlsProps | Untitled | |
baseURL | string | The API URL through which all requests will be sent is mainly needed for internal development of Amaspace. You can use “https://api.amaspace.co/api/” by default. |
🎛 mode Description
| Mode | Description |
|---|---|
| VIEWER | Read-only mode — the user can preview the scene or product, but cannot make edits. Useful for embedding a 3D viewer. |
| EDITOR | Full editing mode — allows users to interact with the scene, apply customization options, and modify objects/materials. |
| TRYON | Virtual try-on mode — optimized for product placement on a live camera feed (e.g., trying on accessories). |
🎛 AMAControlsPropsProps
| Prop | Default | Type | Description |
|---|---|---|---|
pan | true | boolean | Enables or disables panning (moving the camera across the scene). |
zoomToCursor | false | boolean | Controls whether zoom is centered on the cursor position instead of scene center. |
disable | false | boolean | Disables all camera controls (pan, zoom, rotation). |
Example:
<EditorConstructor
type="model"
assetId={assetId}
apiKey={apiKey}
presetConfig={{
mode: AMAMode.EDITOR,
applyProductRules: false,
customDomain: "https://custom.domain.com"
}}
/>🪝 Hooks
Hooks work only when the editor is mounted in the DOM.
useUtilsEditor— Core hook for models/scenes UntitleduseUtilsMaterial— Core hook for materials UntitleduseCustomObjects— Create simple shapes UntitleduseCustomLights— Create lights UntitleduseCustomCameras— Create cameras UntitleduseCheckOptionActions— Work with options Untitled
📜 Workflow
- Add
<EditorConstructor />where needed - Wait for scene load via
useUtilsEditor().loadingProgress - Use hooks to manipulate the scene
Example:
import { useUtilsEditor } from '@amaspace-editor/editor-3d'
const editor = useUtilsEditor()
useEffect(() => {
if (editor.loadingProgress.sceneLoaded) {
console.log("Scene loaded");
}
}, [editor.loadingProgress.sceneLoaded]);API Highlights
Animations
editor.playAnimation(name)
editor.toggleAnimation(name)
editor.playAllAnimations()
editor.stopAllAnimations()
editor.getCurrentAnimation()
editor.animationList()Post-Processing
editor.setPostProcessing({ name, effect: options })Camera
editor.setActiveCamera(camera)
editor.setDynamicCamera({ position: Vector3, target: Vector3 })Scene
editor.setActiveByName('MeshName')
editor.getMeshById('123')
editor.updateObjectData(node, newData)
editor.deleteModelPart(id)Materials
utilsMat.createMaterialFromAsset(asset)
utilsMat.updateMaterialProps(props)
utilsMat.updateMaterialTextures(texture)//Create custom shapes
import React from 'react'
import { useCustomObjects } from '...'
const AddObjectsPanel: React.FC = () => {
const { create } = useCustomObjects()
return (
<div>
<button onClick={() => create.plane()}>Add plane</button>
<button onClick={() => create.box('box-1')}>Add box with id</button>
<button onClick={() => create.sphere()}>Add sphere</button>
<button onClick={() => create.shadowPlane()}>Addshadow plane</button>
<button onClick={() => create.target()}>Add target</button>
</div>
)
}//Create custom lights
import React from 'react'
import { useCustomObjects } from '...'
const AddObjectsPanel: React.FC = () => {
const { create } = useCustomLights()
return (
<div>
<button onClick={() => create.pointLight()}>Add point</button>
<button onClick={() => create.hemisphereLight()}>Add hemi</button>
</div>
)
}//Create custom camera
import React from 'react'
import { useCustomObjects } from '...'
const AddObjectsPanel: React.FC = () => {
const { create } = useCustomCameras()
return (
<div>
<button onClick={() => create.perspective()}>Add perspective camera</button>
</div>
)
}Dynamic Components
Example
import { RemoteComponent } from '@amaspace-editor/editor-3d'
const MyScene = () => {
return (
<canvas>
<RemoteComponent />
<mesh>
<meshBasicMaterial color={0xff0000} />
<boxGeometry args={[1, 1, 1]} />
</mesh>
<React.Suspense fallback={null}>
<RemoteComponent color={color} url='https://cdn.somewebsite.com/some-component.js'/>
</React.Suspense>
</canvas>
)
}Remote Component Example (some-component.js):
import React from 'react'
const Component = ({ color }) => {
return (
<mesh>
<meshStandardMaterial color={color} />
<boxGeometry args={[1, 1, 1]} />
</mesh>
)
}
export default ComponentSupported Dependencies:
React, animejs, @react-three/fiber, @react-three/drei, three, three-stdlib🔄 Dynamic Component Hooks
import { useDynamicComponent, useDynamicComponents } from '@amaspace-editor/editor-3d'
const resultComponentsArray = useDynamicComponent('comp.js');
const ResultComponent = useDynamicComponents(['comp1.js', 'comp2.js']);Last updated on